Node-red rf button multifunction single/double/triple press

How to make flow for rf button multifunction(single press/double press/triple press)?

my button sends command only when pressed.

Can someone show me example flow or share similar solution.

Is the RF code different for each press?

No. Code is alway the same.

I'm not sure about this completely, but something like this can be done

[{"id":"3d20d166.20e64e","type":"function","z":"18c83e13.bcdd42","name":"Count clicks","func":"var count = context.get(\"count\") || 0;\n\nif(msg.count === count && count !== 0){\n context.set(\"count\",0);\n return [null,msg];\n}\n\nif(count < 3){\n if(msg.delay === undefined){\n count++\n context.set(\"count\",count);\n }\n msg.delay = true;\n msg.count = count;\n return [msg,null];\n}\n\n","outputs":2,"noerr":0,"x":430,"y":520,"wires":[["e24258f7.cf6408"],["91d1cd16.daa69"]]},{"id":"27f0311a.6bd7de","type":"inject","z":"18c83e13.bcdd42","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":520,"wires":[["3d20d166.20e64e"]]},{"id":"e24258f7.cf6408","type":"delay","z":"18c83e13.bcdd42","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":430,"y":420,"wires":[["3d20d166.20e64e"]]},{"id":"91d1cd16.daa69","type":"debug","z":"18c83e13.bcdd42","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":540,"wires":[]}]

1 Like