Two-way switch with two one-way switches

Ensure you have no other automations controlling the two lights then use the 4 automations shown below.

They are very similar to the previous examples you posted except they also have a condition. The condition attempts to ensure that, before changing the switch’s state, the switch is currently in the opposite state (so it doesn’t try to turn off a light that’s already off).

At this late stage, in this grand problem-solving session, I have no reason to be optimistic; my guess is these four automations won’t fix the problem. However, each one of the four automations is as straightforward as can be and employs no tricky templating. Following the automation’s logic is very easy. So if these ordinary automations fail to make the lights work in unison, they serve to demonstrate that the underlying problem isn’t going to yield to ordinary solutions (in this specific situation).

- alias: 'turn on 2'
  trigger:
  - entity_id: switch.shenzhen_neo_1
    platform: state
    to: 'on'
  condition:
    condition: template
    value_template: "{{ is_state('switch.shenzhen_neo_2', 'off') }}"
  action:
  - service: switch.turn_on
    data:
      entity_id: switch.shenzhen_neo_2

- alias: 'turn off 2'
  trigger:
  - entity_id: switch.shenzhen_neo_1
    platform: state
    to: 'off'
  condition:
    condition: template
    value_template: "{{ is_state('switch.shenzhen_neo_2', 'on') }}"
  action:
  - service: switch.turn_off
    data:
      entity_id: switch.shenzhen_neo_2


- alias: 'turn on 1'
  trigger:
  - entity_id: switch.shenzhen_neo_2
    platform: state
    to: 'on'
  condition:
    condition: template
    value_template: "{{ is_state('switch.shenzhen_neo_1', 'off') }}"
  action:
  - service: switch.turn_on
    data:
      entity_id: switch.shenzhen_neo_1

- alias: 'turn off 1'
  trigger:
  - entity_id: switch.shenzhen_neo_2
    platform: state
    to: 'off'
  condition:
    condition: template
    value_template: "{{ is_state('switch.shenzhen_neo_1', 'on') }}"
  action:
  - service: switch.turn_off
    data:
      entity_id: switch.shenzhen_neo_1

I suggest you start by using the first two automations (‘turn off 2’ and ‘turn on 2’) and confirm they work. I suspect they will (because they’re not substantially different from what you’ve already used). Then add the remaining two automations. I imagine that will cause it to misbehave in the same manner you’ve already experienced. Or maybe not. :crossed_fingers:

2 Likes