-
-
Save farmio/bc23cc2a1a81408751947309408ff164 to your computer and use it in GitHub Desktop.
blueprint: | |
name: KNX - relative dimming for lights | |
description: Controll Home Assistant Light entities from KNX switching and relative dimming (DPT 3.007) telegrams. | |
domain: automation | |
input: | |
target_lights: | |
name: Light | |
description: The lights that shall be controled. | |
selector: | |
target: | |
entity: | |
domain: light | |
switch_address: | |
name: Switch group address | |
description: > | |
Group address for switching the lights on and off. DPT 1 | |
Example: '1/2/3' | |
dimm_address: | |
name: Relative dimming address | |
description: > | |
Group address for dimming the lights. DPT 3.007 | |
Example: '1/2/4' | |
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: 2 | |
max: 100 | |
step: 1 | |
unit_of_measurement: steps | |
mode: slider | |
default: 20 | |
# 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" | |
action: | |
- choose: | |
# TURN ON | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "switch" | |
- "{{ trigger.event.data.data == 1 }}" | |
sequence: | |
- service: light.turn_on | |
target: !input target_lights | |
# TURN OFF | |
- conditions: | |
condition: and | |
conditions: | |
- condition: trigger | |
id: "switch" | |
- "{{ trigger.event.data.data == 0 }}" | |
sequence: | |
- service: light.turn_off | |
target: !input target_lights | |
# 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 | |
target: !input target_lights | |
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 | |
target: !input target_lights | |
data: | |
brightness_step: '{{ -dimm_step }}' | |
- delay: | |
milliseconds: '{{ dimm_delay }}' | |
# 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 |
Great job, it works for entities! If I have to replace a hue light bulb, the automation must be updated with the new entity. I suppose it's because the entity_list is used... would it be possible to add a "device_list" or "area_list" too? If an area is used, a new hue bulp must only be set to the correct room (in the hue app) no update of the automation is needed.
@kruzgix Hi!
Im not very familiar with either devices nor areas (don't have either of them in my installation), but for this blueprint to work the targets have to be of domain light
which I think wouldn't work with an area.
If you had to replace a physical device you can then just assign it the entity_id of the old light so all previous automations stay intact.
Another way could be to use a light_group
which, afaik behaves like a light entity.
@kruzgix Hi 👋!
Areas should work properly now.
The blueprint also keeps working when the KNX integration was reloaded.
Hi, it works well, but how does it work with the state adress?
I don't get that.
Or do you need to expose it seperatly?
Thanks in advance.
@Reteip10 right, use expose
. This blueprint only has one-way communication.
Or fork the blueprint and add it 😉
What about controlling color_temp for tunable white bulbs? Did you happen to implement it before?
I guess it would work the same way as brightness - so you may just fork it and add the options you need for your installation.
hm, but color_temp only accepts mirads as input, not steps. I think we need to convert it somehow.
Depends on the actuator, I guess. The ones I know support DPT 3 color temp dimming, just like brightness.
And HA supports Kelvin too, so no need to deal with Mireds afaic.
Yeah, kelvin should be fine for Phillips Finance white
Updated for accepting different step codes. Step codes are not evaluated, only control bit.