Thank you tom_l. The two links you sent are a good explanation. Just wondering that my configuration file only contained a reference to history (and nothing about recorder), and I could not find these two pages by navigating the website. It seems you need to know they exist before you can access them.
What I understand now is that by configuring history I can modify what I want to see, while configuring the recorder would modify what gets stored. Interestingly the default value of keeping records for 10 days did not work for me.
I configured 10 days now explicitly and need to watch what’s going to happen.
I’m going to add that I ran into a similar problem, with the Logbook tab not loading and my home-assistant_v2.db growing to be very large (4.2GB in my case).
I believe the problem was the introduction of a “date” field that was of course changing every second of every day. This “blew up” the log. After excluding it from the logbook (and history and recorder) and deleting the old home-assistant_v2.db file and then restarting. The logbook page started working again. Here’s my example config to exclude the date element.
Thank you @randomstring for bumping up this thread. I just checked my history size and was wondering about 8.6 GB of sqlite data. And this although I had added these lines into my configuration:
recorder:
purge_keep_days: 10
purge_interval: 5
Following https://www.home-assistant.io/docs/backend/database/ I connected to the database and ran select * from states;
Among the result were entries with a timestamp from february 2019 - definitely older than 10 days.
Would that mean the settings in the configuration do not work? What might be missing?
I have constantly had issues with my database being corrupted and Im not sure whether its related to running theses commands as your doing above in recorder. Since removing the commands and running keep_days:10 separately in dev-tools > services, followed by repack:true I’ve had no issues.
I tried doing the same, and I think I found dev-tools>services pane (my Homeassistant shows all the german labels). But when I choose which service to run I can neither find keep_days or repack. How exactly did you do that?
Select recorder.purge as Services
then enter {“keep_days”: “10”} in service data and click on ‘CALL SERVICE’
and enter {“repack”: “true”} in service data and click on ‘CALL SERVICE’
Thank you for pointing it out. So I checked my system again, and my home-assistant_v2.db was 8.8 GB in size.
Then I ran recorder.purge service with { “keep_days”: “10” } and it took a long time (two more files were created, I waited until they were gone). After that home-assistant_v2.db was at 8.9 GB size. Hmmm…
Then I ran recorder.purge service with { “repack”: “true” } and again it took a long time, After that home-assistant_v2.db took 8.9 GB still.
Looks like your workaround does not work for me. The file is just growing.
This is getting frustrating. As you suggested I ran the service with { “keep_days”: “5” }, then with { “repack”: “true” } and still my DB is at 8.9 GB. There must be some something we have not yet spotted.
I am running Homeassistant 0.98.4 inside a docker container (my config directory is mounted from outside so I have access to those files regardless of the container).
Just before following your hint now I tried one more test by running recorder.purge with
{ “keep_days”: 10 }
and
{ “repack”: true }
(note the missing qutoes around the values. On purpose I passed them as number and boolean rather than string). Unfortunately this also did not help.
So my next step is to assume the file is corrupt and simply remove it.
After a { “repack”=true } with no database file it got recreated and is 4 kB in size. Let’s see how fast it will grow now…
Thank you for that hint. While restarting I moved to homeassistant v0.98.5. The lines you suggest produce this output:
[homeassistant.components.filesize.sensor] Filepath /config/home-assistant_v2.db is not valid or allowed
This is strange as the file itself exists and should be accesible at that path. However it is a side effect when visualizing my original problem so I won’t bother.
Ah, now it works. I have a sensor now and Homeassistant can even produce a nice graph.
I tried to lookup the documentation for the filesize platform but could not find anything. It seems Homeassistant has many nice features but usability is low if people don’t know about them.
Hi, i have an unsolved question about the db management:
I want to see some mqtt sensor frequently updated on my frontend (every 10s that is the telemetry time set in the tasmota sensor) but i want to store it in the db every 1-2 minutes. Is this possible?
You could create a template sensor which has the state of the mqtt sensor. Then exclude the mqtt sensor for the recorder and only log the template sensor to the db.