4 posts / 0 new
Last post
Bruce Brentlinger
MQTT commands to OVMS

There is a lot of different information online about how to send a command to the OVMS and get it to do something or at least generate a response (much of it is very old).  But I have not been able to get anything to work.

I get metrics from the OVMS, but as far as sending commands I am stuck.

My car is a nissan leaf 2012 SV

OVMS box firmware 3.3.005-3-g4f3f7688/ota_1/main (build idf v3.3.4-851-gfa4f07fb3b Sep 7 2025 08:02:51) using dexters-web.de.

I am using MQTT explorer to listen to traffic.  It only sees the commands, and I don't see any responses there.

Also the web console ovms shell shows no response to mqtt commands.

I have tried using the ovms integration and plain yaml.

Here are some automations that I have tried for testing.

let's assume my prefix is "ovms" and my vehicle ID is "828Longan25" command to test "wifi".

Then:

alias: "Test OVMS WiFi Command every 10s"
description: "Send the 'wifi' command to OVMS every 10 seconds for testing"
trigger:
  - platform: time_pattern
    seconds: "/10"  # runs every 10 seconds
action:
  - action: mqtt.publish
    data:
      topic: "ovms/client/828Longan25/command/test"
      payload: "wifi"
mode: single

Another try:

alias: "Test OVMS WiFi Command every 10s"
description: "Send 'wifi' command to OVMS every 10 seconds"
trigger:
  - platform: time_pattern
    seconds: "/10"
action:
  - service: ovms.send_command
    data:
      vehicle_id: 828Longan25
      command: wifi
      timeout: 10   # optional, defaults to integration’s setting
mode: single

Another try:

alias: "Test OVMS WiFi Command MQTT"
description: "Send wifi command to OVMS v3 module every 10 seconds"
trigger:
  - platform: time_pattern
    seconds: "/10"
action:
  - variables:
      cmd_id: "{{ now().timestamp() | int | string | replace('.', '') }}"  # unique ID
  - service: mqtt.publish
    data:
      topic: "ovms/client/828Longan25/client/rr/command/{{ cmd_id }}"
      payload: '{"command":"wifi"}'
      qos: 1
mode: single


Can anyone here help?
Thank you.

Bruce Brentlinger
Update:  I have the command

Update:  I have the command yaml working.  Getting hardware to respond has been another matter.  I have only been successful in getting port 1 to respond to the on/off yaml.

markwj
markwj's picture
Without details on your MQTT

Without details on your MQTT server, it is hard to diagnose. But my best guess would be the topic is wrong. In particular, the beginning of the topic. Details here:

https://docs.openvehicles.com/en/latest/userguide/commands.html#v3-server-mqtt

Have a look at this example:

https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/blob/master/client/ovms_v3shell.pl

Perhaps get that working first with your MQTT server and vehicle, then replicate in your own command yaml.

Bruce Brentlinger
The mistake I made was that I

The mistake I made was that I was publishing to the wrong topic.  
I was publishing to "ovms/client/828Longan25/command/test".  

The correct topic is "ovms/[mqtt-client]/[car-id]/client/home-assistant/command/1"
which for me is "ovms/ovms/828Longan25/client/home-assistant/command/1"

Out of all the well meaning but not very useful posts with incomplete information and yaml that doesn't work.  I finally found jdanders (Thank you!) who has the most helpful information that really works and has complete yaml and information that I could work with.

jdanders instructions:
https://www.openvehicles.com/node/3309 (last post)
https://github.com/jdanders/ovms-leaf-home-assistant-yaml

mqtt:
  switch:
  - name: Leaf Climate Control
    qos: 1
    command_topic: "ovms/[mqtt-client]/[car-id]/client/home-assistant/command/1"
    state_topic: "ovms/[mqtt-client]/[car-id]/client/home-assistant/response/1"
    state_on: "Climate Control \non\n"
    state_off: "Climate Control \noff\n"
    payload_on: "climatecontrol on"
    payload_off: "climatecontrol off"

My switch that works:
mqtt:
  switch:
    - name: "Ovms switch port 1 (system activate)"
      qos: 1
      command_topic: "ovms/ovms/828Longan25/client/home-assistant/command/1"
      state_topic: "ovms/ovms/828Longan25/client/home-assistant/response/1"
      payload_on: "egpio output 1 1"
      payload_off: "egpio output 1 0"
      state_on: "EGPIO port 1 set to output level 1\n"
      state_off: "EGPIO port 1 set to output level 0\n"

I think there is still a lot that can be done to help noobs like me get OVMS running with home assistant.  What would be very helpful is to have a centralized user manual/tutorial where people can go to get something that works, rather than spending days/weeks sifting through unhelpful posts.  I would be interested in helping with that when I am done setting up my leaf and get less busy.  Getting the leaf home assistant integration working with commands would be good too.

Log in or register to post comments
randomness