Hi, I’m new to HA so just experimenting with options at the moment.
My main use is to monitor and manage my energy consumption, export and import.
I have the following feeding into HA.
- Growatt inverter (Via Solar Assistant).
- Iotawatt power monitor.
- Hildebrand Glow smart meter.
HA OS is running on a Pi4b.
I understand that data is retained for only 10 days by default in HA.
So should I…
- Feed the HA data I want to keep into Influxdb?
- Or, setup an external MariaDB on my NAS to use as the HA database?
I already do have some data feeding from HA into InfluxDB but that does seem a bit wasteful using 2 DB’s to store the same info.
How easy is it to setup HA to use and external DB?
Is this a better way forward or should I stick with InfluxDB?
I have been experimenting with different charts in HA and think I can get the info I need from them. So that would remove the need for grafana and Influxdb.
Looking for opinions on which is the best/easiest/most robust way to go from those with experience please.
I think you’ll be better off separating the data you want to keep from the HA database structure.
If you already feed some data to InfluxDB, then that’s a reasonable approach. Decide what you want to retain, for how long, and in what format, and manage it external to HA.
The HA database was designed to store everything HA related in one place, and only for a limited time. This is great for beginners, but anyone with some database experience is going to see the obvious limitations with this approach.
Once the data you care about are safely stored where and how you want them, you can reduce the
purge_keep_days to a minimum,
exclude anything you don’t want HA to maintain, and keep HA lean and efficient.
@CaptTom . Thanks for that well reasoned advice.
So, is there any merit in the argument for moving the HA database to my NAS in order to prolong the life of my Pi’s SD card in any case?
I can see the merits of the InfluxDB option and will probably go that way for long term data storage. Just looking for best practices all round.
As I say, I’m new to HA and only really monitoring energy at the moment but will be expanding that once I’m happy with how my energy monitoring is going.
I can only offer my own opinion. I would not have included energy monitoring data into the pre-existing HA database. The HA database was originally designed as a short-term repository, with a default purge duration of 10 days. The real value in energy monitoring comes when you have long-term historical data to compare.
So, once you strip out the energy data to a more appropriate storage location, the HA database design is adequate for what remains. Ruthlessly exclude any entities you don’t need to retain or which spam the database with frequent state changes, and set your purge days to the minimum you can tolerate. That’s what I do and my RPi 3B+ has happily hosted the database, on an SD card, for over three years now.
There may be dissenting opinions. That’s the great thing about HA; there are so many ways to implement almost anything you want to do.
Just my 2 cents;
I use a mysql database (running on a separate unix machine) amongst other databases (non HA related)