Has Anyone Implemented Double-Tap Logic in NR?

I’m curious to hear if anyone has implemented double-tap logic for a button in Node RED. I have a Hue Tap Dial device that I have integrated via Home Assistant into NR as part of my Beta setup and have successfully used a counter to detect both single and double-clicks. I would be interested to find out alternatives.

Thanks,
Simon

I did something for Pico to handle multi-tap:

It might be helpful, I test it with a “tap-simulator”:

[{"id":"40dacf0ad1e1201c","type":"group","z":"6c2e4ac868bc9921","name":"Btn1 Simulator","style":{"fill":"#ffC000","label":true,"color":"#000000","label-position":"n"},"nodes":["88be0d19795bf732","4488b1ea79448756","0b0b9a19d380345c","fe80a380eaa8b3ca","42d0cac0135a6174","57fe5fc77ab5b35d","562fa305a4c16190","2bf82859972696ba","52c23907e9e2ad82","673de388d2fdd7bf","86016dcdb1cd71f5","9b5984b5ac7c93d3","fe63d903ca9a9654","bb74de0e60023e1b","9504501c481de697","d91b63140b60433a","cd8c9dd9925e7624"],"x":394,"y":779,"w":572,"h":482},{"id":"88be0d19795bf732","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Single","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":490,"y":820,"wires":[["fe80a380eaa8b3ca"]]},{"id":"4488b1ea79448756","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Double","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":490,"y":940,"wires":[["42d0cac0135a6174"]]},{"id":"0b0b9a19d380345c","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Long","props":[{"p":"payload"},{"p":"delay","v":"1200 + $random() * 3000\t","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":490,"y":880,"wires":[["fe80a380eaa8b3ca","9b5984b5ac7c93d3"]]},{"id":"fe80a380eaa8b3ca","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 4}","op1type":"json","op2type":"json","duration":"150","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":660,"y":880,"wires":[["673de388d2fdd7bf"]]},{"id":"42d0cac0135a6174","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 3}","op1type":"json","op2type":"json","duration":"400","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":660,"y":940,"wires":[["fe80a380eaa8b3ca"]]},{"id":"57fe5fc77ab5b35d","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 3}","op1type":"json","op2type":"json","duration":"800","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":660,"y":1100,"wires":[["42d0cac0135a6174"],["fe80a380eaa8b3ca"]]},{"id":"562fa305a4c16190","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Triple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":490,"y":1100,"wires":[["57fe5fc77ab5b35d"]]},{"id":"2bf82859972696ba","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 3}","op1type":"json","op2type":"json","duration":"1200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":660,"y":1160,"wires":[["57fe5fc77ab5b35d"],["fe80a380eaa8b3ca"]]},{"id":"52c23907e9e2ad82","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Quadruple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":500,"y":1160,"wires":[["2bf82859972696ba"]]},{"id":"673de388d2fdd7bf","type":"change","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"msg.topic = btn1","rules":[{"t":"set","p":"payload.deviceId","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"payload.action","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":920,"wires":[["63d41a2a3d857440"]]},{"id":"86016dcdb1cd71f5","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 4}","op1type":"json","op2type":"json","duration":"1200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":1040,"wires":[["673de388d2fdd7bf"]]},{"id":"9b5984b5ac7c93d3","type":"function","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Long press delay","func":"node.status({fill:\"green\", shape:\"dot\", text:Math.round(msg.delay) + 'ms'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":820,"wires":[[]]},{"id":"fe63d903ca9a9654","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Quintuple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":500,"y":1220,"wires":[["bb74de0e60023e1b"]]},{"id":"bb74de0e60023e1b","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 3}","op1type":"json","op2type":"json","duration":"1600","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":660,"y":1220,"wires":[["2bf82859972696ba"],["fe80a380eaa8b3ca"]]},{"id":"9504501c481de697","type":"trigger","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"","op1":"{\"param\": 3}","op2":"{\"param\": 4}","op1type":"json","op2type":"json","duration":"400","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":660,"y":1040,"wires":[["fe80a380eaa8b3ca"],["86016dcdb1cd71f5"]]},{"id":"d91b63140b60433a","type":"inject","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Double LP","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":500,"y":1040,"wires":[["9504501c481de697"]]},{"id":"cd8c9dd9925e7624","type":"comment","z":"6c2e4ac868bc9921","g":"40dacf0ad1e1201c","name":"Long press 2nd tap","info":"","x":510,"y":1000,"wires":[]}]
2 Likes

Looks like it could be similar to what I found… It uses a counter and resets after the desired timeout, which, considering I am using the HA Hue integration, I may have to set a little longer than normal…

I would post the text for the flow, but worry is may have too many other things mixed in to make it confusing or at least unusable for others…

Yes, that looks like about the same principle, the only thing added to the pico flow is long press, but that will not work unless you have access to separate push and release events.

The main reason I entertained NR is that I seemed to need the double-tap option, though I now realise that I need to cater for the single-tap and double-tab in the same way (NR), which is a bit of a pain (no one’s fault), i.e. if I double-tap one of the Study buttons it currently changes both the lights (via the Hue app setup I have) and raises or lowers the roller blinds in the Study.

I did like the idea of keeping the lighting control within Hue, not sure why, but it felt “nice”, removing the need for another hub. But am thinking I will either move that control into HE or NR (Core)…

I use a toggle as well as a subflow. It’s worked really well for me. The only downside is that I can never remember which taps do what. I have these running on an opple button.
:rofl:

[{"id":"70c2e683.a04438","type":"subflow","name":"Toggle","info":"Basic flow to process a toggle.","category":"","in":[{"x":200,"y":180,"wires":[{"id":"ffc6e6b1.c48ab8"}]}],"out":[{"x":960,"y":160,"wires":[{"id":"d6b5dd16.925e1","port":0},{"id":"719140f9.8b90e","port":0}]}],"env":[],"meta":{"author":"AprilB"},"color":"#DDAA99"},{"id":"db5a0a3f.9a5928","type":"switch","z":"70c2e683.a04438","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":530,"y":180,"wires":[["d6b5dd16.925e1"],["719140f9.8b90e"]]},{"id":"d6b5dd16.925e1","type":"change","z":"70c2e683.a04438","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"next","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":140,"wires":[[]]},{"id":"719140f9.8b90e","type":"change","z":"70c2e683.a04438","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"next","pt":"flow","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":200,"wires":[[]]},{"id":"ffc6e6b1.c48ab8","type":"function","z":"70c2e683.a04438","name":"get next value","func":"msg.payload = flow.get(\"next\")||0;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":180,"wires":[["db5a0a3f.9a5928"]]},{"id":"b4db2dfc1c6caff1","type":"subflow:70c2e683.a04438","z":"0477d51280830841","name":"","env":[],"x":1800,"y":280,"wires":[["56ebecc0c545799b"]]}]
1 Like

I still use this to this day and it has been 99% flawless and the reason I don’t say 100% is when I have issues I am not sure if it is a communication, physical, or something wrong with my endpoints. And after another try it works, so I never look into it.

The main benefit of this method is it is infinitely scaling. You can double, triple, quad, quin, etc. tap as well as all of the holds including double, triple, etc. (and of course the releases associated with each of those). Now all you have to do is remember what each situation does, then get your loved ones to do the same :upside_down_face:

So for me I have it where the “singles” control lights, “doubles” control fans, and “triples” control curtains and most people are able to remember that since the buttons all do the same type of things, just for different devices.

4 Likes

I’m using an aqara QLML004-2015 button:


May be this is OT as you probably would like to see some examples of multi tap management from scratch not relying on the device internal multitap management.

[{"id":"ee283e0426d28195","type":"tab","label":"BUTTONS","disabled":false,"info":"","env":[]},{"id":"b0dc35cb93573779","type":"junction","z":"ee283e0426d28195","x":440,"y":240,"wires":[[]]},{"id":"8f9f24561498d4cb","type":"junction","z":"ee283e0426d28195","x":440,"y":320,"wires":[[]]},{"id":"c43122938cf98d34","type":"zigbee2mqtt-in","z":"ee283e0426d28195","name":"BT01-LUCI-LETTO","server":"411e2b8e9bdac70b","friendly_name":"BT01 (WXKG12LM)","device_id":"0x00158d0002d45c32","state":"0","outputAtStartup":false,"filterChanges":true,"enableMultiple":false,"x":130,"y":200,"wires":[["4c85f014f08b5bb4"]]},{"id":"4c85f014f08b5bb4","type":"switch","z":"ee283e0426d28195","name":"","property":"payload.action","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"hold","vt":"str"},{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":310,"y":200,"wires":[["890ac648362e6fde"],["36f0974d60263cf8"],["b0dc35cb93573779"],["8f9f24561498d4cb"]]},{"id":"99c1035ad8dcdc50","type":"shelly-gen1","z":"ee283e0426d28195","hostname":"192.168.1.59","description":"Luce LETTO","mode":"none","server":"561da6b1b53a8fed","outputmode":"status","uploadretryinterval":"0","pollinginterval":5000,"pollstatus":false,"getstatusoncommand":true,"devicetype":"Relay","outputs":1,"x":690,"y":160,"wires":[["706f5666ee9156b9"]]},{"id":"36f0974d60263cf8","type":"change","z":"ee283e0426d28195","name":"toggle luce","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"turn\":\"toggle\", \"relay\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":160,"wires":[["99c1035ad8dcdc50"]]},{"id":"384cd962d6890d76","type":"zigbee2mqtt-out","z":"ee283e0426d28195","name":"PL01-LETTO-COMODINO","server":"411e2b8e9bdac70b","friendly_name":"PL01-LETTO (SP 120)","device_id":"0x00158d00032aaa89","command":"state","commandType":"z2m_cmd","payload":"payload","payloadType":"msg","optionsValue":"","optionsType":"nothing","x":740,"y":80,"wires":[]},{"id":"0e2ed1d8df2e77b5","type":"comment","z":"ee283e0426d28195","name":"DOUBLE press: toggle Luce soffitto","info":"","x":580,"y":120,"wires":[]},{"id":"487a500a1f2c1b75","type":"comment","z":"ee283e0426d28195","name":"SINGLE press: toggle Luce comodino","info":"","x":590,"y":40,"wires":[]},{"id":"890ac648362e6fde","type":"change","z":"ee283e0426d28195","name":"toggle comodino","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"state\":\"toggle\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":80,"wires":[["384cd962d6890d76"]]},{"id":"706f5666ee9156b9","type":"change","z":"ee283e0426d28195","name":"set global.ST_LETTO","rules":[{"t":"set","p":"#:(ram)::ST_LETTO","pt":"global","to":"{\"on\":msg.payload.relays[0].ison, \"action\":msg.payload.relays[0].source}","tot":"jsonata","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":160,"wires":[[]]},{"id":"411e2b8e9bdac70b","type":"zigbee2mqtt-server","name":"CORE","host":"10.10.2.1","mqtt_port":"1883","mqtt_username":"","mqtt_password":"","mqtt_qos":"0","tls":"","usetls":false,"base_topic":"zigbee2mqtt"},{"id":"561da6b1b53a8fed","type":"shelly-gen1-server","port":"3865","hostname":""}]
1 Like

It seemed a little difficult to achieve the double-tap detection elsewhere, and given I had something that worked in NR, but with a delay in comm’s from Hue to HA to NR and the limitations with the config in the Hue App for single and long presses… I bit the bullet and paired the Study Hue Tap Dial to my Core, now using Zigbee2MQTT in Node Red to trigger either Hue Scenes on a single-tap or my Bond for my Shades on a double-tap. Much more responsive now :slight_smile: Who knows, I may even move the rest of my lighting over to Core… :slight_smile:

1 Like


:eyes:

Waiting with breathless anticipation.

1 Like

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