How to change state of the switch

I have simple flow where I can enable/disable button and when is clicked, only 5sec delay is done.
My question is, if is possible somehow implement this:
When delay is finished that button is again disabled and when button isn't clicked in 10second, is also disabled.
Sending my code:

[{"id":"fb381298223f4873","type":"ui_button","z":"59fb2f9263e14661","name":"","group":"33a8383128087223","order":1,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"as","payloadType":"str","topic":"topic","topicType":"msg","x":560,"y":1200,"wires":[["968b1b67c4b9ab21"]]},{"id":"e1130c8f9458f535","type":"ui_switch","z":"59fb2f9263e14661","name":"","label":"switch","tooltip":"","group":"33a8383128087223","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"enable","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":150,"y":1200,"wires":[["49f2d117ee53df6e","496f143afa9580e0"]]},{"id":"49f2d117ee53df6e","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":330,"y":1240,"wires":[]},{"id":"496f143afa9580e0","type":"change","z":"59fb2f9263e14661","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1200,"wires":[["7632b397da650807","fb381298223f4873"]]},{"id":"7632b397da650807","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":1160,"wires":[]},{"id":"8ba91a0651fdc867","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":1200,"wires":[]},{"id":"968b1b67c4b9ab21","type":"delay","z":"59fb2f9263e14661","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":720,"y":1200,"wires":[["8ba91a0651fdc867"]]},{"id":"33a8383128087223","type":"ui_group","name":"Group 1","tab":"1377960af0a72398","order":1,"disp":true,"width":6},{"id":"1377960af0a72398","type":"ui_tab","name":"OSTATNÍ ZAŘÍZENÍ","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

I don't understand the question.

Is it you are wanting the button to be enabled only for 5 seconds (starting when you press the switch node?)

For my example I used a delay 5sec but in the future I want replace delay with functions and yes, when delay is finished (in the future functions) I want that switch goes off = also button is disabled.

Ok. I have done this before, so I will try my best to help you.

I can see a problem with what you have done.

The delay node isn't activated until the button is pressed. I'm not sure that is what you want.

This may work better.
Though it isn't perfect. I don't want to hand you the solution.
(You will need to add a change node to get things working better.)

And there are some other gremlins which need your attention.
The switch node may not be the best option here.

The other trick is maybe instead of the delay node, try the trigger node.

No sure what you mean, but expected function is :
With switch enable button (this I need to prevent a unwanted click). when button is enabled, click on the button will send a command to main unit (in my code is replaced by delay). When command is sent (finished) then I need change switch to off which also change a state of button to disabled.

I can show you a solution that works.

But I don't know if you want to understand it and do it yourself or be given the answer.

show me and we can discuss points which are hard to understand for me

One way:

[{"id":"984c039df8c2b7ef","type":"ui_switch","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"","label":"safety lock","tooltip":"","group":"c7a27394.057878","order":14,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":1770,"y":1480,"wires":[["cc7a0523bdcbe803","9671f89989381e8e"]]},{"id":"e2ef697a54b18e0b","type":"inject","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":1750,"y":1420,"wires":[["984c039df8c2b7ef"]]},{"id":"9671f89989381e8e","type":"trigger","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"","op1":"","op2":"false","op1type":"nul","op2type":"bool","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1930,"y":1420,"wires":[["984c039df8c2b7ef"]]},{"id":"084f1df60dac2f7a","type":"change","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"disable ","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":2240,"y":1430,"wires":[["984c039df8c2b7ef"]]},{"id":"cc7a0523bdcbe803","type":"change","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1950,"y":1480,"wires":[["19d3ed706256be59"]]},{"id":"19d3ed706256be59","type":"ui_button","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"","group":"c7a27394.057878","order":15,"width":5,"height":1,"passthru":false,"label":"Action","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":2110,"y":1480,"wires":[["8e9f451f6117af1d","084f1df60dac2f7a"]]},{"id":"8e9f451f6117af1d","type":"function","z":"7e987ddf260bdf0d","g":"5e617997398223b5","name":"actual action goes on","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2290,"y":1480,"wires":[[]]},{"id":"c7a27394.057878","type":"ui_group","name":"Alternate","tab":"bb73106a674aef89","order":1,"disp":true,"width":"9","collapse":false},{"id":"bb73106a674aef89","type":"ui_tab","name":"Button press examples","icon":"dashboard","order":41,"disabled":false,"hidden":false}]

I don't like that only because it keeps things happening when it isn't being used.

Another way:

[{"id":"f78bdf06ae572875","type":"subflow","name":"Button toggle with enable","info":"Update 2022 02 21\n\nTo initialise the node send a message of `Z` into the input.\n\nIf you want a specific ouptut:\n`A` sets the mode to what the `a` named messages indicate.\n\n`B` sets the mode to what the `b` named messages indicate.\n\nThe output from the `button` node must be `X` to toggle the state, and the button must NOT pass the input onto the output!\n\nYou MUST set the `environment` variables listed below or it won't work.\n(Example)\n```\nmode: (0/1) (see below)\ndisabledColour: brown\ndisabledTXT:  something\ncolourA: lime\ncolourB: green\ntxtA: Log\ntxtB: Stop\ntxtclrA: black\ntxtclrB: black\npayloadA: GO\npayloadB: STOP\ntopicSET: CONTROL\ndelay: 800\n```\n```\nmode - toggle mode or single mode (0/1).\nThis means in toggle mode you get 2 output messages.\nSingle mode you only get one output message.\n```\n```\ndelay - (optional)  millisecond delay for time button is active.\n```\n```\ndisabledColour - the colour the button is when disabled.\n```\n```\ndisabledTXT - This is used when the `mode` is set to `1`.  The text is displayed by default.\n```\n```\ncolourA - the background colour if condition `A` is selected.  (Temporary)\n```\n```\ncolourB - the background colour if condition `B` is selected.  (Temporary)\n```\n```\ntxtA - The text to display if condition `A` is selected.\n```\n```\ntxtB - The text to display if condition `B` is selected.\n```\n```\ntxtclrA - the colour of the text if condition `A` is selected.\n```\n```\ntxtclrB - the colour of the text if condtion `B` is selected.\n```\n```\npayloadA - the text sent to the output if condtion `A` is selected.\n```\n```\npayloadB - the text sent to the output if condition `B` is selected.\n```\n```\nThese payloads can then be used to set context values or used to control (external node) `gate`\n```\n```\ntopicSET - the message topic which is sent to the `gate`.\n(this is needed if/when used to control the afore mentioned `gate` nodes.)\n```\n\nThe *temporary* meaning is that the button will show that colour for a few seconds\nthen it will turn to the `disabled` colour.\n\nThe active time is `3` seconds (adjustable via the `delay` value) to press/toggle the button once initially pressed.\nNow: if you keep pressing the button, it will *wait* until you finish pressing it.\n\nThe background colours (and text colours) apply to the `button` node (or other) that is pressed.\nThat node must be configured to allow inputs of `{{msg.txt}}`, `{{msg.colour}}` and `{{mdg.fontclr}}`.\n","category":"","in":[{"x":130,"y":180,"wires":[{"id":"bc8e2ea24946f650"},{"id":"7f6db7e922a9aec4"}]}],"out":[{"x":620,"y":140,"wires":[{"id":"7f6db7e922a9aec4","port":0}]},{"x":620,"y":220,"wires":[{"id":"7f6db7e922a9aec4","port":1}]}],"env":[{"name":"delay","type":"num","value":"","ui":{"type":"input","opts":{"types":["num"]}}},{"name":"mode","type":"num","value":"","ui":{"type":"input","opts":{"types":["num"]}}},{"name":"disabledColour","type":"str","value":""},{"name":"disabledTXT","type":"str","value":""},{"name":"colourA","type":"str","value":""},{"name":"txtA","type":"str","value":""},{"name":"txtclrA","type":"str","value":""},{"name":"colourB","type":"str","value":""},{"name":"txtB","type":"str","value":""},{"name":"txtclrB","type":"str","value":""},{"name":"payloadA","type":"str","value":""},{"name":"payloadB","type":"str","value":""},{"name":"topicSET","type":"str","value":""}],"meta":{},"color":"#3FADB5","outputLabels":["To the `GATE` node","To the `BUTTON` node"],"icon":"node-red-dashboard/ui_switch.png","status":{"x":620,"y":300,"wires":[{"id":"6aaf4e9c71587bfd","port":0}]}},{"id":"7f6db7e922a9aec4","type":"function","z":"f78bdf06ae572875","name":"Push Button","func":"//  ----    Assign variable names to ENV variables.\n//  all future use of variables is by their names below.\n//  These are the userdefined variables from ENV\nconst INPUT = msg.payload;\n//var mode = env.get(\"mode\");\nvar mode = parseInt(env.get(\"mode\"));\nconst Disabledcolour = env.get(\"disabledColour\");\nconst disabledTXT = env.get(\"disabledTXT\");\nconst colourA = env.get(\"colourA\");\nconst colourB = env.get(\"colourB\");\nconst txtA = env.get(\"txtA\");\nconst txtB = env.get(\"txtB\");\nconst txtclrA = env.get(\"txtclrA\");\nconst txtclrB = env.get(\"txtclrB\");\nconst payloadA = env.get(\"payloadA\");\nconst payloadB = env.get(\"payloadB\");\nlet topic = env.get(\"topicSET\");\nif (topic === undefined)\n    topic = \"\";\n\n//  These are other variables\nlet state = context.get(\"STATE\")||0;\nconst enabled = context.get(\"ENABLED\")||0;\n\nif (msg.topic === \"D\")\n{\n    context.set(\"DEBUG\",msg.payload);\n    //  Show env \n    node.warn(\"Disabled colour \" + Disabledcolour);\n    node.warn(\"Disabled text \" + disabledTXT);\n    node.warn(\"colourA \" + colourA);\n    node.warn(\"colourB \" + colourB); \n    node.warn(\"txtA \" + txtA);\n    node.warn(\"txtB \" + txtB);\n    node.warn(\"txtclrA \" + txtclrA);\n    node.warn(\"txtclrB \" + txtclrB);\n    node.warn(\"payloadA \" + payloadA);\n    node.warn(\"payloadB \" + payloadB);\n    node.warn(\"topic \" + topic);\n    return;\n}\n\nlet debug = context.get(\"DEBUG\") || 0;\n\nif (debug === 1)\n{\n    node.warn(\"INPUT \" + INPUT);\n    node.warn(\"Disabled colour \" + Disabledcolour);\n    node.warn(\"Disabled text \" + disabledTXT);\n    node.warn(\"colourA \" + colourA);\n    node.warn(\"colourB \" + colourB); \n    node.warn(\"txtA \" + txtA);\n    node.warn(\"txtB \" + txtB);\n    node.warn(\"txtclrA \" + txtclrA);\n    node.warn(\"txtclrB \" + txtclrB);\n    node.warn(\"payloadA \" + payloadA);\n    node.warn(\"payloadB \" + payloadB);\n    node.warn(\"topic \" + topic);\n}\n\n//  =========================================\n//      Main routine below.\n//  Set condition if the message is either A or B\nconst msg1 = {};\n\nif (msg.payload === \"A\")\n{\n    msg.payload = payloadA;\n    msg.topic = topic;\n\n    msg1.txt = txtA;\n    msg1.colour = Disabledcolour;\n    msg1.fontclr = txtclrA;\n    \n    context.set(\"STATE\",0);\n\n    return [msg,msg1];\n}\n\nif (msg.payload === \"B\")\n{\n    msg.payload = payloadB;\n    msg.topic = topic;\n\n    msg1.txt = txtB;\n    msg1.colour = Disabledcolour;\n    msg1.fontclr = txtclrB;\n    \n    context.set(\"STATE\",1);\n\n    return [msg,msg1];\n}\n///////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n//      Now on to the real stuff.\nif (msg.payload === \"X\")\n{\n    //\n    //  Button pressed.\n    //\n    node.status({fill: \"green\",text: \"Pressed\"});\n    if (enabled === undefined)\n    {\n        node.status({text:\"Button_Toggle_Enable_Context_Not_Set\"});\n        node.warn(\"Button toggle enable context not set\");\n        return [null,null];\n    }\n    if (enabled === 0)\n    {\n        if (state === 0)\n        {\n            //\n            //  Set things for state 0\n            //\n//            msg.payload = payloadA;\n//            msg.topic = topic;\n            msg1.colour = colourA;\n            msg1.txt = txtA;\n            msg1.fontclr = txtclrA;\n        }\n        else \n        if (state === 1)\n        {\n            //\n            //  Set things for state 1\n            //\n//            msg.payload = payloadB;\n//            msg.topic = topic;\n            msg1.colour = colourB;\n            msg1.txt = txtB;\n            msg1.fontclr = txtclrB;\n        }\n        context.set(\"ENABLED\",1);\n        return [null,msg1];\n    }\n    //  To here `enabled` === 0.  Now set to 1.\n\n    //      ENABLED from here down.\n    if (enabled === 1)\n    {\n\n        state = (state + 1)% 2;\n        context.set(\"STATE\",state);\n\n\n        if (mode === 1)\n        {\n            state = 1;\n            mode = 0;\n        }\n        //  Code here for MODE === 0\n        if (mode === 0)\n        {\n            if (state === 0)\n            {\n                //\n                //  Condition A\n                //\n                node.status({fill: \"yellow\",text: \"A\"});\n                msg.payload = payloadA;\n                msg1.colour = colourA;\n                msg1.txt = txtA;\n                msg1.fontclr = txtclrA;\n            } else\n            if (state === 1)\n            {\n                //\n                //  Condition B\n                //\n                node.status({fill: \"red\",text: \"B\"});\n                msg.payload = payloadB;\n                msg1.colour = colourB;\n                msg1.txt = txtB;\n                msg1.fontclr = txtclrB;\n            }\n        }   //  END FOR MODE === 0\n    }\n    msg.topic = topic;\n    return [msg,msg1];\n}\n\nif (msg.payload === \"Z\")\n{\n    //\n    ////node.warn(\"Timed out\");\n    //\n    context.set(\"ENABLED\",0);\n    if (mode === 0)\n    {\n        node.status({text: \"\"});\n        if (payloadA === undefined)\n        {\n            return [null,null];\n        }\n//        context.set(\"ENABLED\",0);\n        if (state === 0)\n        {\n            //\n            //  Set things for state 1\n            //\n            msg.payload = payloadA;\n            msg.topic = topic;\n            msg1.colour = Disabledcolour;\n            msg1.txt = txtA;\n            msg1.fontclr = txtclrA;\n        }\n        else if (state === 1)\n        {\n            //\n            //  Set things for state 2\n            //\n            msg.payload = payloadB;\n            msg.topic = topic;\n            msg1.colour = Disabledcolour;\n            msg1.txt = txtB;\n            msg1.fontclr = txtclrB;\n        }\n    }\n \n    if (mode === 1)\n    {\n        //\n        //  Condition A\n        //\n        node.status({text: \"\"});\n        context.set(\"STATE\",0);\n        msg1.colour = Disabledcolour;\n        msg1.txt = disabledTXT;\n    }\n\n    return [null,msg1];\n}","outputs":2,"noerr":0,"initialize":"// Code added here will be run once\n// whenever the node is started.\n\ncontext.set(\"ABGC\", env.get(\"colourA\"));\ncontext.set(\"BBGC\", env.get(\"colourB\"));\n//\n//  Disabled button background colour.\n//\ncontext.set(\"DISABLEDCLR\",env.get(\"disabledColour\"));\n//\n//  Now do text.\n//\ncontext.set(\"Atxt\", env.get(\"txtA\"));\ncontext.set(\"Btxt\", env.get(\"txtB\"));\n//\n//  Font colours.\n//\ncontext.set(\"AFC\",env.get(\"txtclrA\"));\ncontext.set(\"BFC\",env.get(\"txtclrB\"));\n//\n//  Payloads.\n//\ncontext.set(\"PayloadA\", env.get(\"payloadA\"));\ncontext.set(\"PayloadB\", env.get(\"payloadB\"));\n\n","finalize":"","libs":[],"x":440,"y":180,"wires":[[],[]],"outputLabels":["To gate","To button"]},{"id":"6aaf4e9c71587bfd","type":"status","z":"f78bdf06ae572875","name":"","scope":["7f6db7e922a9aec4"],"x":460,"y":300,"wires":[[]]},{"id":"d13a8e023b434961","type":"trigger","z":"f78bdf06ae572875","name":"","op1":"","op2":"Z","op1type":"nul","op2type":"str","duration":"3","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":315,"y":150,"wires":[["7f6db7e922a9aec4"]],"l":false},{"id":"bc8e2ea24946f650","type":"switch","z":"f78bdf06ae572875","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"X","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":195,"y":150,"wires":[["69a7bd973e5f8bdd"]],"l":false},{"id":"69a7bd973e5f8bdd","type":"function","z":"f78bdf06ae572875","name":"set msg.delay","func":"msg.delay = env.get(\"delay\") || 1000;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":245,"y":150,"wires":[["d13a8e023b434961"]],"l":false},{"id":"bd1396b75a314127","type":"ui_button","z":"7e987ddf260bdf0d","g":"4254e69c62b12307","name":"Double press","group":"2d3c012e72579d4d","order":0,"width":"3","height":"2","passthru":false,"label":"{{msg.txt}}","tooltip":"","color":"{{msg.fontclr}}","bgcolor":"{{msg.colour}}","icon":"","payload":"X","payloadType":"str","topic":"topic","topicType":"msg","x":1750,"y":1730,"wires":[["6ee44862c31ba778"]]},{"id":"6ee44862c31ba778","type":"subflow:f78bdf06ae572875","z":"7e987ddf260bdf0d","g":"4254e69c62b12307","name":"","env":[{"name":"delay","value":"1500","type":"num"},{"name":"mode","value":"1","type":"num"},{"name":"disabledColour","value":"black","type":"str"},{"name":"disabledTXT","value":"Press to activate","type":"str"},{"name":"colourA","value":"red","type":"str"},{"name":"colourB","value":"blue","type":"str"},{"name":"txtA","value":"Are you sure?","type":"str"},{"name":"txtB","value":"Done!","type":"str"},{"name":"txtclrA","value":"white","type":"str"},{"name":"txtclrB","value":"white","type":"str"},{"name":"payloadA","value":"A","type":"str"},{"name":"payloadB","value":"B","type":"str"},{"name":"topicSET","value":"restore","type":"str"}],"x":1950,"y":1730,"wires":[["300b961c28d814cb"],["bd1396b75a314127"]]},{"id":"300b961c28d814cb","type":"debug","z":"7e987ddf260bdf0d","name":"This gets things done","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2220,"y":1730,"wires":[]},{"id":"2d3c012e72579d4d","type":"ui_group","name":"Double press","tab":"bb73106a674aef89","order":3,"disp":true,"width":"6","collapse":false},{"id":"bb73106a674aef89","type":"ui_tab","name":"Button press examples","icon":"dashboard","order":41,"disabled":false,"hidden":false}]

You have to double click the button to get things done.

ok, let me check, but double click I don't like....

Doble click is really hard to understand for me, also there I see a problem how to implement a feed back that operation was finished successfully.

... and you are right, one way solution is still running due to 3sec timer to reset switch back to off.

To get the "double click" to work, you single click and get asked "Are you sure?"
Click it again - while it is showing that text - and the output is ... activated

it's clear, but I activate a output - for me it means I will send a command and I will also receive a answer from main unit. For me is complete operation done when answer is received and this feed back isn't chance to implement.
In the one way yes, when feed back is received I will send off to the switch, but there is problem with loop.

You didn't exactly say that originally.

If you need to receive a confirmation: what happens if it fails?
How is it indicated?

That opens a whole different can of worms.

Never seen a error answer, only answer "done" from main unit.
For me one way solution is very nice. Only loop via 3s triger is problem - question is, if isn't possible start triger only with message "ON" from the switch. Then I think loop will be solved.

If you've never seen an error message......

Ok, so you want to disable things when the done is received.

Hang on.

This seems to work.

Extra debug nodes here to show you what is going on.

[{"id":"c29b03b122a331fb","type":"ui_switch","z":"0918ee609bf69fc7","name":"","label":"switch","tooltip":"","group":"33a8383128087223","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"enable","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":4020,"y":415,"wires":[["8c1a2dd4781cb48c","83eb215a571273b2","00859721a58436ba"]]},{"id":"2bb840c51e1076bb","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":3870,"y":415,"wires":[["c29b03b122a331fb"]]},{"id":"05948a9305d8d470","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":3900,"y":325,"wires":[["c29b03b122a331fb"]]},{"id":"b70d9609f25ebda6","type":"inject","z":"0918ee609bf69fc7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":3900,"y":365,"wires":[["c29b03b122a331fb"]]},{"id":"8c1a2dd4781cb48c","type":"debug","z":"0918ee609bf69fc7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":4200,"y":455,"wires":[]},{"id":"83eb215a571273b2","type":"change","z":"0918ee609bf69fc7","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":4230,"y":415,"wires":[["2963c829720688f0","57330380ef7eca11"]]},{"id":"00859721a58436ba","type":"switch","z":"0918ee609bf69fc7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":4070,"y":500,"wires":[["dc3688994692c79f"]]},{"id":"dc3688994692c79f","type":"delay","z":"0918ee609bf69fc7","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":4210,"y":500,"wires":[["9e571bb4fec9639e","2bb840c51e1076bb"]]},{"id":"41919ee1db15fdb4","type":"delay","z":"0918ee609bf69fc7","name":"Stuff getting done.","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":4680,"y":440,"wires":[["2bb840c51e1076bb","34f6a021f53664f4"]]},{"id":"2963c829720688f0","type":"debug","z":"0918ee609bf69fc7","name":"Allow button to be pressed.","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":4280,"y":370,"wires":[]},{"id":"57330380ef7eca11","type":"ui_button","z":"0918ee609bf69fc7","name":"","group":"33a8383128087223","order":1,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"as","payloadType":"str","topic":"topic","topicType":"msg","x":4430,"y":415,"wires":[["747619a6153b942a","41919ee1db15fdb4"]]},{"id":"9e571bb4fec9639e","type":"debug","z":"0918ee609bf69fc7","name":"5 seconds have passed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":4420,"y":500,"wires":[]},{"id":"34f6a021f53664f4","type":"debug","z":"0918ee609bf69fc7","name":"For the sake of showing the things have happened.","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":4780,"y":500,"wires":[]},{"id":"747619a6153b942a","type":"debug","z":"0918ee609bf69fc7","name":"Get tings done.","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":4460,"y":370,"wires":[]},{"id":"33a8383128087223","type":"ui_group","name":"Group 1","tab":"1377960af0a72398","order":1,"disp":true,"width":6},{"id":"1377960af0a72398","type":"ui_tab","name":"OSTATNÍ ZAŘÍZENÍ","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

what's about this :

[{"id":"984c039df8c2b7ef","type":"ui_switch","z":"59fb2f9263e14661","name":"","label":"safety lock","tooltip":"","group":"c7a27394.057878","order":14,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"x":350,"y":1780,"wires":[["cc7a0523bdcbe803","c1a1e7b6e84ae7b4"]]},{"id":"9671f89989381e8e","type":"trigger","z":"59fb2f9263e14661","name":"","op1":"","op2":"false","op1type":"nul","op2type":"bool","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":360,"y":1680,"wires":[["920b730df4b2b2f9","984c039df8c2b7ef"]]},{"id":"084f1df60dac2f7a","type":"change","z":"59fb2f9263e14661","name":"disable ","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1120,"y":1720,"wires":[["984c039df8c2b7ef","34cbe6f2c4a86cf6"]]},{"id":"cc7a0523bdcbe803","type":"change","z":"59fb2f9263e14661","name":"","rules":[{"t":"set","p":"enabled","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1780,"wires":[["19d3ed706256be59","d5b9c0262ae4515c"]]},{"id":"19d3ed706256be59","type":"ui_button","z":"59fb2f9263e14661","name":"","group":"c7a27394.057878","order":15,"width":5,"height":1,"passthru":false,"label":"Action","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":710,"y":1780,"wires":[["8e9f451f6117af1d"]]},{"id":"8e9f451f6117af1d","type":"function","z":"59fb2f9263e14661","name":"actual action goes on","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":940,"y":1780,"wires":[["084f1df60dac2f7a"]]},{"id":"920b730df4b2b2f9","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":1680,"wires":[]},{"id":"34cbe6f2c4a86cf6","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1290,"y":1720,"wires":[]},{"id":"d5b9c0262ae4515c","type":"debug","z":"59fb2f9263e14661","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":1820,"wires":[]},{"id":"c1a1e7b6e84ae7b4","type":"switch","z":"59fb2f9263e14661","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":190,"y":1680,"wires":[["9671f89989381e8e"]]},{"id":"c7a27394.057878","type":"ui_group","name":"Alternate","tab":"bb73106a674aef89","order":1,"disp":true,"width":"9","collapse":false},{"id":"bb73106a674aef89","type":"ui_tab","name":"Button press examples","icon":"dashboard","order":41,"disabled":false,"hidden":false}]

looks no loop

If it works for you that's all that matters.

only one small "bug" is there. If complete communication with main unit is longer then 3seconds, switch goes off depend on trigger/delay and not answer from main unit.

But I see there is a chance to reset a trigger

Well, increase the local time in the trigger node to more than what you think the actual command time needs to complete.

But again: That is a whole other can of worms.