Skip to content

Instantly share code, notes, and snippets.

@creedda
Forked from fireboy1919/light-state-sync.yaml
Last active January 20, 2025 12:20
Show Gist options
  • Save creedda/31d391e007b978aed3879fcc1d0fb22c to your computer and use it in GitHub Desktop.
Save creedda/31d391e007b978aed3879fcc1d0fb22c to your computer and use it in GitHub Desktop.
Synchronize States Between Two Lights
blueprint:
name: Synchronize brightness states and rgb states
description: Synchronize the on/off state of 2 entities
domain: automation
input:
entity_1:
name: First entity
selector:
entity: {}
entity_2:
name: Second entity
selector:
entity: {}
source_url: https://gist.github.com/creedda/31d391e007b978aed3879fcc1d0fb22c
mode: restart
max_exceeded: silent
variables:
entity_1: !input entity_1
entity_2: !input entity_2
trigger:
- platform: state
entity_id: !input entity_1
- platform: state
entity_id: !input entity_1
attribute: brightness
- platform: state
entity_id: !input entity_1
attribute: rgb_color
- platform: state
entity_id: !input entity_2
- platform: state
entity_id: !input entity_2
attribute: brightness
- platform: state
entity_id: !input entity_2
attribute: rgb_color
condition: []
action:
- choose:
- conditions:
condition: template
value_template: "{{ is_state(trigger.to_state.entity_id, 'on') }}"
sequence:
- service: light.turn_on
data:
rgb_color: '{{ state_attr(trigger.to_state.entity_id, "rgb_color") }}'
brightness: '{{ state_attr(trigger.to_state.entity_id, "brightness") }}'
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}'
default:
- service: light.turn_off
target:
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}'
@creedda
Copy link
Author

creedda commented Dec 28, 2023

Also created a Volume Version for Media Players:
https://gist.github.com/creedda/a346d0c1ef3a883caeb7207e83ecf58c

@thiswillbeyourgithub
Copy link

I had issues so ended up with my own mechanism. I'm linking it here in case it helps others :)

https://gist.github.com/thiswillbeyourgithub/5471d6a48648a8b83020150cad66b8b6

@iluvatyr
Copy link

iluvatyr commented Dec 8, 2024

I had issues so ended up with my own mechanism. I'm linking it here in case it helps others :)

https://gist.github.com/thiswillbeyourgithub/5471d6a48648a8b83020150cad66b8b6

What issues?

@thiswillbeyourgithub
Copy link

I don't remeber I'm sorry. I had much trouble setting up my lights and I had just arrived to the world of HA so it might be me or a quirck of my lights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment