Hi all. I setup Valetudo last night on my v1 Xiaomi rockrobo and I’m working on getting it integrated with my HA. I’m running into a problem I don’t understand, where publishing to MQTT works but using the same topic and payload in a script does not work. I know I’m doing something wrong but I can’t figure out what it is. Does anyone else know what I’m doing wrong by looking at the info below?
Here’s what I have in the MQTT publish page.
Topic:
valetudo/robot/ZoneCleaningCapability/start/set
Payload:
[
"261b106a-0175-215b-85c0-2a7b254fd042"
]
When I hit “PUBLISH” on that it works and the vacuum goes along to the zone I’ve chosen and there are no issues.
Here’s what I have in the script:
alias: Vacuum All
sequence:
- service: mqtt.publish
data_template:
topic: valetudo/robot/ZoneCleaningCapability/start/set
payload: "261b106a-0175-215b-85c0-2a7b254fd042"
No errors in HA when I tell that to run, but here’s what I see inside Valetudo’s logs immediately after hitting run:
[2021-07-28T00:16:00.252Z] [ERROR] unhandledRejection SyntaxError: Unexpected token b in JSON at position 3
at JSON.parse (<anonymous>)
at PropertyMqttHandle.setter (/snapshot/Valetudo/backend/lib/mqtt/capabilities/ZoneCleaningCapabilityMqttHandle.js:50:38)
at PropertyMqttHandle.set (/snapshot/Valetudo/backend/lib/mqtt/handles/PropertyMqttHandle.js:105:27)
at PropertyMqttHandle.setHomie (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:298:20)
at Object.topics.<computed> [as valetudo/robot/ZoneCleaningCapability/start/set] (/snapshot/Valetudo/backend/lib/mqtt/handles/MqttHandle.js:82:28)
at MqttClient.<anonymous> (/snapshot/Valetudo/backend/lib/mqtt/MqttController.js:304:42)
at MqttClient.emit (node:events:394:28)
at MqttClient._handlePublish (/snapshot/Valetudo/node_modules/mqtt/lib/client.js:1277:12)
at MqttClient._handlePacket (/snapshot/Valetudo/node_modules/mqtt/lib/client.js:410:12)
at work (/snapshot/Valetudo/node_modules/mqtt/lib/client.js:321:12)
I’ve tried adding the payload to the script in the following formats and all give the json error:
payload: "261b106a-0175-215b-85c0-2a7b254fd042"
payload: 261b106a-0175-215b-85c0-2a7b254fd042
payload: "[261b106a-0175-215b-85c0-2a7b254fd042]"
payload: "['261b106a-0175-215b-85c0-2a7b254fd042']"
payload: '261b106a-0175-215b-85c0-2a7b254fd042'
Since the script’s mqtt.publish is getting to the vacuum in order for an error to show up in its logs, I’m assuming the topic is correct and it’s the payload that’s the issue.
Using the publish option on the MQTT page works but attempting to use this script does not and all I get is the above error.
Any idea what I’m doing wrong? First time I’ve tried creating a script in HA so I’m 99% sure it’s my error. Thank you for any help or suggestions!