#Grouping together two switches and a light sometimes goes rogue

1 messages · Page 1 of 1 (latest)

pale isle
#

Hi!

I have an automation that groups together two switches (one ESPHome and one Zigbee2MQTT) and a light (Zigbee2MQTT) so they keep their state in sync. It works really well other than very occasionally going rogue and getting into a loop where everything tries to continuously switch on and off as fast as possible. The only way to resolve it is to disable the automation.

Here is the automation config:

id: '1732099708681'
alias: Turn off/on Patio Lights
description: ''
triggers:
  - entity_id:
      - switch.patio_light
      - switch.laundry_switch_bottom
    from:
      - 'off'
      - 'on'
    to:
      - 'off'
      - 'on'
    trigger: state
conditions: []
actions:
  - target:
      entity_id:
        - light.patio_lights
        - switch.patio_light
        - switch.laundry_switch_bottom
    action: homeassistant.turn_{{ trigger.to_state.state }}
mode: single

Both times the loop has happened we were attempting to turn the light on using the ESPHome device (switch.patio_light).

The Trace Timeline has the following in the first event:

(switch.patio_light) turned on

Then the second event has this weirdness:

(light.patio_lights) turned on
(switch.laundry_switch_bottom) turned off
(switch.laundry_switch_bottom) turned on
(switch.laundry_switch_bottom) turned off
(switch.laundry_switch_bottom) turned on

Any ideas what could be causing this?

Thank you!

unkempt vector
#

This looks scary, I dont understand why it doesnt go into a loop every time. I would check with if states for each device (if 1 is on, turn 2 and 3 on) etc. But there's probably a neater way of doing it.

ebon ember
pale isle
#

Thanks for the replies. Is it considered scary because the actions are against the same entities as the triggers?

#

The code snippet that @ebon ember posted looks quite similar but my interpretation is that it is acting on other entities and isn't filtering for particular state changes. Is that the takeaway?

pale isle
#

I found some similar blueprints and people are experiencing the same issue, the cause is toggling one of the switches in fast succession. The ESPHome device uses a remote that has pretty poor debouncing so this makes sense. I was able to recreate it easily.

ebon ember
#

It's scary because it is set to trigger itself and could easily as you have seen loop do a runaway..

#

A trigger causes a trigger causes a trigger never ending...

#

Mine you flip the switch to off and the other follow. done.

pale isle
#

Thanks, that makes a lot of sense. Unfortunately I have more than one switch to follow. I have managed to prevent the runaway by not performing an action on the triggering entity: