Skip to content

Instantly share code, notes, and snippets.

@PilaScat
Last active March 3, 2026 12:54
Show Gist options
  • Select an option

  • Save PilaScat/311961355f3b16c7b3c983bc74803718 to your computer and use it in GitHub Desktop.

Select an option

Save PilaScat/311961355f3b16c7b3c983bc74803718 to your computer and use it in GitHub Desktop.
Bidirectional synchronization between one or more switches and one or more light entities.
blueprint:
name: Sync Switches and Lights
description: >
Bidirectional synchronization between one or more switches
and one or more light entities. When any switch or light
changes state, all the others automatically follow.
Protected against infinite loops.
domain: automation
input:
switch_entities:
name: Switches
description: Select one or more switches to synchronize
selector:
entity:
domain: switch
multiple: true
light_entities:
name: Lights
description: Select one or more lights to synchronize
selector:
entity:
domain: light
multiple: true
variables:
switches: !input switch_entities
lights: !input light_entities
mode: single
trigger:
- platform: state
entity_id: !input switch_entities
to: "on"
id: switch_on
- platform: state
entity_id: !input switch_entities
to: "off"
id: switch_off
- platform: state
entity_id: !input light_entities
to: "on"
id: light_on
- platform: state
entity_id: !input light_entities
to: "off"
id: light_off
action:
- choose:
# Switch turned ON → turn on all lights and other switches that are off
- conditions:
- condition: trigger
id: switch_on
sequence:
- service: light.turn_on
target:
entity_id: >
{{ lights | select('is_state', 'off') | list }}
- service: switch.turn_on
target:
entity_id: >
{{ switches
| reject('eq', trigger.entity_id)
| select('is_state', 'off')
| list }}
# Switch turned OFF → turn off all lights and other switches that are on
- conditions:
- condition: trigger
id: switch_off
sequence:
- service: light.turn_off
target:
entity_id: >
{{ lights | select('is_state', 'on') | list }}
- service: switch.turn_off
target:
entity_id: >
{{ switches
| reject('eq', trigger.entity_id)
| select('is_state', 'on')
| list }}
# Light turned ON → turn on all switches and other lights that are off
- conditions:
- condition: trigger
id: light_on
sequence:
- service: switch.turn_on
target:
entity_id: >
{{ switches | select('is_state', 'off') | list }}
- service: light.turn_on
target:
entity_id: >
{{ lights
| reject('eq', trigger.entity_id)
| select('is_state', 'off')
| list }}
# Light turned OFF → turn off all switches and other lights that are on
- conditions:
- condition: trigger
id: light_off
sequence:
- service: switch.turn_off
target:
entity_id: >
{{ switches | select('is_state', 'on') | list }}
- service: light.turn_off
target:
entity_id: >
{{ lights
| reject('eq', trigger.entity_id)
| select('is_state', 'on')
| list }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment