Linked Entities - keep mutlple entities state in sync (lights, switches, etc.)

Thanks for the advise, I think I may have found something but I´m not sure if it´s related to the issue. Going back to the previous execution that actually triggered the sync I realised the execution has a 4 seconds delay (roughly the same time I took between switching both switches):

Is it possible that the first automation is still running when I switch the second switch instead of triggering a new automation, and that´s the reason it fails to sync?

That would do it.

I also have the issue that only one switch acts as a master. If I add a second switch (even on the same plate) it is controlled by the first switch as expected, but operating switch 2 does not have any effect on switch 1.
Other than that, this is the only blueprint I’ve found that doesn’t make the lights go crazy when a switch is operated twice in quick succession!

Jason, in my house I have 14 Sonoff TX3 switches (3 buttons) configured with many combinations. I created this because I wanted to control several lights from different switches (from different rooms).

There’s no master switch concept in this automation: any entity’s state in the same group modifies the state of the other entities of the group.

I’m running a lot of these automations using this for lights, but also switches, valves, etc.

Do some debugging with automation trace to understand what happens when switch 2 triggers, there must be a reason why it doesn’t proceed with the relevant actions.

As a test I swapped out the ZTB23 switch for a standard Zemismart unit, and they work perfectly.
My guess is that the ZTB23 has some weird command support. I know they only work with Z2MQ, and not ZHA, but I have no idea how to debug that!
Thanks for the response, as it made me chase the issue in hardware :slight_smile:

1 Like

Everything works great as far as syncing the lights statuses and adjusting/ syncing brightness.

The automation is however putting none and none for user and parent ID, which doesn’t allow me to disable an automation based on physical button push.

I’ve tried so many things to make it work but I’m at a loss. Anyone have any suggestions?

Log below at any time light comes on via motion detection, mmWave, or physical button.

state of light liv id: 01JAJTEVQ7JPQEB1B8TQD9EH68 parent_id: None user_id: None triggered by automation Disable Breakfast triggered by state of Breakfast

Matrix’s I am working from:

I don’t think the automation is responsible of determining those, it’s HA. Maybe @jsenecal could help clearing this out.

Hi @alexdelprete
Same problem here. My two switches are in a small room. When I turn on the first one, I have to wait 4 or 5 seconds to turn off the light via the second switch. If I try to turn off the second switch before that time, they get out of sync.
I don’t understand what is causing this delay. My switches use the Tuya Local integration and the blueprint is set to a 200ms delay.

Same effect maybe, not the same problem. Like I told heisenberg, use automation trace log to see what’s happening, and try to debug where the delay happens. I’m pretty confident tuya stuff plays a role in that.

Hi the blueprint is not working for me. i get this error in the TraqceLog: expected int for dictionary value @ data[‘brightness’]
I try to link a Tasmota Switch with a Zigbee Relay. Both Are changed via the internal System from Switch to Light and dont have a brightness regulation

I have a ceiling fan (localtuya integrated) with two associated wall dimmers (smartthings integrated) - one intended for the light and one intended for the fan speed.

I set up one instance of this blueprint that works great for associating the light and its switch!

But then the fan speed and other switch doesnt seem to function. I am guessing this is because Im trying to intermingle brightness and speed in that the values are in different scales ? i.e. brightness is 0-255 and the fan speed is 0-100. would there be a way to add some kind of conversion for values? or is there something else im missing? the trace log doesnt seem to say anything is wrong, but the entities dont update. trace log says this, it doesnt seem like its actually executing anything?

Triggered by the state of fan.main_bedroom_fan at August 6, 2025 at 4:10:52 PM

Test If template renders a value equal to true

Choose: Option 3 executed

Finished at August 6, 2025 at 4:10:52 PM (runtime: 0.23 seconds)

I figured it out after some trial and error - it was two fold issues, namely the brightness attribute only pulled the 0-255 instead of brightness pct 0-100, and then the set fan speed function only calls the set % service instead of the light service, so it wasnt properly calling the light object to react. So for future compatibility I just added the brightness callout and the fan speed callout to each ‘choice’ so it executes on each process, and then did some calculations to make the 255 range apply. Im guessing there could be an option somewhere to select what range an object uses to provide for conversion variables

Here is the snippet of the code I got working
(Note on some of the math, the rounding is due to the fan only working in increments of 10%, the actual calculations could probably be streamlined somewhere).

> - conditions:
>     - condition: trigger
>       id: set_speed
>     sequence:
>     - variables:
>         set_fan_speed: '{{ trigger.to_state.attributes.percentage }}'
>     - service: fan.set_percentage
>       data:
>         entity_id: '{{linked_entities | reject(''eq'', trigger.entity_id) | list }}'
>         percentage: '{{ ((set_fan_speed/10) | round(0))*10 }}'
>     - service: light.turn_on
>       data:
>         entity_id: '{{linked_entities | reject(''eq'', trigger.entity_id) | list }}'
>         brightness_pct: '{{ ((set_fan_speed/10) | round(0))*10 }}'
>     - delay:
>         milliseconds: !input delay_miliseconds
>   - conditions:
>     - condition: trigger
>       id: set_brightness
>     sequence:
>     - variables:
>         set_light_brightness: '{{ (trigger.to_state.attributes.brightness)/255 *100 }}'
>         set_fan_speed: '{{ (trigger.to_state.attributes.brightness)/255 *100 }}'
>     - service: light.turn_on
>       data:
>         entity_id: '{{linked_entities | reject(''eq'', trigger.entity_id) | list }}'
>         brightness_pct: '{{ ((set_light_brightness/10) | round(0))*10 }}'
>     - service: fan.set_percentage
>       data:
>         entity_id: '{{linked_entities | reject(''eq'', trigger.entity_id) | list }}'
>         percentage: '{{ ((set_fan_speed/10) | round(0))*10 }}'
>     - delay:
>         milliseconds: !input delay_miliseconds

@alexdelprete it would be really functional if this blueprint could use Helper Groups as the source of the entities… then we could leverage the value of groups as they are pretty useless since they do not (except on/off) sync natively.

@alexdelprete This blueprint is superb, thank you. I’d love to be able to sync thermostats… could support for this entity type be added in future?

Works like a champ except it does not keep color in sync. Any way of doing that?

In my case is working except by a problematic issue. I don’t know if it’s something related with Z2M or what is the problem, but works until you change the actuator of the automatization.
Example:

  • I have two switches
  • I power on the 1st switch and the 2nd powers on at the same time.
  • I power off the 1st switch and the 2nd powers off too.
  • Until here everything is right, but now if I go to the 2nd switch and I power it on, the 1st one ignores the order.
  • If I repeat the cicle in the 2nd switch (off and on again) then it start working and responding to the 2nd switch.
  • Now it works all the time without any issue but the issue was migrated to the 1st switch, and is solved in the same way doing the complete cycle again.

The order doesn’t cares, just the action of to use another switch. Every time you use a different switch you have to do it twice make it work. It doesn’t cares how much times you use the same switch, it always works, but once you change the swith it fails the first time. Later will work until you change the switch again and again… Looks like It’s not happening all the time, or at least on a second try on my dinning room was working, but a second and third try on my kitchen didn’t. In both cases the links were done between a light and a switch.
I am pretty sure that is not my HASS or my Z2M installations, because a manual automatization that I did to do the same is working as expected in any case.

Best regards.

Hey, I really like this blueprint and I used it to sync my new Philips Hue Play light bars. You get 2 in the box, and they are individually controlled, but I wanted to set them up as a single light in the living room. The blueprint did most everything, but it didn’t control the RGB changes of the lights. To update that, I simply copied set_light_color_temp and changed it to set_light_color, like so:

- conditions:
    - condition: trigger
      id: set_color
  sequence:
    - variables:
        set_light_color: "{{ trigger.to_state.attributes.rgb_color }}"
    - data:
        entity_id: "{{linked_entities | reject('eq', trigger.entity_id) | list }}"
        rgb_color: "{{ set_light_color }}"
      action: light.turn_on
    - delay:
        milliseconds: 0

Works great so far!

Hi @alexdelprete,

Thank you for the awesome and simple blueprint. Saved me some time and I learned few things.

I am trying to sync the rgb color from a led bulb to a waveshare device that has a display. I am using Lvgl LED to display the state of the LED bulb. I tried updating your script but it still does not work. I have a forked version of your blueprint. Can you please help me understand why rgb updates are not reflecting in other entities ?

Thanks
Satish

I was able to correct the variable attribute (from rgb to rgb_color). That fixed the problem.