Disable a switch if another switch is turned on

I have got a relay hooked up to my raspberry pi connected to some water valves in my garden. Now I would like only be able to only turn on one switch at a time.
Only idea I had was to have an automation that instantly turns off the switch if there is another one turned on already. Problem is the switch is on for about a second before turning off again.
Does anyone have a better solution for that?
Heres the automation I came up with:

automation:
  - alias: Switch 1
    trigger:
      platform: state
      entity_id: switch.switch1
      to: 'on'
    condition:
      condition: or
      conditions:
        - condition: state
          entity_id: switch.switch2
          state: 'on'
          - condition: state
          entity_id: switch.switch3
          state: 'on'
    action:
      - service: homeassistant.turn_off
        entity_id: switch.switch1
1 Like

You could use 3 input_booleans as proxies for the 3 switches.
There may still be a delay when the input_boolean is on, but the actual switch would never get turned on unless the proper conditions were met.

1 Like

Thanks a lot, it works. For anyone interested, here is my code:

input_boolean:
  switch_1:
    name: Switch 1
    initial: off
  switch_2:
    name: Switch 2
    initial: off

automation:
  - alias: Input Boolean
    trigger:
      platform: state
     entity_id: input_boolean.switch_1
      to: 'on'
    condition:
      - condition: state
        entity_id: input_boolean.switch_2
        state: 'off'
    action:
      - service: homeassistant.turn_on
        entity_id: switch.switch_1