Advanced control of any light entity from KNX (state, brightness, dim, temperature, color + states feedback)

Install

Click on this badge to import :

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Note: You can also find the blueprint code here KNX - Light entities control · GitHub

Main features

This is my first blueprint, it can be used to fully control a light entity from KNX telegrams, including state (on/off), brightness (as percentage or relative dimming), tunable white temperature (K°), and color (rgb).

The blueprint will also send state feedback to KNX for any change of those 4 parameters, and answer “GroupValueRead” telegrams for those states.

Prerequisites

Any light entity and a working KNX setup

Setup

Create a new automation based on this Blueprint, and fill the inputs with the “Group Address” that you want to use to control the light or to get its state feedback. Every input (= GA) is optional, except the light entity obviously.

If you intend to use the relative dimming commands, you will need to create an “Helper” entity which will act as a global variable since those are not (yet ?) supported in HA automations.
To do so, go to Settings → Devices & Services → Helpers → Create Helper → Toggle. Give it a name and Save. You will need to select this Helper entity when configuring the Blueprint.

There are 2 additional parameters for relative dimming which, when enabled, will prevent the light to turn off when dimming down (stays at minimum dimming when reached) and prevent the light to turn on when dimming up (if the light is currently off).

Changelog

2023-04-28 : Initial release
2023-04-28 : Fix for relative dimming
2023-05-12 : New parameter to prevent a light to switch off when it reaches the lowest dimm level
2023-05-25 : Fix Dim up stop telegram
2023-06-14 : New parameter to prevent a light to switch on when dimming up
2023-11-14 : New support for tunable white temperature (thanks to @macflei for sponsoring) + Bug fix for brightness and color state feedback caused by HA update
2024-01-02 : Bug fix when brightness or temperature became unavailable
2024-01-05 : Add support for “transition” + some code cleaning (thank you @turboPasqual )

Specials

Special thanks to farmio and his " KNX - relative dimming for lights" blueprint on which this version is based.

Enjoy :wink:

7 Likes

Great blueprint. Thanks.
Is it perhaps possible to expand the blueprint to include a function for Tuneable Withe (DPT 7.600)?

1 Like

Hello macflei, it should be possible to modify the blueprint for that without too much work, but I don’t own any light with tuneable white so it’s not easy for me to test that. I suggest that you have a look at the blueprint’s code and modify it, it should be very similar to the “brightness” parts.

Thanks for the feedback.
It’s actually not possible for me to adapt the code myself.
I hardly understand the connections in the code at all :slight_smile:
All I could do is sponsor a corresponding lamp.

PS: Unfortunately my English is not good. So I used Google Translator during the conversation :slight_smile:

Hi Kalhimeo,

First of thank you for the blueprint. It works very well. I used to make the connection KNX to HA/Shelly lights via Node-red and that also works very well but is more difficult to maintain.
Your blueprint makes it a lot easier.

I do have some questions or feature requests.
Would it be possible to specify a default brightness when turning on the lights. Now it turns on at the brightness when previously turned off.
Additional to this would it be possible to make this time dependent. Say Full brightness when turning on during the day and dimmed at night.
And finally that it can listen on a Central GA for turning off multiple lights at once.

Once again thank you.

Best regards,
Michiel

Hello Michiel,

Thanks for the nice feedback :slight_smile:

Regarding your feature requests, I am afraid that those are outside the scope of this blueprint and that it would be better to implement that with separate automations on HA side.

For the group thing, you can create a light group in HA and select that light entity in the blueprint instead of your individual Shelly, it will turn all lights in that group on or off with the knx group address that you specify.

PS : as a side note, I have updated the blueprint to support tunable white temperature and fix a bug with state feedback introduced by HA update

1 Like

Great blueprint. Exactly what I needed. Was looking for a way to solve light status logic in my KNX - home assistant setup. Used this blueprint to link home assistant group lights with a KNX group adress that has the same multiple light actuators (one per room, one per floor and all). This way home assistant handles the logic to determine the state of these light groups in KNX based on the states of the individual lights. Works great.

1 Like

Indeed a great blueprint.
Started to develop something myself, which was a stupid idea given the complexity that is solved by Laurent.
Thanks a lot for saving me hours and hours to get this to work.

1 Like

Hi kalhimeo.

First of all: Thank you very much for this really nice blueprint! It really works very well so far.

Nonetheless there is still one thing that I am trying to change: I would like to implement another way of relative dimming in case the lights support transition. First of all I think the built in transition from a light is much smoother than a step by step transition with this automation. Second: My lights have a default transition of 1 second. When I stop relative dimming, they would still change brightness for 1 second after I had stopped, which feels weird.

Long story short: I think I can implement the change myself and I would share the result here. But right now I am struggling with one part of your code:
(From Line 404 onwards):

                        sequence:
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity
                          - repeat:
                              while:
                                - condition: state
                                  entity_id: !input dimm_entity
                                  state: "off"
                                - condition: template
                                  value_template: "{{ repeat.index <= dimm_steps }}"
                              sequence:
                                - service: light.turn_on
                                  data_template:
                                    brightness_step: "{{ dimm_step }}"
                                    entity_id: "{{ light_entity }}"
                                - delay:
                                    milliseconds: "{{ dimm_delay }}"
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity

Why do you call service: input_boolean.turn_off after the repeat sequence? I would think you need to call service: input_boolean.turn_on instead. Or am I wrong? (The same in line 464).
I already changed it for a local test but could not see any different behaviour.

Can you help me out with this.

Hi, I am happy that you enjoy my blueprint :slight_smile:

I am not sure that I understand the transition question, but if you are looking for a faster or slower way to dimm the light you have to play with the dimm time / dimm steps settings. The transition setting of your light may be the time it takes to go from one dimm value to another (using a direct dimming value).

Regarding the code, the first thing to know is that the automation runs in parallel mode, which means that when it receives a dimm up or down command, it will repeat it until it receives a stop command from a parallel triggering. The purpose of the dimm_entity (=helper) is to catch this stop command and interrupt the dimming sequence.
At the beginning of the the dimm sequence, the dimm_entity is off. The repeat sequence executes until the dimm_entity is changed to on (by the parallel execution of the stop command). When the repeat is over, it changes back the dimm_entity to off to be reset it and be ready for the next dimm command.

So the conclusion is that the service: input_boolean.turn_on is correct :slight_smile:

Hi again.

Thank you for your explanation. That makes totally sense now!

Regarding the transition time: That was not a question. More like an opener why I try to understand your code. So don’t worry about that.
But to let you know: I can use a transition time for my lights and they always have a default transition time of 1 second (if not stated otherwise). That means it takes 1 second to go from old state to new state. At the moment I assume this is normal behaviour for lights that support transition… With this in mind I would like to change the relative dimming behaviour if lights are cappable of “transition”. I am actually working on that and will let you know the outcome.

Hi again.

I think I have finally implemented the “transition” for my lights. It was quite a journey and at the end I threw a lot overboard and changed just very few things.
While I implemented my changes I found a few things, that I would do differently (better?). Here is the list what I have changed:

  • In some places you used “data_template” in your code. I have read that it is deprecated for a few years now and have changed it to “data” and “target”.
  • For relative dimming you use the variable “dimm_steps” and repeat the dimming sequence until dimming get’s stopped or dimm_steps get reached. In case the light is already e.g. at 50% you just need half of your dimm_steps. So I added the variable “current_dimm_steps” for that.
  • To calculate the “current_dimm_steps” I added the helper variable “initial_brightness”. It is not really necessary but makes the code more readable.
  • For relative dimming I added transition: "{{ dimm_delay / 1000 }}" to the service: light.turn_on. I am pretty sure that this won’t cause any problems even when the light does not support this but I cannot be 100% sure. It would be possible to query the light with e.g. a variable: transition_supported: "{{ ((states[light_entity].attributes.supported_features|bitwise_and(32)) == 32) | bool(default=false) }}". But honestly I don’t think this is necessary.

The question is now: Do you want to update your code with my changes? Shall I upload my code to my github? Shall I fork your code (I have no experience with this)? I am unsure how we deal with this but I am fine with every solution.

Anyway here is finally the full code (I think my Visual Studio Code automatically has changed some formatting):

blueprint:
  name: KNX - Light entities control
  description:
    Use KNX to control an Home Assistant light entity with optional switching,
    relative dimming, absolute dimming, tunable white, and RGB color telegrams (+
    state feedback)
  author: kalhimeo
  domain: automation
  input:
    light_entity:
      name: Light Entity
      description: "Choose the light to control and expose with KNX

        "
      selector:
        entity:
          domain:
            - light
          multiple: false
    dimm_entity:
      name: Helper for relative dimming function
      description:
        "If you intend to use the relative dimming function, it is necessary
        to manually create a 'toggle helper' specificly for this light (don't change
        if unused)

        "
      selector:
        entity:
          domain:
            - input_boolean
          multiple: false
      default: {}
    switch_address:
      name: Switch group address
      description:
        "Group address for switching the lights on and off. DPT 1.001 Example:
        '1/0/1' (leave empty if unused)

        "
      default: ""
    dimm_address:
      name: Relative dimming group address
      description:
        "Group address for relative dimming the lights (+/-). DPT 3.007
        Example: '1/1/1' (leave empty if unused)

        "
      default: ""
    value_address:
      name: Absolute dimming group address
      description:
        "Group address for absolute dimming of the light (0-100%). DPT
        5.001 Example: '1/2/1' (leave empty if unused)

        "
      default: ""
    rgb_color_address:
      name: RGB color group address
      description:
        "Group address for RGB color of the light (r,g,b). DPT 232.600
        Example: '1/3/1' (leave empty if unused)

        "
      default: ""
    temperature_address:
      name: Tunable white temperature group address
      description:
        "Group address for white temperature of the light (0-100%). DPT
        7.600 Example: '1/7/1' (leave empty if unused)

        "
      default: ""
    switch_state_address:
      name: Switch state group address
      description:
        "Group address to send feedback of the state of the light. DPT
        1.001 Example: '1/4/1' (leave empty if unused)

        "
      default: ""
    value_state_address:
      name: Brightness state group address
      description:
        "Group address to send feedback of the brightess of the light.
        DPT 5.001 Example: '1/5/1' (leave empty if unused)

        "
      default: ""
    rgb_color_state_address:
      name: RGB color state group address
      description:
        "Group address to send feedback of the RGB color of the light.
        DPT 232.600 Example: '1/6/1' (leave empty if unused)

        "
      default: ""
    temperature_state_address:
      name: Tunable white temperature state group address
      description:
        "Group address to send feedback of the white temperature of the
        light. DPT 7.600 Example: '1/7/1' (leave empty if unused)

        "
      default: ""
    dimm_time:
      name: Dimm time
      description: Time dimming from 0 to 100% shall take.
      selector:
        number:
          min: 1.0
          max: 20.0
          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.0
          max: 100.0
          step: 1.0
          unit_of_measurement: steps
          mode: slider
      default: 20
    dimm_no_off:
      name: Disable switch off with dimm down command
      description:
        If enabled, the dimm down command won't cause the light to switch
        off when reaching 0% (keep the light at minimum dimm)
      selector:
        boolean: {}
      default: false
    dimm_no_on:
      name: Disable switch on with dimm up command
      description:
        If enabled, the dimm up command won't cause the light to switch
        on (if it's actual state is off)
      selector:
        boolean: {}
      default: false
  source_url: https://gist.github.com/kalhimeo/88f6e38b45aa872961cc7b748eacef3d
mode: parallel
max_exceeded: silent
variables:
  light_entity: !input light_entity
  dimm_entity: !input dimm_entity
  switch_address: !input switch_address
  dimm_address: !input dimm_address
  value_address: !input value_address
  temperature_address: !input temperature_address
  rgb_color_address: !input rgb_color_address
  switch_state_address: !input switch_state_address
  value_state_address: !input value_state_address
  temperature_state_address: !input temperature_state_address
  rgb_color_state_address: !input rgb_color_state_address
  _dimm_time: !input dimm_time
  _dimm_steps: !input dimm_steps
  dimm_no_off: !input dimm_no_off
  dimm_no_on: !input dimm_no_on
  dimm_time: "{{ _dimm_time | float(default=4) }}"
  dimm_steps: "{{ _dimm_steps | int(default=20) }}"
  dimm_step: "{{ (255 / dimm_steps) | round(0,'ceil') }}"
  dimm_delay: "{{ dimm_time * 1000 / dimm_steps }}"
  initial_brightness: "{{ (state_attr(light_entity, 'brightness') | int(default=0)) }}"
trigger:
  - platform: homeassistant
    event: start
    id: initialize
  - platform: event
    event_type: automation_reloaded
    id: initialize
  - platform: event
    event_type: service_registered
    event_data:
      domain: knx
      service: event_register
    id: initialize
  - platform: state
    entity_id: !input light_entity
    id: light_entity
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input switch_address
      telegramtype: GroupValueWrite
      direction: Incoming
    id: switch_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input dimm_address
      telegramtype: GroupValueWrite
      direction: Incoming
    id: dimm_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input value_address
      telegramtype: GroupValueWrite
      direction: Incoming
    id: value_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input temperature_address
      telegramtype: GroupValueWrite
      direction: Incoming
    id: temperature_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input rgb_color_address
      telegramtype: GroupValueWrite
      direction: Incoming
    id: rgb_color_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input switch_state_address
      telegramtype: GroupValueRead
      direction: Incoming
    id: switch_state_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input value_state_address
      telegramtype: GroupValueRead
      direction: Incoming
    id: value_state_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input temperature_state_address
      telegramtype: GroupValueRead
      direction: Incoming
    id: temperature_state_address
  - platform: event
    event_type: knx_event
    event_data:
      destination: !input rgb_color_state_address
      telegramtype: GroupValueRead
      direction: Incoming
    id: rgb_color_state_address
action:
  - choose:
      - conditions:
          - condition: trigger
            id: initialize
        sequence:
          - if:
              - condition: template
                value_template: "{{ switch_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ switch_address }}"
          - if:
              - condition: template
                value_template: "{{ switch_state_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ switch_state_address }}"
          - if:
              - condition: template
                value_template: "{{ dimm_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ dimm_address }}"
          - if:
              - condition: template
                value_template: "{{ value_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ value_address }}"
                  type: percent
          - if:
              - condition: template
                value_template: "{{ value_state_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ value_state_address }}"
                  type: percent
          - if:
              - condition: template
                value_template: "{{ temperature_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ temperature_address }}"
                  type: color_temperature
          - if:
              - condition: template
                value_template: "{{ temperature_state_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ temperature_state_address }}"
                  type: color_temperature
          - if:
              - condition: template
                value_template: "{{ rgb_color_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ rgb_color_address }}"
          - if:
              - condition: template
                value_template: "{{ rgb_color_state_address != '' }}"
            then:
              - service: knx.event_register
                data:
                  address: "{{ rgb_color_state_address }}"
      - conditions:
          condition: template
          value_template:
            "{{ trigger is defined and trigger.platform == 'event' and
            trigger.event.event_type == 'knx_event' and trigger.event.data.direction
            == 'Incoming' and trigger.event.data.destination != '' }}"
        sequence:
          - choose:
              - conditions:
                  - condition: trigger
                    id: switch_address
                  - condition: template
                    value_template: "{{ switch_address != '' }}"
                sequence:
                  - choose:
                      - conditions:
                          - condition: template
                            value_template: "{{ trigger.event.data.data | int(default=0) == 0 }}"
                        sequence:
                          - service: light.turn_off
                            target:
                              entity_id: "{{ light_entity }}"
                      - conditions:
                          - condition: template
                            value_template: "{{ trigger.event.data.data | int(default=0) == 1 }}"
                        sequence:
                          - service: light.turn_on
                            target:
                              entity_id: "{{ light_entity }}"
              - conditions:
                  - condition: trigger
                    id: switch_state_address
                  - condition: template
                    value_template: "{{ switch_state_address != '' }}"
                sequence:
                  - if:
                      - condition: or
                        conditions:
                          - condition: state
                            entity_id: !input light_entity
                            state: "off"
                          - condition: state
                            entity_id: !input light_entity
                            state: unavailable
                          - condition: state
                            entity_id: !input light_entity
                            state: unknown
                    then:
                      - service: knx.send
                        data:
                          address: "{{ switch_state_address }}"
                          payload: 0
                          response: true
                    else:
                      - service: knx.send
                        data:
                          address: "{{ switch_state_address }}"
                          payload: 1
                          response: true
              - conditions:
                  - condition: trigger
                    id: dimm_address
                  - condition: template
                    value_template: "{{ dimm_address != '' }}"
                  - condition: template
                    value_template: "{{ not not dimm_entity }}"
                sequence:
                  - choose:
                      - conditions:
                          - condition: template
                            value_template:
                              "{{ trigger.event.data.data == 0  or trigger.event.data.data
                              == 8 }}"
                        sequence:
                          - service: input_boolean.turn_on
                            data: {}
                            target:
                              entity_id: !input dimm_entity
                      - conditions:
                          - condition: template
                            value_template: "{{ 9 <= trigger.event.data.data <= 15 }}"
                          - condition: template
                            value_template:
                              "{{ not dimm_no_on or states(light_entity) != 'off'
                              }}"
                        sequence:
                          - variables:
                              current_dimm_steps: "{{ ((255 - initial_brightness) / 255 * dimm_steps) | round(0, 'ceil') | int }}"
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity
                          - repeat:
                              while:
                                - condition: state
                                  entity_id: !input dimm_entity
                                  state: "off"
                                - condition: template
                                  value_template: "{{ repeat.index <= current_dimm_steps }}"
                              sequence:
                                - service: light.turn_on
                                  data:
                                    brightness_step: "{{ dimm_step }}"
                                    transition: "{{ dimm_delay / 1000 }}"
                                  target:
                                    entity_id: "{{ light_entity }}"
                                - delay:
                                    milliseconds: "{{ dimm_delay }}"
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity
                      - conditions:
                          - condition: template
                            value_template: "{{ 1 <= trigger.event.data.data <= 7 }}"
                        sequence:
                          - variables:
                              current_dimm_steps: "{% if dimm_no_off %}{{ (([(initial_brightness - 1), 0] | max) / 255 * dimm_steps) | round(0, 'ceil') | int }}{% else %}{{ (initial_brightness / 255 * dimm_steps) | round(0, 'ceil') | int }}{% endif %}"
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity
                          - repeat:
                              while:
                                - condition: state
                                  entity_id: !input dimm_entity
                                  state: "off"
                                - condition: template
                                  value_template: "{{ repeat.index <= current_dimm_steps }}"
                                - condition: template
                                  value_template:
                                    "{{ not dimm_no_off or state_attr(light_entity,
                                    'brightness') | int(default=255) != 1 }}"
                              sequence:
                                - if:
                                    - condition: template
                                      value_template:
                                        "{{ dimm_no_off and (state_attr(light_entity,
                                        'brightness') | int(default=255) - dimm_step) < 1 }}"
                                  then:
                                    - service: light.turn_on
                                      data:
                                        brightness: 1
                                        transition: "{{ dimm_delay / 1000 }}"
                                      target:
                                        entity_id: "{{ light_entity }}"
                                  else:
                                    - service: light.turn_on
                                      data:
                                        brightness_step: "{{ -dimm_step }}"
                                        transition: "{{ dimm_delay / 1000 }}"
                                      target:
                                        entity_id: "{{ light_entity }}"
                                    - delay:
                                        milliseconds: "{{ dimm_delay }}"
                          - service: input_boolean.turn_off
                            data: {}
                            target:
                              entity_id: !input dimm_entity
              - conditions:
                  - condition: trigger
                    id: value_address
                  - condition: template
                    value_template: "{{ value_address != '' }}"
                sequence:
                  - choose:
                      - conditions:
                          - condition: template
                            value_template:
                              "{{ trigger.event.data.data[0] | int(default=0) == 0
                              }}"
                        sequence:
                          - service: light.turn_off
                            target:
                              entity_id: "{{ light_entity }}"
                      - conditions:
                          - condition: template
                            value_template:
                              "{{ trigger.event.data.data[0] | int(default=0) != 0
                              }}"
                        sequence:
                          - service: light.turn_on
                            data:
                              brightness: "{{ trigger.event.data.data[0] | int(default=255) }}"
                            target:
                              entity_id: "{{ light_entity }}"
              - conditions:
                  - condition: trigger
                    id: value_state_address
                  - condition: template
                    value_template: "{{ value_state_address != '' }}"
                sequence:
                  - service: knx.send
                    data:
                      address: "{{ value_state_address }}"
                      payload:
                        - "{{ state_attr(light_entity, 'brightness') | int(default=0) }}"
                      response: true
              - conditions:
                  - condition: trigger
                    id: temperature_address
                  - condition: template
                    value_template: "{{ temperature_address != '' }}"
                sequence:
                  - choose:
                      - conditions:
                          - condition: template
                            value_template:
                              "{{ trigger.event.data.value | int(default=3000) !=
                              0 }}"
                        sequence:
                          - service: light.turn_on
                            data:
                              kelvin: "{{ trigger.event.data.value | int(default=3000) }}"
                            target:
                              entity_id: "{{ light_entity }}"
              - conditions:
                  - condition: trigger
                    id: temperature_state_address
                  - condition: template
                    value_template: "{{ temperature_state_address != '' }}"
                sequence:
                  - service: knx.send
                    data:
                      address: "{{ temperature_state_address }}"
                      type: color_temperature
                      payload:
                        "{{ state_attr(light_entity, 'color_temp_kelvin') | int(default=0)
                        }}"
                      response: true
              - conditions:
                  - condition: trigger
                    id: rgb_color_address
                  - condition: template
                    value_template: "{{ rgb_color_address != '' }}"
                sequence:
                  - service: light.turn_on
                    data:
                      rgb_color:
                        - "{{ trigger.event.data.data[0] | int(default=0) }}"
                        - "{{ trigger.event.data.data[1] | int(default=0) }}"
                        - "{{ trigger.event.data.data[2] | int(default=0) }}"
                    target:
                      entity_id: "{{ light_entity }}"
              - conditions:
                  - condition: trigger
                    id: rgb_color_state_address
                  - condition: template
                    value_template: "{{ rgb_color_state_address != '' }}"
                sequence:
                  - if:
                      - condition: template
                        value_template:
                          "{{ state_attr(light_entity, 'rgb_color')[0] is defined
                          and state_attr(light_entity, 'rgb_color')[1] is defined and state_attr(light_entity,
                          'rgb_color')[2] is defined }}"
                    then:
                      - service: knx.send
                        data:
                          address: "{{ rgb_color_state_address }}"
                          payload:
                            - "{{ state_attr(light_entity, 'rgb_color')[0] | int(default=0) }}"
                            - "{{ state_attr(light_entity, 'rgb_color')[1] | int(default=0) }}"
                            - "{{ state_attr(light_entity, 'rgb_color')[2] | int(default=0) }}"
                          response: true
                    else:
                      - service: knx.send
                        data:
                          address: "{{ rgb_color_state_address }}"
                          payload:
                            - 0
                            - 0
                            - 0
                          response: true
      - conditions:
          - condition: trigger
            id: light_entity
          - condition: template
            value_template: "{{ light_entity != '' }}"
        sequence:
          - if:
              - condition: template
                value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"
              - condition: template
                value_template: "{{ switch_state_address != '' }}"
            then:
              - choose:
                  - conditions:
                      condition: template
                      value_template: "{{ trigger.to_state.state == 'off' }}"
                    sequence:
                      - service: knx.send
                        data:
                          address: "{{ switch_state_address }}"
                          payload: 0
                  - conditions:
                      condition: template
                      value_template: "{{ trigger.to_state.state == 'on' }}"
                    sequence:
                      - service: knx.send
                        data:
                          address: "{{ switch_state_address }}"
                          payload: 1
          - if:
              - condition: template
                value_template: "{{ value_state_address != '' }}"
              - condition: or
                conditions:
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.brightness is defined and
                      trigger.from_state.attributes.brightness is defined and trigger.to_state.attributes.brightness
                      != trigger.from_state.attributes.brightness }}"
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.brightness is defined and
                      trigger.from_state.attributes.brightness is not defined }}"
                  - condition: template
                    value_template:
                      "{{ trigger.from_state.attributes.brightness is defined
                      and trigger.to_state.attributes.brightness is not defined }}"
            then:
              - service: knx.send
                data:
                  address: "{{ value_state_address }}"
                  payload:
                    - "{{ trigger.to_state.attributes.brightness | int(default=0) }}"
          - if:
              - condition: template
                value_template: "{{ temperature_state_address != '' }}"
              - condition: or
                conditions:
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.color_temp_kelvin is defined
                      and trigger.from_state.attributes.color_temp_kelvin is defined and trigger.to_state.attributes.color_temp_kelvin
                      != trigger.from_state.attributes.color_temp_kelvin }}"
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.color_temp_kelvin is defined
                      and trigger.from_state.attributes.color_temp_kelvin is not defined }}"
                  - condition: template
                    value_template:
                      "{{ trigger.from_state.attributes.color_temp_kelvin is defined
                      and trigger.to_state.attributes.color_temp_kelvin is not defined }}"
            then:
              - service: knx.send
                data:
                  address: "{{ temperature_state_address }}"
                  type: color_temperature
                  payload:
                    "{{ trigger.to_state.attributes.color_temp_kelvin | int(default=0)
                    }}"
          - if:
              - condition: template
                value_template: "{{ rgb_color_state_address != '' }}"
              - condition: or
                conditions:
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.rgb_color is defined and
                      trigger.from_state.attributes.rgb_color is defined and trigger.to_state.attributes.rgb_color
                      != trigger.from_state.attributes.rgb_color }}"
                  - condition: template
                    value_template:
                      "{{ trigger.to_state.attributes.rgb_color is defined and
                      trigger.from_state.attributes.rgb_color is not defined }}"
                  - condition: template
                    value_template:
                      "{{ trigger.from_state.attributes.rgb_color is defined and
                      trigger.to_state.attributes.rgb_color is not defined }}"
            then:
              if:
                - condition: template
                  value_template:
                    "{{ trigger.to_state.attributes.rgb_color[0] is defined
                    and trigger.to_state.attributes.rgb_color[1] is defined and trigger.to_state.attributes.rgb_color[2]
                    is defined }}"
              then:
                - service: knx.send
                  data:
                    address: "{{ rgb_color_state_address }}"
                    payload:
                      - "{{ trigger.to_state.attributes.rgb_color[0] | int(default=0) }}"
                      - "{{ trigger.to_state.attributes.rgb_color[1] | int(default=0) }}"
                      - "{{ trigger.to_state.attributes.rgb_color[2] | int(default=0) }}"
              else:
                - service: knx.send
                  data:
                    address: "{{ rgb_color_state_address }}"
                    payload:
                      - 0
                      - 0
                      - 0

thank you very much for sharing your code. There are indeed good improvements there.

Since my code is hosted in a “secret” git (to make it more simple) I don’t think that it’s possible to fork it in the “official” way. But if you agree I could include your changes in my blueprint repo when I have a few minutes to go through and revie everything ?

Of course I agree. Feel free to take either the full code or just some parts of it. I am happy with everything :slight_smile:

1 Like

Thanks, I updated my code with your changes, I think that I did not forget anything. Do not hesitate to report if you find any bug :slight_smile:

1 Like

Hi @kalhimeo,
thanks for your great work! It would be very nice if you can add support for HSV input values (beside RGB) :slight_smile: I got a “MDT Glastaster 2” KNX device which only sends HSV values.

Can i use this Blueprint with Datatype: 251.600 ?

Hello,

thanks for sharing this Integration!

Unfortunately, I do not quite understand, what it gives compared to the “stock” KNX-Integration, which can also “ully control a light entity from KNX telegrams, including state (on/off), brightness (as percentage or relative dimming), tunable white temperature (K°), and color (rgb)”, no?

Greetings,
Hendrik

This is meant to control non-Knx lights from eg. knx push buttons. It’s not meant to control knx-lights as the system can do that anyway.

Hi,
I’ve connected my KNX project file to HA
But I just don’t know how to get a dimmable card on my dashboard. I’m not so familar with the KNX Adresses.

So far I’ve managed to create a knx.yaml file as follows and it does turn On/Off
the light.

light:

  • name : “keuken”
    address: “1/1/10”

state_address: “1/1/10”

Then I’ve tried to use this blueprint but with no luck as I don’t really know where to put the KNX addresses

Maybe somebody could provide me a yaml code based upon my KNX structure from the picture.

Sorry for these dumb or silly questions.