-
-
Save mateuszdrab/80e428305d17eba9de315b65ca72daa5 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: Inverted Link On/Off State of Multiple Devices | |
| description: | | |
| If one entity turns ON, all others turn OFF. | |
| If one entity turns OFF, all others turn ON. | |
| domain: automation | |
| homeassistant: | |
| min_version: 2022.5.0 | |
| input: | |
| linked_entities: | |
| name: Entities | |
| 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 in ['on','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_{{ 'off' if trigger.to_state.state == 'on' else 'on' }} | |
| target: | |
| entity_id: > | |
| {{ expand(linked_entities) | |
| | 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