Lock the switches against each other

Hello,
I'm looking for a solution to interlock 2 switches in the dashboard. If 1 switch goes "on", switch 2 goes "off" and vice versa. I plan to have several switches and only one should always be on, all others must then automatically switch to off.

Is there a solution for this?

Greetings Volker

Welcome to the forum @volker1078

This should be easy. Add an inject node and connect it to a switch node and connect that to a debug node. So first, go to the dashboard and press the switch then go to the editor and see what arrives in the debug.

Now look at the switch node and check out it's options. Can you put something in the inject node to effect the switch?

If you can have the output of the switch node feed a second switch node with a debug node attached to it. What happens?

You will probably have to flip something (like on to off) so you will need some more logic but get to this point first.

Thank you for your answer,
I've already built something, but unfortunately it doesn't work. When I press the switch, the information keeps running through the two switches and Node-Red crashes. The information may only run once after switching through the switch and not again and again.

Here is my node:

[{"id":"8050bd6f.1d3a98","type":"ui_switch","z":"55c5e2d9.cbd9c4","name":"","label":"switch","tooltip":"","group":"3a9a86da.eed4a2","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":210,"y":820,"wires":[["6a52f78a.7f11f","621ddf1f.a14ca"]]},{"id":"edfbfb04.f32dd8","type":"ui_switch","z":"55c5e2d9.cbd9c4","name":"","label":"switch","tooltip":"","group":"3a9a86da.eed4a2","order":1,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":210,"y":940,"wires":[["24224811.a85b9"]]},{"id":"17dbcc7f.da00ec","type":"InvertUltimate","z":"55c5e2d9.cbd9c4","name":"Invert","x":530,"y":820,"wires":[["99bc7a4b.572d28","edfbfb04.f32dd8"]]},{"id":"99bc7a4b.572d28","type":"debug","z":"55c5e2d9.cbd9c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":750,"y":820,"wires":[]},{"id":"6a52f78a.7f11f","type":"debug","z":"55c5e2d9.cbd9c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":350,"y":740,"wires":[]},{"id":"4feb16db.681ce8","type":"debug","z":"55c5e2d9.cbd9c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":590,"y":740,"wires":[]},{"id":"621ddf1f.a14ca","type":"switch","z":"55c5e2d9.cbd9c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":820,"wires":[["17dbcc7f.da00ec","4feb16db.681ce8"],[]]},{"id":"60bb035c.cba2bc","type":"InvertUltimate","z":"55c5e2d9.cbd9c4","name":"Invert","x":530,"y":940,"wires":[["8050bd6f.1d3a98","149f9e0e.0d2e3a"]]},{"id":"24224811.a85b9","type":"switch","z":"55c5e2d9.cbd9c4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":380,"y":940,"wires":[["60bb035c.cba2bc"],[]]},{"id":"149f9e0e.0d2e3a","type":"debug","z":"55c5e2d9.cbd9c4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":730,"y":920,"wires":[]},{"id":"3a9a86da.eed4a2","type":"ui_group","z":"","name":"Test","tab":"4e23a76c.608818","disp":true,"width":"6","collapse":false},{"id":"4e23a76c.608818","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

Greetings Volker

That is what will happen with switches. They can't really be grouped in the way we are expecting to.
But it is easy enough to get done with buttons.
See this example
https://flows.nodered.org/flow/cd90709d95fcba9970bd88205871c3c7

I haven't looked in detail at your flow but it sounds as if you have Pass Through selected in the switches, clear that selection and it should stop the loop.

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