Created
December 25, 2021 20:46
-
-
Save marciogranzotto/5182db93be505d56584440dd54285d51 to your computer and use it in GitHub Desktop.
Home Assistant Automation Blueprint for syncing the states of two lights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Sync two lights | |
description: Turn on a light when other one is turend on and vice versa | |
domain: automation | |
input: | |
light_entity1: | |
name: Light 1 | |
selector: | |
entity: | |
domain: light | |
light_entity2: | |
name: Light 2 | |
selector: | |
entity: | |
domain: light | |
variables: | |
light_entity1: !input light_entity1 | |
light_entity2: !input light_entity2 | |
trigger: | |
- platform: state | |
entity_id: | |
- !input light_entity1 | |
- !input light_entity2 | |
from: 'on' | |
to: 'off' | |
- platform: state | |
entity_id: | |
- !input light_entity1 | |
- !input light_entity2 | |
from: 'off' | |
to: 'on' | |
action: | |
service_template: > | |
{% if trigger.to_state.state == 'on' %} | |
light.turn_on | |
{% elif trigger.to_state.state == 'off' %} | |
light.turn_off | |
{% endif %} | |
data_template: | |
entity_id: > | |
{% if trigger.from_state.entity_id == light_entity1 %} | |
{{ light_entity2 }} | |
{% elif trigger.from_state.entity_id == light_entity2 %} | |
{{ light_entity1 }} | |
{% endif %} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment