Synchronize two dimmers

I have a wiz bulb and a Shelly gen3 WLAN 0-10V dimmer controlling fluorescent lamps.
I want to create an automation setting the brightness value of WIZ Lamp to the same value as the shelly-dimmer whenever the brightness of the Shelly dimmer changes.
After reading a ton of documentation I have still not fully understood the yaml syntax. How can a value be read from other entities?

This works to set the WIZ

- action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 20
    target:
      entity_id: light.wiz_rgbw_tunable_a9b4e8

The same works with the Shelly dimmer

- action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 5
    target:
      entity_id: light.dimmer_esszimmer_light_0```

I think the answers here are what you are looking for.

There also is a custom integration that does something similar, but while keeping relative difference intact:

Both entities are lights in your setup?
Did you convert the switches to lights using Helper?

If not…

Have you simply tried grouping them in a Helper?

It would depend on exactly how you’re interfacing with the lights. It could be as simple as creating a light group. But, if you’re allowing someone to manually change brightness of one light one via a physical switch or dial, and this must be a two-way sync, then it needs more effort.

Actually I want my family to be able to dim both lights just with the buttons wired to the shelly dimmer. And that is working now! Thanks guys.
Just grouping the lights doesn’t do that.

I used sed to replace the slashes in filepaths inside a shell-script, but the different braces and quotes in

brightness: "{{ state_attr(trigger.entity_id, 'brightness') | int }}"

just melt my brain. I would greatly appreciate a detailed dissection of that line.
And when to use 2 or 4 spaces indentation?
Significant whitspace or curly braces – YAML is combining the worst of both worlds.

Working Version of the automation.

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

You’re not alone in having trouble reading templates. I edited the original breakdown that I posted here out and I put a more complete breakdown in a community guide topic because I think it is useful for everyone. That topic is more up to date, so it is best to read it there. It is part of the Cookbook where you can find other topics you might be interested in or might like to contribute to.

3 Likes