8 posts / 0 new
Last post
rabbitev
rabbitev's picture
sending commands to a car

I am trying to figure out the options for sending commands to a vehicle, specifically door lock/unlock, without the native app.  that would allow me to integrate it into my app.

Is the best path to create my own v3 server, and send commands through that server?

 

thanks for any help...

markwj
markwj's picture
I would suggest you either

I would suggest you either use protocol v3 (MQTT), or the HTTP API to the existing servers:

https://docs.openvehicles.com/en/latest/protocol_httpapi/index.html

mdallaire
Looking at my mqtt server I

Looking at my mqtt server I see that my ovms is subscribed to /ovms/ovmsleaf/[vehiculeid]/client/+/command/+ and /ovms/ovmsleaf/[vehiculeid]/client/+/active.

I assume there is a way to send commands on the +/command/+ topic but I can't seem to find any documentation on the command format and syntax expected. Is it something that is ready to be used or is it there in preparation for future features?

I have a Leaf 2015 that I have integrated in home-assistant as sensors but I would also like to send some commands like start charge or HVAC from home-assistant via MQTT.

markwj
markwj's picture
There is an experimental

There is an experimental implementation of this in the current firmware.

The v3 code in the module firmware listens on <topic_prefix>/client/+/command/+. It is expecting client/<client>/command/<id> and the command itself in the payload.

The command is run, and the response returned in the payload of <topic_prefix>/client/<client>/response/<id>.

The overall design approach is to separate each connecting client into their own namespace (identified by unique <client>), and to allow each client to run multiple commands perhaps concurrently or pipelined (each command/response connected via unique <id> within each client namespace).

mdallaire
I am very excited to try this

I am very excited to try this. In my case I am trying to publish the following without success:

ovms/ovmsleaf/[vehiculeid]/client/mqtt-explorer-83dfce13/command/1

The raw payload is the following:

climatecontrol on

I am using the session client name of my current mqtt client (MQTT Explorer) but I assume I could use pretty much any string, such as "home-assistant" when I get to integrate further?

The <id> is just a number, incremental or not, for the specific command and it's result? If I just want to send the occasional climatecontrol on/off I could reuse the same ID?

Do I need to send something on the /client/<client>/active topic for OVMS to start listening to commands?

Am I wrong to assume that the behavior should be about the same as using the shell?

Sorry if this is a lot of questions at once.

markwj
markwj's picture
The prefix 'ovms/ovmsleaf/',

The prefix 'ovms/ovmsleaf/', seems strange, but so long as you are sure that matches the ovms config, it should be ok.

The client ID is up to you. So long as it is unique.

So long as the server v3 component is enabled, started and connected, it should pickup commands, and the commands themselves are simple shell commands.

Probably easiest to turn on debug logging for the server v3 component (log level verbose ovms-server-v3), and see what that shows.

mdallaire
ovmsleaf is the mqtt username

ovmsleaf is the mqtt username used to login to my mqtt server. It gets in the topic automatically.

I just got to testing this again and it worked perfectly this time, I was able to start and stop climate control and got the response to the command in MQTT. Is there anything you would like to be tested to help with the developpement of the v3 server? I am in the process of integrating this in my home-assistant, when I am satisfied with the results I will post some of the configs to help other people get going.

markwj
markwj's picture
A home assistant integration

A home assistant integration would be cool. Just not sure if that should be via MQTT (v3) or the v2 HTTP API.

Log in or register to post comments