I am trying to get my Sonos to select a random favorite on motion. I wrote the following automation and function which passes the source as msg.source to the service ‘select_source’. However the source does not seem to change even though I see msg.source perform exactly how I want. Any ideas?
[{"id":"3da1476f8204e30b","type":"function","z":"23b7103827a39559","name":"","func":"const source = [\n \"Chill\",\n \"Classical\",\n \"Spa\",\n \"Classical for Studying Radio\",\n \"HRT Radio Knin 90.2\"\n];\n\nmsg.source = source[Math.floor(Math.random() * source.length)];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":1280,"wires":[["1565af1dedd7ff62","8d90092c374562e8"]]},{"id":"1565af1dedd7ff62","type":"api-call-service","z":"23b7103827a39559","name":"Select Laundry Music","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"media_player","service":"select_source","areaId":[],"deviceId":[],"entityId":["media_player.laundry_room"],"data":"{\"source\":\"{{source}}\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[{"property":"reset","propertyType":"msg","value":"true","valueType":"bool"}],"queue":"none","x":798,"y":1280,"wires":[["1ffc8af6bdf292b3"]]},{"id":"c764c89680707c8f","type":"inject","z":"23b7103827a39559","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":480,"y":1280,"wires":[["3da1476f8204e30b"]]},{"id":"1ffc8af6bdf292b3","type":"debug","z":"23b7103827a39559","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":1280,"wires":[]},{"id":"8d90092c374562e8","type":"debug","z":"23b7103827a39559","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":1240,"wires":[]},{"id":"6e751b1b.8f17c4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]