openvehicles / Open-Vehicle-Android

Android App for OVMS
Other
54 stars 45 forks source link

Android intent? #132

Closed glynhudson closed 3 years ago

glynhudson commented 3 years ago

Hi, I'm trying to follow the docs on the wiki to use an Android Intent Action to get the ovms android app to send a message to a vehicle to start a custom script.

I'm using Tasker to send the intent but I'm not having any luck so far, any ideas what I'm doing wrong? I'm also sending a intent with the service password and vehicle ID

Screenshot_20211013-005013

dexterbg commented 3 years ago

I'm not familiar with Tasker, but that doesn't look right: parameters need to be set as typed "Extras". From your screenshot it looks like you set them as some text blob in "Data".

glynhudson commented 3 years ago

Thanks, I've tried sending the commands as 'extras':

  A1: Send Intent [
         Action: com.openvehicles.OVMS.SendCommand
         Cat: None
         Extra: sel_vehicleid:XXXX
         Extra: sel_server_password:XXXX
         Extra: msg_command:7,script eval abrp.send(1)
         Target: Activity ]

Still no luck, the Tasker log may have some clues:

13-10-2021 JU: 17.38.43#b#JU: Send Intent: analyse done: 7,script eval abrp.send(1): class: ???  obj: null partWithoutMods: null static: false const false casted: false
13-10-2021 E: 17.38.43#b#E: added string extra: msg_command/7,script eval abrp.send(1)
13-10-2021 E: 17.38.43#b#E: start activity...
13-10-2021 Utils: 17.38.43#b#Utils: startActivityWrapper: activity not found
13-10-2021 Log: 17.38.43#b#Log: startActivityWrapper action: com.openvehicles.OVMS.SendCommand
13-10-2021 Log: 17.38.43#b#Log: startActivityWrapper pkg: null

I've configured the OVMS app to allow intents and have tried sending the intent as Target: Activity and Target: Broadcast

dexterbg commented 3 years ago

Glyn, this is really not a Tasker support forum… all I can do is show you the respective Automagic action definition:

  <action type="send_broadcast">
    <useDefaultName>false</useDefaultName>
    <name>SetProfil</name>
    <intentAction>com.openvehicles.OVMS.SendCommand</intentAction>
    <categoryListEnabled>false</categoryListEnabled>
    <categoryList>android.intent.category.DEFAULT</categoryList>
    <dataEnabled>false</dataEnabled>
    <data></data>
    <dataTypeEnabled>false</dataTypeEnabled>
    <dataType>text/plain</dataType>
    <explicitComponent>false</explicitComponent>
    <packageName></packageName>
    <className></className>
    <flagList>FLAG_ACTIVITY_NEW_TASK</flagList>
    <extras>putString("sel_vehicleid", "XXXX");
putString("sel_server_password", "XXXX");
putString("msg_command", "7,script eval abrp.send(1)");
</extras>
    <waitForResult>false</waitForResult>
    <accessResultExtras></accessResultExtras>
  </action>

From your log it appears Tasker only adds the "msg_command" extra.

dexterbg commented 3 years ago

I just tried Automate, works out of the box as well. With Automate, use "Broadcast send" with package "com.openvehicles.OVMS", action "com.openvehicles.OVMS.SendCommand" and the extras using JSON syntax:

{"sel_vehicleid": "XXXX", "sel_server_password": "XXXX", "msg_command": "7,script eval abrp.send(1)"}
glynhudson commented 3 years ago

Thanks, this worked great 👍

Screenshot_20211102-021750