-
Notifications
You must be signed in to change notification settings - Fork 46
Command Execution via Broadcast Intent
- Action code:
com.openvehicles.OVMS.action.COMMAND
The results of commands sent to the App using this intent are displayed to the user, either by resuming the App and switching to the notification page if the App is currently started/paused, or by opening a dedicated system overlay window if the App is not currently started.
This intent processes commands in user syntax (as in the notifications tab), so standard text commands can be given without further encoding. It supports queueing, i.e. multiple commands can be sent at once to be executed in series. It works regardless of the background service mode and is the foundation of the new command shortcut feature (add OVMS command shortcuts to the desktop or other Apps).
Intent extras expected/supported:
Type | Name | Example | Remarks |
---|---|---|---|
String | vehicleid |
MYCAR42 |
optional, can be omitted with apikey
|
String | password |
the_secret |
optional, can be omitted with apikey
|
String | apikey |
pU4ZnVwWGxsWHuyeG2VZFFNNz |
alternative authorization key, see App options menu |
String | title |
Start charge |
optional, used for the result display |
String | command |
charge start |
optional, no command means only change the car |
Commands need to be in user input syntax:
- MMI/USSD commands: prefix
*
, example:*100#
- Modem commands: prefix
@
, example:@ATI
- MP MSG commands: prefix
#
, example:#31
- Text commands: everything else, example:
stat
- Action code:
com.openvehicles.OVMS.SendCommand
Commands sent to the App using this intent will be executed in the background, without results being shown to the user. To be able to use this, you need to enable third party command support in the App's options menu.
Type | Name | Example | Remarks |
---|---|---|---|
String | sel_vehicleid |
MYCAR42 |
optional, can be omitted with apikey
|
String | sel_server_password |
the_secret |
optional, can be omitted with apikey
|
String | apikey |
pU4ZnVwWGxsWHuyeG2VZFFNNz |
alternative authorization key, see App options menu |
String | msg_command |
7,stat |
MP command syntax, e.g. 7,stat / 20,1234
|
String | command |
stat |
User command syntax, e.g. stat / #20,1234
|
Note: the call changes the active vehicle as necessary. If you want to execute a command without changing the vehicle, save the previous vehicle (see update broadcast) and issue a second command to switch back.
On msg_command
: the SendCommand API was built around the V2 message protocol, so you need to send commands as MP commands. See https://docs.openvehicles.com/en/latest/protocol_v2/commands.html for a list. MP command code 7 passes standard text (former SMS) commands to the shell, that's what the above example shows (for V2 command STAT?
).
To send a V3 shell command, simply prefix it with 7,
. Example: 7,charge stop
. By supplying the vehicle credentials (id & password) you're automatically in "enabled" mode, so all commands can be used.
- Action code:
com.openvehicles.OVMS.CommandResult
To enable command result broadcasts, you need to enable third party command support in the App's options menu.
Type | Name | Example |
---|---|---|
String | sel_server |
ovms.dexters-web.de |
String | sel_vehicleid |
MYCAR42 |
String | sel_vehicle_label |
Twizy |
String | cmd_vehicleid |
MYCAR42 |
String | cmd_code |
7 |
String | cmd_error |
0 |
String | cmd_data |
Charge Stopped CHG: 624 (~716) Wh Full: 33 min. … |
String[] | cmd_result |
[ "7", "0", "Charge Stopped CHG: 624 (~716) Wh Full: 33 min. …" ] |
Within an adb shell, you can issue commands with the activity manager (am) tool to perform various system actions.
- Send interactive command request:
am start -a com.openvehicles.OVMS.action.COMMAND -e apikey … -e command "stat"
- Send background command request:
am broadcast -a com.openvehicles.OVMS.SendCommand -e apikey … -e command "stat"