EDIT: One switch or the other ON (not both ON), how to?

Hi,

I have 2 switch, switch A and switch B. I would need that only ONE switch can be on at the same time.

  • if switch A is ON, cannot turn on switch B
  • if switch B is ON, cannot turn on switch A
  • if both are off, is possible to turn on only one

What would be the best way to achieve this? Automation, or?, How?

Thanks

Using input boolean you’d need to have the option to disable the control. Currently this is not supported.
Could there be another approach to the automation you are trying to achieve ?

Are they physical switches? If so, most switches are made to do automation second to actually working like a switch. What I’m trying to say is if they are physical switches, both would probably work as physical switches, then HA would recognize the new state and adjust. But the adjustment will lag by a second or so. Can you be more specific on what you are trying to do and what equipment you have to try and do it with?

Ah… They could be physical switches too ! How oldskool :wink:

yes, either with built in WiFI (either Sonoff or those ready made plug/jack)

attach two electric appliances that consumes a lot. Don’t want them both ON because I could risk power cut off from my utility

actually the goal is not automation (should change the title), what I need is that either switch should not be on concurrently

If you have a physical switch that is able to report its status you can create an automation that checks this and acts upon it. Should be easy to do. But you need a switch with reliable status reporting. How do you want to activate those switches ?

you have recommendation?

What will be your trigger to activate your switch ?

One is a boiler, for which is fine some hours during 24h (can be a preset timing)
The other is an electric heater which should work for some hours during 24h (can be a preset timing).

But some manual (with manual I mean with HASS interface or a call with HTTP SHORTCUT of some sort) changes should be allowed (for the electric heater mainly).
Ideally even manual changes too

problem is with manual switches, the initial connection is going to be made and the startup current (which for motors is the large part normally) will already be flowing before HA can react to it through an automation. The best way to do it would be to have 4 switches (yea I know). Two that do nothing but signal HA to turn the equipment on or off. Two that connect to the actual equipment that only HA controls. That way when HA gets a request to turn something on, it can check the status of the other, turn it off if needed before it turns on the second one. The extra switches that report to HA can either be HA input booleans that you control from your phone or a screen somewhere, or a simple pushbutton switch somewhere. They don’t even have to be full house power, they can be simple 5 volt switches on a battery that talk through zwave or a serial connection to HA.

@turboc is absolutely right. The only way to have a reliable solution is to do any switching through hass. You could use manual switching. But it should be sending it’s signals to hass. Not directly to your devices.

yes I understand.

But I rather not make it too complicated and try it more simpler. I can risk some power cut off, and will act accordingly.

FOr the moment is fine a simple solution even if for few seconds the two sitches might be on.

Could you help in coding it, or give some clue how to do it? Thanks

to my simplistic mind, it’s two automations,
Trigger on switch A turning on
Action, turn off switch B

Trigger on switch B turning on
Action turn off switch A

It never hurts to turn off a switch that is already off.

like thgis?

  - alias: "heater on - boiler off"
    trigger:
      - platform: state
        from: 'off'
        to: 'on'
        entity_id: switch.heater
    action:
      service: switch.turn_off
      entity_id: switch.boiler
  - alias: "boiler on - heater off"
    trigger:
      - platform: state
        from: 'off'
        to: 'on'
        entity_id: switch.boiler
    action:
      service: switch.turn_off
      entity_id: switch.heater

I would think so, but I’ve moved all of my automations to AppDaemon so my YAML is a little rusty.