HowTo: Save statistics for some entities for a longer Tim

Hi there!

I am using HomeAssistant for over a year now. It is my platform to connect my KNX installation, my Hue lamps, SONOS, iOS and my heat pump.

Especially for my heatpump I want so save some entity statistics for a longer time (several Years) to make year by year comparisons.

Currently I am using the integrated SQLite DB with standard settings. The Purge time seems to be 10 days, because my APEX Charts end there after rebooting the system. HA is running on a RPI4, all data is stored on SD Card.

It would be possible to move the system to a NAS or at least the DB. But for me the current configuration seams to be the easiest way to run HA.

So what is your advice to store statistics of special entities for several years and visualize them via APEX charts within HA?


Hi :wave:!
There are long term statistics in HA. These save sensor data in lower resolution, but, like the name implies, for longer term. You can use this eg. from statistics cards.

Other than that you could look into setting up an InfluxDB somewhere (HA Addon, NAS, another Raspi etc) and use the influx integration to forward (selected, filtered or all) entity states there. This can then be used outside of HA also.

Hi! Thanks for your quick response.

I think I was a little bit confused with longterm statistics. The heat pump values are mostly energy values and as I understood, the should be stored as longterm stat automatically.

I learned, stat I have to use Statistics Graph to display them. And I saw, they are stored and visible as expected. But they are not visible to Apex Charts.

That’s wired. I would expect them to other integrations and adding as well.
This is what I mean:

I run MariaDB on a NAS and keep 2 years of history. Other folks use InfluxDB for long term storage. SqlLite probably won’t cut it.

I moved HA from Pi to my NAS (VM). After restoring the last backup it just worked as expected - pretty straightforward!

NAS has SSD Cache and more than enough power and diskspace. This way I can avoid SD card errors, save some power and an extra device (NAS is always on). And I am free to change purge rate or use an external DB in my NAS as well.