A non-useless interlock for two switches

I have 16 switches and some switch pairs cannot be ON at the same time, because this would damage the setup that is controlled by the switches. For example when switch3 is ON, then switch4 should be forced to OFF, until switch3 is OFF again.

If I just use the interlock functionality then it just turns switch4 ON (when I click the toggle button for switch4 in my browser, while switch3 is ON) and switch3 OFF, which is not what I want. Is there a way to DISABLE a switch, and ENABLE it back? I just found the commands switch.turn_off switch.turn_on and switch.turn_off switch.togglefor controlling switches.

Would implementing a WHILE loop be a reliable way to ensure switch4 cannot be ON while switch3 is ON? Or would switch4 quickly turn ON, before the code kicks in and switches OFF switch4?

i.e. (please forgive my pseudo code):
while (id(switch3).state) {
// Switch3 is ON: switch.turn_off (Switch4)
} else {
// Switch3 is OFF: do nothing

I am thankful for any help.

I think you need to create an interlock Group, in other words gpio3 and gpio4 would need to be in the same interlock group in order to only have one activated. It may be helpful to see what you have in your yaml.

See here

1 Like

Interlocks are very useful and of you want a “non-useless” interlock, the first thing you need to do is understand what an interlock does because what your wanting to do isn’t the job of the interlock. It’s only job is to make sure the switches you define are never ON at the same time and it’s job isn’t to turn off or toggle switches. You must program that logic so a switch is turned off or on in combination with an opposite switch toggle. It’s only useless because you didn’t read the 2 paragraphs that explain what the interlock is for and what it does and your using it wrong.

Thanks for the quick answer. It just does the same unfortunately. It switches on the swich you click and switches the other one off. So it doesnt block you from turning on one switch.

Thanks for your answer. I read the interlock decription and understand what an interlock does (I also tested it). Which is why I also understood that it doesn’t fit my needs. Thats why I asked for an alternative.

There isn’t an alternative, you just need to program the logic how you want it to operate if you need something other than what interlock is meant for. Look under the automations section in the docs, whatever you need will be in there and with examples.

… and any proper interlock is not software … it is hardware relays in combination. Software runs the risk that channels are switched on simultaneously at boot…