I have the following automations setup for turning on/off all my outside lights whenever either one of the wall switches (with shelly 1s) is flipped.
alias: "All outside lights OFF with one switch"
trigger:
- platform: state
entity_id: switch.garage_side_light_relay_1, light.back_flood_left, light.front_porch_lights_2, light.lights_driveway_near_road
to: "off"
action:
- service: homeassistant.turn_off
entity_id: group.outside_lights
And another automation for the on:
alias: "All outside lights ON with one switch"
trigger:
- platform: state
entity_id: switch.garage_side_light_relay_1, light.back_flood_left, light.front_porch_lights_2, light.lights_driveway_near_road
to: "on"
action:
- service: homeassistant.turn_on
entity_id: group.outside_lights
This has been working flawlessly for a while until today when my 10 y.o. launched iOS Home app and started tapping on the outdoor light icons and then all the outside lights got ‘out of sync’ and would turn on/off rapidly without stopping. I had to go into HA to turn off the automations to fix.
How can I prevent them from getting out of sync? (this also happens if someone switches 2 or more of the switches on at the same time (there are two switches beside each other on the wall for 2 of the lights)
I’m not certain this will fix the issue but it’s worth a try. This single automation handles turning the lights on and off. The main difference is that it won’t turn on a light that’s already on (or turn off a light that’s already off).
We could include mode: single in the automation but it’s unnecessary because it’s the default mode and the behavior we want for this automation. Let’s say light.back_flood_left is currently off and homeassistant.turn_on turns it on. That means the light’s state will change and re-trigger the automation. If the automation is still busy turning on the other lights, mode: single will cause it to ignore the re-trigger (and log a warning message which you can safely ignore). In other words, while it’s busy turning the lights on, subsequent requests to trigger the automation are ignored. That’s precisely how we want this particular automation to work. We only want it to handle triggers when it’s not busy turning lights on or off.