Three-way light automation triggers itself

I have 3 lamps that I want to automate together. A and B are smaller lights and C is a larger light.

If A or B is turned on, C must turn on. If A or B is turned off, C must turn off. The other light (B or A) must not be affected.

If C is turned on, A and B must both turn on. If C is turned off, A and B must both turn off.

The problem is that the actions of the automation act as a trigger for itself. This means that if A is turned on, C turns on and C turning on subsequently triggers B to turn on. Everything turns on or off.

I have put a 5s delay at the end of the timer and set it to “single” mode. This has solved the undesired behaviour. I would prefer not to have the delay at all - just in case the light is flicked on and off by accident. Is there a way to prevent triggers from otherwise being generated by an automation? Sort of like an “island mode” for an automation…

I don’t know if I’m making sense…

There are blueprints that solve this problem in the blueprint section. There’s a few custom integrations that do this as well. If you just want an automation, here’s one that I use that solves this problem too:

- alias: Toggle - Cabinet String Lights
  id: toggle_cabinet_string_lights
  mode: parallel
  trigger:
  - platform: state
    entity_id: &cabinet_string_entities
    - switch.kitchen_cabinet
    - switch.wled_all_cabinets
  variables:
    entities: *cabinet_string_entities
    state_list:
    - 'on'
    - 'off'
    continue: >
      {{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
    to_state: >
      {{ trigger.to_state.state | default(none) if continue else none }}
    targets: >
      {{ expand(entities) | rejectattr('entity_id', 'eq', trigger.entity_id) | rejectattr('state', 'eq', to_state) | map(attribute='entity_id') | list if continue else [] }}
  condition:
  - condition: template
    value_template: "{{ continue and to_state in state_list and targets | count > 0 }}"
  action:
  - service: switch.turn_{{ to_state }}
    target:
      entity_id: "{{ targets }}"

This can only be added as a yaml automation, you cannot add this via the UI. If this is too complicated, I recommend using one of the blueprints in the blueprint section of the forums.

1 Like

Built to withstand hurricane force winds! :+1:t3:

Lol yeah, it’s the “laziest” robust automation I could come up with so that I only maintain 1 list and it de-bounces subsequent state changes.