Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@marciogranzotto
Created December 25, 2021 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marciogranzotto/5182db93be505d56584440dd54285d51 to your computer and use it in GitHub Desktop.
Save marciogranzotto/5182db93be505d56584440dd54285d51 to your computer and use it in GitHub Desktop.
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