KNX Cookbook

Is there a workaround to assign areas to knx devices?

Hey together, thank you very much for this cookbook, this helped me a lot understanding KNX and HA. However, there is one thing I cannot get to work and that is to use a KNX scene as a trigger for an automation.
In ETS, I created a switch, which simply sends scene number 64 to the bus.
In knx.yaml I added:

- name: Scene_Testszene_64
      state_address: '10/1/241'
      type: scene_number

The scene number appears correctly in HA:

Then I would like to use the scene as a trigger for an automation. In the following, to make it easy, it is just supposed to switch on a light. However, when I hit the switch on my KNX switch, nothing happens.
I have been working around with in automations.yaml

- id: KNX_Scene_64
  alias: KNX Szene "Test"
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.scene_testszene_64
    to: '64'
  condition: []
  action:
  - service: light.turn_on
    entity_id: light.arbeitszimmer

or with

- id: KNX_Scene_64
  alias: KNX Szene "Test"
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.scene_testszene_64
    to: '64'
  condition:
  - condition: template
    value_template: '{{ (float(trigger.to_state.state) == 64) }}'
  action:
  - service: light.turn_on
    entity_id: light.arbeitszimmer

but I cannot get it working. Hopefully, there is somebody around here, who can help me.
Thanks a lot in advance. If you need additional information, I am glad to send them.
Thank you,
Stefan

Try either one or both of

  • set always_callback = True for the sensor
  • use numeric_state as trigger platform and int instead of string in to:
1 Like

@farmio Thank you very much. always_callback = true did the trick.
Numeric_state looked odd, as it wanted to get above and below

Yeah, right. I think this is odd too. An exact: condition would be nice.

Hey! Just a heads up for the 2021.2 release tonight:

  • knx_event data attribute address is renamed to destination (because source and others are added) so rename this in your automations etc.
  • fire_event boolean configuration is deprecated - you can delete it safely
  • fire_event_filter configuration is renamed to just event_filter - no flames involved :fire:

and a little shameless plug :wink: you can use (and possibly improve) my blueprint for dimming HA lights from knx KNX - relative dimming for lights

2 Likes

I’m getting a house with a new KNX instalation in a couple months.

The KNX system will control the basic functions like blinds and lights, but I’m looking forward to connecting it to home assistant for more advanced features.

If it’s not the best place to ask this I apologize, but if you were on my shows, what advice would you give to your past self regarding integrating KNX in home assistant?
The only one I know so far is that while my KNX/IP router supports KNX secure, I shouldn’t use it.

Just be sure to get the .knxproj file from your integrator if you don’t create it yourself.

I will.

Also, I had t find a compromise between the extreme reliability of KNX stuff and the higher price. The TLDR is that most of my actuators (lights, blinds and electrovalves) are wired and KNX, but not every sensor is. I have one KNX sensor temperature on each floor because it’s part of a small screen and two wired presence+luminance sensors.

I’ll buy a bunch of wireless zigbee/zwave door and water leackage sensors. If I wanted to add those HA entities as if they were KNX devices with their own address, is there anything I must ask the installer about leaving reserved KNX addresses for those or not really?

No this will be fine. The addresses don’t matter.

My second advice would have been: absolutely put a presence detector in EVERY room. I didn’t and regret it. At least put a cable in the ceiling so you can do it later.

Most knx wall switches have temperature sensors integrated. But they sure cost more than conventional switches (from 50 to 500 €… have a look at Lingg&Janke or MDT for cheap ones)

All the electric equipment in the new home is from Schneider Electric because my aunt worked there for 25 years and I get almost 50% off on everything. Some of their switches have temperature sensors indeed, but I don’t need too many. I’ll have heated floors with a heatpump. That kind of heating has so much inertia that there’s no point even on having zones, you have the heating 24/7.

I have only two KNX presence+luminance detectors, but I might expand it with cheaper zigbee presence detectors and use HA to integrate them. It’s just a cost saving measure, but one has to decide when to stop spending more money. Also I’m not sure I want presence detectors on bedrooms.
Wireless presence detectors have come a long way, they are dirty cheap and batteries last for years.

That’s my plan at least.

Thank you for all this information. My KNX and HA are working pretty well together.

There is just one thing I’ve spend already a lot of hours at without getting the result I want.

I do have a couple of MDT-push buttons with leds. And in the near future I want to get myself also some MDT Led-indicators like this one: https://www.mdt.de/EN_LED_Indicator.html. Just cause they will fit next to the doors and it’s easy to see if everything is fine when leaving the house (doors/windows/…).

While it’s pretty simple to get the leds coloured by the state in KNX itself, it seems impossible to get it done with my states from Home Assistant.

As an example:

When the Alarm Panel card has different states I want to see those in my knx-leds.

Like: armed/pending/disarmed = red/blue/green

Or, like my sensor that tells me when to put my garbage outside:
Tomorrow/Today: Yellow/Red

I did try this by “send”, also did try this with “notify”, but nothing seems to work.

If I knew in front how easy everything is setup with zigbee and stuff like that together with HA, I probably would have gotten a lot more of the cheap stuff instead of KNX. I have about 15 KNX-presence detectors in and around my house and I still am buying extra from time to time (have 2 extra now, and probably will get like 2-3 more in the next months…). Not cause the KNX-stuff is not good, but cause it’s almost impossible to think about all possibilities once you start wiring your house with EIB-cables.

I have a lot of Glastasters and other buttons. Most (some exceptions of course) gets hardly used, cause my phone is mostly more close and has more possibilities… I’m not using Google Home cause my accent makes her crazy :slight_smile:

A cheap Xiaomi sensor gives me temperature and humidity. My expensive Glastasters lacks the second. So in the end I could buy expensive humidity-sensors (I do have double places at some spots like the bathroom to place one under the button-switch), or buy like 10 zigbee devices for the price of one humidity sensor… Same with the presence-detection, except for places where you almost don’t move. There I have 3361MWW from Jung and they are incredible in my opinion.

Also, don’t try to put too much logic in knx. Just the basics. I spend a lot of time with stuff like scening, and it’s almost all replaced by HA now. And get (like someone stated before) the project file. From time to time you can get ETS for an ok price, or maybe find a friend who can help you change some things.

I’m living at my place for about 9 months now, and still am changing stuff every now and then like button-rearrangements.

Create an automation that uses knx.send accordingly to the expected data format of your Led-Display. Notify is just for strings.

I’m going the opposite direction. Everything in KNX and HA works just as a gateway to non-knx devices. Whatever you feel comfortable, I guess.

2 Likes

My rule of thumb when designing system house was: If something needs a wire any way to be convenient (blind motors, lights, electrovalves), it’s KNX. Mostly actuators and switches, things that need proper power.

If something can work work wirelessly changing batteries every few years, I go zigbee and rely on HA to avoid breaking the bank.

The only exception is a fire alarm (because its critical nature) and two presence/light sensors in the most critical areas of the house.

I already have a some zigbee stuff I’ll be moving to the new place.

Thank your both for your input.

Thank you for your help already! Still without any succes. But at least I know I have to use the knx.send command now…

- alias: testledkleur
  trigger:
  - platform: state
    entity_id: input_boolean.testboolean
    from: "on"
    to: "off"
  action:
    - service: knx.send
      data:
        address: '31/0/4'
        payload:
          - 'off'
          - '00'
          - '0'
          - '$00'
          - '$0'

This is what I’m trying now, none of those work. Probably I’m not looking at the correct place for the expected data format I think. But if I look in ETS at “1.001 switch” it says $00 or $01…

The best is not to guess but check what is the DPT type that your KNX device expects on the group address. You should be able to see it in your ETS project. Once you have it I found more reliable the use of the expose: of an entity from HA to KNX bus. E.g.:

tunneling:
  host: 10.144.1.140
  port: 3671
  local_ip: 10.144.1.163
expose:
  - type: '1byte_unsigned'
    entity_id: 'sensor.ac_fan_speed_set_sypialnia'
    address: '1/4/9'
  - type: 'temperature'
    entity_id: 'sensor.aeotec_limited_zwa021_thermostatic_valve_temperature'
    address: '1/4/29'

this gives you full control of what is the data type you are sending, in above example the 1byte_unsigned is for int value (DPT_5.010) and the second for temperature (DPT_9.001).
Alternatively you can also set the type in the knx.send service. In either case check the proper type in the following table:

1 Like

DPT 1 means binary. You are trying to send a list of strings.
'0' is the character 0, not the number. Number is without quotation marks.
- at the beginning converts the payload to a list, but you don’t want a list in this case.
ETS displays hexadecimal numbers with a $ prefix, I think.

Try

(...)
data:
  payload: 0

An expose won’t get you what you want since you need to translate non-binary state (alarm status) to multiple binary GAs as far as I understood.

2 Likes

And by checking some other places the proper “type” for binary data should be:
type: "binary" either in knx.send or in expose:
And actually it seems that you can directly expose the entity e.g.:

# Example configuration.yaml entry
knx:
  expose:
    - type: "binary"
      entity_id: "binary_sensor.kitchen_window"
      address: "0/6/5"

More examples here:

1 Like

No, knx.send doesn’t accept type: binary
Exposing the entity directly to a binary address requires a binary state. Alarm seems to be non-binary.