History stats incorrectly tied to sun entity

There’s something weird going on with history_stats for me, too. Not sure if it was 2022.9.x or earlier, but I know it didn’t used to do this…

What’s happening is that the underlying binary sensor rolls off if the heat hasn’t come on for the recorder purge_keep_days. When it finally comes on the state changes to “on” (from non-existent) and the history_stats starts updating.

But it adds all the hours between midnight and when it came on! For example, the other day it came on for 15 minutes, starting at 13:02. Instead of adding 0.25 hours to the history_stats, HA added 13.3 hours!

I’m just throwing this out there because it seems like a recently-introduced bug. Who knows what else might be affected!

Good to know, Thanks.

That sounds an awful lot like a discussion I had about history stats not working correctly for binary sensors in another context. Problem is I can’t remember all of the details, but what I do remember from it is that IMHO the history stats does not work correctly for binary sensors if there is totally no history in the recorder prior to the start if the history measurement. I was told it was by design, but it clearly also showed wring history stats values.

But as far as I could see, that is not the case for the OP, as there was history in the graphs before daystart. So in short, yeah I think the history sensor is broken when there’s no prior history in the recorder before the start of the history period. But I do not think it is the same problem mentioned here.

The worrying thing about this though is that I think there are bugs in history stats that do not show up for everyone because they are related to how much (seemingly irrelevant) history is in recorder.

1 Like