History_stats: total runtime of entity unplausible

The History Stats integration relies on the History integration which relies on the Recorder integration.

In other words, History Stats uses the data stored by Recorder which, by default, is limited to 10 days (unless you increased/decreased it). Anything older than 10 days is automatically purged. Increasing the limit will, of course, increase the database’s size because it records the history of every entity in your system (unless configured otherwise).

So your “total” History Stats sensor bases its calculation on the available data in the database which is limited to the last X days (where X is the duration of the purge cycle).

What I suggest you do is create a single History Stats sensor that calculates daily runtime. Then create daily/weekly/monthly/yearly sensors with the Utility Meter integration. Sensors based on that integration store their data in a table within the database that is excluded from the periodic purge cycles.

I provided an example in the following topic: