Skip to content

Instantly share code, notes, and snippets.

@sotatech
Last active August 18, 2025 10:08
Show Gist options
  • Select an option

  • Save sotatech/3bac2f378b95b1f8fcf5d7188a12d348 to your computer and use it in GitHub Desktop.

Select an option

Save sotatech/3bac2f378b95b1f8fcf5d7188a12d348 to your computer and use it in GitHub Desktop.
KNX Light Sync Blueprint
blueprint:
name: KNX Central Light Sync
description: >
Sync one or more Home Assistant lights with KNX central group addresses
(on/off, relative dimming, absolute dimming).
Bi-directional: reacts to KNX commands and reports state back to KNX.
Loop-safe with small debounce.
domain: automation
input:
lights:
name: Lights
description: One or more HA light entities to sync with KNX
selector:
entity:
domain: light
multiple: true
ga_switch:
name: KNX On/Off GA
description: Group address for central On/Off (DPT 1.001)
selector:
text:
ga_dimming:
name: KNX Relative Dimming GA
description: Group address for relative dimming (DPT 3.007)
selector:
text:
ga_brightness:
name: KNX Absolute Brightness GA
description: Group address for absolute brightness (DPT 5.001)
selector:
text:
step_size:
name: Step size (% per KNX step)
description: Percent change per KNX relative dimming step (default 10)
default: 10
selector:
number:
min: 1
max: 50
unit_of_measurement: "%"
mode: slider
mode: restart
trigger:
# KNX → HA events
- platform: event
event_type: knx_event
event_data:
destination: !input ga_switch
- platform: event
event_type: knx_event
event_data:
destination: !input ga_dimming
- platform: event
event_type: knx_event
event_data:
destination: !input ga_brightness
# HA → KNX (light state change)
- platform: state
entity_id: !input lights
for: "00:00:01" # debounce to avoid loop
action:
- choose:
# ---- KNX → HA ----
# On/Off
- conditions:
- condition: template
value_template: "{{ trigger.platform == 'event' and trigger.event.data.destination == (ga_switch | string) }}"
sequence:
- choose:
- conditions: "{{ trigger.event.data.data == 1 }}"
sequence:
- service: light.turn_on
target:
entity_id: !input lights
- conditions: "{{ trigger.event.data.data == 0 }}"
sequence:
- service: light.turn_off
target:
entity_id: !input lights
# Relative dimming
- conditions:
- condition: template
value_template: "{{ trigger.platform == 'event' and trigger.event.data.destination == (ga_dimming | string) }}"
sequence:
- variables:
direction: "{{ (trigger.event.data.data | int | bitwise_and(8)) // 8 }}" # 0=down, 1=up
step: "{{ trigger.event.data.data | int | bitwise_and(7) }}" # 1-7
pct_step: "{{ step * (step_size | int) * (1 if direction == 1 else -1) }}"
- service: light.turn_on
target:
entity_id: !input lights
data:
brightness_step_pct: "{{ pct_step }}"
# Absolute brightness
- conditions:
- condition: template
value_template: "{{ trigger.platform == 'event' and trigger.event.data.destination == (ga_brightness | string) }}"
sequence:
- service: light.turn_on
target:
entity_id: !input lights
data:
brightness_pct: "{{ trigger.event.data.data }}"
# ---- HA → KNX ----
- conditions:
- condition: template
value_template: "{{ trigger.platform == 'state' and trigger.to_state.context.parent_id is none }}"
sequence:
# Report On/Off
- service: knx.send
data:
address: !input ga_switch
payload: "{{ 1 if trigger.to_state.state == 'on' else 0 }}"
# Report Brightness
- choose:
- conditions: "{{ trigger.to_state.state == 'on' and trigger.to_state.attributes.brightness is defined }}"
sequence:
- service: knx.send
data:
address: !input ga_brightness
payload: "{{ (trigger.to_state.attributes.brightness / 255 * 100) | round(0) }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment