Node-Red Flow Samples/Sharing

Because I can't seem to let the whole multi-tap thing go... here is a simple subflow that encapsulates the timed-counter & switch so you can separate single/double/triple/quadruple+ taps after a button press .. Also you set the timing in the properties of the subflow instance node.. default is 450 ms. Note: On my system (C-4) Lutron 5 button picos the 2 & 4 buttons seem to need a bit longer time for multi tap at 700 ms..

Not shown on this partial sequence is "Increase" and "Decrease" Levels - Thanks to multi tap I can control dimming on 2 different sets of lights with one set of up/down buttons.. of course you have to be careful and not click up or down too fast when accessing single tap set.. but it's pretty intuitive once you get the hang of it.

Make sure you install the "node-red-contrib-timed-counter" node before importing this...

Button Taps

[{"id":"d0e305e1.7ad558","type":"subflow","name":"Button Taps","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"4e584c74.8f1724"}]}],"out":[{"x":640,"y":40,"wires":[{"id":"959b5260.c1c1c","port":0}]},{"x":640,"y":100,"wires":[{"id":"959b5260.c1c1c","port":1}]},{"x":640,"y":160,"wires":[{"id":"959b5260.c1c1c","port":2}]},{"x":640,"y":220,"wires":[{"id":"959b5260.c1c1c","port":3}]}],"env":[{"name":"TIME_LIMIT_MS","type":"num","value":"450"}],"color":"#E2D96E","inputLabels":["Button Press"],"outputLabels":["Single Tap","Double Tap","Triple Tap","Quad+ Tap"],"icon":"node-red-dashboard/ui_button.png","status":{"x":640,"y":280,"wires":[{"id":"b4ba35d5.020018","port":0}]}},{"id":"959b5260.c1c1c","type":"switch","z":"d0e305e1.7ad558","name":"Single Tap \\n Double Tap \\n Triple Tap \\n Quad+ Tap","property":"count","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"str"},{"t":"gte","v":"4","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":430,"y":80,"wires":[[],[],[],[]]},{"id":"4e584c74.8f1724","type":"timed-counter","z":"d0e305e1.7ad558","name":"","timelimit":"${TIME_LIMIT_MS}","timeunit":1,"withhold":true,"fixedtimeout":false,"pertopic":false,"x":200,"y":80,"wires":[["959b5260.c1c1c","b4ba35d5.020018"]]},{"id":"b4ba35d5.020018","type":"function","z":"d0e305e1.7ad558","name":"set status payload","func":"\nvar payload = {\n\"fill\": \"green\",\n\"shape\":\"dot\",\n\"text\": ( msg.count == 1 ? \"Single\" : (msg.count == 2 ? \"Double\": (msg.count == 3 ? \"Triple\": (msg.count == 4 ? \"Quadruple\": msg.count.toString() )))) + \" Tap\"\n};\n\nmsg.payload = payload;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":160,"wires":[[]]},{"id":"72661f7b.08887","type":"subflow:d0e305e1.7ad558","z":"af91369d.586338","name":"","x":880,"y":1980,"wires":[[],[],[],[]]}]


EDIT: Latest is here...

4 Likes