After the below conversation with @Cjkeenan I came up with a different solution for this. It handles multi-taps (however many you can handle to tap and remember), long press + long press release (combine these for dimming?), each long press and long press release even tells you have many taps you did in case you want multiple, different, long taps on each button. Yes, this flow gives you more events than you probably need, but there is no need to actually use them all.
The image shows a Pico input node connected, set it to “All” and you will get the events needed. Do NOT select a device in that node.
The function node “Clean input” is where you map Pico device Id’s to device names, the example shows 2 mapped to “office” and 3 to “outside”. Add more and change the names as needed.
Once you’ve added those parts, tap a button and enable the “output” debug node to see your events. Once you see that working you can disable the “Clean Input” debug node to have less output to drown in.
Everything in the green area is needed, to the right of it are examples on how to filter on the different button presses, two methods are shown. Use what fits you and delete what doesn’t.
If the timing needs to be changed the long press timing is currently 1200ms and can be changed in node “Long press timeout”. For single tap timeout change “Click timeout”, default is 400ms. If you change it, make sure the timeout in “Delay reset” is 100ms less than “Click timeout”.
EDIT: Updated this post with a complete example for use with picos.
The flow from the above image, but excluding the Pico input node:
[{"id":"fad76a8cbc7c3e4e","type":"debug","z":"d56760f70d673389","name":"Output Btn1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2550,"y":260,"wires":[]},{"id":"dba8949ff17f353c","type":"debug","z":"d56760f70d673389","name":"Output Btn Off","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2740,"y":400,"wires":[]},{"id":"f68c6aef7447c26e","type":"switch","z":"d56760f70d673389","name":"Output Btn1","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"triple","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":2330,"y":260,"wires":[["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"]]},{"id":"f5e9de586f8fc5db","type":"switch","z":"d56760f70d673389","name":"Office Btn Off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"single","vt":"str"},{"t":"eq","v":"double","vt":"str"},{"t":"eq","v":"triple","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"eq","v":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":2500,"y":400,"wires":[["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"]]},{"id":"a6052f40cb19f1f8","type":"switch","z":"d56760f70d673389","name":"Split Buttons","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"office_btn_on","vt":"str"},{"t":"eq","v":"office_btn_off","vt":"str"},{"t":"eq","v":"office_btn_up","vt":"str"},{"t":"eq","v":"office_btn_down","vt":"str"},{"t":"eq","v":"office_btn_middle","vt":"str"},{"t":"eq","v":"outside_btn_on","vt":"str"},{"t":"eq","v":"outside_btn_off","vt":"str"},{"t":"eq","v":"outside_btn_up","vt":"str"},{"t":"eq","v":"outside_btn_down","vt":"str"},{"t":"eq","v":"outside_btn_middle","vt":"str"}],"checkall":"false","repair":false,"outputs":10,"x":2130,"y":260,"wires":[["f68c6aef7447c26e"],[],[],[],[],[],[],[],[],[]]},{"id":"503358e7b91d3bb2","type":"debug","z":"d56760f70d673389","name":"output","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2110,"y":540,"wires":[]},{"id":"42f4c7032a077dd9","type":"switch","z":"d56760f70d673389","name":"Device","property":"device","propertyType":"msg","rules":[{"t":"eq","v":"office","vt":"str"},{"t":"eq","v":"outside","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":2130,"y":420,"wires":[["148c866ccdd3ffe3"],[]]},{"id":"148c866ccdd3ffe3","type":"switch","z":"d56760f70d673389","name":"Office Buttons","property":"button","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"up","vt":"str"},{"t":"eq","v":"down","vt":"str"},{"t":"eq","v":"middle","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":2300,"y":400,"wires":[[],["f5e9de586f8fc5db"],[],[],[]]},{"id":"4244bec1bc5a89a9","type":"group","z":"d56760f70d673389","name":"Button Press/Release to Composite Events","style":{"fill":"#92d04f","label":true,"label-position":"n","color":"#000000"},"nodes":["566628c2a6b66b30","6751fc1606969615","4dd0a8c27a03ad3d","3a9554bb87c9e28e","cb2e26c8d552ab20","c52576da737c8261","9272a1b69a7a2351","e68d645b520e820f","0dea44ba596b8be6","b36ce4e8b4bf4303","eed7811944f93142","ab25f68a52fb876c","63d41a2a3d857440","b75e27e5d4f7cb7a","96d30637f7e5d396","015aa7d8cd447e1b","d9a52256e6d1f489","659164e248890a23","cb8cd5b8ccfb399b","5e979a9f9a14eb5e","6ddc55965ab7dda1","367c03ce362bbc97"],"x":614,"y":119,"w":1412,"h":502},{"id":"566628c2a6b66b30","type":"trigger","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Click timeout","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"500","extend":true,"overrideDelay":false,"units":"ms","reset":"press","bytopic":"topic","topic":"topic","outputs":1,"x":1290,"y":580,"wires":[["6751fc1606969615","c52576da737c8261","9272a1b69a7a2351"]]},{"id":"6751fc1606969615","type":"debug","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Debug 3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1540,"y":580,"wires":[]},{"id":"4dd0a8c27a03ad3d","type":"trigger","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Long press timeout","op1":"","op2":"long","op1type":"nul","op2type":"str","duration":"1200","extend":false,"overrideDelay":false,"units":"ms","reset":"release","bytopic":"topic","topic":"topic","outputs":1,"x":1010,"y":200,"wires":[["3a9554bb87c9e28e","cb2e26c8d552ab20","b36ce4e8b4bf4303","b75e27e5d4f7cb7a","367c03ce362bbc97"]]},{"id":"3a9554bb87c9e28e","type":"delay","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Delay reset","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1290,"y":320,"wires":[["0dea44ba596b8be6","ab25f68a52fb876c"]]},{"id":"cb2e26c8d552ab20","type":"debug","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Debug 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1380,"y":200,"wires":[]},{"id":"c52576da737c8261","type":"function","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Map btn events","func":"eventMap = {\n 1: 'single',\n 2: 'double',\n 3: 'triple',\n 4: 'quadruple',\n 5: 'quintuple',\n};\nif (msg.payload <= 5) {\n msg.payload = eventMap[msg.payload]; \n}\nflow.set(msg.topic + '_tap', 0)\nflow.set(msg.topic + '_longtap', 0);\nif (msg.payload !== undefined) {\n return msg;\n} else {\n return null;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1560,"y":540,"wires":[["367c03ce362bbc97"]]},{"id":"9272a1b69a7a2351","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":500,"wires":[["4dd0a8c27a03ad3d"]]},{"id":"e68d645b520e820f","type":"function","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Count taps","func":"if (msg.payload == 'release') {\n const c = flow.get(msg.topic + '_tap');\n msg.payload = 1;\n if(Number.isFinite(c)) {\n msg.payload = c+1;\n }\n flow.set(msg.topic + '_tap', msg.payload)\n node.status({fill:\"green\", shape:\"dot\", text:msg.payload});\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1090,"y":580,"wires":[["566628c2a6b66b30"]]},{"id":"0dea44ba596b8be6","type":"function","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Reset taps","func":"flow.set(msg.topic + '_tap', 0);\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":320,"wires":[[]]},{"id":"b36ce4e8b4bf4303","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"simulate release","rules":[{"t":"set","p":"payload","pt":"msg","to":"release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":420,"wires":[["eed7811944f93142"]]},{"id":"eed7811944f93142","type":"rbe","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1030,"y":480,"wires":[["e68d645b520e820f"]]},{"id":"ab25f68a52fb876c","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":440,"wires":[["566628c2a6b66b30"]]},{"id":"63d41a2a3d857440","type":"function","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Clean input","func":"// Use this function to create a unique topic per button\n// and to update the payload to be one of \"release\" or \"press\" \n// depending on the incoming payload from your device.\npicoButtonMap = {\n 2: 'on',\n 3: 'middle',\n 4: 'off',\n 5: 'up',\n 6: 'down',\n};\npicoDeviceMap = {\n 2: 'office',\n 3: 'outside',\n}\n\n// Get the device name from picoDeviceMap\nlet picoDevice = picoDeviceMap[msg.payload.deviceId];\npicoDevice = picoDevice == undefined ? msg.payload.deviceId : picoDevice;\nmsg.device = picoDevice;\n// Get the button name from picoButtonMap\nlet picoButton = picoButtonMap[msg.payload.action];\npicoButton = picoButton == undefined ? msg.payload.action : picoButton;\nmsg.button = picoButton;\n\nmsg.topic = picoDevice + '_btn_' + picoButton;\n\n// Example translation of events\nswitch (msg.payload.param) {\n case 4:\n msg.payload = 'release';\n break;\n case 3:\n msg.payload = 'press';\n break;\n}\nif (msg.payload == 'press') {\n const c = flow.get(msg.topic + '_tap');\n msg.taps = c == undefined ? 1 : c+1;\n flow.set(msg.topic + '_longtap', c+1);\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":360,"wires":[["4dd0a8c27a03ad3d","eed7811944f93142","d9a52256e6d1f489","659164e248890a23"]]},{"id":"b75e27e5d4f7cb7a","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":240,"wires":[["96d30637f7e5d396"]]},{"id":"96d30637f7e5d396","type":"throttle","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Long Release","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"blockSize":0,"locked":true,"x":1120,"y":380,"wires":[["015aa7d8cd447e1b"]]},{"id":"015aa7d8cd447e1b","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Long Release","rules":[{"t":"set","p":"payload","pt":"msg","to":"long_release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":380,"wires":[["cb8cd5b8ccfb399b"]]},{"id":"d9a52256e6d1f489","type":"switch","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"==release","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":940,"y":300,"wires":[["96d30637f7e5d396"]]},{"id":"659164e248890a23","type":"debug","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Clean Input","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":520,"wires":[]},{"id":"cb8cd5b8ccfb399b","type":"function","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Add taps","func":"let c = flow.get(msg.topic + '_longtap');\nc = c == undefined ? 0 : c;\nmsg.taps = c;\nflow.set(msg.topic + '_longtap', 0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1680,"y":380,"wires":[["367c03ce362bbc97"]]},{"id":"5e979a9f9a14eb5e","type":"comment","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"Long press events contain number of taps including the long press","info":"","x":1760,"y":160,"wires":[]},{"id":"6ddc55965ab7dda1","type":"comment","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"NOTE: Multiple buttons can use the same flow at the same time","info":"","x":870,"y":160,"wires":[]},{"id":"367c03ce362bbc97","type":"change","z":"d56760f70d673389","g":"4244bec1bc5a89a9","name":"output","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1910,"y":380,"wires":[["a6052f40cb19f1f8","503358e7b91d3bb2","42f4c7032a077dd9"]]}]
I don’t have a Pico here, but if there is an event for press and release for a button a flow like the below can be used:
The Single, Long and Double inject nodes combined with the leftmost “trigger 150ms” and “trigger 400ms” are just there to simulate button presses with press and release events. Your pico data should come into the switch node and be separated into press and release events there. At the debug “output” node is where the single, double and long press events would come out. I hope this can help with building your logic to fit the picos.