Multiple button events to single output

This flow was originally designed to handle multiple inputs from ZigBee buttons, that does not have multiple button events. Input can be anything, so the flow is not limited to be used with buttons.

Sets output based on number of inputs received within timespan. Outputs contains number of detected pres

[{"id":"26dc23f0398a79c2","type":"subflow","name":"Multipress","info":"","category":"","in":[{"x":40,"y":460,"wires":[{"id":"c2c049ba0d3221b1"},{"id":"38fadaf395ea0d75"},{"id":"72c4dc5febf27b7b"}]}],"out":[{"x":1110,"y":220,"wires":[{"id":"a097ef0bd92f0533","port":0}]},{"x":1120,"y":260,"wires":[{"id":"892af95c35da20eb","port":0}]},{"x":1110,"y":300,"wires":[{"id":"d4d3d74391052d5b","port":0}]},{"x":1120,"y":340,"wires":[{"id":"fb0d6c0a66e1df43","port":0}]},{"x":1150,"y":400,"wires":[{"id":"f9e3c1e5b294383f","port":0}]}],"env":[],"meta":{"module":"multipress","version":"0.0.1","author":"Torben Stallknecht <[email protected]>","desc":"Multi button press flow"},"color":"#3FADB5","inputLabels":["No Of pushes"],"outputLabels":["Single","Double","Tripple","Quadro","Complete payload"],"status":{"x":1080,"y":160,"wires":[{"id":"eeee16cdd86d70ce","port":0}]}},{"id":"fc0263cd622c89ae","type":"change","z":"26dc23f0398a79c2","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":380,"wires":[["38fadaf395ea0d75"]]},{"id":"83e63bac5a7e69c4","type":"switch","z":"26dc23f0398a79c2","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":420,"y":280,"wires":[["a097ef0bd92f0533"],["892af95c35da20eb"],["d4d3d74391052d5b"],["fb0d6c0a66e1df43"]]},{"id":"c2c049ba0d3221b1","type":"trigger","z":"26dc23f0398a79c2","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"500","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":200,"y":280,"wires":[["9c4e7cf586f4231f","83e63bac5a7e69c4"]]},{"id":"a097ef0bd92f0533","type":"change","z":"26dc23f0398a79c2","name":"Single Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["f9e3c1e5b294383f","eeee16cdd86d70ce"]]},{"id":"892af95c35da20eb","type":"change","z":"26dc23f0398a79c2","name":"Double Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":260,"wires":[["f9e3c1e5b294383f","eeee16cdd86d70ce"]]},{"id":"d4d3d74391052d5b","type":"change","z":"26dc23f0398a79c2","name":"Tripple Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":300,"wires":[["f9e3c1e5b294383f","eeee16cdd86d70ce"]]},{"id":"fb0d6c0a66e1df43","type":"change","z":"26dc23f0398a79c2","name":"Four Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"4","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":340,"wires":[["f9e3c1e5b294383f","eeee16cdd86d70ce"]]},{"id":"45f054435fe0ba3a","type":"comment","z":"26dc23f0398a79c2","name":"DELAY - Instructions","info":"In order to ensure correct triggering,\nthe delay should be set to be a little \nlonger than it would take to perfrom the maximum \namount of presses.\n\n","x":350,"y":420,"wires":[]},{"id":"de4eb71303ab40f6","type":"comment","z":"26dc23f0398a79c2","name":"Input","info":"","x":230,"y":40,"wires":[]},{"id":"508fdcc1deb34a36","type":"comment","z":"26dc23f0398a79c2","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":1090,"y":40,"wires":[]},{"id":"9c4e7cf586f4231f","type":"delay","z":"26dc23f0398a79c2","name":"Delay","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":390,"y":380,"wires":[["fc0263cd622c89ae"]]},{"id":"45c69515b0bc0fec","type":"change","z":"26dc23f0398a79c2","name":"Flow set count","rules":[{"t":"set","p":"count","pt":"flow","to":"count","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1140,"y":460,"wires":[[]]},{"id":"38fadaf395ea0d75","type":"counter","z":"26dc23f0398a79c2","name":"Count presses","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"1","x":720,"y":460,"wires":[["45c69515b0bc0fec"]]},{"id":"72c4dc5febf27b7b","type":"change","z":"26dc23f0398a79c2","name":"Store origional payload","rules":[{"t":"set","p":"org_payload","pt":"flow","to":"payload","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":500,"wires":[[]]},{"id":"f9e3c1e5b294383f","type":"function","z":"26dc23f0398a79c2","name":"Merge presses with payload","func":"var presses = msg.payload;\n\nmsg.payload = flow.get(\"org_payload\");\n\nmsg.payload.presses = presses;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":920,"y":400,"wires":[[]]},{"id":"eeee16cdd86d70ce","type":"change","z":"26dc23f0398a79c2","name":"Format status","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t    \"fill\":\"green\",\t    \"shape\":\"dot\",\t    \"text\": \"Presses: \" & payload\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":160,"wires":[[]]}]

Flow Info

Created 1 year, 2 months ago
Rating: 4 4

Owner

Actions

Rate:

Node Types

Core
  • change (x8)
  • comment (x3)
  • delay (x1)
  • function (x1)
  • switch (x1)
  • trigger (x1)
Other
  • counter (x1)
  • subflow (x1)

Tags

  • multi
  • button
  • press
  • presses
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option