I’m trying to centralize some of my node red functions and i’m getting an error. I have a function that adds items to the msg.payload object. Here is what it looks like once passed:
{"_msgid":“6ef988d8.562e88”,“topic”:"",“payload”:{“target”:[“homeUsers”],“alexa”:{“soundLevel”:0.7}},"_event":“node:d1e72375.c13ee”}
I’m trying to pass msg.payload.alexa.soundLevel to a call service node that changes the volume of one of my voice assistants. This is the JSON in the call service node is:
{
"entity_id": "media_player.xxxx",
"volume_level": "{{payload.alexa.soundLevel}}"
}
I keep getting this error
Call-service API error. Error Message: expected float for dictionary value @ data[‘volume_level’]
I’ve tried several different options:
{{alexa.soundLevel}}
{{soundLevel}}
Here is my flow
[{"id":"384402ce.39cd6e","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"4dbe100e.9dda68","type":"link in","z":"384402ce.39cd6e","name":"alert","links":["3af64e36.53af12","a308c302.ac65f8","4ced1d53.8e9f4c"],"x":175,"y":180,"wires":[["94ddd62e.0171c"]]},{"id":"94ddd62e.0171c","type":"switch","z":"384402ce.39cd6e","name":"target-groups","property":"payload.target","propertyType":"msg","rules":[{"t":"cont","v":"homeUsers","vt":"str"},{"t":"cont","v":"everyone","vt":"str"},{"t":"cont","v":"guests","vt":"str"},{"t":"cont","v":"keith","vt":"str"},{"t":"cont","v":"kristy","vt":"str"},{"t":"cont","v":"kids","vt":"str"},{"t":"cont","v":"owners","vt":"str"},{"t":"cont","v":"grandparents","vt":"str"}],"checkall":"true","repair":false,"outputs":8,"x":330,"y":240,"wires":[["8c749e70.d98cd"],[],[],[],[],[],[],[]]},{"id":"4ced1d53.8e9f4c","type":"link out","z":"384402ce.39cd6e","name":"","links":["4dbe100e.9dda68"],"x":515,"y":380,"wires":[]},{"id":"778f78.2f164888","type":"inject","z":"384402ce.39cd6e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":440,"wires":[["8bc9220.ba11e6"]]},{"id":"8bc9220.ba11e6","type":"function","z":"384402ce.39cd6e","name":"set payload info","func":"//msg.payload = \"test\";\n//msg.target = [\"abc\", \"123\"];\nmsg.payload = {\n target: [\"homeUsers\"],\n alexa: {\n soundLevel: 0.7\n }\n}\nreturn msg","outputs":1,"noerr":0,"x":400,"y":400,"wires":[["4ced1d53.8e9f4c"]]},{"id":"3bc9a8bb.8d10b8","type":"api-call-service","z":"384402ce.39cd6e","name":"Set Volume","server":"c67aefa2.888ea","version":1,"debugenabled":false,"service_domain":"media_player","service":"volume_set","entityId":"","data":"{\"entity_id\":\"media_player.xxxxxx\",\"volume_level\":\"{{payload.alexa.soundLevel}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":true,"x":510,"y":600,"wires":[[]]},{"id":"1322dc53.5799ac","type":"link in","z":"384402ce.39cd6e","name":"alexa-play-sound","links":["8c749e70.d98cd"],"x":200,"y":620,"wires":[["280a773.b31aa88"]]},{"id":"280a773.b31aa88","type":"switch","z":"384402ce.39cd6e","name":"","property":"payload.alexa.soundLevel","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":290,"y":620,"wires":[["3bc9a8bb.8d10b8","d7302f1c.5087e"],[]]},{"id":"d7302f1c.5087e","type":"debug","z":"384402ce.39cd6e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":690,"y":240,"wires":[]},{"id":"8c749e70.d98cd","type":"link out","z":"384402ce.39cd6e","name":"","links":["1322dc53.5799ac"],"x":560,"y":240,"wires":[]},{"id":"c67aefa2.888ea","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I have a few other flows i plan on creating that will be based off of this. Any suggestions?