Sensor not updating when same value received

Hi there,

I have a Konnected Pro module with a DHT temp sensor connected to it. This is feeding in to HA via the Konnected integration. I have it configured to send an update/event every 1 minute.

The issue I have is that HA is not updating the sensor’s last_updated value if the temperature value has not changed, even though the module is sending a new event/message every minute.

I can see the the event is being sent to HA (I have enabled debug - homeassistant.components.konnected.handlers). So why isn’t HA updating the sensor entities attributes?

Thanks,

J.

If the state changes, last_changed is modified
If the state or an attribute is modified, last_updated is modified.
If there is no state or attribute changes, neither is updated.

Hi,

So in my case (as the sensor doesn’t have any dynamic attributes) when the value/state stays the same, HA will think it hasn’t received an update?

Any idea how to fix this? I have tried the update_entity call, but that didn’t work.

The Konnected handler is detecting the update, it appears it’s the rest of HA that is ignoring it.

There is no fix, it works as designed. If updates are sent without any actual changes, the last_* won’t be changed either.
What are you trying to achieve?

Hi again,

Maybe I’m trying to be too clever, but I have an automation that checks HA to see if it hasn’t been updated by a sensor in a set period, it then generates an alert/notification.

I do also check for the sensor being offline too.

Ps - In my simple mind the design/logic/use of last_changed and last_updated seems wrong. I would have thought last_updated should be updated even if the values are the same, last_changed should be used for when a value actually changes. The temp sensor doesn’t have any attributes that change, so with the current design I believe the two timestamps will be the same. If necessary there could be another time stamp variable used for attributes.

Saving the same data over and over again is quite pointless.
It just takes up space and eats on the write cycles on the memory cards/SSDs.

Bump. I have this issue as well. Currently I can’t see if I am still receiving the same value, or if my sensor has died (which happens a lot with various integrations).
This is an issue with some graphing cards as well, as they just continue on charting a line even if the sensor is dead.
Is there a solution to this??

Here is a use case where it makes sense:

I keep track of the number of hours my heating system runs. From that I can calculate my fuel consumption as I know the average consumption per hour. My set up is as follows.

  • I have a sensor.runtime which is updated every day with the daily value. This sensor is updated through MQTT.
  • I have a utility meter
utility_meter:
  runtime_since_refill:
    source: sensor.runtime
    name: Runtime since refill
    delta_values: true
    tariffs:
      - basic

Now if the sensor.runtime does not update, my utility does not update either. So those days are not taken into account in the calculation.

You got me…
There is no integration that can do that.

History Stats - Home Assistant (home-assistant.io)

Actually (and sorry forgot to mention that in my update) there is. As I use MQTT I can define force_update: true for MQTT (binary) sensors. But if it were an ordinary sensor, you’re correct.

You didn’t click on the link did you?

I did, :grinning: but I does not solve my case where I need the sum of a set of sensor states. The runtime sensor returns values like 1.03, 2.11, 2.11, 3.0. After this sequence the runtime_since_refill sensor should be 8.25 not 6.14. So using a state does not really work. I do not get state changes, I get how much work the system did.

Secondly, my current solution takes network issues and HA downtime into account (I use a mail account to buffer information). But that is specific to my situation.

Thank you for your reply btw