Value aggregator integration

I’ve recently learned that Home Assistant has these interesting integrations called “Recorder” and “History” which control how many days of events, sensor data, etc. are kept. That’s good, but in my opinion not enough. I, as a user, would like to be able to keep sensor data for years without making my DB huge. This could be done by aggregating older data into less detailed, smaller buckets. For example, it would be nice to:

  • keep fully detailed recorded sensor data for the last 24 hours
  • for previous days aggregate the detailed data and only keep the min/max/average for every hour
  • for the previous weeks aggregate the daily data and only keep the min/max/average for every day
  • for the previous months aggregate the weekly data and only keep the min/max/average for every week
  • for the previous years aggregate the monthly data and only keep the min/max/average for every month

You see where I’m going with this? the further you go back in the past, the least details the user is interested in, but he still wants to know the min/max/average on a less granular level.

A good example is the energy produce by my solar panels. For today I want to be able to pot a detailed graph with values recorded every minute. But for yesterday it’s enough to have one value for each hour. For last week it’s enough to have the aggregated values per day. And if I want to plot a graph for last year, I only need the aggregated values on a monthly level (or on a daily level in the worst case).

I strongly suggest this for future development, because it’s a great compromise between sensor value lifetime and sensor value detail, while keeping the DB at decent sizes.


You can do all of this with an Influx db and some sql scripts to clean up the database daily, weekly and monthly. Those scripts can probably be automated with HA.

Yeah… you can probably do it with the default SQLite DB too, simply by running some aggregator scripts ona regular basis… but wouldn’t it be nicer if this was implemented in HA instead of everybody hacking together their own scripts?

1 Like

Is there any development on this issue? Installing a second database for storing a few aggregated numbers seems to be a huge overhead for very few data.
+1 for a HA internal long term storage solution

@Un4Seen did you solve this with acceptable effort?

1 Like

@Helferlein No, never solved it,still struggling with the recorder… I wish HA would implement a proper solution.

I’m not sure, but the recent developments re: statistics might be the solution to your problem. The ore Energy feature has daily, weekly, monthly etc. stats.