Syncing My Brightness

Good Day,

I would like to Sync My dining Room pot light brightness to my hallway lights when I change the brightness.

Im trying to do this through the Gui, and have messed with the Yaml right now. I have it working so it checks if the hallway light is on, and if it is, then set the brightness. The part i am missing is I want to copy the brightness.

This is what I have.

Trigger

platform: state
entity_id:
  - light.dining_room_lights
attribute: brightness

Conditions

condition: and
conditions:
  - condition: device
    type: is_on
    device_id: 2bcfe318c4e9d57e970ca5d2cd01cad2
    entity_id: light.upstairs_hallway_lights
    domain: light

Action

type: turn_on
device_id: 2bcfe318c4e9d57e970ca5d2cd01cad2
entity_id: light.upstairs_hallway_lights
domain: light
brightness_pct: 10

As you see right now, if the hallway lights are on, it will set them to 10%. I would like to copy the exact behavior of the dining room lights.

Thanks :slight_smile: Home Assistant is the most addicting thing I have ever done other than smoke. lol, should of done this years ago.

Why don’t you create a group with those two lights (or sets of lights) and then change the brightness to the group instead of individual lights?

If you still wanna do with an automation, try this:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - light.dining_room_lights
    attribute: brightness
condition:
  - condition: state
    entity_id: light.upstairs_hallway_lights
    state: "on"
action:
  - service: light.turn_on
    data:
      brightness_pct: "{{ state_attr('light.dining_room_lights', 'brightness_pct') | int(50) }}"
    target:
      entity_id: light.upstairs_hallway_lights

So I have implemented the above.

When I change the brightness on the dining room lights via the peco, the hallway lights will react (1 Time) but will not copy the brightness. They go to 50 % range regardless. When I turn the hallway lights off and on again, then they once again will only react once when I change the dining room brightness.

If you want to mirror off also then you can do like this:

description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - light.dining_room_lights
    attribute: birghtness
    id: "on"
  - platform: state
    entity_id:
      - light.dining_room_lights
    to: "off"
    id: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
        sequence:
          - service: light.turn_on
            data:
              brightness: "{{ state_attr('light.dining_room_lights', 'brightness') | int }}"
            target:
              entity_id: light.upstairs_hallway_lights
      - conditions:
          - condition: trigger
            id: "off"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.upstairs_hallway_lights
            data: {}

Sorry about the first edit. My phone wouldn’t copy the complete yaml. It keep insisting on a partial or old copy…

3 Likes

Hey, so this is not copying the brightness. When I dim the dining room lights, the hallway lights don’t change, this is only for the off switch.

Can you show us the entities you have here in developer tools?

You mean these?
There are many many pages worth of screenshots, just want to confirm

That’s not developer tools

In developer tools Im not seeing an entities tab, Im sorry…:confused:

Sorry I confused you.
I meant I want to see the entities as in the light.dining… in the developer tools → states.
The developer tools → states show all the attributes of an entity and the real values.
So keep both lights on and take a screenshot of what the states and attributes are on that view

Ahh got it,

See below, the dining room lights and the hallway lights,

And could you please share you latest version of your automation (yaml)?

This is the latest,

description: ""
trigger:
  - platform: state
    entity_id:
      - light.dining_room_lights
    attribute: birghtness
    id: "on"
  - platform: state
    entity_id:
      - light.dining_room_lights
    to: "off"
    id: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
        sequence:
          - service: light.turn_on
            data:
              brightness: "{{ state_attr('light.dining_room_lights', 'brightness') | int }}"
            target:
              entity_id: light.upstairs_hallway_lights
      - conditions:
          - condition: trigger
            id: "off"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.upstairs_hallway_lights
            data: {}
mode: single

Looks like there is a typo here.

Try this:

description: ""
trigger:
  - platform: state
    entity_id:
      - light.dining_room_lights
    attribute: brightness
    id: "on"
  - platform: state
    entity_id:
      - light.dining_room_lights
    to: "off"
    id: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
        sequence:
          - service: light.turn_on
            data:
              brightness: "{{ state_attr('light.dining_room_lights', 'brightness') | int }}"
            target:
              entity_id: light.upstairs_hallway_lights
      - conditions:
          - condition: trigger
            id: "off"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.upstairs_hallway_lights
            data: {}
mode: restart
1 Like

Oops :grimacing: my bad

2 Likes

Amazing Guys, How do I mark this as Solved?

and how would one make this backwards compatible so the Dining room also listens to the hallway?

Ultimately, what I’m looking to do, and Ill make a separate post for it, is have all my pot lights upstairs brightness synced, and all listening to each other, but if I Quickly press the light on 3 times, it adds it to the sync group, and when I turn it off 3 times or something, if removes it… So I can add and remove from the lutron wall switch… :slight_smile:

It’s probably doable but I don’t know how these switches work.
I believe you would need one boolean per light to be “in or out of group”.
Then (I would do this way), use a history stats counter to count how many times the light has been switched in a short period.
Use this as a trigger to toggle the boolean.

Regarding syncing all lights, I believe we would have to loop through all lights you have, if boolean is on for this specific light, then set brightness.

This is not a simple automation, we would need to see a few of the entities (just list them) then perhaps we could help you out with this.
It’s always better to get real entity names both for you and us.

Next time, come with all your known requirements from the beginning, as that might drive to a different approach. :wink:

But let’s go… Try this:

description: ""
trigger:
  - id: "brightness"
    platform: state
    entity_id:
      - light.dining_room_lights
      - light.upstairs_hallway_lights
    attribute: brightness
  - id: "off"
    platform: state
    entity_id:
      - light.dining_room_lights
      - light.upstairs_hallway_lights
    to: "off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "brightness"
        sequence:
          - service: light.turn_on
            data:
              brightness: "{{ state_attr(trigger.entity_id, 'brightness') | int }}"
            target:
              entity_id: 
                - light.dining_room_lights
                - light.upstairs_hallway_lights
      - conditions:
          - condition: trigger
            id: "off"
        sequence:
          - service: light.turn_off
              entity_id: 
                - light.dining_room_lights
                - light.upstairs_hallway_lights
            data: {}
mode: restart

But again, creating a light group makes more sense in this case. You will have a new light entity that represents both lights, than any change to that new entity will apply to all the lights. No need for creating an automation for this.

In order to create a light group, go to Settings > Devices and Services, select the tab Helpers and then click on Create helper (bottom right), then select Group > Light group


Then give a name for your new light and select all the lights that should be part of that group:


And click Submit.

Now you can add this new light to your dashboards or automation, and everything you ask that light to do (turn on/off, change brightness, color, etc) will happen on both lights at the same time. And you can still control your lights individually using the original entities.

1 Like

I have shared my opinion about this on this other post: :wink: