Shared On/Off State
v0.01
Disclaimer:
This is my first attempt at writing a blueprint. Let me know if you have any feedback or edits I should make.
Description:
This automation shares the state of selected entities.
If you turn On/Off any entity in this group, either through software or physically, every other entity in this group will share the same state.
Example Usage:
- 3-way switch (or more!)
- Shared state On/Off groups
Shout Out
Special thanks to Petro for his comment from which I took heavy inspiration from.
I was trying to emulate a 3-way switch and couldn’t find any good examples until I stumbled upon his comment. I couldn’t find any blueprints that worked as well as him comment, so I created one. Thanks Petro!
blueprint:
name: Shared On/Off State
description: "# Shared On/Off State\n
**v0.01**\n\n
## Disclaimer:\n
This is my first attempt at writing a blueprint. Let me know if you have any feedback or edits I should make.\n
## Description:\n
This automation shares the state of selected entities.\n
If you turn On/Off any entity in this group, either through software or physically,
every other entity in this group will share the same state.\n
## Example Usage:\n
- 3-way switch (or more!)\n
- Shared state On/Off groups\n
## Shout Out\n
Special thanks to Petro for
[his comment](https://community.home-assistant.io/t/emulate-a-three-way-switch/167863/9)
from which I took heavy inspiration from. \n
I was trying to emulate a 3-way switch and couldn't find any good examples until I stumbled upon his comment.
I couldn't find any blueprints that worked as well as him comment, so I created one. Thanks Petro!\n
"
domain: automation
input:
switch_entities:
name: Select the On/Off entities you'd like to share state.
selector:
entity:
domain:
- switch
- fan
- light
multiple: true
mode: single
max_exceeded: silent
trigger:
platform: state
entity_id: !input switch_entities
from: &states
- "on"
- "off"
to: *states
variables:
entities: !input switch_entities
value: >
{{ trigger.to_state.state }}
targets: >
{{ expand(entities) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}
condition:
- condition: template
value_template: >
{{ targets not in ([], none) }}
action:
- service: homeassistant.turn_{{ value }}
target:
entity_id: "{{ targets }}"