Button kit - single and double click

Thanks, now I can pulse both relays. Now I want to resolve another problem. I would like to use remote push-button to control both relays. When I press button one time i want to pulse first relay and when I do double click I want to pulse second relay. Any advice?

Ydenek

Hi,

what about button press and long press? We already use that in Door Sensor project. Soon we add that functionality to the Button firmware.

If you really would like single and double click. There are two options whre the double click detect:

  • The detection can be done on the wirelless node by programming your code
  • By using default firmware in the node and some logic in the node-red.

The disadvantage of double-click is that when you do a single click, the code has to wait few hundred milliseconds in case you do the second click. This way you create a small delay which may not be desirable in some use cases.

Which way would you prefer?

Hi, some time ago I’ve created a flow to detect single/double/triple click. I put it here so others can use it.

Copy and select Import in the node-RED to use the flow.

[{"id":"92cf627f.2ad4a","type":"inject","z":"93c7e767.1355c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":200,"wires":[["6223891d.e5d878"]]},{"id":"c2dbb31a.6f1e9","type":"debug","z":"93c7e767.1355c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":200,"wires":[]},{"id":"99fa2425.52ef38","type":"trigger","z":"93c7e767.1355c8","op1":"","op2":"0","op1type":"nul","op2type":"num","duration":"2000","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":540,"y":200,"wires":[["27db4813.6c4fb8"]]},{"id":"6223891d.e5d878","type":"function","z":"93c7e767.1355c8","name":"","func":"counter = flow.get(\"counter\") | 0;\ncounter++;\n\nflow.set(\"counter\", counter);\n\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":200,"wires":[["99fa2425.52ef38"]]},{"id":"27db4813.6c4fb8","type":"change","z":"93c7e767.1355c8","name":"clear counter","rules":[{"t":"set","p":"payload","pt":"msg","to":"counter","tot":"flow"},{"t":"set","p":"counter","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":200,"wires":[["c2dbb31a.6f1e9"]]},{"id":"aead153b.dced68","type":"mqtt in","z":"93c7e767.1355c8","name":"","topic":"node/push-button:0/push-button/-/event-count","qos":"2","broker":"732137d.d2b0dc8","x":270,"y":120,"wires":[["6223891d.e5d878"]]},{"id":"732137d.d2b0dc8","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]

Martin