Synchronize the on-off state and brightness of two lights

Inspired by this:

I created a new blueprint that will synchronize the on-off state and brightness of two lights. Note that if one of the lights becomes unavailable, the other one will turn off. This is a good default for me, but it might not suit your use case.

Would be easy to extend to synchronizing other features as well, but these are the ones that I actually use.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

  name: Synchronize brightness 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/fireboy1919/997c80db37de30da76f67c5daeaba27b
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_2
- platform: state
  entity_id: !input entity_2
  attribute: brightness
condition: []
action:
- choose:
    - conditions:
        condition: template
        value_template: "{{ is_state(trigger.to_state.entity_id, 'on') }}"
      sequence:
        - service: light.turn_on
          data:
            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 %}'
4 Likes

Thank you so much for this. Really missed this kind of functionality from smart lighting on smartthings, and this one is concise and easy to understand.

1 Like

Thank you!

Great blueprint, thanks for sharing!

One question. Have you considers a second entry in the choose section with a condition
"{{ is_state(trigger.to_state.entity_id, 'off') }}"
Using that rather than a default ensures that nothing happens to the target entity if the trigger entity becomes unavailable.

And another suggestion, include synchronization of the dimmer state?

1 Like

Is there a way to add a delay, becuase i have a dimmer light switch in my bedroom and a light bulb I want it to synchronize with. If i change the dimmer to quickly on the light switch, the light bulb and the light seitch start basically arguing and it looks like the light is flickering. Does anyone have a solution for this?

1 Like

Another suggestion will be to add also the colors synchronization :slight_smile: