Skip to content

Instantly share code, notes, and snippets.

@charlieoleary
Last active January 1, 2026 00:24
Show Gist options
  • Select an option

  • Save charlieoleary/33d838f067a74eb323cfc020cf2c20ec to your computer and use it in GitHub Desktop.

Select an option

Save charlieoleary/33d838f067a74eb323cfc020cf2c20ec to your computer and use it in GitHub Desktop.
Hue Sync Blueprint
blueprint:
name: Sync Switch and Hue / Smart Bulb States
description: >
When you're using smart switches in combination with Hue bulbs (or other smart
bulbs), this blueprint keeps the states synchronized to avoid having incorrect
information in either app.
domain: automation
input:
switch_entity:
name: Switch Entity
selector:
entity:
domain: switch
light_entity:
name: Light Entity
selector:
entity:
domain: light
light_debounce_seconds:
name: Debounce Light Changes (seconds)
description: >
Set this to 1 or 2 if you notice a flicker when turning the lights on or off.
default: 1
selector:
number:
min: 0
max: 10
mode: slider
step: 1
mode: single
trigger:
- platform: state
entity_id: !input switch_entity
to:
- "on"
- "off"
- platform: state
entity_id: !input light_entity
to:
- "on"
- "off"
for:
seconds: !input light_debounce_seconds
variables:
switch_entity: !input switch_entity
light_entity: !input light_entity
desired: "{{ trigger.to_state.state }}"
action:
- condition: template
value_template: "{{ desired in ['on','off'] }}"
- choose:
# Switch changed, update light if needed
- conditions:
- condition: template
value_template: "{{ trigger.entity_id == switch_entity and states(light_entity) != desired }}"
sequence:
- service: "{{ 'light.turn_on' if desired == 'on' else 'light.turn_off' }}"
target:
entity_id: "{{ light_entity }}"
# Light changed, update switch if needed
- conditions:
- condition: template
value_template: "{{ trigger.entity_id == light_entity and states(switch_entity) != desired }}"
sequence:
- service: "{{ 'switch.turn_on' if desired == 'on' else 'switch.turn_off' }}"
target:
entity_id: "{{ switch_entity }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment