This works via Dev Tools, but not Node Red. What am I missing?

I’m trying to get my vacuum (Valetudo RE) to clean rooms in a specific order. This works via Dev Tools:

service: mqtt.publish
data:
  topic: valetudo/rockrobo-s6/custom_command
  payload: >-
    {"command": "segmented_cleanup", "segment_ids": ["Office","Guest
    Bedroom","Entryway","Laundry Room","Kitchen","Living Room","Dining
    Room","Master Bedroom","Master Closet"],"repeats": 1,"afterCleaning":
    "Trash"}

However, the same command does not work via NR. You can see the error in the screenshot.

nothing goes in the entity id field and all of the data parts go in the data field.

data field

{
  "topic": "valetudo/rockrobo-s6/custom_command"
  "payload":  {
    "command": "segmented_cleanup", 
    "segment_ids": ["Office","Guest Bedroom","Entryway","Laundry Room","Kitchen","Living Room","Dining Room","Master Bedroom","Master Closet"],
    "repeats": 1,
    "afterCleaning": "Trash"
  }
}
1 Like

Oh, duh! Of course its not an entity. Sometimes I’m amazed that I don’t fall over more when walking.

Hmmm… You missed the comma after the topic, but even after adding it, I get API error. Any other ideas. Here’s my test:

[{"id":"afc7effa.60399","type":"inject","z":"93889ed6.50652","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":690,"y":1180,"wires":[["59b53273.43870c"]]},{"id":"59b53273.43870c","type":"api-call-service","z":"93889ed6.50652","name":"","server":"61a3b09d.8395a","version":1,"debugenabled":false,"service_domain":"mqtt","service":"publish","entityId":"","data":"{\t   \"topic\": \"valetudo/rockrobo-s6/custom_command\",\t   \"payload\":  {\t       \"command\": \"segmented_cleanup\",\t       \"segment_ids\": [\t           \"Office\",\t           \"Guest Bedroom\",\t           \"Entryway\",\t           \"Laundry Room\",\t           \"Kitchen\",\t           \"Living Room\",\t           \"Dining Room\",\t           \"Master Bedroom\",\t           \"Master Closet\"\t       ],\t       \"repeats\": 1,\t       \"afterCleaning\": \"Trash\"\t  }\t}","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":1120,"wires":[["47c686cc.e300b8"]]},{"id":"47c686cc.e300b8","type":"debug","z":"93889ed6.50652","name":"vac","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":1100,"wires":[]},{"id":"61a3b09d.8395a","type":"server","name":"Home Assistant","addon":true}]

Looks like the mqtt payload needs to be a string.

[{"id":"afc7effa.60399","type":"inject","z":"ffbd7f06.4a014","name":"","props":[{"p":"mqttPayload","v":"{\"command\":\"segmented_cleanup\",\"segment_ids\":[\"Office\",\"Guest Bedroom\",\"Entryway\",\"Laundry Room\",\"Kitchen\",\"Living Room\",\"Dining Room\",\"Master Bedroom\",\"Master Closet\"],\"repeats\":1,\"afterCleaning\":\"Trash\"}","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":642,"y":304,"wires":[["7bc118e5.f19238"]]},{"id":"59b53273.43870c","type":"api-call-service","z":"ffbd7f06.4a014","name":"","server":"","version":3,"debugenabled":true,"service_domain":"mqtt","service":"publish","entityId":"","data":"{\t   \"topic\": \"valetudo/rockrobo-s6/custom_command\",\t   \"payload\": mqttPayload\t}","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":938,"y":304,"wires":[["47c686cc.e300b8"]]},{"id":"47c686cc.e300b8","type":"debug","z":"ffbd7f06.4a014","name":"vac","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1106,"y":304,"wires":[]},{"id":"7bc118e5.f19238","type":"json","z":"ffbd7f06.4a014","name":"","property":"mqttPayload","action":"str","pretty":false,"x":770,"y":304,"wires":[["59b53273.43870c"]]}]
1 Like

I’m confused. Wasn’t it already a string?

It’s a JSON object that needs to be converted to a string representation.