Sync_state: force states updates for unchanged values

Dear KNX Team,

I am looking for a way to force state updates even if the KNX sensor value is unchanged. These frequent updates can be handy to visualise sensor data in Grafana. I have tried to use sync_state expire / every, however the “GroupValueRead” result is not passed to InfluxDB if the value is unchanged. Therefore, I guess that the KNX library only triggers HA state updates when the sensor value has actually changed. It would be nice if we had an option to force these updates.

As a workaround, I am currently using a template sensor that copies the value of the KNX entity every 5 minutes. It works, but it is not very convenient, let alone manageable.

PS: I am aware that Grafana offers the fill(previous) function, but this requires that at least one sensor value is available in the specified time span. And that is not always the case.

Hi :wave:!
Have a look at this issue: always_callback does not trigger a state update within homeassistant · Issue #965 · XKNX/xknx · GitHub

TLDR: I don’t think it’s feasible to implement workarounds in knx for shortcomings of other (InfluxDB) integrations.

You should rather do a feature request for the influx integration to store unchanged sensor data periodically.

Thanks a lot for your feedback. Initially, I was also of the opinion that the restriction is coming from the InfluxDB integration, but today I came across this solution:

sensor:
  - platform: template
    sensors:
      ff_bathroom_heating_valveposition_db:
        unit_of_measurement: percent
        value_template: "{{ states('sensor.ff_bathroom_heating_valveposition') }}"
        unique_id: ff_bathroom_heating_valveposition_db
        attribute_templates:
          update_now: "{{ now().minute }}"

This template sensor triggers a state update every minute. All updates are forwarded to influxdb, regardless of the value. Therefore, I assumed that the xknx/knx integration does change detection and updates the HA state only when the value has changed.

It does, unless you configure always_callback: true (for sensors at least, not sure for binary sensors). But then it still only triggers on GroupValueWrite (See link above). Most Knx actuator can be set to send their value periodically, so this should be a fine workaround (and also reduce bus load as there is no need for the read telegram).

Drawback of your solution is that these state (attribute) changes are not only stored in influx, but also in HAs database. (Same for always_callback).

1 Like

Oh boy, I have not seen this option. Thanks a lot for your support. It will do job.