Hi Guys,
The problem:
I’m struggling with a (what i think) is a big short comming of home assistant.
I have a lot of sensors that all record data into the home assistant database. Temperature sensors, energy meters, water and gas meters. Now all the data points are stored in the home assistant database and it grows rapidly!
You can set the retention period in the recorder to keep the database at a reasonable size, but this will destroy your data.
When i’m very interested in keeping the data for these sensors for a long period of time to spot any trends. For example: The temperature of the refrigerator is slowly decreasing over 1 month of time, or an appliance now use 15% more power than 6 months ago.
The current solution:
Many of the suggestions on the form point to the influxdb addon. Shoot your data into that database and just use Grafana to do all the “magic”.
But i feel like this is the wrong approach.
First of all, now since we have Lovelace, our dashboards and graphs are getting smoother and nicer every day. Even still this is just starting to develop, all the stuff looks amazing so far. I want all the graphs and data to have one source.
Second, you can’t do anything with the old data. There is no good way for home assistant to access the data in an automation or something like that. For example, list the biggest energy consumer of the last month, or what is the average
Third, It takes a lot of effort to get it setup. I have around 20 temperature sensors and 15 smart plugs. This takes an significant amount of setting up. And most of the stuff needs to be hard coded, so any adjustment or change needs to be made in many places.
What should it be:
Modify the Recorder component
There are a couple of options. The first one is to modify the recorder component to have a separated short and longtem policy. On the Domoticz platform they have this build in:
You can set the short time storage of the sensor data. After this period, the software will automatic start to down sample. For example, temperature will be saved to a min, max and avg value each day. In this case all the data will be stored for years (or any other time to be defined)
Create a component for long time storage
A component can be created that does all the desired stuff. You can specify which sensors should be recorder, and what should be recorder.
- Time intervals: hourly, daily, montly
- Calculations: Min, Max, Avg, Difference,
- How long to keep
May bee there are other options around.I’m more a scripter than a programmer, so i’m probably not capable enough to get this going on my own. So anyone having similar toughs on this to get this off the ground ?
There are some other people who where looking for something similar: