[SOLVED] KNX - Switch payload

Hi everyone,
I am relatively new to HA and just connected an existing KNX system which has a very limited number of devices (rollershutter and the ventilation system).

I would like to connect the ventilation system first assuming it’s the easiest one.
Monitoring ON/OFF triggered from a KNX wall switch shows:

So I created a switch in my knx.yaml:

switch:
  - name: "Lüftung"
    address: "3/0/7"

This sends obviously true / false which does not trigger the ventilation system.
I also tried a template in my switches.yaml:

# KNX Test
- platform: template
  switches:
    luftung_knx:
      friendly_name: "Lüftung (KNX)"
#      value_template: "{{ is_state('lights_living', 'on') }}"
      turn_on:
        service: knx.send
        data:
          address: "3/0/7"
          payload: ["1"]
      turn_off:
        service: knx.send
        data:
          address: "3/0/7"
          payload: ["0"]

(I also tried payload: ["0"] and payload: ["1"] repectively.
Both result in:

I assume there is an easy way to do it, but I am stuck.
Unfortunately payload is not an allowed variable in the generic KNX switch.

Any suggestion would be greatly appreciated

EDIT:

I found out that a button works to activate the ventilation system:

button:
    - name: "KNX Lüftungs-Test (Button)"
      address: "3/0/7"
      payload: 1
      payload_length: 0

The magic part is the length 0 (1 Bit).
However this s not accepted by the switch type in KNX. :frowning:

Hi :wave:!

This is exactly what a switch entity sends when turning it “on”.

This however sends a 1byte payload with value 1.
payload: 1 would send DPT 1 style (1 bit) - so just a number, not a list.

I can’t say why the switch didn’t work for you, but your button solution should send exactly the same. If you try the switch again, have a look at the group monitor to see what is going on.

Edit: have seen your monitor picture above. There are telegrams coming from 0.1.2 - not Shute what device this is, but it’s possible that the individual addresses you are using there might cause problems (unless this a KnxIP device), or you need to account for filter tables in your couplers.

Thank you for your help!

This is what I tried initially: a regular switch:

switch:
  - name: "Lüftung"
    address: "3/0/7"

but this does not send a bit (0 / 1), but 0x00 / 0x01

Without this the button obviously defaults to a length of 1 - which I assume is the same default for the switch.
So I guess, I would need this parameter for the switch, which is not available yet.

Yes, this is a wall switch I have used to find out the ventilation’s address.

I am connected to the KNX IP interface (0.1.255)

A regular knx switch can’t send these (0x01 - 1byte) payloads. Your template switch using knx.send on the other hand would do exactly that.

Default payload length of a button is 0 - see documentation.
There is no option to send anything but a 1-bit payload with a switch.

You mean 0x00 and 0x01 respectively?

If this is wrong (sending a 0x01) how to modify the template switch to send a 0 / 1 only?

turn_on:
        service: knx.send
        data:
          address: "3/0/7"
          payload: ["1"]

sorry, I am not getting it,

Exactly. I edited the post above to make that clearer.

Just use a regular switch - like your first example:


If you want to do it via a template for other reasons see

In yaml [] marks a list. So payload: [0] is a list with 1 item with value 0.
whereas payload: 0 is just the number 0
A plain number is sent as 1bit payload (in knx payloads up to 6bit are encoded differently, therefore we need to distinguish).

This is what I did in the beginning, but just get true / false (vs. 0/1):

EDIT:
You are right - thank you so much.
True / false is accepted and switches the ventilation.
Somehow, this was not the case in the beginning (possibly still wrong adress).

Thank you very much for pointing me in the right direction! :slight_smile:

1 Like

That’s the same. It shows true or false instead of the raw payload when you have provided a knxproj file and the GA is defined DPT 1 there.

1 Like