home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.34k stars 29.88k forks source link

Tellstick sensors actual "last updated time stamp" not reflected in HA #38992

Closed BoneheadFraggle closed 3 years ago

BoneheadFraggle commented 4 years ago

The actual last_updated time stamp of a Tellstick sensor, the time when the last signal from the sensor was received, is not reflected in the sensor in Home Assistant. It seems like Home Assistant's "last_updated" is always the same as "last_changed".

Example:

The Tellstick add-on log shows: "fineoffset temperature 216 -24.2° 2020-08-10 19:33:40"

..where "2020-08-10 19:33:40" is when the last signal from the sensor was received.

At the same time, {{ states.sensor.tellstick_id_248_temperature.last_changed }} shows "2020-08-10 17:20:49.056231+00:00" (with 2 hours compensation for UTC / GMT + 2). Almost 13 minutes difference.

This is not an issue for sensors that change their value often. But when you have a thermometer sensor in a temperature controlled environment, or an aquarium where there should be very few changes in the temperature, you never know if you can trust the value.

This also means that is not possible to have automations trigger on a sensor that is not updated for a long time.

Basically, there is no automatic way to know if:

  1. The temperature is correct, the sensor is updated 10 seconds ago and working well or
  2. The temperature is much to low, but the sensor hasn't updated the value due to an error.

Suggestion: Trigger Home Assistant's "last_updated" to be changed whenever a signal is received - even if the sensor's new value is the same as the current value,

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

spacegaier commented 3 years ago

Your message sounds a bit as if you think that HA enforces that last_updated has to always be the same as last_changed. That is of course not the case, e.g. see this ping sensor.

image

In case of the ping integration, the timestamp gets updated since during each data retrieval the attributes change (round trip times). If however, both the attribute and the state itself are unchanged, then no new state record is written to the database since it would be redundant and just consume resources, unless the force_update property is passed on by the integration. Some offer this option, but most don't currently.

BoneheadFraggle commented 3 years ago

Actually, what I try to describe is the opposite of "that HA enforces that last_updated has to always be the same as last_changed".

I think it would make sense if last_updated actually showed when the sensor was updated the last time, even if the value was the same as the update before. And last_changed would show when the actual state/value was changed the last time.

If used for monitoring temperatures for example, it is of great importance to know that the sensor is updating, even if the temperature is totally stable and doesn't change. Otherwise you will never know if the temperature is actually absolutely stable, or if the sensor has stopped delivering new values (is broken).

spacegaier commented 3 years ago

Yes, but that is not the way HA works and I think that is by design, since otherwise we would end up with a lot of redundant DB entries. As I said every integration can already decide to override the behavior via force_update if continuous data points (= writing a state entry even if the state and all attributes stay the same) are required.

So if you want Tellstick to do that, then the integration would need to add that. If you feel that HA in general should automatically offer that option for all integrations (e.g. a switch somewhere in YAML and/or GUI frontend to enable/disable per integration), then probably you would need to raise an architecture ticket. Perhaps a third timestamp last_contacted or last_queried or something could be added that is however not stored in the DB (transient) and only kept around for as long as the HA instance runs.

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.