Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Home Assistant Automation Blueprint for syncing the states of two lights
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