Knx.telegram - usage in automation

Hi,

I try to set a helper variable to on or off with an automation, when a KNX datagram arrives:
The Automation trigger is working fine, but the conditions never match.
Could anyone explain why - the documentation about knx.telegram isn’t helpful for me at this point?

alias: "KNX event: Data condition test"
description: Test automation for receiving knx events with data condition
trigger:
  - platform: knx.telegram
    destination: 5/1/10
    group_value_read: false
    outgoing: false
    alias: knx.telegram on 5/1/10
condition: []
action:
  - choose:
      - conditions:
          - condition: template
            value_template: telegram.value == 0
        sequence:
          - data: {}
            target:
              entity_id: input_boolean.on_holidays
            action: input_boolean.turn_on
      - conditions:
          - condition: template
            value_template: telegram.value == 1
        sequence:
          - data: {}
            target:
              entity_id: input_boolean.on_holidays
            action: input_boolean.turn_off
    enabled: true
mode: single

Hi :wave:!
Templates have to go into "{{ }}".
So it’s

value_template: "{{ trigger.value == 0 }}"

I think the telegram.* things in the docs are actually a doc-bug - it should be trigger.*.
You can see that when you trigger the trigger manually (from ETS or a button) and then klick the blue/yellow bar at the top.
See Home Assistant - KNX: trigger actions from a KNX switch

1 Like

Thank you! It is working fine now.
I did a second mistake: Use of the “value” trigger variable instead of “payload”.
The “value” variable is always “null”

Not when you uploaded your project file :wink:

Be aware that .payload contains a list for DPT other than 1,2,3. So eg. a percent value can be accessed trigger.payload[0] == 255 which is equivalent to trigger.value == 100 using project data.

1 Like

Thank you.
I uploaded an updated ETS Project file to HA, now.
Value is still “null”.

Maybe the DPT isn’t supported, it isn’t set in the project or the GA isn’t included at all.

Strange - i suppose that is a simple DPT 1?

That only you can answer.
If it is DPT 1 you would be on the safe side if you used HA 2024.8.2 - value would be a string then. But using .payload for DPT 1 is perfectly fine (and independent of project file changes).

1 Like

Well, I found it.
These kind of groups had DPT “automatic” assigned in ETS. After setting this to DPT 1 and a reupload of the project file to HA, it is working fine. :smile:

1 Like