-
-
Save ryansch/5fb70645e9017263bf0614cfbd74a0c9 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Link Multiple Switches v1.0.1
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 Multiple Switches | |
description: | | |
## Link multiple switches together v1.0.1 | |
Select multiple switch entities to link their on/off state. If any selected switch entity is turned on or off, the other selected entities will be sent a matching on or off command. | |
Requires Home Assistant 2022.5.0 or newer. | |
Credit to @adchevrier for the initial blueprint: https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities/259010 | |
Credit to @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: | |
switches: | |
name: Switch Entites | |
selector: | |
entity: | |
domain: switch | |
multiple: true | |
source_url: https://gist.github.com/aderusha/4f25658dbb855675b5b5ccf296fd801b | |
mode: queued | |
max_exceeded: silent | |
variables: | |
switches: !input 'switches' | |
trigger: | |
- platform: state | |
entity_id: !input 'switches' | |
to: | |
- 'off' | |
- 'on' | |
condition: | |
- condition: template | |
value_template: '{{ trigger.to_state.state != trigger.from_state.state }}' | |
- condition: template | |
value_template: '{{ trigger.to_state.state != "unknown" }}' | |
- 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(switches) | selectattr("entity_id", "!=", trigger.entity_id) | map(attribute="entity_id") | list }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment