It helps to write the conditions properly. I also threw in a 1 second limit on changes to stop any potential loops. It prevents things from being rapidly synced if you rapidly change them, but that isn’t a big problem. I’ve tested this on a number of paired lights & switches and I think this works well.
I see this is old, but still active, here is how I do it, no loops, can add many entities. The boolean ensures it runs once, more important if you have a bunch
alias: Pool Pumps On
description: 'Ensure both pumps are on/off at same time'
trigger:
- platform: state
entity_id: 'switch.pool_heat_circ_pump, switch.pool_pump'
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.pool_pumps
state: 'off'
action:
- service: switch.turn_on
data: {}
entity_id: 'switch.pool_heat_circ_pump, switch.pool_pump'
- service: input_boolean.turn_on
data: {}
entity_id: input_boolean.pool_pumps
mode: single
alias: Pool Pumps Off
description: 'Ensure both pumps are on/off at same time'
trigger:
- platform: state
entity_id: 'switch.pool_heat_circ_pump, switch.pool_pump'
from: 'on'
to: 'off'
condition:
- condition: state
entity_id: input_boolean.pool_pumps
state: 'on'
action:
- service: switch.turn_off
data: {}
entity_id: 'switch.pool_heat_circ_pump, switch.pool_pump'
- service: input_boolean.turn_off
data: {}
entity_id: input_boolean.pool_pumps
mode: single
I really like this scheme.
I wish I were better versed at templates to come up with some of these.
Thanks for sharing.
Works really well and is pretty elegant.
I just add it to a subfolder under config/homeassistant/blueprints/automation and after calling the service automation.reload on the UI it is selectable.
My need is exactly the opposite of this. I have 2 pumps one being a backup of the other. The plumbers suggested it’d be a good practice to rotate their on/off status to increase their lifetime and for some other reasons.
I connected them to a sonoff wireless switch and wrote the following automation, which works. Sadly it’s super primitive and also prone to many fail cases such as any power failure during the automation or say if HA goes down during the automation for some reason. Is there a smart way to mirror the opposite states for two switches without having two automations?
Hello, I’m completely new to HA and automations. I have a running network of zigbee devices and more and more of them are coming.
I already have 15 ZBMINI switches operational, and now I wanted to use ZBMINI in the staircase switch scenarios, however it seems that the wiring I have doesn’t allow me for this use case (no direct L out to the light). Do you think, it would be possible to use a pair of ZBMINIL2 and somehow program mirroring automation for this use case?
You could just add it to the end of the automations.yaml file then see if it appears in the Automations UI. As old as it is, there’s no assurance that the automation would work.
Took a little fiddling to get the formatting right… But this works GREAT syncing Virtual switches in Smartthings and real switches in HA. This is a cool/easy way to get Alex/Google Voice Assistant to turn on and off devices in HA.