Where you are "falling over" is the signals from the input.
It isn't a simple signal - which can be good in some cases - it is a "button pressed" signal and a "button released" signal.
Really all you are interested in is the "pressed" side of things. the "released" is problematic.
I don't like giving people the answer to their questions all the time, but there are exceptions.
Ok, I shall post a bit of code which does what you want, but it an EXAMPLE.
Let's walk through the stages as I see them:
You press the button and the LED(s) are turned ON for 10
seconds.
After that, they are turned OFF.
That's easy as it is.
But when you introduce conditionality: it's a whole different game.
Alas I have to revert to using things I originally didn't like using. But I can't see a better way without complicating it in a whole other way.
So: When the button is pressed, a 10
second count down starts. If the button is pressed again, it has to cancel the (other) existing count down.
That is where the tricks come in.
You set another variable (a flow context - please look into what they are) and it controls what happens during the main countdown.
If the button is pressed again: A signal has to be sent to the trigger
node to stop.
That is msg.reset
.
And!
After 10
seconds, all has to be reset again back to Square one.
[{"id":"6d7fa7a4.e16ff","type":"function","z":"cc2f40ef.95dc","name":"INPUT","func":"\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":360,"wires":[["53f44ea2.c4cd98","e92fd930.c1501"]]},{"id":"896bd893.3c131","type":"trigger","z":"cc2f40ef.95dc","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"500","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Press simulation","x":190,"y":360,"wires":[["6d7fa7a4.e16ff"]]},{"id":"53f44ea2.c4cd98","type":"switch","z":"cc2f40ef.95dc","name":"","property":"thing","propertyType":"flow","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":360,"wires":[["5ae8be15.34522"],["47be4cfc.689b04"]]},{"id":"e92fd930.c1501","type":"delay","z":"cc2f40ef.95dc","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":590,"y":460,"wires":[["d3882ded.97f0f8"]]},{"id":"57f7d6cc.d8349","type":"inject","z":"cc2f40ef.95dc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":320,"wires":[["896bd893.3c131"]]},{"id":"5ae8be15.34522","type":"trigger","z":"cc2f40ef.95dc","op1":"255,255,255","op2":"0,0,0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"0,0,0","bytopic":"all","name":"","x":760,"y":360,"wires":[["c4ee780.f601808"]]},{"id":"47be4cfc.689b04","type":"change","z":"cc2f40ef.95dc","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":420,"wires":[["5ae8be15.34522"]]},{"id":"d3882ded.97f0f8","type":"switch","z":"cc2f40ef.95dc","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":510,"wires":[["16cf59f5.5d78ce","9c03a370.a91fe"]]},{"id":"c4ee780.f601808","type":"debug","z":"cc2f40ef.95dc","name":"output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":930,"y":360,"wires":[]},{"id":"16cf59f5.5d78ce","type":"debug","z":"cc2f40ef.95dc","name":"Set flow to","active":false,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":590,"y":560,"wires":[]},{"id":"9c03a370.a91fe","type":"trigger","z":"cc2f40ef.95dc","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":750,"y":510,"wires":[["8677a2e2.d08a58"]]},{"id":"8677a2e2.d08a58","type":"change","z":"cc2f40ef.95dc","name":"","rules":[{"t":"set","p":"thing","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":510,"wires":[[]]}]