I need help to fix an unwanted situation in my flow (one button LED RGBW light control).
description for the flow
There is one input button (pressed and released state). if pressed a 1 is send, released a zero is send (trigger after inject node to simulate a button)
under 300ms pressed/active the output has to toggle (on/off and cycle through power states/modes)
over 300ms duration the output has to poll (dim control)
now the problem itself
If pressed duration is near 300ms, the 300ms trigger begins to poll. My toughts goes for message arrival at the 300ms poll trigger (reset message (btn release) arrives polling trigger first and on delay node after it sends the message out of it to polling trigger)
How i can avoid/fix the unwanted reset situation at trigger and delay?
I know that nodered works as it should, so further explanations should not be necessary.
Thanks
[{"id":"16097e45e0489976","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"3d88403e6b2ef8b9","type":"switch","z":"16097e45e0489976","name":"press/release","property":"payload.value","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":620,"y":240,"wires":[["7f8095b2404aba2f","4bf2504c5881be33","31e1c30598d90681"],["492058a455e0fcaf","1de92b88e8ac97fe","4bf2504c5881be33"]],"outputLabels":["press","release"]},{"id":"492058a455e0fcaf","type":"change","z":"16097e45e0489976","name":"setze msg.reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":360,"wires":[["0806d9cf5ac5e713","31e1c30598d90681"]]},{"id":"9b547850f32b76a6","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":80,"wires":[["c8089b162c1d2813"]]},{"id":"c8089b162c1d2813","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":80,"wires":[["a53acddb8cc3aa57"]]},{"id":"1d7dd4efb9c10b88","type":"debug","z":"16097e45e0489976","name":"polling","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1330,"y":400,"wires":[]},{"id":"7f8095b2404aba2f","type":"function","z":"16097e45e0489976","name":"set timestamp","func":"var input = msg.payload.circuit; // Digitaler Eingang aus msg Objekt\nvar flow_pressed = 'DI_' + input + '_pressed'; // als SubFlow '$parent.DI_' + input + '_pressed'\n\nvar pressed = new Date();\nflow.set(flow_pressed, pressed.getTime());\n\n//return msg;","outputs":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1080,"y":60,"wires":[]},{"id":"c652f2fc7b8de7aa","type":"function","z":"16097e45e0489976","name":"delete timestamp","func":"var input = msg.payload.circuit; // Digitaler Eingang aus msg Objekt\nvar flow_pressed = 'DI_' + input + '_pressed'; // als SubFlow '$parent.DI_' + input + '_pressed'\n\nflow.set(flow_pressed, 0);\nnode.warn(flow_pressed + \" is removed\")\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1110,"y":180,"wires":[[]]},{"id":"4bf2504c5881be33","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"2","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1060,"y":140,"wires":[["c652f2fc7b8de7aa"]]},{"id":"1de92b88e8ac97fe","type":"function","z":"16097e45e0489976","name":"duration","func":"var input = msg.payload.circuit; // Digitaler Eingang aus msg Objekt\nvar flow_pressed = 'DI_' + input + '_pressed'; // als SubFlow '$parent.DI_' + input + '_pressed'\nvar input_pressed = new Date(flow.get(flow_pressed));\nvar input_released = new Date();\n\nvar pressed_duration = ( input_released.getTime() - input_pressed.getTime() );\n\nif(pressed_duration <= 300) \n{\n node.warn(\"<=300ms\");\n return msg;\n}\nelse\n{\n node.warn(\">300ms\");\n return {};\n}\n//node.warn(pressed_released_duration + \" Millisekunden\");\n\n// return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":260,"wires":[["e1fdf45980e213fa"]]},{"id":"a53acddb8cc3aa57","type":"change","z":"16097e45e0489976","name":"","rules":[{"t":"set","p":"payload.circuit","pt":"msg","to":"99","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":200,"wires":[["3d88403e6b2ef8b9"]]},{"id":"0806d9cf5ac5e713","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"-300","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1110,"y":400,"wires":[["1d7dd4efb9c10b88","4bf2504c5881be33"]]},{"id":"8e169d02cbf94c47","type":"comment","z":"16097e45e0489976","name":"Polling über 300ms Druckdauer","info":"","x":1090,"y":300,"wires":[]},{"id":"20df2298f121dec7","type":"comment","z":"16097e45e0489976","name":"Reset","info":"","x":1010,"y":100,"wires":[]},{"id":"e1fdf45980e213fa","type":"debug","z":"16097e45e0489976","name":"toggle","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1210,"y":260,"wires":[]},{"id":"31e1c30598d90681","type":"delay","z":"16097e45e0489976","name":"","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":1060,"y":340,"wires":[["0806d9cf5ac5e713"]]},{"id":"8739a41002887189","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":120,"wires":[["de93b8a176fc75b4"]]},{"id":"de93b8a176fc75b4","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"298","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":120,"wires":[["a53acddb8cc3aa57"]]},{"id":"d64142e358388ecb","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":160,"wires":[["f07127d584d119bc"]]},{"id":"f07127d584d119bc","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"299","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":160,"wires":[["a53acddb8cc3aa57"]]},{"id":"e299ff68fe0a222a","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":200,"wires":[["efa4fbf27796ba53"]]},{"id":"efa4fbf27796ba53","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"300","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":200,"wires":[["a53acddb8cc3aa57"]]},{"id":"226aae708156c4c4","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":240,"wires":[["7e839ebf4ad94a87"]]},{"id":"7e839ebf4ad94a87","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"301","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":240,"wires":[["a53acddb8cc3aa57"]]},{"id":"fca7f008d8991685","type":"comment","z":"16097e45e0489976","name":"Toggle","info":"","x":1010,"y":220,"wires":[]},{"id":"1810bae81aaa5ecd","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":280,"wires":[["e8547b874fa672da"]]},{"id":"e8547b874fa672da","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"302","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":280,"wires":[["a53acddb8cc3aa57"]]},{"id":"98057a53c4d4fee1","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":320,"wires":[["d9e246794279c9c9"]]},{"id":"d9e246794279c9c9","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"303","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":320,"wires":[["a53acddb8cc3aa57"]]},{"id":"d085ac0103b5ea3e","type":"inject","z":"16097e45e0489976","name":"1","props":[{"p":"payload.value","v":"1","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":360,"wires":[["6099eebda1991729"]]},{"id":"6099eebda1991729","type":"trigger","z":"16097e45e0489976","name":"","op1":"","op2":"{ \"value\": 0 }","op1type":"pay","op2type":"json","duration":"1000","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":280,"y":360,"wires":[["a53acddb8cc3aa57"]]}]