-
-
Save dbrand666/b731672b2a282b9afd51a97e6e5c2b2b to your computer and use it in GitHub Desktop.
| blueprint: | |
| name: Link On/Off State of Multiple Devices | |
| description: "## Link On/Off State of Multiple Devices v1.0.3 | |
| 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. | |
| You can select any entity, but only entities supported by the | |
| `homeassistant.turn_on` or `homeassistant.turn_off` service calls | |
| will work. | |
| ### Requirements | |
| * All selected entities MUST suport `homeassistant.turn_on` and | |
| `homeassistant.turn_off` or errors will be logged and the blueprint | |
| will not work. | |
| * Requires Home Assistant 2022.5.0 or newer. | |
| ### Credits | |
| * [@adchevrier](https://community.home-assistant.io/u/adchevrier) for the | |
| [initial blueprint](https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010) | |
| * [@hebus](https://community.home-assistant.io/u/hebus) for | |
| [this fantastic template](https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010/38)" | |
| domain: automation | |
| homeassistant: | |
| min_version: 2022.5.0 | |
| input: | |
| linked_entities: | |
| name: Entities to link | |
| selector: | |
| entity: | |
| multiple: true | |
| mode: restart | |
| max_exceeded: silent | |
| variables: | |
| linked_entities: !input "linked_entities" | |
| triggers: | |
| - trigger: state | |
| entity_id: !input "linked_entities" | |
| condition: | |
| - condition: template | |
| value_template: > | |
| {{ | |
| trigger.to_state.state != trigger.from_state.state | |
| }} | |
| - condition: template | |
| value_template: > | |
| {{ | |
| (trigger.to_state.state == "on") or | |
| (trigger.to_state.state == "off") | |
| }} | |
| - condition: template | |
| value_template: > | |
| {{ | |
| 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) | |
| }} | |
| actions: | |
| - action: homeassistant.turn_{{ trigger.to_state.state }} | |
| target: | |
| entity_id: > | |
| {{ | |
| expand(linked_entities) | | |
| selectattr("entity_id", "!=", trigger.entity_id) | | |
| map(attribute="entity_id") | | |
| list | |
| }} |
I have the same issue as rubenhak above, I just came to discuss it and then saw his message. I have two lights, A and B. If they both start off and I flip the A switch, A comes on then B 1/2 a second later. If I flip A back off, B goes off. However if I flip A on, they both go on, then I flip B off, B goes off but A stays on. Let me try it with a longer delay to see if that works (I was testing so flipping things quite fast).
The switches in this case are sonoff devices, physical switches. I don't know if A is staying on or going off then on rapidly. I think from looking at the logs (which are not trivial to understand) that A is staying on as it fails the test to switch it off.
In my case I only have two switches I care about, so I may use a simpler recipe which is explicit on 2 switches.
Exactly the same happens to me. I hope they can fix it
This simple task turns out to be quite problematic.
I'm linking two basic Tapo switches using this blueprint. It works, slowly (multi-second delay much of the time), and sometimes it fails to turn on the second light altogether. This is the error I'm getting in that case:
Stopped because an error was encountered at June 17, 2025 at 8:58:01 PM (runtime: 9.54 seconds)
Unable to communicate with the device async_turn_on: ('Unable to query the device: 192.168.68.91: ', TimeoutError())
This task works perfectly and fast when implemented via the Tapo app.
I have the same issue as rubenhak above, I just came to discuss it and then saw his message. I have two lights, A and B. If they both start off and I flip the A switch, A comes on then B 1/2 a second later. If I flip A back off, B goes off.
However if I flip A on, they both go on, then I flip B off, B goes off but A stays on. Let me try it with a longer delay to see if that works (I was testing so flipping things quite fast).
The switches in this case are sonoff devices, physical switches. I don't know if A is staying on or going off then on rapidly. I think from looking at the logs (which are not trivial to understand) that A is staying on as it fails the test to switch it off.
In my case I only have two switches I care about, so I may use a simpler recipe which is explicit on 2 switches.