Skip to content

Instantly share code, notes, and snippets.

@Mohitsharma44
Last active March 10, 2025 00:11
Show Gist options
  • Save Mohitsharma44/7620fb8181c2513536622d74fa6640c3 to your computer and use it in GitHub Desktop.
Save Mohitsharma44/7620fb8181c2513536622d74fa6640c3 to your computer and use it in GitHub Desktop.
Sync Two Lights in HA
blueprint:
name: Sync Two Lights (Bidirectional)
description: >
When either light changes (on/off, brightness, color temperature, or RGB),
the other light is updated to match.
domain: automation
input:
light_a:
name: First Light
description: One of the lights to sync.
selector:
entity:
domain: light
light_b:
name: Second Light
description: The other light to sync.
selector:
entity:
domain: light
mode: restart
trigger:
- platform: state
entity_id:
- !input light_a
- !input light_b
attribute: brightness
- platform: state
entity_id:
- !input light_a
- !input light_b
attribute: rgb_color
- platform: state
entity_id:
- !input light_a
- !input light_b
attribute: color_temp
- platform: state
entity_id:
- !input light_a
- !input light_b
to: "on"
- platform: state
entity_id:
- !input light_a
- !input light_b
to: "off"
action:
- variables:
light_a: !input light_a
light_b: !input light_b
triggered: "{{ trigger.entity_id }}"
other: >
{% if trigger.entity_id == light_a %}
{{ light_b }}
{% else %}
{{ light_a }}
{% endif %}
triggered_state: "{{ states(triggered) }}"
- choose:
- conditions:
- condition: template
value_template: "{{ is_state(triggered, 'off') }}"
sequence:
- service: light.turn_off
data:
entity_id: "{{ other }}"
- conditions:
- condition: template
value_template: "{{ is_state(triggered, 'on') }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ triggered_state.attributes.color_mode == 'rgb' }}"
sequence:
- service: light.turn_on
data_template:
entity_id: "{{ other }}"
brightness: "{{ triggered_state.attributes.brightness | int(default=255) }}"
rgb_color: "{{ triggered_state.attributes.rgb_color }}"
- conditions:
- condition: template
value_template: "{{ triggered_state.attributes.color_mode == 'color_temp' }}"
sequence:
- service: light.turn_on
data_template:
entity_id: "{{ other }}"
brightness: "{{ triggered_state.attributes.brightness | int(default=255) }}"
color_temp: "{{ triggered_state.attributes.color_temp }}"
default:
- service: light.turn_on
data_template:
entity_id: "{{ other }}"
brightness: "{{ triggered_state.attributes.brightness | int(default=255) }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment