KNX Cookbook

I will try that as soon as possible :slight_smile:

Do I also get the brightness this way? I could not see the brightness values as attributes.

Hm
 looks like brightness is no HA Weather entity attribute (it’s used for condition only).
Just create a knx sensor - will do the same.

This is how my sensor looks like now but something seem to be wrong:


platform: template

sensors:

  wetterstation_homefs_temperature:

    friendly_name: "Wetterstation HomeFS Temperatur"

    unit_of_measurement: "°C"

    state: "{{ state_attr('weather.wetterstation_homefs', 'current_temperature') }}"

    unique_id: wetterstation_homefs_temperature

The error shown is:

Invalid config for [sensor.template]: [state] is an invalid option for [sensor.template]. Check: sensor.template->sensors->wetterstation_homefs_temperature->state. (See ?, line ?)

Look at my example above, or just copy it.
No “platform:” and lists “-” where necessary.

Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See ?, line ?).

This is what i got now. The file is where all my other sensors are placed as well.

template:

  - sensor:

    - name: wetterstation_homefs_temperature

      unit_of_measurement: "°C"

      state: "{{ state_attr('weather.wetterstation_homefs', 'current_temperature') }}"

      unique_id: wetterstation_homefs_temperature

It belongs in the root of configuration.yaml, not under a sensor: key

It doesn’t have to be in configuration.yaml though. I have them in a separate file sensors.yaml.

- platform: template
  sensors:
    living_temperature:
      unique_id: living_temperature
      value_template: "{{ state_attr('climate.living', 'current_temperature') }}"
      unit_of_measurement: "°C"

That gets referenced then in configuration.yaml:

sensor: !include sensors.yaml
1 Like

In my setup I can’t see brightness anymore, only the interpreted velue (eg “cloudy”) as a state:

<template TemplateState(<state weather.utemaler_ost=cloudy; temperature=29.2, friendly_name=UtemÄler Þst @ 2021-06-04T07:36:34.793353+02:00>)>

You can also just configure it as knx sensor.

2 Likes

Solved my isses it needs to be value_template instead of just state :slight_smile:

Hey :wave:!
There are lots of KNX news in 2021.7.

  • new Number platform
  • new Select platform for dropdown menus
  • XY-Color lights
  • some climate attributes to support current active mode
  • switches that can respond to Knx GroupValueRead requests and restore their state from HA!

Try it in the current beta! :woman_technologist:

3 Likes

Hi Matthias,
great news! Thanks for all the hard work and free time that you offer to help all of us.

I’m especially looking forward to the HA switches with “Read flag”.
Are the new number and select platforms a general new HA feature that you adapted the KNX integration to?

1 Like

Yes, number entities have been added to HA at beginning of the year and select entities are brand new.
Currently there is no option to view the number entity as slider, like the “mode” for input_number. But I think with enough feature requests this will be added to HA eventually. Or you can maybe use a custom Lovelace card.

Number and select entities can be configured to respond to read requests as well. And, like switch now, restore their state if no state_address is configured.

1 Like

The picture regarding the KNX weather sensor is not clear. I am trying to put all the info in one post to see that I and others fully understand the issue.

The latest KNX weather documentation links the group address as follows:

knx:
  weather:
    - name: "Home"
      address_temperature: "7/0/0"
      address_brightness_south: "7/0/1"
      address_brightness_west: "7/0/2"
      address_brightness_east: "7/0/3"
      address_brightness_north: "7/0/11"
      address_wind_speed: "7/0/4"
      address_rain_alarm: "7/0/5"
      address_frost_alarm: "7/0/6"
      address_wind_alarm: "7/0/7"
      address_day_night: "7/0/8"
      address_air_pressure: "7/0/9"
      address_humidity: "7/0/10"
      sync_state: true

This does not generate any sensor but a “weather.home” which carries temp, wind and sun attributes.
If I understand correctly, next I need to have a template sensor like the following (from one of the above posts):

- platform: template
  sensors:
    living_temperature:
      unique_id: living_temperature
      value_template: "{{ state_attr('climate.living', 'current_temperature') }}"
      unit_of_measurement: "°C"

As 2 posts say contradicting facts, I am not sure if the template sensor needs to be a part of the sensor key or be somewhere at the base of the configuration.yaml file.

That’s intended behavior. A weather configuration creates a weather entity.

I think It can be done both ways.

template:
  sensor:
    - ...
# or
sensor:
  - platform: template
    ...

Anyway I’d suggest to just use knx sensors with the according group address instead of templates. The weather entity was not allowed to have extra state attributes so you can’t get every value out of it anyway.

After playing with the Weather issue the simplest thing is to add sensors under the knx: key as follows:

# KNX Sensor
knx:
   sensor:
       - name: 'roof_brightness'
         state_address: '7/3/1'
         type: illuminance
       - name: 'roof_temperature'
         state_address: '7/3/2'
         type: temperature
       - name: 'roof_wind_speed'
         state_address: '7/3/3'
         type: wind_speed_ms

It works OK.
No template or complex stuff. It can be put in a dedicated yaml file as well.

Hello, Im very new to KNX and to HA as well and try to find my way trough all this things. So fare I implemented some stuff for KNX to HA as well some sensors from my Luxtronik to HA. This is really great! Thank you all for your hard work!

Now I have a question regarding KNX switches. I just send an Impulse (DPT 1.001) to the KNX and there is no state_address in KNX. (its an MDT actor open a VELUX window with the KLF200) In HA the switch is toggled On after using it. But I would like the switch automatically set beck to OFF after a period of time or straight away after toggle. Is this possible in HA?

Thank you for your help.

André

What you ask for is usually called a “momentary switch”, “pulse switch” or “push button”.
HA does not provide this type of switch out of the box, but it is easy to implement this using a HA script, a Node RED flow or a HA template switch.

But before you do this take a step back and rethink the problem:
You should always try to create your KNX setup in a way that its basic functions do not depend on HA. Make KNX work on its own as far as you can.
So if you need an actor to fall back after a short time, try to implement that right within KNX through a logic component. Many KNX devices (like MDT switches) provide a small number of logic gates that can be used freely. Use them to listen on the CO address of the actor and send an OFF signal to that same CO when they see an ON.

1 Like

HA Scripts are basically momentary buttons triggering one or more services.

Go to Open your Home Assistant instance and show your scripts.
Create a new script using knx.send service without a type and payload:1

1 Like