Hi
I used Change Node to create a msg with the information that i want to pass onto my light (philips hue) group.
[{"id":"b7d1b257.10eda","type":"change","z":"b5a4f9b1.de8f78","name":"","rules":[{"t":"delete","p":"data","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"},{"t":"set","p":"data.rgb_color","pt":"msg","to":"[255,244,229]","tot":"str"},{"t":"set","p":"data.transition","pt":"msg","to":"30","tot":"num"},{"t":"set","p":"data.brightness","pt":"msg","to":"$number(\"1\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1340,"wires":[["b68ecf59.c83a3","2e11fe32.ad2b02"]]}]
First i Clean up the payload and data field from the earlyer nodes.
On my debug it looks as expected, with a payload with “on” and my data field with the data expected.
But my call service node will not accept my number brightness as an integer, although I’ve really tried formatting it according to what I could find on google/exambles.
Complete test flow below
[{"id":"b68ecf59.c83a3","type":"api-call-service","z":"b5a4f9b1.de8f78","name":"Stuen On","server":"468387c0.b24028","version":1,"service_domain":"light","service":"turn_on","entityId":"light.stuen","data":"{\"brightness\":\"{{payload.brightness}}\",\"rgb_color\":\"{{payload.rgb_color}}\",\"transition\":\"{{payload.transition}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":995,"y":1320,"wires":[[]],"l":false},{"id":"b7d1b257.10eda","type":"change","z":"b5a4f9b1.de8f78","name":"","rules":[{"t":"delete","p":"data","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"},{"t":"set","p":"data.rgb_color","pt":"msg","to":"[255,244,229]","tot":"str"},{"t":"set","p":"data.transition","pt":"msg","to":"30","tot":"num"},{"t":"set","p":"data.brightness","pt":"msg","to":"$number(\"1\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":1340,"wires":[["b68ecf59.c83a3","2e11fe32.ad2b02"]]},{"id":"2e11fe32.ad2b02","type":"debug","z":"b5a4f9b1.de8f78","name":"Test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":1360,"wires":[]},{"id":"d09e1434.713278","type":"inject","z":"b5a4f9b1.de8f78","name":"Test knap","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":1420,"wires":[["b7d1b257.10eda"]]},{"id":"468387c0.b24028","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false}]
I’m thinking I have a problem, with the JSON field in call service node, where I try to import the data.
Can anyone help?
JSON in call service node
{"brightness":"{{payload.brightness}}","rgb_color":"{{payload.rgb_color}}","transition":"{{payload.transition}}"}
Edit:
Adding the error message as text, so Google can find it for others in the future
“Call-service API error. Error Message: expected int for dictionary value @ data[‘brightness’]”