Hi there!, I use a history_stats template to track my studying time when the study mode boolean is turned on.
Since this worked pretty well, I wanted to have theses statistics as a graph to see my daily study time on my Dashboard. I pick “max” so I get the max value of the day - which should be the value at the end of the day. This does work, but since it resets at 00:00:00, the highest value of yesterday stays for today, if the value of today is lower than yesterdays.
I tried moving the Time of the template up and down, but it does not work anymore. Moving it to 1 AM has still the problem and moving it down to 23:59:00 to reset, doesn’t count my study time of today at all. The only workaround for me is to set the graph to show hours instead. It’s not the same but at least it looks kinda correct. Daily hours would be nicer tho.
What am I doing wrong? Is there any way to fix this?
If I change the Card back to “day” and the template time to 0:00:00 you can see, that each day with a high value is followed by the same value (because on the next day I have studied less and the “max value” of the day is the one at 00:00:00)
Thanks a lot, This works pretty well - I didn’t know the last reading works with mini-graph.
One more follow-up question: While my sensor data gets deleted after 7 Days, I can still access older values with the statistics-graph card. (See screnshots above).
The mini-graph card can only show me these 7 days. What is the reason behind this?
Thanks a lot!
The history sensor uses the state history from the recorder database. This is deleted once it is older than your recorder purge_keep_days setting (10 days by default).
LTS (long term statistics) are not purged. They don’t take up much room in the recorder database.
@tom_l actually this is exactly what is happening when today’s value is lower than yesterday’s (or current hour value is lower than previous hour value) - values stored in statistics table are wrong so long term statistic is wrong. Short term data works fine as far as I know.
The reason why I posted it here is that this post come up when I was searching for this long term statistic bug.
The important thing is that it is two years old and solved already. Please don’t necropost. Home assistant development moves very quickly and old posts become irrelevant or just plain wrong.
I know this is old and ‘solved’ but for the future googler and @xamrex who also still encounter this issue like myself, this appears to be an ok workaround based on one successful day for me: