Pico button logic

That last sequence is just outputting longs only for me…weird. Yeah the one with functions worked for me, sort of. I deleted it now, but I think the longs were also followed by singles and for some reason only some buttons could do multi-pushes reliably, but that sounds like a HE thing not a algorithm thing. Example being the on, off, and favorite buttons work well for everything (except long is followed by a single, upon further thought, is this intended to show when long has ended?), but the up and down buttons fail the multi-clicks and just report multiple singles.

You were saying that you didn’t like that the “passthrough”, for lack of a better name, was being triggered by a push not a release. Can you elaborate into why that is a bad idea?

1 Like

There was an issue with long presses in the first version, only certain length ones worked. It has been updated above. Simulated presses don’t get the same variation as when you have an actual button to use…

Looking at it again I may have been partially hasty in that assessment, I suppose it could be fine, but it would mean triggering before releasing the button a second time, so holding it on the second press would result in a single click if held the “right” amount of time.

1 Like

ahhh, a very interesting edge case. In my testing holding on the second yields a double not a single (which I think and argument could be made for this is the correct response, or actually it could be whole new input, single long, but that is a whole can of worms :upside_down_face:), but I will keep on playing to see how I can break it.

That fixed my long press issue though I wonder if having a single on release of a long is a feature not a bug, it depends on if it can be differentiated from a true single though.

The other issues I have with the up and down buttons do still exist though. Very weird because on, off, and favorite work fine.

Anywho, thanks Markus for the assistance, you have been a massive help. I need to get some sleep now.

2 Likes

Ah, yes, that can be a good thing to do at times… Sleep well!

2 Likes

I revisited the multi-click flow with functions and cleaned up that one a bit more as well as added a screenshot, see above for the flow. The functions are fairly minimal and should be easy to edit to fit any type of button with a press and release event.

2 Likes

I’ll have to take a look through this thread later on the computer and see how your flow works out, I’ve got a couple picos being handled in nodered. Haven’t implemented long press/hold functionality, but I used a timed-counter node and it made multiple presses much less complicated

1 Like

Updated the first post with a much more complete flow for use with Picos. For a flow to test with WITHOUT a Pico or any other button device, try the following:

[{"id":"fad76a8cbc7c3e4e","type":"debug","z":"90c76dfa1004a4a8","name":"Output Btn1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2410,"y":440,"wires":[]},{"id":"dba8949ff17f353c","type":"debug","z":"90c76dfa1004a4a8","name":"Output Btn2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2410,"y":580,"wires":[]},{"id":"cfedf1610efa9cce","type":"switch","z":"90c76dfa1004a4a8","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":2210,"y":440,"wires":[["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"]]},{"id":"e9857185e513ed66","type":"switch","z":"90c76dfa1004a4a8","name":"Output Btn2","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":2210,"y":580,"wires":[["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"]]},{"id":"0c7eaba28c190575","type":"switch","z":"90c76dfa1004a4a8","name":"Split Buttons","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"btn1","vt":"str"},{"t":"eq","v":"btn2","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":2010,"y":500,"wires":[["cfedf1610efa9cce"],["e9857185e513ed66"]]},{"id":"f9e026f42b9b6ed0","type":"debug","z":"90c76dfa1004a4a8","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2010,"y":680,"wires":[]},{"id":"40dacf0ad1e1201c","type":"group","z":"90c76dfa1004a4a8","name":"Btn1 Simulator","style":{"fill":"#ffC000","label":true,"color":"#000000","label-position":"n"},"nodes":["88be0d19795bf732","4488b1ea79448756","0b0b9a19d380345c","fe80a380eaa8b3ca","42d0cac0135a6174","57fe5fc77ab5b35d","562fa305a4c16190","2bf82859972696ba","52c23907e9e2ad82","673de388d2fdd7bf","86016dcdb1cd71f5","9b5984b5ac7c93d3","fe63d903ca9a9654","bb74de0e60023e1b","9504501c481de697","d91b63140b60433a","cd8c9dd9925e7624"],"x":14,"y":159,"w":572,"h":482},{"id":"88be0d19795bf732","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Single","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":200,"wires":[["fe80a380eaa8b3ca"]]},{"id":"4488b1ea79448756","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Double","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":320,"wires":[["42d0cac0135a6174"]]},{"id":"0b0b9a19d380345c","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Long","props":[{"p":"payload"},{"p":"delay","v":"1200 + $random() * 3000\t","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":260,"wires":[["fe80a380eaa8b3ca","9b5984b5ac7c93d3"]]},{"id":"fe80a380eaa8b3ca","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press_event","op2":"release_event","op1type":"str","op2type":"str","duration":"150","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":260,"wires":[["673de388d2fdd7bf"]]},{"id":"42d0cac0135a6174","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press1","op2":"press2","op1type":"str","op2type":"str","duration":"400","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":320,"wires":[["fe80a380eaa8b3ca"]]},{"id":"57fe5fc77ab5b35d","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press1+2","op2":"press3","op1type":"str","op2type":"str","duration":"800","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":480,"wires":[["42d0cac0135a6174"],["fe80a380eaa8b3ca"]]},{"id":"562fa305a4c16190","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Triple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":480,"wires":[["57fe5fc77ab5b35d"]]},{"id":"2bf82859972696ba","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press1+2+3","op2":"press4","op1type":"str","op2type":"str","duration":"1200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":540,"wires":[["57fe5fc77ab5b35d"],["fe80a380eaa8b3ca"]]},{"id":"52c23907e9e2ad82","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Quadruple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":540,"wires":[["2bf82859972696ba"]]},{"id":"673de388d2fdd7bf","type":"change","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"msg.topic = btn1","rules":[{"t":"set","p":"topic","pt":"msg","to":"btn1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":300,"wires":[["63d41a2a3d857440"]]},{"id":"86016dcdb1cd71f5","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press_event","op2":"release_event","op1type":"str","op2type":"str","duration":"1200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":480,"y":420,"wires":[["673de388d2fdd7bf"]]},{"id":"9b5984b5ac7c93d3","type":"function","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Long press delay","func":"node.status({fill:\"green\", shape:\"dot\", text:Math.round(msg.delay) + 'ms'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":200,"wires":[[]]},{"id":"fe63d903ca9a9654","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Quintuple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":600,"wires":[["bb74de0e60023e1b"]]},{"id":"bb74de0e60023e1b","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press1+2+3+4","op2":"press5","op1type":"str","op2type":"str","duration":"1600","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":600,"wires":[["2bf82859972696ba"],["fe80a380eaa8b3ca"]]},{"id":"9504501c481de697","type":"trigger","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"","op1":"press1","op2":"press2","op1type":"str","op2type":"str","duration":"400","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":420,"wires":[["fe80a380eaa8b3ca"],["86016dcdb1cd71f5"]]},{"id":"d91b63140b60433a","type":"inject","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Double LP","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":420,"wires":[["9504501c481de697"]]},{"id":"cd8c9dd9925e7624","type":"comment","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Long press 2nd tap","info":"","x":130,"y":380,"wires":[]},{"id":"5b99eb46dd3b6e0c","type":"group","z":"90c76dfa1004a4a8","name":"Btn2 Simulator","style":{"fill":"#ffC000","label":true,"color":"#000000","label-position":"n"},"nodes":["71f93de2dee2702c","9b55833483b560e9","10dda1646cfb96ba","2184dfefc1674e2a","a57f90ec756c6a71","c8186496e34930b4","efc1590db5638361","1305f136c74c39d4","f87ce53ab188f7df","a3aff3105b73ecf3","5d2c1b904c9bca6f","2183920f3d7488f8","da83377274429c8f","bb0c394feb6016e8","ca1022a57aab6242"],"x":14,"y":659,"w":572,"h":422},{"id":"71f93de2dee2702c","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Single","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":700,"wires":[["2184dfefc1674e2a"]]},{"id":"9b55833483b560e9","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Double","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":820,"wires":[["a57f90ec756c6a71"]]},{"id":"10dda1646cfb96ba","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Long","props":[{"p":"payload"},{"p":"delay","v":"1200 + $random() * 3000\t","vt":"jsonata"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":760,"wires":[["2184dfefc1674e2a","5d2c1b904c9bca6f"]]},{"id":"2184dfefc1674e2a","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press_event","op2":"release_event","op1type":"str","op2type":"str","duration":"150","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":760,"wires":[["a3aff3105b73ecf3"]]},{"id":"a57f90ec756c6a71","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press1","op2":"press2","op1type":"str","op2type":"str","duration":"200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":820,"wires":[["2184dfefc1674e2a"]]},{"id":"c8186496e34930b4","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press1+2","op2":"press3","op1type":"str","op2type":"str","duration":"400","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":880,"wires":[["a57f90ec756c6a71"],["2184dfefc1674e2a"]]},{"id":"efc1590db5638361","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Triple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":880,"wires":[["c8186496e34930b4"]]},{"id":"1305f136c74c39d4","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press1+2+3","op2":"press4","op1type":"str","op2type":"str","duration":"600","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":940,"wires":[["c8186496e34930b4"],["2184dfefc1674e2a"]]},{"id":"f87ce53ab188f7df","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Quadruple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":940,"wires":[["1305f136c74c39d4"]]},{"id":"a3aff3105b73ecf3","type":"change","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"msg.topic = btn2","rules":[{"t":"set","p":"topic","pt":"msg","to":"btn2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":760,"wires":[["63d41a2a3d857440"]]},{"id":"5d2c1b904c9bca6f","type":"function","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Long press delay","func":"node.status({fill:\"green\", shape:\"dot\", text:Math.round(msg.delay) + 'ms'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":700,"wires":[[]]},{"id":"2183920f3d7488f8","type":"inject","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Quintuple","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":1040,"wires":[["da83377274429c8f"]]},{"id":"da83377274429c8f","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press1+2+3+4","op2":"press5","op1type":"str","op2type":"str","duration":"800","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":280,"y":1040,"wires":[["1305f136c74c39d4"],["bb0c394feb6016e8"]]},{"id":"bb0c394feb6016e8","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"","op1":"press_event","op2":"release_event","op1type":"str","op2type":"str","duration":"2200","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":480,"y":1040,"wires":[["a3aff3105b73ecf3"]]},{"id":"ca1022a57aab6242","type":"comment","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Long press 5th tap","info":"","x":150,"y":1000,"wires":[]},{"id":"4244bec1bc5a89a9","type":"group","z":"90c76dfa1004a4a8","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","f621f685527dbfb5"],"x":674,"y":219,"w":1252,"h":502},{"id":"566628c2a6b66b30","type":"trigger","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Click timeout","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"400","extend":true,"overrideDelay":false,"units":"ms","reset":"press","bytopic":"topic","topic":"topic","outputs":1,"x":1350,"y":680,"wires":[["6751fc1606969615","9272a1b69a7a2351","c52576da737c8261"]]},{"id":"6751fc1606969615","type":"debug","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Debug 3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1600,"y":680,"wires":[]},{"id":"4dd0a8c27a03ad3d","type":"trigger","z":"90c76dfa1004a4a8","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":1070,"y":300,"wires":[["cb2e26c8d552ab20","b36ce4e8b4bf4303","3a9554bb87c9e28e","b75e27e5d4f7cb7a","f621f685527dbfb5"]]},{"id":"3a9554bb87c9e28e","type":"delay","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Delay reset","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1350,"y":420,"wires":[["0dea44ba596b8be6","ab25f68a52fb876c"]]},{"id":"cb2e26c8d552ab20","type":"debug","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Debug 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1440,"y":300,"wires":[]},{"id":"c52576da737c8261","type":"function","z":"90c76dfa1004a4a8","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":1620,"y":640,"wires":[["f621f685527dbfb5"]]},{"id":"9272a1b69a7a2351","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1560,"y":600,"wires":[["4dd0a8c27a03ad3d"]]},{"id":"e68d645b520e820f","type":"function","z":"90c76dfa1004a4a8","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":1150,"y":680,"wires":[["566628c2a6b66b30"]]},{"id":"0dea44ba596b8be6","type":"function","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Reset taps","func":"flow.set(msg.topic + '_tap', 0);\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1570,"y":380,"wires":[[]]},{"id":"b36ce4e8b4bf4303","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"simulate release","rules":[{"t":"set","p":"payload","pt":"msg","to":"release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":520,"wires":[["eed7811944f93142"]]},{"id":"eed7811944f93142","type":"rbe","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1090,"y":580,"wires":[["e68d645b520e820f"]]},{"id":"ab25f68a52fb876c","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Press","rules":[{"t":"set","p":"payload","pt":"msg","to":"press","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1370,"y":540,"wires":[["566628c2a6b66b30"]]},{"id":"63d41a2a3d857440","type":"function","z":"90c76dfa1004a4a8","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.\n\n// Example translation of events\nswitch (msg.payload) {\n    case 'release_event':\n        msg.payload = 'release';\n        break;\n    case 'press_event':\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":770,"y":460,"wires":[["4dd0a8c27a03ad3d","eed7811944f93142","d9a52256e6d1f489","659164e248890a23"]]},{"id":"b75e27e5d4f7cb7a","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":340,"wires":[["96d30637f7e5d396"]]},{"id":"96d30637f7e5d396","type":"throttle","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Long Release","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"blockSize":0,"locked":true,"x":1180,"y":480,"wires":[["015aa7d8cd447e1b"]]},{"id":"015aa7d8cd447e1b","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Long Release","rules":[{"t":"set","p":"payload","pt":"msg","to":"long_release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1560,"y":480,"wires":[["cb8cd5b8ccfb399b"]]},{"id":"d9a52256e6d1f489","type":"switch","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"==release","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1000,"y":400,"wires":[["96d30637f7e5d396"]]},{"id":"659164e248890a23","type":"debug","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Clean Input","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":620,"wires":[]},{"id":"cb8cd5b8ccfb399b","type":"function","z":"90c76dfa1004a4a8","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":1720,"y":420,"wires":[["f621f685527dbfb5"]]},{"id":"5e979a9f9a14eb5e","type":"comment","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Long press events contain number of taps including the long press","info":"","x":1660,"y":260,"wires":[]},{"id":"6ddc55965ab7dda1","type":"comment","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"NOTE: Multiple buttons can use the same flow at the same time","info":"","x":930,"y":260,"wires":[]},{"id":"f621f685527dbfb5","type":"change","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Output","rules":[],"action":"","property":"","from":"","to":"","reg":false,"x":1830,"y":500,"wires":[["0c7eaba28c190575","f9e026f42b9b6ed0"]]}]
3 Likes

Jeez Markus, you must really be going crazy with these lockdowns. You are obviously chomping at the bit for a new and interesting challenge. Thank you so much for your flow, I’ll let you know how it works.

As a side note, what lutron nodes would you recommend since I really do not have any reason to keep using the HE ones.

Worked OOB with node-red-contrib-lutron. GREAT WORK Markus :clap:

For stuff like this though (and this may be a beta topic, so feel free to censor), can we expect that devices added via NR nodes to be part of a central device manager on CORE?

Also I feel like we could have a compeitition for the person that uses the most multi-clicks. I am just amazed how simple this is working, double…no problem, 15…also no problem :rofl:

4 Likes

What a remarkable discussion and creation! @markus, you continue to amaze me. And kudos to @Cjkeenan for understanding/testing it all.

4 Likes

Flow is working great. Anyone know if there is a good way to do link outs generically? Also are links in general bad for performance?

1 Like

Great! Can you post a more focused image? I can’t read it even after saving the image and blowing it up.

I don’t think they are. I think I read where they simply forward messages but I suggest you ask in the NR forum.

The logic is the same from the first post but reorganized and condensed a bit to save space. The bottom stuff is just mapping to my picos and linking out each command. If you want see a specific part, let me know.

Here is one of my mappings, I am using single, double, and triple taps. All 45 inputs do not have active uses, but I am just making a generic one that I can copy around. Found a great method for adapting these to a new remote, export just what I pictured, then paste that into a notepad and find and replace the name of the link outs and re-import it. Saves tons of time.

Also pico mapper is just a subflow that outputs the key pressed, but I want to make it easily changeable in case the input uses a different naming convention.

1 Like

It’s good now. I just want to make sure I’m not missing something in the details.

Look at you guys. Going all super clicker on this. Markus gave me this when I woke up this morning.
:grin:
Looks like it’s a hit.

Oh we’ve only just begun. Once CORE Main is completed and available for beta use, then these integrations will be executed through CORE NR nodes until everything else moves forward and will eventually work into our UI. Yes. This is the short answer.

2 Likes

Here is a subflow that might help.

[{"id":"328493fd04d9f5e6","type":"subflow","name":"pico device","info":"","category":"","in":[{"x":40,"y":680,"wires":[{"id":"f24efe01dc4f11a8"}]}],"out":[{"x":860,"y":60,"wires":[{"id":"f2026e4a2b151035","port":0}]},{"x":860,"y":100,"wires":[{"id":"f2026e4a2b151035","port":1}]},{"x":860,"y":140,"wires":[{"id":"f2026e4a2b151035","port":2}]},{"x":860,"y":180,"wires":[{"id":"f2026e4a2b151035","port":3}]},{"x":860,"y":220,"wires":[{"id":"f2026e4a2b151035","port":4}]},{"x":860,"y":260,"wires":[{"id":"f2026e4a2b151035","port":5},{"id":"f2026e4a2b151035","port":6},{"id":"f2026e4a2b151035","port":7}]},{"x":860,"y":320,"wires":[{"id":"eec4c1ecee8ce080","port":0}]},{"x":860,"y":360,"wires":[{"id":"eec4c1ecee8ce080","port":1}]},{"x":860,"y":400,"wires":[{"id":"eec4c1ecee8ce080","port":2}]},{"x":860,"y":440,"wires":[{"id":"eec4c1ecee8ce080","port":3}]},{"x":860,"y":480,"wires":[{"id":"eec4c1ecee8ce080","port":4}]},{"x":860,"y":520,"wires":[{"id":"eec4c1ecee8ce080","port":5},{"id":"eec4c1ecee8ce080","port":6},{"id":"eec4c1ecee8ce080","port":7}]},{"x":860,"y":580,"wires":[{"id":"fd38db16456ad64d","port":0}]},{"x":860,"y":620,"wires":[{"id":"fd38db16456ad64d","port":1}]},{"x":860,"y":660,"wires":[{"id":"fd38db16456ad64d","port":2}]},{"x":860,"y":700,"wires":[{"id":"fd38db16456ad64d","port":3}]},{"x":860,"y":740,"wires":[{"id":"fd38db16456ad64d","port":4}]},{"x":860,"y":780,"wires":[{"id":"fd38db16456ad64d","port":5},{"id":"fd38db16456ad64d","port":6},{"id":"fd38db16456ad64d","port":7}]},{"x":860,"y":840,"wires":[{"id":"3e842f490655cc0c","port":0}]},{"x":860,"y":880,"wires":[{"id":"3e842f490655cc0c","port":1}]},{"x":860,"y":920,"wires":[{"id":"3e842f490655cc0c","port":2}]},{"x":860,"y":960,"wires":[{"id":"3e842f490655cc0c","port":3}]},{"x":860,"y":1000,"wires":[{"id":"3e842f490655cc0c","port":4}]},{"x":860,"y":1040,"wires":[{"id":"3e842f490655cc0c","port":5},{"id":"3e842f490655cc0c","port":6},{"id":"3e842f490655cc0c","port":7}]},{"x":860,"y":1100,"wires":[{"id":"98ed294f16e8658b","port":0}]},{"x":860,"y":1140,"wires":[{"id":"98ed294f16e8658b","port":1}]},{"x":860,"y":1180,"wires":[{"id":"98ed294f16e8658b","port":2}]},{"x":860,"y":1220,"wires":[{"id":"98ed294f16e8658b","port":3}]},{"x":860,"y":1260,"wires":[{"id":"98ed294f16e8658b","port":4}]},{"x":860,"y":1300,"wires":[{"id":"98ed294f16e8658b","port":5},{"id":"98ed294f16e8658b","port":6},{"id":"98ed294f16e8658b","port":7}]}],"env":[{"name":"device","type":"str","value":"office"}],"meta":{},"color":"#DDAA99"},{"id":"f2026e4a2b151035","type":"switch","z":"328493fd04d9f5e6","name":"On Button","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":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"lte","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":680,"y":160,"wires":[[],[],[],[],[],[],[],[]]},{"id":"4fbc0b61caa3ac5b","type":"switch","z":"328493fd04d9f5e6","name":"Button","property":"button","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"up","vt":"str"},{"t":"eq","v":"middle","vt":"str"},{"t":"eq","v":"down","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":350,"y":680,"wires":[["f2026e4a2b151035"],["eec4c1ecee8ce080"],["fd38db16456ad64d"],["3e842f490655cc0c"],["98ed294f16e8658b"]]},{"id":"eec4c1ecee8ce080","type":"switch","z":"328493fd04d9f5e6","name":"Up Button","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":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"lte","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":680,"y":420,"wires":[[],[],[],[],[],[],[],[]]},{"id":"fd38db16456ad64d","type":"switch","z":"328493fd04d9f5e6","name":"Middle Button","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":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"lte","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":660,"y":680,"wires":[[],[],[],[],[],[],[],[]]},{"id":"3e842f490655cc0c","type":"switch","z":"328493fd04d9f5e6","name":"Down Button","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":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"lte","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":670,"y":940,"wires":[[],[],[],[],[],[],[],[]]},{"id":"98ed294f16e8658b","type":"switch","z":"328493fd04d9f5e6","name":"Off Button","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":"long","vt":"str"},{"t":"eq","v":"long_release","vt":"str"},{"t":"eq","v":"quadruple","vt":"str"},{"t":"eq","v":"quintuple","vt":"str"},{"t":"lte","v":"6","vt":"num"}],"checkall":"false","repair":false,"outputs":8,"x":680,"y":1200,"wires":[[],[],[],[],[],[],[],[]]},{"id":"f24efe01dc4f11a8","type":"switch","z":"328493fd04d9f5e6","name":"Device","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"device","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":150,"y":680,"wires":[["4fbc0b61caa3ac5b"]]},{"id":"8ebab313b5cbb6a3","type":"subflow:328493fd04d9f5e6","z":"e8d4d70ac54ecb83","name":"","x":150,"y":280,"wires":[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]}]
1 Like

@Cjkeenan and @LosinIt thank you for the nice words :slight_smile:

I’m happy to see it all working for you @Cjkeenan!
I would love to see a dimmer implementation using the long and long_release events. Basically, starting a timer which keeps increasing or decreasing the dimmer level every x00ms and stopping the timer once long_release arrives.

@april.brandt answered the part about CORE, I just want to add that having a flow created this way also helps me in implementing the same logic in pure code inside the built-in integration.

2 Likes

This is what I have so far, but it is a bit steppy for my taste, unsure if that is my kasa switch or my sequence. Link-ins are the from the button array with no changes in output. Link-outs are to set level command that is part of my normal motion sequence.
Current setup:
Up/Down: +/- 25
Hold: +/- 10 every 350ms

HE Kasa Driver Auto Level Change for Reference
	def curLevel = device.currentValue("level").toInteger()
	if (curLevel == 100) { return }
	def newLevel = curLevel + 4
	if (newLevel > 100) { newLevel = 100 }
	setLevel(newLevel, 0)
	runIn(1, levelUp)
}

def levelDown() {
	def curLevel = device.currentValue("level").toInteger()
	if (curLevel == 0) { return }
	def newLevel = curLevel - 4
	if (newLevel < 0) { newLevel = 0 }
	setLevel(newLevel, 0)
	if (newLevel == 0) { off() }
	runIn(1, levelDown)
}

4 is nice to help with the steppiness, but 1s is a bit slow and to speed it up might flood the network (wifi switch remember)

2 Likes

That does sound like a hard device to get it smooth on, I do Tasmota WiFi devices over MQTT and do get it smooth, but I prefer ramp up and down to be implemented on device like you can do with ESPHome. You can do that with Tasmota as well, but I’ve not bothered since it is rather painful to do. For the zigbee lights I have they don’t all have it built in and simulating it is choppy for the most part.
I will have to go and dig to see if any of my zigbee buttons send both press and release events so that I can try this on my own as well.

Yeah the kasa switches seem to have a ramping function built in so it is decent, but I am fighting the responsiveness to change more than the ramp. So I am having to balance the frequency of change with the change percentage and then the network responsiveness while I am at it. I think the settings that I have now, updated above, are decent enough to live with and see how it goes. The steps are noticeable but they are by no means jarring as there is a transition. Plans are to swap these out for Inovelli Blue’s once they are released, so we will see how those fare.

Ideally I would want percentage change to be 1, or the highest number that has no significant visual impact, and then just tune the loop delay until it feels right, probably like 1s-1.5s for 0-100, not sure exactly though.

1 Like

Finding the perfect balance is what we all strive for in our automations I suppose :slight_smile: Never really quite getting there… As far as flooding a WiFi network with IoT messages, that’s probably never going to be a problem considering the bandwidth. The devices themselves though, that’s the issue… I turn on (with ramp up) 27 GU10 WiFi spots in unison and even run pulsating colour changes (for alerts) in unison over multiple lights at once. But I have yet to see a manufacturer firmware for a WiFi light to do that without having issues.

2 Likes