I've re-written the code to optimise how it works and for how long you can be pressing the button.
The old flow limits you to 6 seconds. Granted that is a long time, but it is limited.
I re-wrote how it works which allows unlimited pressing of the button.
Also with the old way you had to wait 6 seconds between sequences, which is also a bit long.
The new one takes that down to 1 second.
This new way the reset
signal is kept from being sent because the button has been pressed again with an interval of less than 1 second
.
This is 4 examples.
I pressed the inject
node 1, 2,3 and 4 times, and got those 4 messages.
Sorry too: I haven't updated an of the comment
nodes.
I was a bit over come with excitement that I got the re-write done and wanted to share.
(Yeah, I know. Not really professional.)
[{"id":"1139a03d.d1ca","type":"change","z":"184dc884.7aba5f","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":610,"y":2270,"wires":[["fcb3cb17.693a9"]]},{"id":"900577c3.9deb4","type":"inject","z":"184dc884.7aba5f","name":"Reset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":"0.5","x":430,"y":2230,"wires":[["1139a03d.d1ca"]]},{"id":"820bd696.fbc028","type":"debug","z":"184dc884.7aba5f","name":"Four presses","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1180,"y":2370,"wires":[]},{"id":"525e3ec9.3bb6b8","type":"inject","z":"184dc884.7aba5f","name":"Start","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":273.33331298828125,"y":2201.111083984375,"wires":[["fcb3cb17.693a9","ba72e20d.299b8"]]},{"id":"fcb3cb17.693a9","type":"counter","z":"184dc884.7aba5f","name":"","init":"0","step":"1","lower":null,"upper":null,"mode":"increment","outputs":"1","x":620,"y":2200,"wires":[["9faf97df.4ce4a"]]},{"id":"4189a6d1.44073","type":"switch","z":"184dc884.7aba5f","name":"count presses","property":"count","propertyType":"flow","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"}],"checkall":"true","repair":false,"outputs":4,"x":790,"y":2310,"wires":[["83d02113.4743b8"],["fbfe53e5.4fcae8"],["e22efc97.c6b018"],["d9a249bd.1f82a8"]],"info":"Just expand the flow.count to how ever many\npresses you want/need."},{"id":"ba72e20d.299b8","type":"trigger","z":"184dc884.7aba5f","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"1","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":440,"y":2310,"wires":[["62860129.ec7bd","4189a6d1.44073"]]},{"id":"9faf97df.4ce4a","type":"change","z":"184dc884.7aba5f","name":"Flow set","rules":[{"t":"set","p":"count","pt":"flow","to":"count","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":2200,"wires":[["a018a094.13d14"]]},{"id":"ddd0ab58.0a3e58","type":"debug","z":"184dc884.7aba5f","name":"Tripple press","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1180,"y":2330,"wires":[]},{"id":"ed9739c.0628148","type":"debug","z":"184dc884.7aba5f","name":"Double press","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1180,"y":2290,"wires":[]},{"id":"8082f0.4ba02d1","type":"debug","z":"184dc884.7aba5f","name":"Single Press","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1180,"y":2250,"wires":[]},{"id":"83d02113.4743b8","type":"change","z":"184dc884.7aba5f","name":"Single Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"Single Press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":2250,"wires":[["8082f0.4ba02d1"]]},{"id":"fbfe53e5.4fcae8","type":"change","z":"184dc884.7aba5f","name":"Double Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"Double Press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":2290,"wires":[["ed9739c.0628148"]]},{"id":"e22efc97.c6b018","type":"change","z":"184dc884.7aba5f","name":"Tripple Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"Tripple Press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":2330,"wires":[["ddd0ab58.0a3e58"]]},{"id":"d9a249bd.1f82a8","type":"change","z":"184dc884.7aba5f","name":"Four Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"Four Press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1000,"y":2370,"wires":[["820bd696.fbc028"]]},{"id":"a1783324.3f9f","type":"comment","z":"184dc884.7aba5f","name":"DELAY - Readme","info":"The DELAY time has to be a bit longer than how\nlong it takes you to press the button the\nmaximum number of times.\nRead information in the SWITCH node too!","x":820,"y":2120,"wires":[]},{"id":"660d35d0.b41aa4","type":"comment","z":"184dc884.7aba5f","name":"Input","info":"","x":430,"y":2160,"wires":[]},{"id":"f91932b.cacfb5","type":"comment","z":"184dc884.7aba5f","name":"Outputs","info":"Debug nodes are here now, but just connect\nthem to what ever you want.\nThe messages sent are in the nodes just before\nthe debug nodes.\n","x":1160,"y":2210,"wires":[]},{"id":"a018a094.13d14","type":"debug","z":"184dc884.7aba5f","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"count","targetType":"msg","x":1000,"y":2200,"wires":[]},{"id":"62860129.ec7bd","type":"delay","z":"184dc884.7aba5f","name":"Delay","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":430,"y":2270,"wires":[["1139a03d.d1ca"]]}]