Skip to content

Instantly share code, notes, and snippets.

@aderusha
Created September 12, 2022 21:19
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save aderusha/4d2c8600a2e4771b91b8efc555946413 to your computer and use it in GitHub Desktop.
Save aderusha/4d2c8600a2e4771b91b8efc555946413 to your computer and use it in GitHub Desktop.
Select multiple entities to link their on/off state. If any selected entity is turned on or off, the other selected entities will be sent a matching on or off command.
@PramodAryalGithub
Copy link

Thank you for sharing. However there is a bug. If you link up 2 devices and operate On/OFF on one device and switch to other, it might take a couple of tries to sync again.

@dbrand666
Copy link

@aderusha You may be interested in my tiny change that seems to fix the infinite on/off cycling if an on and off are received too close together. https://gist.github.com/dbrand666/b731672b2a282b9afd51a97e6e5c2b2b

@IvanNik
Copy link

IvanNik commented Nov 15, 2022

I've also seen infinite cycling with sonoff linked switches. Thanks @dbrand666

@Renji-FR
Copy link

@dbrand666 Your tiny change is about the mode? from queue to restart correct?

How is it possible to get a infinite loop on/off with this security '{{trigger.to_state.context.parent_id is none or (trigger.to_state.context.id != this.context.id and trigger.to_state.context.parent_id != this.context.id) }}' ?

@dbrand666
Copy link

I did an analysis here:
https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010/81?u=dbrand666
I think I went a little overboard - assuming there are multiple controllers. In HA, there's only one queue we really need to worry about.

@RhavoX
Copy link

RhavoX commented Apr 1, 2024

There is a bug in this blueprint. If you turn lights on and off in quick succession they desynchronize sometimes and keep turning on and off... Fast... This could wear out the switches if this happens randomly or at night where you might not notice. I guess some small delays could be introduced to double check the state?

@RhavoX
Copy link

RhavoX commented Apr 1, 2024

After some tweaking it seems that the mode is the issue for me. Changing this to restart fixed the issue. Perhaps some improvements could be made here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment