Forked from jmaroeder/link_multiple_devices.yaml
Last active
September 29, 2025 07:50
-
-
Save Santanachia/8523f6f16c619e646495383b91a3ef7e 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Link State of Multiple Devices | |
| description: | | |
| ## Link On/Off/Brightness/Color Temp of Multiple Devices v1.1.2 | |
| Select multiple entities to link their on/off, brightness and color temperature. If any selected entity is turned on or off, or its brightness/color temp. is adjusted, 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) | |
| * [@dbrand666](https://github.com/dbrand666) for [various fixes](https://gist.github.com/dbrand666/b731672b2a282b9afd51a97e6e5c2b2b) | |
| * [@jmaroeder](http://github.com/jmaroeder) for [adding brightness](https://gist.github.com/jmaroeder/c0952533a3f2c746eef83db268ddbbba) | |
| domain: automation | |
| homeassistant: | |
| min_version: 2022.5.0 | |
| input: | |
| linked_entities: | |
| name: Entities to link | |
| selector: | |
| entity: | |
| multiple: true | |
| transition: | |
| name: Transition | |
| selector: | |
| number: | |
| min: 0 | |
| max: 3600 | |
| unit_of_measurement: seconds | |
| default: 0 | |
| mode: restart | |
| max_exceeded: silent | |
| variables: | |
| linked_entities: !input linked_entities | |
| transition: !input transition | |
| trigger: | |
| - platform: state | |
| entity_id: !input linked_entities | |
| - platform: state | |
| entity_id: !input linked_entities | |
| attribute: brightness | |
| condition: | |
| - condition: template | |
| value_template: > | |
| {{ trigger.to_state.state != trigger.from_state.state or | |
| (trigger.to_state.attributes.brightness is defined and | |
| trigger.to_state.attributes.brightness != trigger.from_state.attributes.brightness) or | |
| (trigger.to_state.attributes.color_temp is defined and | |
| trigger.to_state.attributes.color_temp != trigger.from_state.attributes.color_temp) }} | |
| - 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 }}' | |
| data: > | |
| {% if trigger.to_state.state == "on" %} | |
| { | |
| {% if trigger.to_state.attributes.brightness is defined -%} | |
| "brightness": {{ trigger.to_state.attributes.brightness }}, | |
| {%- endif %} | |
| {% if trigger.to_state.attributes.color_temp is defined -%} | |
| "color_temp": {{ trigger.to_state.attributes.color_temp }}, | |
| {%- endif %} | |
| "transition": {{ transition }} | |
| } | |
| {% else %} | |
| {} | |
| {% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment