Listening for all keypresses?

I’m new to Node Red, so apologies if this is blatantly obvious to others.

I want a simple automation where if I triple click down on any light switch (dimmer or switch) in the house, all of the lights turn off. Good news is I have this working (well…kinda)! :slight_smile:

But I’m unsure of the following:

  1. Is there a more efficient way of doing this? I’m worried perhaps my approach isn’t great.
  2. I’d like to ignore this for 2 or 3 switches, but I’m not sure how to add that to this flow
  3. Are all of these events logged? When I turn on all the lights/fans in the house, I find that a) it takes a really long time to turn them all off and b) some don’t turn off. But I’m not sure how to debug what’s going on.
[{"id":"b88860e25be046b0","type":"tab","label":"All Lights Off","disabled":false,"info":"","env":[]},{"id":"94a88fb7ee98feec","type":"inject","z":"b88860e25be046b0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":580,"wires":[[]]},{"id":"3d5d1d1aed13ec8c","type":"ha-get-entities","z":"b88860e25be046b0","name":"get lights that are on","server":"7114fde5.02aa54","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":320,"y":160,"wires":[["098f15ac1853c245"]]},{"id":"098f15ac1853c245","type":"api-call-service","z":"b88860e25be046b0","name":"turn lights off","server":"7114fde5.02aa54","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\": $join(payload.entity_id, \",\")}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":510,"y":220,"wires":[[]]},{"id":"9b4f15e000925d96","type":"server-events","z":"b88860e25be046b0","name":"all lights triple click down (except theater closet)","server":"7114fde5.02aa54","version":2,"eventType":"zwave_js_value_notification","exposeToHomeAssistant":false,"eventData":"{\"value\":\"KeyPressed3x\",\"property_key\":\"001\"}","haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"waitForRunning":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"$outputData(\"eventData\").event_type","valueType":"jsonata"}],"event_type":"","x":180,"y":240,"wires":[["92f92829d5c1d782","3d5d1d1aed13ec8c"]]},{"id":"92f92829d5c1d782","type":"ha-get-entities","z":"b88860e25be046b0","name":"get fans that are on","server":"7114fde5.02aa54","version":0,"rules":[{"property":"entity_id","logic":"starts_with","value":"fan.","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":310,"y":320,"wires":[["4a67b2a4b7c68799"]]},{"id":"4a67b2a4b7c68799","type":"api-call-service","z":"b88860e25be046b0","name":"turn fans off","server":"7114fde5.02aa54","version":5,"debugenabled":false,"domain":"fan","service":"turn_off","areaId":[],"deviceId":[],"entityId":[],"data":"{\"entity_id\": $join(payload.entity_id, \",\")}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":510,"y":280,"wires":[[]]},{"id":"24773876dc609804","type":"debug","z":"b88860e25be046b0","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":400,"y":480,"wires":[]},{"id":"7114fde5.02aa54","type":"server","name":"Home Assistant","addon":true}]

I can’t be sure from the flow but for #3, are your lights/fans Zwave and, if yes, how many are you trying to turn off simultaneously? I am guessing that they are mostly if not all Zwave from this in the node setup:

If that’s the case, you are probably overwhelming your Zwave network. I don’t use HA for this but I had a Good Night Routine to turn off all of my lights and it required that I staggered the off commands. I also checked to see the state of the light before sending a command so it didn’t send an off command to something already off. For the node pallet and hub I use, the state is stored in Node Red so getting a device’s status didn’t require sending anything to the device. I don’t know if that is the case for the HA nodes.

Yes…everything is zwave.

The script is supposed to first check if a light is on, but in my testing, I turned everything on, so it is likely I overwhelmed the network :slight_smile:

How would you stagger the off commands without having to specify each light (I have 30+ switches in the house)