I’ve got a scenario: I have 2 light switches - one on each end of the hallway. Master is wired to the light and Slave is not wired to anything.
What I want is when either of the switches is turned on the other one reflects the state.
Right now I achieved it with 4 automations:
when Master is ON: turn on Slave
when Master is OFF: turn off Slave
when Slave is ON: turn on Master
when Slave is OFF: turn off Master
Is there a more elegant way to achieve it?
I tried to put them in the Group and use without automations but it didn’t seem to work: If I started with everything off, then turned on Slave - it would change state of Slave and Group to ON but it wouldn’t affect the Master.
Haven’t really worked with trigger ids yet, but that’s how I keep my XMas lights in sync:
alias: Switch - Sync XMas Lights
trigger:
- platform: state
entity_id: >-
switch.xmas_living_room,switch.xmas_lobby,switch.outdoor_1,switch.outdoor_2
from: 'on'
to: 'off'
- platform: state
entity_id: >-
switch.xmas_living_room,switch.xmas_lobby,switch.outdoor_1,switch.outdoor_2
from: 'off'
to: 'on'
action:
- service: switch.turn_{{ trigger.to_state.state }}
target:
entity_id:
- switch.xmas_lobby
- switch.xmas_living_room
- switch.outdoor_1
- switch.outdoor_2
mode: single
You might even be able to skip the second trigger if you also remove the ‘from’ and ‘to’ from the first one - not sure what it would do when the state changes e.g. from ‘unavailable’ to ‘on’ or from ‘off’ to ‘unavailable’, though.
I got the same warnings with my previous solution (using scenes/automations). I think what happens is that when you press SWITCH 1, SWITCH 2 and 3 will change state but they themself trigger the same automation, hence the warning ‘automation already running’.
It works well but i’m afraid my logfile will be quite large in a few years and bloated with these warnings. I’m no expert in HA so i’m not sure how to proceed from here.
Anyone else getting these warnings?
[edit] i changed ‘mode: single’ to ‘mode: restart’ and the warnings stopped. it doesn’t seem to affect the automation so i think i keep it this way.