# Listening for all keypresses?

**URL:** <https://discourse.nodered.org/t/listening-for-all-keypresses/75435>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [19 February 2023 20:41 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435 "2023-02-19T20:41:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anikkar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/anikkar/32/76402_2.png) [@anikkar](https://discourse.nodered.org/u/anikkar)\
**Post date:** [19 February 2023 20:41 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/1 "2023-02-19T20:41:28Z")

</div>

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)! 🙂

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.

```auto
[{"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}]

```

Thanks!

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 February 2023 20:56 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/2 "2023-02-19T20:56:45Z")

</div>

If I import your flow into a typical Node-red installation I get this:

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1cc15ac2b8bd86fb4a784a574ea3a06412acc397.jpeg)

Everything except the inject and debug nodes is "Unknown".

You will probably find more people familiar with how things work in Home Assistant on the Home Assistant forum.

---

<div class="post-metadata">

**Author:** ![anikkar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/anikkar/32/76402_2.png) [@anikkar](https://discourse.nodered.org/u/anikkar)\
**Post date:** [19 February 2023 21:13 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/3 "2023-02-19T21:13:31Z")

</div>

Weird...I just exported the current flow, which looks like this for me:

 ![Screen Shot 2023-02-19 at 1.11.15 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/3673bfa2e9ab0954fe9a1d8bc62e942e4ebed9d2.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 February 2023 21:16 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/4 "2023-02-19T21:16:35Z")

</div>

That's because you have Home Assistant and I don't.

I am sure there are HA users on this forum, but most people here just use Node-red.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [19 February 2023 22:00 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/5 "2023-02-19T22:00:37Z")

</div>

Welcome to the Forum, @anikkar.

I'm afraid you have tripped over a couple of the obstacles described in this [FAQ](https://discourse.nodered.org/t/note-to-new-forum-members/71295). You will almost certainly get more help with this issue on the Home Assistant forum, but you can expect lots of support on Node-RED issues here if you follow that advice.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [20 April 2023 22:00 UTC](https://discourse.nodered.org/t/listening-for-all-keypresses/75435/6 "2023-04-20T22:00:41Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
