Forgive me, I'm a bit confused. You seem to reply to me when you seem to want to use another members approach, which is fine, but what are you trying to achieve? Have you looked at my approach on the second flow in my first comment? Maybe we're just talking past each other, so here is more in depth what my "concept" is about. Maybe I just wasn't clear enough. Maybe you can tell me at which step my thought process starts to deviate from yours, or if I got it all wrong. Maybe ask the other person about it, perhaps they can help you more.
It gets imported as a new flow...
[{"id":"e38dbb3a.cdd128","type":"subflow","name":"short long times","info":"","category":"","in":[{"x":40,"y":80,"wires":[{"id":"477f641c.1f309c"}]}],"out":[{"x":360,"y":80,"wires":[{"id":"477f641c.1f309c","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"477f641c.1f309c","type":"function","z":"e38dbb3a.cdd128","name":"short long times","func":"const pushed = env.get(\"pushed\");\nconst released = env.get(\"released\");\nclearTimeout(context.retouchTimer);\nmsg.timespushed = context.get(\"count\") || 0;\nif(msg.payload === pushed) context.set(\"count\", msg.timespushed +=1);\nelse if(msg.payload !== released) return null;\nif(!msg.timespushed) {\n msg.timespushed = context.get(\"lastlongpress\");\n msg.longpress = true;\n return msg;\n}\ncontext.retouchTimer = setTimeout(function() {\n context.set(\"count\", 0);\n msg.longpress = msg.payload === pushed;\n if(msg.longpress) context.set(\"lastlongpress\", msg.timespushed);\n else msg.payload = pushed;\n node.send(msg, false);\n}, env.get(\"awaitRetouch\") || 600);\n","outputs":1,"noerr":0,"x":190,"y":80,"wires":[[]],"outputLabels":["short"],"icon":"node-red/timer.svg"},{"id":"180442f7.70de1d","type":"tab","label":"As detailed as it gets","disabled":false,"info":""},{"id":"65be4757.a5206","type":"mqtt in","z":"180442f7.70de1d","name":"","topic":"shellies/shellydimmer2-/input/0","qos":"2","datatype":"auto","broker":"4665a0b7.9250b","x":250,"y":400,"wires":[["ea6965a5.f8cba8"]]},{"id":"c97f0f10.2106f","type":"comment","z":"180442f7.70de1d","name":"STEP 1 : Input and prepare for further processing","info":"","x":280,"y":240,"wires":[]},{"id":"47923019.b41a88","type":"comment","z":"180442f7.70de1d","name":"I don't have shelly products, so I don't know what it spits out","info":"","x":320,"y":340,"wires":[]},{"id":"57ef1e7.014166","type":"comment","z":"180442f7.70de1d","name":"Have a look at the full msg object with the debug node","info":"","x":320,"y":600,"wires":[]},{"id":"d4969161.69fd68","type":"comment","z":"180442f7.70de1d","name":"Check that the input is there and clean (debounced)","info":"","x":340,"y":640,"wires":[]},{"id":"f1cbc266.741fa","type":"comment","z":"180442f7.70de1d","name":"If its not like an mqtt node, see where the button state information is and what it looks like","info":"","x":420,"y":760,"wires":[]},{"id":"c6f218b9.a14268","type":"comment","z":"180442f7.70de1d","name":"If it's not in msg.payload move it there:","info":"","x":310,"y":800,"wires":[]},{"id":"53f0dcd5.1198f4","type":"comment","z":"180442f7.70de1d","name":"Maybe check how the response time looks like","info":"","x":330,"y":680,"wires":[]},{"id":"2b21bf45.c80fc8","type":"comment","z":"180442f7.70de1d","name":"STEP 2 : Filter the Input (optional) ","info":"","x":980,"y":240,"wires":[]},{"id":"69926259.abac04","type":"comment","z":"180442f7.70de1d","name":"Maybe change the input to your needs:","info":"","x":310,"y":920,"wires":[]},{"id":"ea6965a5.f8cba8","type":"function","z":"180442f7.70de1d","name":"debounce","func":"// basic debounce function\n// define time span in next line\nconst debounceTime = 80; // in Milliseconds\n\nclearTimeout(context.debounce);\ncontext.debounce = setTimeout(function() {\n node.send(msg, false);\n}, debounceTime);\n","outputs":1,"noerr":0,"x":950,"y":400,"wires":[["8e9fc4f6.e4e918"]]},{"id":"8e9fc4f6.e4e918","type":"rbe","z":"180442f7.70de1d","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1120,"y":400,"wires":[["d1e7dd86.9c0a5"]]},{"id":"11036b37.b9d385","type":"comment","z":"180442f7.70de1d","name":"If the hardware doesn't do it or you can't config it in your input node","info":"","x":1130,"y":340,"wires":[]},{"id":"34190ef.9111372","type":"comment","z":"180442f7.70de1d","name":"google switch bouncing to know more","info":"","x":1010,"y":460,"wires":[]},{"id":"4c7d6b5e.ace0a4","type":"comment","z":"180442f7.70de1d","name":"STEP 3 : does the press counting within time frame or else calls it a long press","info":"","x":1900,"y":240,"wires":[]},{"id":"d1e7dd86.9c0a5","type":"function","z":"180442f7.70de1d","name":"short long times","func":"const pushed = \"1\"; // define payload to be interpreted as push button pushed \nconst released = \"0\"; // define payload to be interpreted as push button released\nconst awaitRetouch = 600; // milliseconds to wait for a button state change before output\n\nclearTimeout(context.retouchTimer);\nmsg.timespushed = context.get(\"count\") || 0;\nif(msg.payload === pushed) context.set(\"count\", msg.timespushed +=1);\nelse if(msg.payload !== released) return null;\nif(context.get(\"lastlongpress\")) { // long released\n msg.timespushed = context.get(\"lastlongpress\");\n context.set(\"lastlongpress\", 0);\n msg.longpress = true;\n return msg;\n}\ncontext.retouchTimer = setTimeout(function() {\n context.set(\"count\", 0);\n msg.longpress = msg.payload === pushed;\n if(msg.longpress) context.set(\"lastlongpress\", msg.timespushed);\n else{ // short released\n msg.payload = pushed;\n // node.send(msg); // uncomment to send a fake ...\n // msg.payload = released; // ... short released if needed\n }\n node.send(msg, false);\n}, awaitRetouch);\n","outputs":1,"noerr":0,"x":1740,"y":400,"wires":[["88772d2.30ff55"]]},{"id":"f25035de.ed90e8","type":"comment","z":"180442f7.70de1d","name":"if you don't need it skip step 2 (remove them)","info":"","x":1030,"y":500,"wires":[]},{"id":"60fbae8a.c662","type":"comment","z":"180442f7.70de1d","name":"change the first 3 lines in the node to fit your input, thats it!","info":"","x":1840,"y":340,"wires":[]},{"id":"7dd14553.0157f4","type":"change","z":"180442f7.70de1d","name":"","rules":[{"t":"move","p":"deviceInfo.buttonState","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":800,"wires":[["d47d7b2f.c8874"]]},{"id":"d47d7b2f.c8874","type":"switch","z":"180442f7.70de1d","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"my Finger is on the Button","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":600,"y":920,"wires":[["97d9c28a.bbb68","e284933b.0e90a"],["2ef9afc.a9055d","ddf6f8e4.be6b8"]]},{"id":"2ef9afc.a9055d","type":"change","z":"180442f7.70de1d","name":"pushed","rules":[{"t":"set","p":"payload","pt":"msg","to":"pushed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":920,"wires":[[]]},{"id":"97d9c28a.bbb68","type":"change","z":"180442f7.70de1d","name":"released","rules":[{"t":"set","p":"payload","pt":"msg","to":"released","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":960,"wires":[[]]},{"id":"566d835c.f8fc84","type":"comment","z":"180442f7.70de1d","name":"if you intend to reuse it in your flows you may alternatively use the subflow from my example:","info":"","x":1950,"y":640,"wires":[]},{"id":"f22604e5.e331c8","type":"subflow:e38dbb3a.cdd128","z":"180442f7.70de1d","name":"","env":[{"name":"pushed","value":"1","type":"num"},{"name":"released","value":"0","type":"num"},{"name":"awaitRetouch","value":"1500","type":"num"}],"x":2460,"y":640,"wires":[[]]},{"id":"4c47606c.435638","type":"comment","z":"180442f7.70de1d","name":"just double click on it and click on Environment Variables to configure","info":"","x":1890,"y":700,"wires":[]},{"id":"895a0c16.1ab74","type":"comment","z":"180442f7.70de1d","name":"you said something about 1 and 0 and 1/0 ?","info":"","x":1810,"y":460,"wires":[]},{"id":"3280d6e5.50033a","type":"comment","z":"180442f7.70de1d","name":"If type string \"1\" '0' doesn't work try number 1 0","info":"","x":1850,"y":500,"wires":[]},{"id":"a5139eb3.b43a38","type":"comment","z":"180442f7.70de1d","name":"that will set it for this node instance","info":"","x":1800,"y":740,"wires":[]},{"id":"49aad3f.48c38ac","type":"comment","z":"180442f7.70de1d","name":"the benefit of this is you can change things on an per instance basis","info":"","x":1910,"y":780,"wires":[]},{"id":"b774d80.c3a59a8","type":"comment","z":"180442f7.70de1d","name":"but you can also change things for all subflows by editing the template e.g.:","info":"","x":1930,"y":880,"wires":[]},{"id":"68297932.c877e8","type":"comment","z":"180442f7.70de1d","name":"stuff step 2 in it if you always have the same inputs","info":"","x":1920,"y":920,"wires":[]},{"id":"9cb5b0cd.7b706","type":"comment","z":"180442f7.70de1d","name":"or step 4 if you always use the same nuber of outputs (presses)","info":"","x":1960,"y":960,"wires":[]},{"id":"e284933b.0e90a","type":"change","z":"180442f7.70de1d","name":"pushed","rules":[{"t":"set","p":"payload","pt":"msg","to":"pushed","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":1000,"wires":[[]]},{"id":"ddf6f8e4.be6b8","type":"change","z":"180442f7.70de1d","name":"released","rules":[{"t":"set","p":"payload","pt":"msg","to":"released","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":880,"wires":[[]]},{"id":"5971c70b.dc00b","type":"comment","z":"180442f7.70de1d","name":"or just set the time frame for all by writing it right into it","info":"","x":1930,"y":1000,"wires":[]},{"id":"ae8a11cc.39255","type":"comment","z":"180442f7.70de1d","name":"i.e. each subflow node - different settings","info":"","x":1880,"y":820,"wires":[]},{"id":"d831f658.61aea","type":"comment","z":"180442f7.70de1d","name":"STEP 4 : extract the info that the last node added to the msg object","info":"","x":2960,"y":240,"wires":[]},{"id":"88772d2.30ff55","type":"switch","z":"180442f7.70de1d","name":"last press long","property":"longpress","propertyType":"msg","rules":[{"t":"false"},{"t":"true"}],"checkall":"false","repair":false,"outputs":2,"x":2880,"y":400,"wires":[["eedd4628.abcbf8"],["93337500.ff1e68"]]},{"id":"54a8be14.34af28","type":"comment","z":"180442f7.70de1d","name":"was the last press a long one?","info":"","x":2880,"y":340,"wires":[]},{"id":"97586743.7333c","type":"comment","z":"180442f7.70de1d","name":"NO","info":"","x":3120,"y":400,"wires":[]},{"id":"26920a2b.16ca4e","type":"comment","z":"180442f7.70de1d","name":"YES","info":"","x":3020,"y":480,"wires":[]},{"id":"eedd4628.abcbf8","type":"switch","z":"180442f7.70de1d","name":"times pushed","property":"timespushed","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"str"},{"t":"gte","v":"5","vt":"num"}],"checkall":"false","repair":false,"outputs":5,"x":3770,"y":400,"wires":[["e6caf836.f914f8"],[],[],[],[]]},{"id":"93337500.ff1e68","type":"switch","z":"180442f7.70de1d","name":"times pushed","property":"timespushed","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"str"},{"t":"gte","v":"5","vt":"num"}],"checkall":"false","repair":false,"outputs":5,"x":3250,"y":640,"wires":[["bfb76ef7.ea8258"],[],[],[],[]]},{"id":"a48837d0.cde9f8","type":"comment","z":"180442f7.70de1d","name":"How many times was it pressed shortly","info":"","x":3850,"y":340,"wires":[]},{"id":"9070ec49.1eb5b","type":"comment","z":"180442f7.70de1d","name":"you can easy change the number of outputs here","info":"","x":3880,"y":460,"wires":[]},{"id":"b26f8d5a.4f374","type":"comment","z":"180442f7.70de1d","name":"How many times was it pressed before (including the last long one)","info":"","x":3420,"y":540,"wires":[]},{"id":"630156f4.836078","type":"comment","z":"180442f7.70de1d","name":"my point is, there is no fixed order and you can freely change things if you, like don't need stuff","info":"","x":3100,"y":740,"wires":[]},{"id":"1a8dc298.1f9415","type":"comment","z":"180442f7.70de1d","name":"do something on a long press here like dimming","info":"","x":2940,"y":520,"wires":[]},{"id":"ff751329.cdc9c8","type":"comment","z":"180442f7.70de1d","name":"do something on a short press here like switching on or off","info":"","x":3410,"y":400,"wires":[]},{"id":"961bc3e8.09e9a","type":"comment","z":"180442f7.70de1d","name":"you don't need that info? remove that node","info":"","x":3350,"y":580,"wires":[]},{"id":"42c2e925.710d1","type":"comment","z":"180442f7.70de1d","name":"quantic universe 101","info":"Don't take it too serious...","x":610,"y":980,"wires":[]},{"id":"a08efeb6.ca398","type":"comment","z":"180442f7.70de1d","name":"STEP 5 : Do stuff","info":"","x":4320,"y":220,"wires":[]},{"id":"8797d411.962be8","type":"comment","z":"180442f7.70de1d","name":"I already gave quite some raw examples of how one can approach this step","info":"","x":4500,"y":260,"wires":[]},{"id":"7c327edd.ed46d","type":"comment","z":"180442f7.70de1d","name":"but it ultimately depends on STEP 6 : Output","info":"","x":4490,"y":320,"wires":[]},{"id":"ecf0d416.b26ee","type":"comment","z":"180442f7.70de1d","name":"or more specifically, what the output expects to recive to make it work","info":"","x":4570,"y":360,"wires":[]},{"id":"1cb943aa.fd9dc4","type":"comment","z":"180442f7.70de1d","name":"I don't know that!","info":"","x":4440,"y":400,"wires":[]},{"id":"1aceddf8.5bd262","type":"function","z":"180442f7.70de1d","name":"what does it expect? this?","func":"node.status(msg.payload.toString());\nmsg.payload = {data: {\"brightness\": msg.payload, \"transition\": 1} };\nreturn msg;\n","outputs":1,"noerr":0,"x":4600,"y":860,"wires":[["c06d2fc1.90c598"]]},{"id":"e6caf836.f914f8","type":"function","z":"180442f7.70de1d","name":"toggle light","func":"if(msg.payload === \"1\") {\n msg.payload = context.get(\"lastoutput\") === \"on\" ? \"off\" : \"on\";\n context.set(\"lastoutput\", msg.payload);\n node.status(msg.payload === \"on\" ? {fill:\"yellow\",shape:\"dot\",text:\"ON\"} : {fill:\"grey\",shape:\"ring\",text:\"OFF\"});\n return msg;\n}\n","outputs":1,"noerr":0,"x":4290,"y":780,"wires":[["a038860f.85463"]]},{"id":"c06d2fc1.90c598","type":"debug","z":"180442f7.70de1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":4850,"y":820,"wires":[]},{"id":"bdb87bc7.828c7","type":"comment","z":"180442f7.70de1d","name":"pure guesswork here:","info":"","x":4030,"y":760,"wires":[]},{"id":"a038860f.85463","type":"function","z":"180442f7.70de1d","name":"what does it expect for on/off ?","func":"\n\nreturn msg;\n","outputs":1,"noerr":0,"x":4600,"y":780,"wires":[["c06d2fc1.90c598"]]},{"id":"bfb76ef7.ea8258","type":"function","z":"180442f7.70de1d","name":"whats your 50% value?","func":"const value = 120; // ????\n\nif(msg.topic === \"brightness\") {\n context.set(msg.topic, msg.payload); // stores last brightness\n return null;\n}\nif(msg.payload === \"1\") { // pushed\n if(context.get(\"brightness\")) {\n msg.payload = context.get(\"brightness\") < value ? \"inc\" : \"dec\";\n }else msg.payload = \"inc\"; // first dimming action\n}else msg.payload = \"stop\";\nreturn msg;\n","outputs":1,"noerr":0,"x":4050,"y":860,"wires":[["daa7d37d.e666a"]]},{"id":"17e9cb20.79db6d","type":"change","z":"180442f7.70de1d","name":"brightness","rules":[{"t":"set","p":"topic","pt":"msg","to":"brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":4310,"y":940,"wires":[["bfb76ef7.ea8258"]]},{"id":"daa7d37d.e666a","type":"time-based-dimmer","z":"180442f7.70de1d","name":"","interval":"50","step":"1","minValue":"90","maxValue":"150","startIncCommand":"inc","stopIncCommand":"stop","startDecCommand":"dec","stopDecCommand":"stop","x":4290,"y":860,"wires":[["1aceddf8.5bd262","17e9cb20.79db6d"]]},{"id":"4665a0b7.9250b","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closeQos":"0","closeRetain":"false","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]