# How to detect multiple presses on a single button

**URL:** <https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560>\
**Category:** Share Your Projects\
**Created:** [19 January 2020 07:44 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560 "2020-01-19T07:44:08Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![tsknightstorm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tsknightstorm/32/65501_2.png) [@tsknightstorm](https://discourse.nodered.org/u/tsknightstorm)\
**Post date:** [8 July 2022 23:00 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/42 "2022-07-08T23:00:22Z")

</div>

Recently I got back to this thread and learned about your improvements. So now I took the time to update my solution specialized for Shelly devices. With @BartButenaers node it is now much cleaner. Thank you for your great work.  
@BartButenaers – One thing I miss a little and this is a “trippe\_clicked” output. I guess that would be a easy extension of that node.

Here is my solution

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e1f6fa0af9609ef42d3841babf6099f3cbba758.png)

```auto
[
    {
        "id": "a85fa439244b9676",
        "type": "button-events",
        "z": "811f7114.3750e",
        "name": "",
        "outputs": 4,
        "inputField": "payload",
        "inputFieldType": "msg",
        "outputField": "payload",
        "outputFieldType": "msg",
        "downValue": "1",
        "downValueType": "str",
        "upValue": "0",
        "upValueType": "str",
        "idleValue": "1",
        "clickedInterval": "500",
        "pressedInterval": "500",
        "debounceInterval": "0",
        "events": [
            {
                "type": "clicked"
            },
            {
                "type": "double_clicked"
            },
            {
                "type": "pressed"
            },
            {
                "type": "released"
            }
        ],
        "x": 460,
        "y": 1980,
        "wires": [
            [
                "e23c379d3ec280dd"
            ],
            [
                "e23c379d3ec280dd"
            ],
            [
                "cdf19b51c3385ad9"
            ],
            [
                "cdf19b51c3385ad9"
            ]
        ]
    },
    {
        "id": "cdf19b51c3385ad9",
        "type": "one-button-dimmer",
        "z": "811f7114.3750e",
        "name": "",
        "interval": "150",
        "step": "3",
        "minValue": "5",
        "maxValue": "100",
        "startCommand": "pressed",
        "stopCommand": "released",
        "x": 720,
        "y": 2020,
        "wires": [
            [
                "e23c379d3ec280dd"
            ]
        ]
    },
    {
        "id": "e23c379d3ec280dd",
        "type": "function",
        "z": "811f7114.3750e",
        "name": "click action",
        "func": "const out_ceilingLight = \"shellies/shelly1pm-C44728/relay/0/command\";\nconst out_vintageLight = \"shellies/ShellyVintage-6EE939/light/0/set\";\n\n// click action\nswitch(msg.payload)\n{\n\n case \"clicked\": // single click action\n node.send({topic: out_ceilingLight, payload: {\"turn\": \"toggle\"}});\n break;\n \n case \"double_clicked\": // double click action\n node.send({topic: out_vintageLight, payload: {\"turn\": \"toggle\"}});\n break;\n \n case \"tripple_clicked\": // three clicks action\n // right now not possible with Button events\n break;\n \n default: // number -> dimming\n node.send({topic: out_vintageLight, payload: {\"brightness\": msg.payload ,\"turn\": \"on\"}});\n\n break;\n}\n\n\nnode.status({text: msg.payload});",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Code added here will be run once\n// whenever the node is deployed.\nconst dimmingTopic = \"dimming\";\ncontext.set(dimmingTopic, 200); ",
        "finalize": "",
        "libs": [],
        "x": 1010,
        "y": 1980,
        "wires": [
            [
                "7cba755bbd268e7e"
            ]
        ]
    },
    {
        "id": "7cba755bbd268e7e",
        "type": "mqtt out",
        "z": "811f7114.3750e",
        "name": "",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "23a96fe8.c5ef",
        "x": 1190,
        "y": 1980,
        "wires": []
    },
    {
        "id": "5de9bb49e3bf8824",
        "type": "mqtt in",
        "z": "811f7114.3750e",
        "name": "Taster Kinderzimmer",
        "topic": "shellies/shelly1pm-C44728/input/0",
        "qos": "2",
        "datatype": "auto",
        "broker": "23a96fe8.c5ef",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 150,
        "y": 1980,
        "wires": [
            [
                "a85fa439244b9676"
            ]
        ]
    },
    {
        "id": "23a96fe8.c5ef",
        "type": "mqtt-broker",
        "name": "",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [9 July 2022 09:30 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/43 "2022-07-09T09:30:44Z")

</div>

> [@tsknightstorm](#):
>
> I guess that would be a easy extension of that node.

Hi @tsknightstorm,  
It is quite the opposite. My node is based on the [https://www.npmjs.com/package/button-events](https://www.npmjs.com/package/button-events) which doesn't support tripple clicks. If you want, you can ask the author whether he wants to add it to his library. Afterwards I can implement it into my node.  
Bart

---

<div class="post-metadata">

**Author:** ![tsknightstorm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tsknightstorm/32/65501_2.png) [@tsknightstorm](https://discourse.nodered.org/u/tsknightstorm)\
**Post date:** [18 July 2022 05:33 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/44 "2022-07-18T05:33:16Z")

</div>

V1.1.0 of button-events is out that supports now tripple and quadruppe click events. Would it be possible for you to update also your node? In my oppinion this is the perfect solution for button clicks in Node Red.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [18 July 2022 21:20 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/45 "2022-07-18T21:20:09Z")

</div>

Hi @tsknightstorm,

I assume that Bryan has added this feature on your request? But I don't see your question somewher in his Github repo... Anyway thanks a lot for making this node better!!!

I have quickly added the new features to my node, so it now should support tripple and quadrupple clicks. Here is my test flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/b/5ba3c597a8f73dbb02f923b83742f09b51fc491f.png)

```auto
[{"id":"e94468b6.358e18","type":"debug","z":"fbee74db83781e91","name":"Clicked","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1420,"y":2240,"wires":[]},{"id":"4bc6d6f0.115498","type":"inject","z":"fbee74db83781e91","name":"Inject 0","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"ZERO","payload":"0","payloadType":"num","x":810,"y":2360,"wires":[["ecd423af.746cd"]]},{"id":"c6658632.447978","type":"button-events","z":"fbee74db83781e91","name":"","outputs":5,"inputField":"payload","inputFieldType":"msg","outputField":"payload","outputFieldType":"msg","downValue":"0","downValueType":"num","upValue":"1","upValueType":"num","idleValue":"1","clickedInterval":"2000","pressedInterval":"5000","debounceInterval":"200","events":[{"type":"clicked"},{"type":"pressed"},{"type":"double_clicked"},{"type":"triple_clicked"},{"type":"quadruple_clicked"}],"x":1180,"y":2320,"wires":[["e94468b6.358e18"],["625d6be5.811694"],["b0bd0d59.bc7cf"],["b6d3f93f86c1d86d"],["12b7543be70d8565"]]},{"id":"9130e7a8.87df08","type":"inject","z":"fbee74db83781e91","name":"Inject 1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"ONE","payload":"1","payloadType":"num","x":810,"y":2420,"wires":[["ecd423af.746cd"]]},{"id":"3ac673fa.12ef9c","type":"ui_chart","z":"fbee74db83781e91","name":"Poor man oscilloscope","group":"27b65cf1.24c8e4","order":3,"width":0,"height":0,"label":"Poor man oscilloscope","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"step","nodata":"","dot":false,"ymin":"0","ymax":"2","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":1200,"y":2420,"wires":[[]]},{"id":"ecd423af.746cd","type":"switch","z":"fbee74db83781e91","name":"","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"2","vt":"num"},{"t":"lt","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":990,"y":2360,"wires":[["c6658632.447978"],["3ac673fa.12ef9c"]]},{"id":"b0bd0d59.bc7cf","type":"debug","z":"fbee74db83781e91","name":"Double clicked","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1440,"y":2320,"wires":[]},{"id":"625d6be5.811694","type":"debug","z":"fbee74db83781e91","name":"Pressed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1420,"y":2280,"wires":[]},{"id":"b6d3f93f86c1d86d","type":"debug","z":"fbee74db83781e91","name":"Triple clicked","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1430,"y":2360,"wires":[]},{"id":"12b7543be70d8565","type":"debug","z":"fbee74db83781e91","name":"Quadruple clicked","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1450,"y":2400,"wires":[]},{"id":"a5609c591f687241","type":"trigger","z":"fbee74db83781e91","name":"","op1":"0","op2":"1","op1type":"str","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":960,"y":2260,"wires":[["c6658632.447978"]]},{"id":"b282ad502bae2e6d","type":"inject","z":"fbee74db83781e91","name":"Create pulse","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":750,"y":2260,"wires":[["a5609c591f687241"]]},{"id":"27b65cf1.24c8e4","type":"ui_group","name":"HLS demo","tab":"787ed714.674938","order":1,"disp":true,"width":"12","collapse":false},{"id":"787ed714.674938","type":"ui_tab","name":"Code","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

```

I have not tested this very deeply, so I would appreciate if you could do some more tests, and review the readme page (see [triple\_and\_double\_clicks](https://github.com/bartbutenaers/node-red-contrib-button-events/tree/triple_and_double_clicks) branch on Github) and the information on the node's info panel...

This version is not available on npm yet, but you can install it directly from my Github repo (when you have git installed) from within your .node-red folder:

```auto
npm install bartbutenaers/node-red-contrib-button-events#triple_and_double_clicks

```

BTW I find it difficult to adjust the different timings of this node, to get it correct for real physical button clicks. Therefore at the time being I have asked Bryan (see [here](https://github.com/bnielsen1965/button-events/issues/2)) whether he could add a feature for this. If you have ever ideas about this, I would appreciate a lot if you could discuss this with Bryan. I think this would make this node much more useful. But unfortunately I don't have time to do this all on my own...

Thanks!!  
Bart

---

<div class="post-metadata">

**Author:** ![johntdyer](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johntdyer/32/2638_2.png) [@johntdyer](https://discourse.nodered.org/u/johntdyer)\
**Post date:** [27 July 2022 12:43 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/46 "2022-07-27T12:43:57Z")

</div>

Any idea when this will be published ? Its actually difficult to install npm's directly when using the node-red add-on in Home Assistant, so a proper npm release would be great

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 July 2022 21:25 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/47 "2022-07-27T21:25:57Z")

</div>

Which one?

If it is the one from @bart the command is shown:  
`npm install bartbutenaers/node-red-contrib-button-events#triple_and_double_clicks`

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 July 2022 22:04 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/48 "2022-07-27T22:04:10Z")

</div>

> [@Trying\_to\_learn](#):
>
> the command is shown

Nope! Bart has already said in his previous post that he has not yet published the recent changes to npm yet, and it can only be installed direct from Bart's repo.  
You are unable to install the recent update direct from npm or node-RED's manage palette, which the OP has requested

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 July 2022 22:07 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/49 "2022-07-27T22:07:27Z")

</div>

Oh, sorry... I am way out of the conversation and probably should have not replied.

But I got a notification and read it as I saw it.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 July 2022 22:26 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/50 "2022-07-27T22:26:38Z")

</div>

> [@Trying\_to\_learn](#):
>
> I am way out of the conversation and probably should have not replied.

Been there, done that 😆

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [28 July 2022 05:17 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/51 "2022-07-28T05:17:14Z")

</div>

> [@johntdyer](#):
>
> Any idea when this will be published

@johntdyer,  
I need to finish some parts, together with @tsknightstorm. But she has a very busy personal life at the moment. So I assume somewhere in august, as soon as we both have time.  
Bart

---

<div class="post-metadata">

**Author:** ![tsknightstorm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tsknightstorm/32/65501_2.png) [@tsknightstorm](https://discourse.nodered.org/u/tsknightstorm)\
**Post date:** [8 August 2022 09:17 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/52 "2022-08-08T09:17:08Z")

</div>

Bart has now published a beta release. If someone is happy to help testing, we would appreciate it.

> [@\[ANNOUNCE\] node-red-contrib-button-events version 2.0.0 beta](https://discourse.nodered.org/t/announce-node-red-contrib-button-events-version-2-0-0-beta/66159):
>
> Hi folks, When I published at the time being my [node-red-contrib-button-events](https://github.com/bartbutenaers/node-red-contrib-button-events) node, I was not 100% pleased with it. Because you needed to figure out the button click timings yourself, and I don't expect that everybody has an oscilloscope at home. Although in this community I would not be surprised if 99% would have such a device on the dining room table rofl Thanks to the enthousiastic cooperation with @tsknightstorm, which provided me a boost to implement together a series of new feature…

---

<div class="post-metadata">

**Author:** ![ChrisF](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@ChrisF](https://discourse.nodered.org/u/ChrisF)\
**Post date:** [17 January 2023 10:45 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/53 "2023-01-17T10:45:01Z")

</div>

Hello all,  
I also looking for a solution to dim my light in CamperVan.  
I have connected to a Raspberry Pi with your Sonoff Zigbee dongle and a philips hue button via Zigbee2Mqtt learned.  
I would like to control it so that:  
1x press = light on 20%  
2x press = 40%  
3x press = 60%  
4x press = 80%  
5x press = 100%  
Press 1x long = light off

for alternatives I am of course open (for example keep switch pressed etc.)

Finally the whole thing has to be sent via MQTT to a Wemos D2 mini. The dimming is then done via a Mosfet.

Is this feasible and can someone help me here or send a flow that I can adapt.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 January 2023 10:48 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/54 "2023-01-17T10:48:23Z")

</div>

That shouldn't be too hard to do.  
My node would go most of the way to doing what you want.

You may need to declare what the messages need to be though.

If/when I get time I could make a demo version though.

---

<div class="post-metadata">

**Author:** ![ChrisF](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@ChrisF](https://discourse.nodered.org/u/ChrisF)\
**Post date:** [17 January 2023 10:54 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/55 "2023-01-17T10:54:43Z")

</div>

Hello,  
thank you for your fast answer.  
The system itself already exists.  
Currently it works so that everything is controlled via a touchscreen.  
I would "only" have to integrate the Zigbee button into the system.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 January 2023 10:56 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/56 "2023-01-17T10:56:24Z")

</div>

You haven't told me what the messages need to be.

Does the `Zigbee` send both an `up` and `down` message when the button is pressed?  
If it doesn't it will be hard to detect a long press.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 January 2023 11:21 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/57 "2023-01-17T11:21:12Z")

</div>

Here is a NEARLY WORKING example.

```auto
[{"id":"4be6db179f2af0b9","type":"subflow","name":"Press count","info":"Used to count button presses and send the number in a message.\nSet the *timeout* value in the `delay` variable.\n\nThen send the output message into a `switch` node to do wonderful things.\n\nThe output message is a `number`.","category":"","in":[{"x":60,"y":330,"wires":[{"id":"a457eafcdad07d0b"}]}],"out":[{"x":820,"y":210,"wires":[{"id":"900cc4787c0480a4","port":0}]}],"env":[{"name":"delay","type":"num","value":"","ui":{"type":"input","opts":{"types":["num"]}}}],"meta":{},"color":"#D8BFD8","icon":"node-red-dashboard/ui_button.png","status":{"x":820,"y":370,"wires":[{"id":"900476fafffa3ae3","port":0}]}},{"id":"c2137fa8aec03468","type":"inject","z":"4be6db179f2af0b9","name":"Reset","repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"","payloadType":"date","x":280,"y":290,"wires":[["5188ca7c92884164"]]},{"id":"de02a7b5bf7954d2","type":"trigger","z":"4be6db179f2af0b9","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"0.5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":300,"y":250,"wires":[["a14dd5822f1f6015","900cc4787c0480a4"]]},{"id":"5188ca7c92884164","type":"change","z":"4be6db179f2af0b9","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"foo","tot":"str"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":250,"wires":[["d5314c210f7d9a76"]]},{"id":"d5314c210f7d9a76","type":"counter","z":"4be6db179f2af0b9","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":"1","x":460,"y":330,"wires":[["6a5f10e31345b897","bb0e17c295353204"]]},{"id":"6a5f10e31345b897","type":"change","z":"4be6db179f2af0b9","name":"Flow set","rules":[{"t":"set","p":"count","pt":"flow","to":"count","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":280,"wires":[[]]},{"id":"a457eafcdad07d0b","type":"change","z":"4be6db179f2af0b9","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"delay","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":145,"y":330,"wires":[["d5314c210f7d9a76","de02a7b5bf7954d2"]],"l":false},{"id":"a14dd5822f1f6015","type":"change","z":"4be6db179f2af0b9","name":"","rules":[{"t":"delete","p":"delay","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":415,"y":250,"wires":[["5188ca7c92884164"]],"l":false},{"id":"900cc4787c0480a4","type":"function","z":"4be6db179f2af0b9","name":"","func":"msg.payload = flow.get(\"count\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":460,"y":210,"wires":[[]]},{"id":"bb0e17c295353204","type":"function","z":"4be6db179f2af0b9","name":"CounterValue","func":"node.status({text: \"Counting \" + msg.count});\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":330,"wires":[[]]},{"id":"900476fafffa3ae3","type":"status","z":"4be6db179f2af0b9","name":"","scope":["bb0e17c295353204"],"x":670,"y":370,"wires":[[]]},{"id":"368441726da6ee2d","type":"switch","z":"61bbf627ae47ef79","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":6,"x":530,"y":370,"wires":[["eb54e503b5d97e8c"],["f181fd63da81183e"],["160f7a1381ce6497"],["4a85fa0b5cdb8740"],["14373e93f065b9ac"],["b7b26884eb6dad18"]]},{"id":"2408dde860e38d1e","type":"subflow:4be6db179f2af0b9","z":"61bbf627ae47ef79","name":"","env":[{"name":"delay","value":"500","type":"num"}],"x":360,"y":370,"wires":[["8c5f32e93ce2032d","368441726da6ee2d"]]},{"id":"eb54e503b5d97e8c","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"20% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":310,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"f181fd63da81183e","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"40% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":350,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"160f7a1381ce6497","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"60% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":390,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"4a85fa0b5cdb8740","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"80% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":430,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"14373e93f065b9ac","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"100% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":470,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"b7b26884eb6dad18","type":"change","z":"61bbf627ae47ef79","name":"Wipe","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":520,"wires":[["23049a79b40fe27a","3fd47f6616a9cca0"]]},{"id":"a8a93eacebc03ec5","type":"inject","z":"61bbf627ae47ef79","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":370,"wires":[["2408dde860e38d1e"]]},{"id":"eb74d0ccc1eef85e","type":"switch","z":"61bbf627ae47ef79","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Up","vt":"str"},{"t":"eq","v":"Down","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":420,"wires":[["2408dde860e38d1e","a938402218c16029"],["544b88e0a5acdbc3"]]},{"id":"fce5c98a896cee68","type":"change","z":"61bbf627ae47ef79","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":320,"wires":[["2408dde860e38d1e"]]},{"id":"8c5f32e93ce2032d","type":"debug","z":"61bbf627ae47ef79","name":"debug 54","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":310,"wires":[]},{"id":"3fd47f6616a9cca0","type":"debug","z":"61bbf627ae47ef79","name":"Light brightness","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":380,"wires":[]},{"id":"23049a79b40fe27a","type":"ui_text","z":"61bbf627ae47ef79","group":"d646d4608d936642","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":940,"y":470,"wires":[]},{"id":"c6f481318e118641","type":"ui_template","z":"61bbf627ae47ef79","group":"d646d4608d936642","name":"vol -","order":79,"width":1,"height":1,"format":"<div id=\"VolDown\">\n <md-button class=\"md-button TV-HDMI\" aria-label=\"VolDown\">\n <span style=\"color:{{msg.colour}}\" class=\"fa fa-minus remote-icon\"> </span>\n </md-button>\n</div>\n\n<script>\n\n(function($scope) {\n \n$('#VolDown').on('touchstart mousedown', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"VolDown\",\"payload\": \"Down\"});\n});\n\n$('#VolDown').on('touchend mouseup', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"VolDown\",\"payload\": \"Up\"});\n});\n \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":190,"y":470,"wires":[["248a731374d2e269","eb74d0ccc1eef85e"]]},{"id":"a938402218c16029","type":"change","z":"61bbf627ae47ef79","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":420,"wires":[["544b88e0a5acdbc3"]]},{"id":"544b88e0a5acdbc3","type":"delay","z":"61bbf627ae47ef79","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":560,"wires":[["b1457747009dbc0b"]]},{"id":"08eed27cd045d4d0","type":"inject","z":"61bbf627ae47ef79","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":320,"wires":[["fce5c98a896cee68"]]},{"id":"b1457747009dbc0b","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":560,"wires":[["23049a79b40fe27a"]]},{"id":"248a731374d2e269","type":"debug","z":"61bbf627ae47ef79","name":"debug 55","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":200,"y":530,"wires":[]},{"id":"d646d4608d936642","type":"ui_group","name":"Group 1","tab":"1f97ed5dea097aaa","order":1,"disp":true,"width":6},{"id":"1f97ed5dea097aaa","type":"ui_tab","name":"Example","icon":"dashboard","order":45,"disabled":false,"hidden":false}]

```

You just need to work out how to negate the message that turns the light back on to 20% after it is turned off.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [17 January 2023 11:34 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/58 "2023-01-17T11:34:00Z")

</div>

FULLY WORKING version.

You have to hold the button for `3` seconds to turn the light OFF

```auto
[{"id":"4be6db179f2af0b9","type":"subflow","name":"Press count","info":"Used to count button presses and send the number in a message.\nSet the *timeout* value in the `delay` variable.\n\nThen send the output message into a `switch` node to do wonderful things.\n\nThe output message is a `number`.","category":"","in":[{"x":60,"y":330,"wires":[{"id":"a457eafcdad07d0b"},{"id":"df8cb339f3aed3ba"}]}],"out":[{"x":820,"y":210,"wires":[{"id":"900cc4787c0480a4","port":0}]}],"env":[{"name":"delay","type":"num","value":"","ui":{"type":"input","opts":{"types":["num"]}}}],"meta":{},"color":"#D8BFD8","icon":"node-red-dashboard/ui_button.png","status":{"x":820,"y":370,"wires":[{"id":"900476fafffa3ae3","port":0}]}},{"id":"c2137fa8aec03468","type":"inject","z":"4be6db179f2af0b9","name":"Reset","repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"","payloadType":"date","x":300,"y":290,"wires":[["5188ca7c92884164"]]},{"id":"de02a7b5bf7954d2","type":"trigger","z":"4be6db179f2af0b9","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"0.5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":320,"y":250,"wires":[["a14dd5822f1f6015","900cc4787c0480a4"]]},{"id":"5188ca7c92884164","type":"change","z":"4be6db179f2af0b9","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"foo","tot":"str"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":250,"wires":[["d5314c210f7d9a76"]]},{"id":"d5314c210f7d9a76","type":"counter","z":"4be6db179f2af0b9","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":"1","x":470,"y":330,"wires":[["6a5f10e31345b897","bb0e17c295353204"]]},{"id":"6a5f10e31345b897","type":"change","z":"4be6db179f2af0b9","name":"Flow set","rules":[{"t":"set","p":"count","pt":"flow","to":"count","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":280,"wires":[[]]},{"id":"a457eafcdad07d0b","type":"change","z":"4be6db179f2af0b9","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"delay","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":145,"y":330,"wires":[["d5314c210f7d9a76","de02a7b5bf7954d2"]],"l":false},{"id":"a14dd5822f1f6015","type":"change","z":"4be6db179f2af0b9","name":"","rules":[{"t":"delete","p":"delay","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":425,"y":250,"wires":[["5188ca7c92884164"]],"l":false},{"id":"900cc4787c0480a4","type":"function","z":"4be6db179f2af0b9","name":"","func":"msg.payload = flow.get(\"count\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":210,"wires":[[]]},{"id":"bb0e17c295353204","type":"function","z":"4be6db179f2af0b9","name":"CounterValue","func":"node.status({text: \"Counting \" + msg.count});\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":650,"y":330,"wires":[[]]},{"id":"900476fafffa3ae3","type":"status","z":"4be6db179f2af0b9","name":"","scope":["bb0e17c295353204"],"x":670,"y":370,"wires":[[]]},{"id":"df8cb339f3aed3ba","type":"switch","z":"4be6db179f2af0b9","name":"","property":"reset","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":180,"y":210,"wires":[["397e91b8f88a8919"]]},{"id":"397e91b8f88a8919","type":"delay","z":"4be6db179f2af0b9","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":310,"y":210,"wires":[["900cc4787c0480a4"]]},{"id":"368441726da6ee2d","type":"switch","z":"61bbf627ae47ef79","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":6,"x":530,"y":370,"wires":[["eb54e503b5d97e8c"],["f181fd63da81183e"],["160f7a1381ce6497"],["4a85fa0b5cdb8740"],["14373e93f065b9ac"],["b7b26884eb6dad18"]]},{"id":"2408dde860e38d1e","type":"subflow:4be6db179f2af0b9","z":"61bbf627ae47ef79","name":"","env":[{"name":"delay","value":"500","type":"num"}],"x":360,"y":370,"wires":[["8c5f32e93ce2032d","368441726da6ee2d"]]},{"id":"eb54e503b5d97e8c","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"20% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":310,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"f181fd63da81183e","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"40% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":350,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"160f7a1381ce6497","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"60% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":390,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"4a85fa0b5cdb8740","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"80% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":430,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"14373e93f065b9ac","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"100% brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":470,"wires":[["3fd47f6616a9cca0","23049a79b40fe27a"]]},{"id":"b7b26884eb6dad18","type":"change","z":"61bbf627ae47ef79","name":"Wipe","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":520,"wires":[["23049a79b40fe27a","3fd47f6616a9cca0"]]},{"id":"a8a93eacebc03ec5","type":"inject","z":"61bbf627ae47ef79","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":370,"wires":[["2408dde860e38d1e"]]},{"id":"fce5c98a896cee68","type":"change","z":"61bbf627ae47ef79","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":270,"wires":[["2408dde860e38d1e"]]},{"id":"9011504eb312ea1b","type":"gate","z":"61bbf627ae47ef79","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":340,"y":440,"wires":[["2408dde860e38d1e"]]},{"id":"8c5f32e93ce2032d","type":"debug","z":"61bbf627ae47ef79","name":"debug 54","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":540,"y":310,"wires":[]},{"id":"3fd47f6616a9cca0","type":"debug","z":"61bbf627ae47ef79","name":"Light brightness","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":380,"wires":[]},{"id":"23049a79b40fe27a","type":"ui_text","z":"61bbf627ae47ef79","group":"d646d4608d936642","order":1,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"row-spread","className":"","x":940,"y":470,"wires":[]},{"id":"08eed27cd045d4d0","type":"inject","z":"61bbf627ae47ef79","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":270,"wires":[["fce5c98a896cee68"]]},{"id":"eb74d0ccc1eef85e","type":"switch","z":"61bbf627ae47ef79","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Up","vt":"str"},{"t":"eq","v":"Down","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":210,"y":480,"wires":[["a938402218c16029","9011504eb312ea1b"],["544b88e0a5acdbc3"]]},{"id":"69ba4d7ee9b81cd5","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":505,"y":500,"wires":[["9011504eb312ea1b"]],"l":false},{"id":"b1457747009dbc0b","type":"change","z":"61bbf627ae47ef79","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":560,"wires":[["23049a79b40fe27a"]]},{"id":"c6f481318e118641","type":"ui_template","z":"61bbf627ae47ef79","group":"d646d4608d936642","name":"vol -","order":79,"width":1,"height":1,"format":"<div id=\"VolDown\">\n <md-button class=\"md-button TV-HDMI\" aria-label=\"VolDown\">\n <span style=\"color:{{msg.colour}}\" class=\"fa fa-minus remote-icon\"> </span>\n </md-button>\n</div>\n\n<script>\n\n(function($scope) {\n \n$('#VolDown').on('touchstart mousedown', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"VolDown\",\"payload\": \"Down\"});\n});\n\n$('#VolDown').on('touchend mouseup', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"topic\":\"VolDown\",\"payload\": \"Up\"});\n});\n \n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":true,"templateScope":"local","className":"","x":190,"y":530,"wires":[["248a731374d2e269","eb74d0ccc1eef85e"]]},{"id":"a938402218c16029","type":"change","z":"61bbf627ae47ef79","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":480,"wires":[["544b88e0a5acdbc3"]]},{"id":"544b88e0a5acdbc3","type":"delay","z":"61bbf627ae47ef79","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":540,"y":560,"wires":[["b1457747009dbc0b","48a1be336e584b23"]]},{"id":"48a1be336e584b23","type":"trigger","z":"61bbf627ae47ef79","name":"","op1":"close","op2":"open","op1type":"str","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":455,"y":500,"wires":[["69ba4d7ee9b81cd5"]],"l":false},{"id":"248a731374d2e269","type":"debug","z":"61bbf627ae47ef79","name":"debug 55","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":200,"y":590,"wires":[]},{"id":"d646d4608d936642","type":"ui_group","name":"Group 1","tab":"1f97ed5dea097aaa","order":1,"disp":true,"width":6},{"id":"1f97ed5dea097aaa","type":"ui_tab","name":"Example","icon":"dashboard","order":45,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![ChrisF](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@ChrisF](https://discourse.nodered.org/u/ChrisF)\
**Post date:** [17 January 2023 16:54 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/59 "2023-01-17T16:54:57Z")

</div>

puuh this heavy 🙂

I have imported the two flows.  
and inserted the hue button.

I have many errors and am a bit overloaded

 ![Bildschirm­foto 2023-01-17 um 17.52.33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf5406e58d262674ca7ab40eee8b518db45bf63b.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 January 2023 17:18 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/60 "2023-01-17T17:18:51Z")

</div>

First identify which node is sending those msgs. If you click on the digits after `node:` in the debug, it will flash the node that sent that meg.

From the text of the message, the msg.payload needs to be a nuvmber so add a debug node to the output of the node feeding the node that spews out the debug and look to see what it contains. It could be you are sending a string that contains a number.

---

<div class="post-metadata">

**Author:** ![ChrisF](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@ChrisF](https://discourse.nodered.org/u/ChrisF)\
**Post date:** [17 January 2023 17:42 UTC](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560/61 "2023-01-17T17:42:18Z")

</div>

![Bildschirm­foto 2023-01-17 um 18.42.03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a21e7cd93839e5455b1fb94fb284d9ad174cc72.png)

[Previous page](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560.md?page=2)

[Next page](https://discourse.nodered.org/t/how-to-detect-multiple-presses-on-a-single-button/20560.md?page=4)
