Does events: all node need an input?

I’ve started to create automations using HA NodeRed integration. I start with an events: all node and update the event data with something unique to capture - i.e. for a Tradfri remote control I use

{
    "device_ieee": "d0:cf:.....:b3:66"
}

I can then check the passed payload to see what buttons are pressed. All good.

As I have several old Tradfri remotes, I’m creating one sub flow to manage them but then I hit a snag - how to inject the device_ieee: into the events: all node?

Should the events: all node have an input to inject these values so that we can more readily use this in sub flows - or am I missing something?

Steve

Use a switch node after the events all node, with an empty event data, and use a JSONata expression in the switch node.

{
  "device_ieee":  $env("device_id")
}

Thanks’ @Kermit -
whilst working on this I realised that events: all doesn’t make sense to include in a sub flow. I eventually went with the following:

This keeps the filtering the event bus, but adds the specific info to the payload.

The sub flow combines all the variable parts of the remote button press event into a command string and then use switch to issue the media player commands.

Tradfri light control remote to media player controller

[{"id":"79e71f2ceeae3357","type":"subflow","name":"Tradfri Subflow","info":"","category":"","in":[{"x":60,"y":140,"wires":[{"id":"cc7f8ba70dcdd770"}]}],"out":[],"env":[],"meta":{},"color":"#DDAA99"},{"id":"e05e9b70b972c3cc","type":"switch","z":"79e71f2ceeae3357","name":"","property":"payload.mycommand","propertyType":"msg","rules":[{"t":"eq","v":"toggle////1/6","vt":"str"},{"t":"eq","v":"step_with_on_off/0/43/5/1/8","vt":"str"},{"t":"eq","v":"step/1/43/5/1/8","vt":"str"},{"t":"eq","v":"press/257/13/0/1/5","vt":"str"},{"t":"eq","v":"press/256/13/0/1/5","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":6,"x":410,"y":320,"wires":[["4ddcce1e0c640f30"],["15146066e5246911"],["ae588ecfb947320f"],["55ba1ffdaa3215a7"],["139d29022c21efb4"],["cadefd1b44029448"]]},{"id":"cc7f8ba70dcdd770","type":"change","z":"79e71f2ceeae3357","name":"","rules":[{"t":"set","p":"payload.mycommand","pt":"msg","to":"payload.event.command & \"/\" & \tpayload.event.args[0] & \"/\" &\tpayload.event.args[1] & \"/\" &\tpayload.event.args[2] & \"/\" &\tpayload.event.endpoint_id & \"/\" & \tpayload.event.cluster_id","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":140,"wires":[["121841b5663ef398","e05e9b70b972c3cc"]]},{"id":"4ddcce1e0c640f30","type":"api-call-service","z":"79e71f2ceeae3357","name":"","server":"2be748d3.da7088","version":5,"debugenabled":false,"domain":"media_player","service":"media_play_pause","areaId":[],"deviceId":[],"entityId":[],"data":"{    \"entity_id\": $$.payload.myplayer }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":140,"wires":[["35af086d6a7c5f26"]]},{"id":"35af086d6a7c5f26","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug 61","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":140,"wires":[]},{"id":"15146066e5246911","type":"api-call-service","z":"79e71f2ceeae3357","name":"","server":"2be748d3.da7088","version":5,"debugenabled":false,"domain":"media_player","service":"volume_up","areaId":[],"deviceId":[],"entityId":[],"data":"{    \"entity_id\": $$.payload.myplayer }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":730,"y":180,"wires":[["799bd3f4063b1ea5"]]},{"id":"799bd3f4063b1ea5","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug 62","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":180,"wires":[]},{"id":"ae588ecfb947320f","type":"api-call-service","z":"79e71f2ceeae3357","name":"","server":"2be748d3.da7088","version":5,"debugenabled":false,"domain":"media_player","service":"volume_down","areaId":[],"deviceId":[],"entityId":[],"data":"{    \"entity_id\": $$.payload.myplayer }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":740,"y":220,"wires":[["733b5bec587dd541"]]},{"id":"733b5bec587dd541","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug 63","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":220,"wires":[]},{"id":"139d29022c21efb4","type":"api-call-service","z":"79e71f2ceeae3357","name":"Play Radio 4","server":"2be748d3.da7088","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"entity_id\": $$.payload.myplayer,\t    \"media_content_type\": \"music\",\t    \"enqueue\": \"false\",\t    \"media_content_id\": \"x-sonosapi-hls:stations%7eplayable%7e%7ebbc_radio_fourfm%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_four?sid=325&flags=296&sn=7\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":690,"y":300,"wires":[["8c35f26ca9ea1173"]]},{"id":"8c35f26ca9ea1173","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug 64","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":300,"wires":[]},{"id":"55ba1ffdaa3215a7","type":"api-call-service","z":"79e71f2ceeae3357","name":"Play Radio 2","server":"2be748d3.da7088","version":5,"debugenabled":false,"domain":"media_player","service":"play_media","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"entity_id\": $$.payload.myplayer,\t    \"media_content_type\": \"music\",\t    \"enqueue\": \"false\",\t    \"media_content_id\": \"x-sonosapi-hls:stations%7eplayable%7e%7ebbc_radio_two%7e%7eurn%3abbc%3aradio%3anetwork%3abbc_radio_two?sid=325&flags=296&sn=11\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":690,"y":260,"wires":[["55320c83b7362847"]]},{"id":"55320c83b7362847","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug 65","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":260,"wires":[]},{"id":"7d56aeda6bb31d59","type":"comment","z":"79e71f2ceeae3357","name":"Use Tradfri remote to control SONOS at msg.player","info":"\n\nExtract key info from the Tradfri Remote (when connected as generic Zigbee device)\n\n\npayload.event.command & \"/\" & \npayload.event.args[0] & \"/\" &\npayload.event.args[1] & \"/\" &\npayload.event.args[2] & \"/\" &\npayload.event.endpoint_id & \"/\" & \npayload.event.cluster_id\n\n msg.\npayload\n\nPower: toggle////1/6\nUp:    step_with_on_off/0/43/5/1/8\nDown:  step/1/43/5/1/8\nLeft:  press/257/13/0/1/5\nRight: press/256/13/0/1/5\n\nThere are also long press codes not yet implemented.\n\n","x":230,"y":60,"wires":[]},{"id":"121841b5663ef398","type":"debug","z":"79e71f2ceeae3357","d":true,"name":"debug SUBFLOW","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":250,"y":200,"wires":[]},{"id":"cadefd1b44029448","type":"debug","z":"79e71f2ceeae3357","name":"Unhandled value.","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":340,"wires":[]},{"id":"2be748d3.da7088","type":"server","name":"Home Assistant","addon":true}]

Steve