Pico button logic

No, we don’t want the first message, we need the second message… Opposite of what the rate limit in the delay node can be used for. With that said, you could use a switch node and a flow variable, but wanted to avoid that.

2 Likes

Perfect, thanks Markus, I have it all working now. Just needed to adjust the checks for the verbiage that the HE nodes use, but it seems to be very reliable. Now to time sit down and understand what you did :sweat_smile:

2 Likes

As I understand it, these are the timings, please correct me if I am wrong:
Long (held): release has to come 1.6 seconds (1.2 + 400ms) after press (why is the delay broken up into two nodes btw?)
Single: just a press, but it has a 500ms delay since it has to see if it is a double first
Double: within 500ms of each other or the single will go through

Also what is tunable here? I assume the 500ms and 400ms?

Edit: NVM, I think I know what the two delays are for (1.2s and 400ms) held is between 1.2s and 1.6s?

I am having issues with the held (long) part actually. But I think I may have a fix?


Just moved the “double passthrough” as I called it to be on the pressed trigger not the release, that way it clears the throttle for the held delay. Still not sure what the additional 400ms delay on the held delay is for.

1 Like

Long will count and send as long as no release happens within 1.2 seconds, the 400ms delay is just there to reset the “trigger 500ms” node. It just needs to be enough for the release to go from the switch node to the trigger 500ms node but arrive before the 500ms node is actually triggered.

Don’t think that is a great way of doing it, triggering on press instead of release. Did you update the reset trigger in trigger 1200ms to be whatever your release event is called?
image

1 Like

Yes, I updated that. Long wasn’t triggering unless I held it for a very specific amount of time and if I went too short or too long it would be a single. With the rewire, I can hold it forever, and the double and single still work fine it seems.

1 Like

This is a flow for up to quadruple click (might not be practical, but it was fun to make), it can handle multiple input buttons into one, just set topic to unique values:

EDIT: Should handle long presses of any length now
EDIT2: To better simulate different length of long press the delay is now 1200ms or more, using a random value…
EDIT3: Cleaned it up a bit and added a screenshot.

[{"id":"fad76a8cbc7c3e4e","type":"debug","z":"90c76dfa1004a4a8","name":"Output Btn1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2190,"y":480,"wires":[]},{"id":"d91b63140b60433a","type":"inject","z":"90c76dfa1004a4a8","name":"Double LP","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":360,"wires":[["9504501c481de697"]]},{"id":"9504501c481de697","type":"trigger","z":"90c76dfa1004a4a8","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":360,"wires":[["fe80a380eaa8b3ca"],["86016dcdb1cd71f5"]]},{"id":"dba8949ff17f353c","type":"debug","z":"90c76dfa1004a4a8","name":"Output Btn2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2190,"y":620,"wires":[]},{"id":"6ddc55965ab7dda1","type":"comment","z":"90c76dfa1004a4a8","name":"NOTE: Multiple buttons can use the same flow at the same time","info":"","x":930,"y":360,"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"],"x":14,"y":159,"w":572,"h":422},{"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":420,"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":420,"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":480,"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":480,"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":"1000","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":460,"y":360,"wires":[["673de388d2fdd7bf"]]},{"id":"9b5984b5ac7c93d3","type":"function","z":"90c76dfa1004a4a8","g":"40dacf0ad1e1201c","name":"Long click delay","func":"node.status({fill:\"green\", shape:\"dot\", text:Math.round(msg.delay) + 'ms'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"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":540,"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":540,"wires":[["2bf82859972696ba"],["fe80a380eaa8b3ca"]]},{"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"],"x":14,"y":599,"w":572,"h":322},{"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":640,"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":760,"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":700,"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":700,"wires":[["a3aff3105b73ecf3"]]},{"id":"a57f90ec756c6a71","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","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":760,"wires":[["2184dfefc1674e2a"]]},{"id":"c8186496e34930b4","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","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":820,"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":820,"wires":[["c8186496e34930b4"]]},{"id":"1305f136c74c39d4","type":"trigger","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","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":880,"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":880,"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":700,"wires":[["63d41a2a3d857440"]]},{"id":"5d2c1b904c9bca6f","type":"function","z":"90c76dfa1004a4a8","g":"5b99eb46dd3b6e0c","name":"Long click delay","func":"node.status({fill:\"green\", shape:\"dot\", text:Math.round(msg.delay) + 'ms'});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":640,"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","3aeeef6229776cf6","17453bc2c63cbced","040bc31d74250bea"],"x":694,"y":399,"w":1392,"h":342},{"id":"566628c2a6b66b30","type":"trigger","z":"90c76dfa1004a4a8","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":1370,"y":700,"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":1620,"y":700,"wires":[]},{"id":"4dd0a8c27a03ad3d","type":"trigger","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Long press timeout","op1":"","op2":"long","op1type":"nul","op2type":"str","duration":"1200","extend":true,"overrideDelay":false,"units":"ms","reset":"release","bytopic":"topic","topic":"topic","outputs":1,"x":1110,"y":440,"wires":[["cb2e26c8d552ab20","b36ce4e8b4bf4303","3a9554bb87c9e28e","17453bc2c63cbced"]]},{"id":"3a9554bb87c9e28e","type":"delay","z":"90c76dfa1004a4a8","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":1370,"y":500,"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":1460,"y":440,"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};\nif (msg.payload <= 4) {\n    msg.payload = eventMap[msg.payload];    \n}\nflow.set(msg.topic + '_click', 0)\nif (msg.payload !== undefined) {\n    return msg;\n} else {\n    return null;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1640,"y":660,"wires":[["17453bc2c63cbced"]]},{"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":1500,"y":620,"wires":[["4dd0a8c27a03ad3d"]]},{"id":"e68d645b520e820f","type":"function","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Count clicks","func":"if (msg.payload == 'release') {\n    let c = flow.get(msg.topic + '_click');\n    msg.payload = 1;\n    if(Number.isFinite(c)) {\n        msg.payload = c+1;\n    }\n    flow.set(msg.topic + '_click', msg.payload)\n    node.status({fill:\"green\", shape:\"dot\", text:msg.payload});\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1190,"y":700,"wires":[["566628c2a6b66b30"]]},{"id":"0dea44ba596b8be6","type":"function","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"Reset clicks","func":"// if (msg.payload == 'long') {\n//     flow.set(msg.topic + '_click', -1)    \n// } else {\n    flow.set(msg.topic + '_click', 0)\n// }\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1610,"y":540,"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":1120,"y":540,"wires":[["eed7811944f93142"]]},{"id":"eed7811944f93142","type":"rbe","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1110,"y":600,"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":1290,"y":600,"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}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":480,"wires":[["4dd0a8c27a03ad3d","eed7811944f93142"]]},{"id":"3aeeef6229776cf6","type":"switch","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","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":"long","vt":"str"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":7,"x":1990,"y":480,"wires":[["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"],["fad76a8cbc7c3e4e"]]},{"id":"17453bc2c63cbced","type":"switch","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","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":1790,"y":520,"wires":[["3aeeef6229776cf6"],["040bc31d74250bea"]]},{"id":"040bc31d74250bea","type":"switch","z":"90c76dfa1004a4a8","g":"4244bec1bc5a89a9","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":"long","vt":"str"},{"t":"eq","v":"5","vt":"num"},{"t":"eq","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":7,"x":1990,"y":620,"wires":[["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"],["dba8949ff17f353c"]]}]
2 Likes

While held, does the pico keep sending press events?

1 Like

No, it just sends a single press and a single release (once released), at least for the HE “Lutron Fast Pico” driver which only has pressed and release functions.

1 Like

Ah, I see where the logic is wrong for the long press, I’ll fix it, it’s probably the easiest way to explain it :stuck_out_tongue:

1 Like

Yeah that works too :laughing:, cheeky 2 path output. What is the issue with the original sequence but rewired?

Err, nvm I see why you edited your message and deleted the code…

1 Like

Logic error again, need to rework this, at this point the multi-click version is probably more reliable, but it is using function nodes… I’ll find a way without function nodes, hang on.

2 Likes

This should be unlocked now

It seems to be good now.

1 Like

I don’t see a problem with this method and it seems to be the most stable of the sequences we have been messing with. The only issue I found is that there is no held release message sent, so if you plan on holding to have a continuous effect (like level change, fan speed, or curtain position) it would have no “off” signal. Also that simple addition of button number being the topic is brilliant.

Spaghetti Monster Reporting for Duty

1 Like

I use this type of technique quite a bit in NR, but it’s important to remember to make sure all nodes can keep track of different topics at once…

If it works as is, that’s great :slight_smile: It is getting messy now with this one I made:

[{"id":"46440bd60ef2ee79","type":"trigger","z":"90c76dfa1004a4a8","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":260,"y":1260,"wires":[["09310dbf507f7e39"]]},{"id":"bf1e191aa503a496","type":"inject","z":"90c76dfa1004a4a8","name":"Double","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":1260,"wires":[["46440bd60ef2ee79"]]},{"id":"09310dbf507f7e39","type":"trigger","z":"90c76dfa1004a4a8","name":"","op1":"press","op2":"release","op1type":"str","op2type":"str","duration":"150","extend":false,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":260,"y":1200,"wires":[["3f4f90b0d0f5f6bf","d2abbd7f52b78459"]]},{"id":"580600c1b144d415","type":"inject","z":"90c76dfa1004a4a8","name":"Single","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":1140,"wires":[["09310dbf507f7e39"]]},{"id":"6af248f9be16eea2","type":"inject","z":"90c76dfa1004a4a8","name":"Long","props":[{"p":"payload"},{"p":"delay","v":"2500","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":1200,"wires":[["09310dbf507f7e39"]]},{"id":"3f4f90b0d0f5f6bf","type":"debug","z":"90c76dfa1004a4a8","name":"Debug 1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":440,"y":1160,"wires":[]},{"id":"d2abbd7f52b78459","type":"switch","z":"90c76dfa1004a4a8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"press","vt":"str"},{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":1200,"wires":[["babd3099aaf957db","61371c4899b88722"],["babd3099aaf957db","61371c4899b88722"]]},{"id":"babd3099aaf957db","type":"trigger","z":"90c76dfa1004a4a8","name":"","op1":"","op2":"long","op1type":"nul","op2type":"str","duration":"1200","extend":true,"overrideDelay":false,"units":"ms","reset":"release","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":1080,"wires":[["407352ca713cf3df","bdf28db8df329a77","ec0ad301ebe3ea90","fc5499a9d4f32f6e"]]},{"id":"61371c4899b88722","type":"rbe","z":"90c76dfa1004a4a8","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":630,"y":1240,"wires":[["54fbbf61c645a170"]]},{"id":"407352ca713cf3df","type":"debug","z":"90c76dfa1004a4a8","name":"Debug 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":1040,"wires":[]},{"id":"bdf28db8df329a77","type":"delay","z":"90c76dfa1004a4a8","name":"","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"0.4","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":810,"y":1200,"wires":[["bb44db9f08af6024","bc7e7198d96f183d"]]},{"id":"ec0ad301ebe3ea90","type":"debug","z":"90c76dfa1004a4a8","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1350,"y":1200,"wires":[]},{"id":"fc5499a9d4f32f6e","type":"change","z":"90c76dfa1004a4a8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"release","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":1140,"wires":[["61371c4899b88722"]]},{"id":"54fbbf61c645a170","type":"switch","z":"90c76dfa1004a4a8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"release","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":670,"y":1360,"wires":[["bb44db9f08af6024","4dd2bf53adc9a2cb"]]},{"id":"bb44db9f08af6024","type":"trigger","z":"90c76dfa1004a4a8","name":"","op1":"","op2":"single","op1type":"nul","op2type":"str","duration":"500","extend":true,"overrideDelay":false,"units":"ms","reset":"long","bytopic":"all","topic":"topic","outputs":1,"x":860,"y":1280,"wires":[["bc7e7198d96f183d","9a6e87595e2f66d4","823adbc9095f9c94"]]},{"id":"bc7e7198d96f183d","type":"throttle","z":"90c76dfa1004a4a8","name":"","throttleType":"reset","timeLimit":0,"timeLimitType":"seconds","countLimit":0,"blockSize":0,"locked":true,"x":1050,"y":1260,"wires":[["d43f338cad13cb3b"]]},{"id":"d43f338cad13cb3b","type":"switch","z":"90c76dfa1004a4a8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"neq","v":"long","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1190,"y":1260,"wires":[["ec0ad301ebe3ea90"]]},{"id":"4dd2bf53adc9a2cb","type":"change","z":"90c76dfa1004a4a8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"double","tot":"str"},{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":1360,"wires":[["bc7e7198d96f183d","823adbc9095f9c94"]]},{"id":"9a6e87595e2f66d4","type":"debug","z":"90c76dfa1004a4a8","name":"Debug 3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":1120,"wires":[]},{"id":"823adbc9095f9c94","type":"debug","z":"90c76dfa1004a4a8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":1380,"wires":[]}]
2 Likes

At this point I think I prefer the one which can do quadruple clicks and is using functions, at least now there are some options out there :slight_smile:

2 Likes

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