How to change state of the switch

I tried implement a trigger reset :

[{"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":250,"y":1800,"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":"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":[["ee2091dddcbe9962","2e5f5d069b9662c2"]]},{"id":"8e9f451f6117af1d","type":"function","z":"59fb2f9263e14661","name":"actual action goes on","func":"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"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":210,"y":1680,"wires":[["9671f89989381e8e"]]},{"id":"ee2091dddcbe9962","type":"change","z":"59fb2f9263e14661","name":"reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"RESET","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":1720,"wires":[["9671f89989381e8e"]]},{"id":"2e5f5d069b9662c2","type":"delay","z":"59fb2f9263e14661","name":"","pauseType":"delay","timeout":"8","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":860,"y":1780,"wires":[["8e9f451f6117af1d"]]},{"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}]

added delay 8sec on the end to see how it works

What does that achieve?

pocessing time is longer than time for reset to off when button isn't clicked
so I can see that switch goes off when all is finished and reset of timer is working

I fear you are making the easy more complicated than it needs to be.

:frowning_face:
No other chance how to reset trigger
Delay 8 sec is only for debug

It is going to be reset anyway because of the red line.

yes trigger must be reset because action (communication with main unit) started and switch state to off will be handled by function and disable on the end.

The switch in this flow will enable or disable the button.
Pressing the button will turn the switch off and so disable the button.
After ten seconds the switch turns off anyway, disabling the button.

I think that's what you want, but you may need a ui-control node to ensure that the switch and button get initialised to OFF and disabled.

[{"id":"0859c4d4a89178b4","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"95dec0d3de4bcbec","type":"group","z":"0859c4d4a89178b4","name":"These nodes use string ON/OFF","style":{"label":true},"nodes":["e1130c8f9458f535","5aaf17dda573ee51","ae99461167c10b19"],"x":114,"y":59,"w":212,"h":202},{"id":"1175c4771e01362c","type":"group","z":"0859c4d4a89178b4","name":"Convert to msg.enabled true/false","style":{"label":true},"nodes":["fb381298223f4873","b1ff96a3f055d01e"],"x":374,"y":119,"w":412,"h":82},{"id":"fb381298223f4873","type":"ui_button","z":"0859c4d4a89178b4","g":"1175c4771e01362c","name":"","group":"33a8383128087223","order":1,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Pressed","payloadType":"str","topic":"topic","topicType":"msg","x":710,"y":160,"wires":[["ae99461167c10b19","033e3fc568c6299b"]]},{"id":"e1130c8f9458f535","type":"ui_switch","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"","label":"switch","tooltip":"","group":"33a8383128087223","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"enable","topicType":"msg","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":230,"y":160,"wires":[["5aaf17dda573ee51","b1ff96a3f055d01e"]]},{"id":"5aaf17dda573ee51","type":"trigger","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"Switch TImeout","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"OFF","bytopic":"all","topic":"topic","outputs":1,"x":220,"y":100,"wires":[["e1130c8f9458f535"]]},{"id":"ae99461167c10b19","type":"change","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"Disable both","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":220,"wires":[["e1130c8f9458f535","b1ff96a3f055d01e"]]},{"id":"b1ff96a3f055d01e","type":"change","z":"0859c4d4a89178b4","g":"1175c4771e01362c","name":"ON/OFF to true/false","rules":[{"t":"move","p":"payload","pt":"msg","to":"enabled","tot":"msg"},{"t":"change","p":"enabled","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"enabled","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":160,"wires":[["fb381298223f4873"]]},{"id":"033e3fc568c6299b","type":"debug","z":"0859c4d4a89178b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":160,"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}]

Edit - the wire between "Disable both" and "ON/OFF to true/false" is unnecessary.

That node is not correctly named. Not a big deal, but it isn't doing that.
All that node is doing is sending a false payload back to the switch node to turn it off.

He can't disable the switch node. Because if that happens, it's all locked and you can't do anything.

The switch is not disabled, it's turned off. Try it and see.
There just wasn't enough space to name the node "Disable button and turn switch off"

Ok, sorry, I was just looking at the picture.

That you called the change node below the switch Disable both rather than turn both off threw me.

yes looks good
this is clever solution for Switch Timeout :

It doesn't turn the button off, it disables it.
It doesn't disable the switch, it turns it off.
Pick your own name for the node.

Well to me msg.payload is very different to msg.disable.

Screenshot from 2022-03-08 20-52-48

Fair enough.

Node renamed, unnecessary wire removed.

[{"id":"0859c4d4a89178b4","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"95dec0d3de4bcbec","type":"group","z":"0859c4d4a89178b4","name":"These nodes use string ON/OFF","style":{"label":true},"nodes":["e1130c8f9458f535","5aaf17dda573ee51","ae99461167c10b19"],"x":114,"y":59,"w":212,"h":202},{"id":"1175c4771e01362c","type":"group","z":"0859c4d4a89178b4","name":"Convert to msg.enabled true/false","style":{"label":true},"nodes":["fb381298223f4873","b1ff96a3f055d01e"],"x":374,"y":119,"w":412,"h":82},{"id":"fb381298223f4873","type":"ui_button","z":"0859c4d4a89178b4","g":"1175c4771e01362c","name":"","group":"33a8383128087223","order":1,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Pressed","payloadType":"str","topic":"topic","topicType":"msg","x":710,"y":160,"wires":[["ae99461167c10b19","033e3fc568c6299b"]]},{"id":"e1130c8f9458f535","type":"ui_switch","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"","label":"switch","tooltip":"","group":"33a8383128087223","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"enable","topicType":"msg","style":"","onvalue":"ON","onvalueType":"str","onicon":"","oncolor":"","offvalue":"OFF","offvalueType":"str","officon":"","offcolor":"","animate":false,"className":"","x":230,"y":160,"wires":[["5aaf17dda573ee51","b1ff96a3f055d01e"]]},{"id":"5aaf17dda573ee51","type":"trigger","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"Switch TImeout","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"OFF","bytopic":"all","topic":"topic","outputs":1,"x":220,"y":100,"wires":[["e1130c8f9458f535"]]},{"id":"ae99461167c10b19","type":"change","z":"0859c4d4a89178b4","g":"95dec0d3de4bcbec","name":"Switch OFF","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":220,"wires":[["e1130c8f9458f535"]]},{"id":"b1ff96a3f055d01e","type":"change","z":"0859c4d4a89178b4","g":"1175c4771e01362c","name":"ON/OFF to true/false","rules":[{"t":"move","p":"payload","pt":"msg","to":"enabled","tot":"msg"},{"t":"change","p":"enabled","pt":"msg","from":"ON","fromt":"str","to":"true","tot":"bool"},{"t":"change","p":"enabled","pt":"msg","from":"OFF","fromt":"str","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":160,"wires":[["fb381298223f4873"]]},{"id":"033e3fc568c6299b","type":"debug","z":"0859c4d4a89178b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":160,"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}]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.