Transmit a scene number by triggering an knx button

Hello,
I recently started integrating my smart home into home assistant. However, now I have encountered a problem.
How do I get a scene number transmitted in HA when I trigger a scene on a KNX button?

Currently my knx.yaml looks like this:

  scene:
  #Gute Nacht
    - name: "Gute_Nacht"
      address: "8/0/1"
      scene_number: 1
  #Guten Morgen
    - name: "Guten_Morgen"
      address: "8/0/1"
      scene_number: 2
  #gemütlich  
    - name: "gemütlich"
      address: "8/0/1"
      scene_number: 3
  #gemütlich_reset
    - name: "gemütlich_reset"
      address: "8/0/1"
      scene_number: 4

  event:
    - address:
      - "8/0/1"
      type: "scene_number"

and my automation:

alias: "Event: Szene vom KNX Bus"
trigger:
  - platform: event
    event_type: knx_event
    event_data:
      destination: 8/0/1
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 1 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.gute_nacht
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 2 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.guten_morgen
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 3 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.gemutlich
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 4 }}"
        sequence:
          - service: switch.turn_on
            target:
              entity_id: scene.gemutlich_reset
            metadata: {}
            data: {}
mode: restart

According to traces the automation is also triggered, but ends with:

Ausgeführt: 23. Januar 2024 um 09:29:26
Ergebnis:

params:
  domain: switch
  service: turn_on
  service_data: {}
  target:
    entity_id:
      - scene.gemutlich_reset
running_script: false

Can someone help me with this?

Best regards,
Tobias

Hi :wave:!

Where exactly is the issue? It looks like the action you configured was called.

Have you maybe tried to use scene.turn_on here instead of switch.turn_on here?

Oh, my mistake. In the meantime I tried switch.turn_on instead of scene.turn_on. now that I use scene.turn_on again, the automation runs every second.

is there a knx telegram triggering the event every second?

Yes:

But now, I think I found my mistake.

I added the direction: Incoming to the automation and now it seems to work.

alias: "Event: Szene vom KNX Bus"
description: ""
trigger:
  - platform: event
    event_type: knx_event
    event_data:
      destination: 8/0/1
      direction: Incoming
action:
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 1 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.gute_nacht
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 2 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.guten_morgen
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 3 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.gemutlich
            metadata: {}
      - conditions:
          - condition: template
            value_template: "{{ trigger.event.data.value == 4 }}"
        sequence:
          - service: scene.turn_on
            target:
              entity_id: scene.gemutlich_reset
            metadata: {}
            data: {}
mode: restart

Ah, with your telegram you are triggering the scene - which sends a telegram when activated.
So now with “Incoming” you are still duplicating the telegram, instead of endless-looping.

HA scenes created by the Knx integration are awkward. Maybe send Knx scene numbers via a button entity instead and use native HA scenes from your automation.