Skip to content

Instantly share code, notes, and snippets.

@igorsantos07
Created September 27, 2025 01:49
Show Gist options
  • Save igorsantos07/af6c56633ca19a13cd2d881b3ee21760 to your computer and use it in GitHub Desktop.
Save igorsantos07/af6c56633ca19a13cd2d881b3ee21760 to your computer and use it in GitHub Desktop.
[Home Assistant] Allows configuration of up to six shared switches at once, so you can group all the three/multi-way devices you have in the same room in a single automation.
blueprint:
name: Multiple multi-way switches
domain: automation
description: |
Allows configuration of up to six shared switches at once, so you can group all the three/multi-way devices you have in the same room in a single automation.
**All groups besides the first one are optional.**
> _Shout out to TopsyKrets, who published a [single-switch version of this blueprint](https://community.home-assistant.io/t/shared-on-off-state-entities-3-way-switch/580684?u=igorsantos07) back in 2023!_
input:
switch_entities1: &input
name: 1st group of entities that will share state
selector: &selector
entity:
domain:
- switch
- fan
- light
multiple: true
switch_entities2: &optional_input
<<: *input
name: The 2nd group of entities that will share state
default: []
description: Optional
switch_entities3:
<<: *optional_input
name: The 3rd group of entities that will share state
switch_entities4:
<<: *optional_input
name: The 4th group of entities that will share state
switch_entities5:
<<: *optional_input
name: The 5th group of entities that will share state
switch_entities6:
<<: *optional_input
name: The 6th group of entities that will share state
mode: single
max_exceeded: silent
triggers:
- &trigger
id: "1"
alias: Group 1
platform: state
entity_id: !input switch_entities1
from: &states
- "on"
- "off"
to: *states
- <<: *trigger
id: "2"
alias: Group 2
entity_id: !input switch_entities2
- <<: *trigger
id: "3"
alias: Group 3
entity_id: !input switch_entities3
- <<: *trigger
id: "4"
alias: Group 4
entity_id: !input switch_entities4
- <<: *trigger
id: "5"
alias: Group 5
entity_id: !input switch_entities5
- <<: *trigger
id: "6"
alias: Group 6
entity_id: !input switch_entities6
variables:
value: "{{ trigger.to_state.state }}"
entities1: !input switch_entities1
entities2: !input switch_entities2
entities3: !input switch_entities3
entities4: !input switch_entities4
entities5: !input switch_entities5
entities6: !input switch_entities6
targets1: "{{ expand(entities1) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
targets2: "{{ expand(entities2) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
targets3: "{{ expand(entities3) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
targets4: "{{ expand(entities4) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
targets5: "{{ expand(entities5) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
targets6: "{{ expand(entities6) | rejectattr('entity_id','eq', trigger.entity_id) | selectattr('state','!=', value) | map(attribute='entity_id') | list }}"
actions:
- choose:
- conditions:
- condition: trigger
id:
- "1"
- condition: template
value_template: >
{{ targets1 not in ([], none) }}
sequence:
- &service
service: homeassistant.turn_{{ value }}
target:
entity_id: "{{ targets1 }}"
- conditions:
- condition: trigger
id:
- "2"
- condition: template
value_template: >
{{ targets2 not in ([], none) }}
sequence:
- <<: *service
target:
entity_id: "{{ targets2 }}"
- conditions:
- condition: trigger
id:
- "3"
- condition: template
value_template: >
{{ targets3 not in ([], none) }}
sequence:
- <<: *service
target:
entity_id: "{{ targets3 }}"
- conditions:
- condition: trigger
id:
- "4"
- condition: template
value_template: >
{{ targets4 not in ([], none) }}
sequence:
- <<: *service
target:
entity_id: "{{ targets4 }}"
- conditions:
- condition: trigger
id:
- "5"
- condition: template
value_template: >
{{ targets5 not in ([], none) }}
sequence:
- <<: *service
target:
entity_id: "{{ targets5 }}"
- conditions:
- condition: trigger
id:
- "6"
- condition: template
value_template: >
{{ targets6 not in ([], none) }}
sequence:
- <<: *service
target:
entity_id: "{{ targets6 }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment