Last active
January 4, 2024 11:45
-
-
Save aschamberger/aa23a4dbc17068649dfde2bb628b9d9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: KNX - control of Zigbee lights | |
description: Control Home Assistant Zigbee Light entities from KNX. | |
domain: automation | |
input: | |
target_light: | |
name: Light | |
description: The light that shall be controled. | |
selector: | |
entity: | |
domain: light | |
switch_address: | |
name: Switch group address. | |
description: > | |
Group address for switching the lights on and off (DPT 1) | |
Example: '1/1/1' | |
dimm_address: | |
name: Relative dimming address. | |
description: > | |
Group address for dimming the lights (DPT 3.007). | |
Example: '1/2/1' | |
dimm_address_absolute: | |
name: Absolute dimming address | |
description: > | |
Group address for absolute dimming the lights (DPT 5.001). | |
Example: '1/3/1' | |
switch_state_address: | |
name: Switch state group address | |
description: > | |
Group address for lights state (DPT 1). | |
Example: '1/4/1' | |
dimm_state_address: | |
name: Dimming state address. | |
description: > | |
Group address for absolute dimming the lights (DPT 5.001). | |
Example: '1/5/1' | |
color_temp_state_address: | |
name: Color temp state address. | |
description: > | |
Group address for color temp state (DPT 7.600). | |
Example: '1/6/1' | |
color_temp_address: | |
name: Color temp address. | |
description: > | |
Group address for setting color temp (DPT 7.600). | |
Example: '1/7/1' | |
dimm_time: | |
name: Dimm time | |
description: Time dimming from 0 to 100% shall take. | |
selector: | |
number: | |
min: 1 | |
max: 20 | |
step: 0.1 | |
unit_of_measurement: seconds | |
mode: slider | |
default: 4 | |
dimm_steps: | |
name: Dimm steps | |
description: Steps used to dimm from 0 to 100%. | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
step: 1 | |
unit_of_measurement: steps | |
mode: slider | |
default: 20 | |
default_brightness: | |
name: Default brightness | |
description: Brightness for light on. | |
selector: | |
number: | |
min: 1 | |
max: 100 | |
step: 1 | |
unit_of_measurement: "%" | |
mode: slider | |
default: 75 | |
default_color_temp: | |
name: Default color temp | |
description: Color temperature for light on. | |
selector: | |
number: | |
min: 2000 | |
max: 7500 | |
step: 1 | |
unit_of_measurement: "K" | |
mode: box | |
default: 3000 | |
source_url: https://gist.github.com/aschamberger/aa23a4dbc17068649dfde2bb628b9d9b | |
# no matched condition stops repeat sequence to stop dimming (dimm 0) | |
mode: restart | |
max_exceeded: silent | |
variables: | |
_dimm_time: !input dimm_time | |
_dimm_steps: !input dimm_steps | |
dimm_time: "{{ _dimm_time|float }}" | |
dimm_steps: "{{ _dimm_steps|int }}" | |
dimm_step: "{{ (255 / dimm_steps) | round(0, 'ceil') }}" | |
dimm_delay: "{{ dimm_time * 1000 / dimm_steps }}" | |
trigger: | |
- platform: homeassistant | |
event: start | |
id: "initialize" | |
- platform: event | |
event_type: automation_reloaded | |
id: "initialize" | |
# when KNX integration was reloaded | |
- platform: event | |
event_type: service_registered | |
event_data: | |
domain: knx | |
service: event_register | |
id: "initialize" | |
- platform: event | |
event_type: knx_event | |
event_data: | |
destination: !input 'switch_address' | |
telegramtype: GroupValueWrite | |
id: "switch" | |
- platform: event | |
event_type: knx_event | |
event_data: | |
destination: !input 'dimm_address' | |
telegramtype: GroupValueWrite | |
id: "dimm" | |
- platform: event | |
event_type: knx_event | |
event_data: | |
destination: !input 'dimm_address_absolute' | |
telegramtype: GroupValueWrite | |
id: "dimm_absolute" | |
- platform: event | |
event_type: knx_event | |
event_data: | |
destination: !input 'color_temp_address' | |
telegramtype: GroupValueWrite | |
id: "color_temp" | |
action: | |
- choose: | |
# TURN ON | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "switch" | |
- "{{ trigger.event.data.data == 1 }}" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input 'target_light' | |
data: | |
color_temp_kelvin: !input 'default_color_temp' | |
brightness_pct: !input 'default_brightness' | |
# TURN OFF | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "switch" | |
- "{{ trigger.event.data.data == 0 }}" | |
sequence: | |
- service: light.turn_off | |
entity_id: !input 'target_light' | |
# DIMM UP | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "dimm" | |
- "{{ 9 <= trigger.event.data.data <= 15 }}" | |
sequence: | |
- repeat: | |
count: '{{ dimm_steps }}' | |
sequence: | |
- service: light.turn_on | |
entity_id: !input 'target_light' | |
data: | |
brightness_step: '{{ dimm_step }}' | |
- delay: | |
milliseconds: '{{ dimm_delay }}' | |
# DIMM DOWN | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "dimm" | |
- "{{ 1 <= trigger.event.data.data <= 7 }}" | |
sequence: | |
- repeat: | |
count: '{{ dimm_steps }}' | |
sequence: | |
- service: light.turn_on | |
entity_id: !input 'target_light' | |
data: | |
brightness_step: '{{ -dimm_step }}' | |
- delay: | |
milliseconds: '{{ dimm_delay }}' | |
# DIMM ABSOLUTE | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "dimm_absolute" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input 'target_light' | |
data: | |
brightness_pct: '{{ trigger.event.data.value }}' | |
# SET COLOR TEMP | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "color_temp" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input 'target_light' | |
data: | |
color_temp_kelvin: '{{ trigger.event.data.value | int(default=3000) }}' | |
# INITIALIZE | |
- conditions: | |
condition: trigger | |
id: "initialize" | |
sequence: | |
- service: knx.event_register | |
data: | |
address: !input 'switch_address' | |
- service: knx.event_register | |
data: | |
address: !input 'dimm_address' | |
- service: knx.event_register | |
data: | |
address: !input 'dimm_address_absolute' | |
type: "percent" | |
- service: knx.event_register | |
data: | |
address: !input 'color_temp_address' | |
type: "color_temperature" | |
- service: knx.exposure_register | |
data: | |
address: !input 'switch_state_address' | |
entity_id: !input 'target_light' | |
type: binary | |
default: false | |
- service: knx.exposure_register | |
data: | |
address: !input 'dimm_state_address' | |
entity_id: !input 'target_light' | |
attribute: brightness | |
type: percentU8 | |
default: 0 | |
- service: knx.exposure_register | |
data: | |
address: !input 'color_temp_state_address' | |
entity_id: !input 'target_light' | |
attribute: color_temp_kelvin | |
type: color_temperature | |
default: 3000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment