Mirror two lights on/off and brightness

Trying to crate an automatuion that mirrors on/off and brightness of each other.
However only the off parts works… any ideas?

- alias: mirrored light.dimmable_light_6
  id: mirrored light.dimmable_light_6
  triggers:
    - platform: state
      entity_id: light.dimmable_light_6
  actions:   
  - choose:
    - conditions: '{{ states.light.dimmable_light_6.state == ''off'' }}'
      sequence:
      - action: light.turn_off
        target:
          entity_id: light.dimmable_light_7
    default:
      - action: light.turn_on
        target:
          entity_id: light.dimmable_light_7
        data:
          brightness: "{{ state_attr('light.dimmable_light_6', 'brightness') }}"

This post syncs the state of multiple switches, you can do the same for lights:

For brightness you need a second automation, using a state trigger on the brightness attribut and setting that in the other lights.

yea thanks.
I got the on/off to synk now.
the brightness sync I have trouble with:


- alias: sync brightness1
  trigger:
    - platform: template
      value_template: "{{ state_attr('light.dimmable_light_7','brightness')  }}"
  condition: []
  action:
    - action: light.turn_on
      target:
        entity_id: light.dimmable_light_6
        brightness: "{{ state_attr('light.dimmable_light_7', 'brightness') }}"
  mode: single

Try something like this (untested):

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - light.dimmer_1
      - light_dimmer_2
    attribute: brightness
    to: 
conditions: []
actions:
  - action: light.turn_on
    metadata: {}
    data:
      brightness: "{{ trigger.to_state.attributes.brightness }}"
    target:
      entity_id: 
        - light.dimmer_1
        - light.dimmer_2

why dont do a group so both can have the same values

3 Likes

I agree :100:, especially if the lights are from same manufacturer.

Based on the info provided, I would think this applies to this scenario.

light:
  - platform: group
    name: Living Room Lights
    unique_id: living_room_lights
    entities:
      - light.lamp_1
      - light.lamp_2

if you are using Zigbee2Mqtt theres a seccion to doit

with tasmota just do GroupTopic

Yes, that would fix the problem controlling it from HA. But these lights are in fact a dimmer comtrolling lights. I want them to mirror each other also when physcly turning the dimmers as well.

What manufacturer and model are we working with?

@WarLion suggestion may still be in play…

i believe those are Zigbee are you using z2m or zha?

on z2m just add both as a group

on ZHA you can use this method

if you are using a smart dimmer just change the action to the new entity

if you really wanna make an automation meaby something like this

alias: Sync light 6 → light 5
mode: queued
triggers:
  - entity_id: light.dimmable_light_6
    trigger: state
    id: light6
  - entity_id: light.dimmable_light_5
    trigger: state
    id: light5
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - light6
        sequence:
          - if:
              - condition: template
                value_template: "{{ trigger.to_state.state == 'on' }}"
            then:
              - action: light.turn_on
                target:
                  entity_id: light.dimmable_light_5
                data:
                  brightness: "{{ trigger.to_state.attributes.brightness }}"
                  color_temp: "{{ trigger.to_state.attributes.color_temp | default(250) }}"
                  rgb_color: >-
                    {{ trigger.to_state.attributes.rgb_color | default([255,
                    255, 255]) }}
                  effect: "{{ trigger.to_state.attributes.effect | default('none') }}"
            else:
              - action: light.turn_off
                target:
                  entity_id: light.dimmable_light_5
                data: {}
  - choose:
      - conditions:
          - condition: trigger
            id:
              - light5
        sequence:
          - if:
              - condition: template
                value_template: "{{ trigger.to_state.state == 'on' }}"
            then:
              - action: light.turn_on
                target:
                  entity_id: light.dimmable_light_6
                data:
                  brightness: "{{ trigger.to_state.attributes.brightness }}"
                  color_temp: "{{ trigger.to_state.attributes.color_temp | default(250) }}"
                  rgb_color: >-
                    {{ trigger.to_state.attributes.rgb_color | default([255,
                    255, 255]) }}
                  effect: "{{ trigger.to_state.attributes.effect | default('none') }}"
            else:
              - action: light.turn_off
                target:
                  entity_id: light.dimmable_light_6
                data: {}

havent try but If your lights don’t support all attributes like color_temp or effect just remove those keys or check if the attribute exists before applying.

No color for those

Supports:

  • power measurements
  • brightness

Thanks that works wonders!