I have a live off-grid battery voltage graphed within programmable device-sourced bounds like “start generator” and “stop generator” and “low voltage cutoff”. If these values haven’t changed in the last 10 or 20 days (whatever the history keep_days is configured for) the entities just disappear from the History Graph Card.
This is a good one. When records are purged at keep_days
, it would make sense to retain just the last one.
Don’t forget to vote for your own WTH!
If I put the entity on a card, it’s last value is presented to the user and is correct.
It just doesn’t graph!
You’re right, I just hadn’t noticed that inconsistency. Still, I’m not sure whether the value displayed is from the database, or from HA’s memory. I think I recall losing these values when HA restarts. Regardless of the mechanism, it’s still a good idea to resolve it.
Same is with Logbook.
Assume that hours_to_show=24, if the sensor hasn’t been changed within this period - then the logbook is empty.
The problem is in the recorder component. The database stores state changes indexed by timecode. It doesn’t store the last valid state of an entity. If the last state change of an entity expires beyond the recorder purge period, it gets purged from the DB. When that happens, a query on the database for this entity will return an empty record, because no state change is available anymore. And yes, this behavior is annoying.
HA stores this internally without using the database. You can see this on entities that were excluded from the recorder. They still display their last state and last changed date on a card.