Hi. I have two smart switches configed in HA. Let’s call them “wall light” and “door Light”. I would like it so if “wall light” is turned on, “door light” will do the same, and visa versa. I have got this working by creating 2 automations - one for Wall Light On and one for Wall Light Off. This is working but I was wondering how to create this as a single automation so that Door Light mimicks the On / Off state of Wall Light. I have tried playing around with the YAML but so far not much luck. I am sure its not too complicated but lack of knowledge here is holding me back.
I was thinking something along these lines:
alias: Sync Wall and Door States
description: Turn Door on/off based on Wall's state.
trigger:
- platform: state
entity_id: switch.wall
condition: []
action:
- service: "switch.turn_{{ trigger.to_state.state }}"
target:
entity_id: switch.door
mode: single