KNX Expose: add cyclic transmission interval option

Hello,

It is a common practice for KNX devices sending certain states on the bus like temperature to send them periodically in addition to state changes.
Indeed other KNX devices on the bus may be passively listening to the group (no read request) and go in error if no message was received within a time period (timeout).

Use case:
I have a KNX Thermostat using an external temperature sensor group on the bus. The thermostat has a timeout and goes in error if no temperature was received within a timeframe. I would like to use a sensor within Home Assistant and expose this to the bus to use it as external temperature sensor for the thermostat. However, there may be no temp change within that period, therefore no state change, so thermostat will go in error and close all valves.

It would be great to have an additional option for each exposed entity which would allow setting an interval forcing a message on the bus even though the state didn’t change.

Regards,

Yanik

You can use an automation with the knx.send service for that.
Or just have longer interval for the error. The temperature will probably change once in 6 hours … on the other hand heating/cooling with the wrong outside temperature as calculation base for 6 hours is probably no big deal.

I’m +1 for adding a cyclical config variable to knx expose. The knx.send() service does not allow you to use templates which makes it impossible to send the current value and secondly requires you to re-code all the group properties.

(Worse alternative: have knx.send with as a payload only the addess send the current value of the associated knx entity)

I don’t see why it would be impossible to send temperatures.
I think in an automation it’s possible to use templates for knx.send payload. On the other hand you can just use "type": "temperature" to send a properly decoded payload.
In this case I wouldn’t use expose at all (in the end it’s no different than a shortcut for such an automation without cyclic sending - except for answering GroupValueRead requests).

farmio: Ah you’re right, I can use templating there (I was looking for data_template or the likes) so indeed it’s possible to build it. In my case I need to respond to both requests and have cyclical sending so I end up with the following (in different files):

- id: knx_send_cyclical
  alias: KNX send cyclical
  trigger:
    - platform: time_pattern
      minutes: "/30"
  action:
    - service: knx.send
      data:
        address: 1/4/0
        payload: "{{ states('sensor.bijkeuken_vloer_temp') }}"
        type: temperature

and

expose:
  - type: temperature
    entity_id: sensor.bijkeuken_vloer_temp
    address: 1/4/0

Which is a full duplication of the info used and obviously a problem waiting to happen if things change. It would be much more elegant to do:

expose:
  - type: temperature
    entity_id: sensor.bijkeuken_vloer_temp
    address: 1/4/0
    cyclical_send: 30m

This would capture everything you’d want to do with responding and sending in the same place. Also in KNX devices these are part of the device parameters which feels analogous to the KNX config in HA to me.

1 Like

I agree that it would be a nice addition. If you’d like to implement it and need a starting point then I’d suggest somewhere here in the HA integration https://github.com/home-assistant/core/blob/53ea24ec159875de2c57390bbd4494ee2d389f74/homeassistant/components/knx/expose.py#L94
or directly in xknx https://github.com/XKNX/xknx/blob/570171edd6e8f0e4a7e4b644a3c3e02f026f329d/xknx/devices/expose_sensor.py similar to the datetime device.