Command queries for location working, but startVehicle command fails
Closed this issue · 3 comments
error: Command error {"command":"startVehicle","err":{"request":{"authRequired":true,"body":"{}"
It appears as though the command is being sent correctly, and I can retrieve status for odometer, tpms etc, but cannot send commands. 2021 Chevy BOLT EV, Canadian OnSTAR account.
I'm having the same issue. The Onstar2MQTT container seems to crash when receiving the startVehicle command.
Actually, I've spent some time with this and sorted it out.
I saw the following error in the log:
undefined:1
{'command': 'startVehicle'}
^
SyntaxError: Unexpected token ' in JSON at position 1
at JSON.parse (<anonymous>)
at MqttClient.<anonymous> (/app/src/index.js:79:41)
at MqttClient.emit (node:events:513:28)
at MqttClient._handlePublish (/app/node_modules/mqtt/lib/client.js:1547:12)
at MqttClient._handlePacket (/app/node_modules/mqtt/lib/client.js:535:12)
at work (/app/node_modules/mqtt/lib/client.js:438:12)
at writable._write (/app/node_modules/mqtt/lib/client.js:452:5)
at doWrite (/app/node_modules/readable-stream/lib/_stream_writable.js:409:139)
at writeOrBuffer (/app/node_modules/readable-stream/lib/_stream_writable.js:398:5)
at Writable.write (/app/node_modules/readable-stream/lib/_stream_writable.js:307:11)
It turns out that Home Assistant's script GUI does undesired things to the MQTT commands needed for this container. If you use the GUI, your YAML will look like this:
alias: Bolt EV - Charge Override
sequence:
- service: mqtt.publish
data:
topic: homeassistant/VIN/command
payload: "{\"command\": \"cancelChargeOverride\"}"
mode: single
icon: mdi:battery-charging
Onstar2MQTT does not like payload data that HA reformats it to as above. It should look like this:
payload: '{"command": "cancelChargeOverride"}'
Note the single quotes surrounding the payload, and no escape characters before the double quotes. I recommend setting up any settings you'd like in the GUI, then switch to YAML mode, fix the payload, then save. This fixed all the scripts for me.
This was the solution for me. Good catch! Thanks for this!