-
-
Save aderusha/4d2c8600a2e4771b91b8efc555946413 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.0 | |
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: queued | |
max_exceeded: silent | |
variables: | |
linked_entities: !input 'linked_entities' | |
trigger: | |
- platform: 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) }}' | |
action: | |
- service: homeassistant.turn_{{ trigger.to_state.state }} | |
target: | |
entity_id: '{{ expand(linked_entities) | selectattr("entity_id", "!=", trigger.entity_id) | map(attribute="entity_id") | list }}' |
When iam using this automation getting this error from
The automation "Link Staircase Light Switches" (automation.link_staircase_down_up_l1_light_switches) has an action that calls an unknown service: homeassistant.turn_unavailable.
This error prevents the automation from running correctly. Maybe this service is no longer available, or perhaps a typo caused it.
HA version 2024.5.4
I have an idea/feature request. One of the lights that I sync using this blueprint is connected to a conventional wall switch. When I turn off the switch, the light goes to Unavailable status.
It would be great if there were a selection option in the setup for the blueprint to set the behavior if one of the synced objects goes unavailable. I'm thinking three options:
- Turn all off
- Turn all on
- Do nothing
I'd give it a try myself but I'm not familiar enough with blueprints to be confident with it.
Hi, I'm trying out this blueprint. It works most of the times. Testing out with two switches. The failure scenario:
- Manually turn on Light 1
- Light 2 turns on
- Within 3 seconds turn off Light 2
- Light 1 stays turns on.
- HA dashboard always reflects the correct state.
NOTE: If I wait longer then the automations would work.
How can I debug this?
I noticed the same behavior with a very similar automation that uses mode: restart
mode.
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?