Please help with setting up automatic deletion of data from the database

Hello,

I would like to ask for help with setting up automatic deletion of data from the database. Since I would not like to lose some data that is already in the database, please check before I put it into operation.
My point is that I want to store some data forever. That’s why I set purge_keep_days: 36500 and listed the entities I want to store forever with include.
So will it work by storing data from enumerated entities for 36,500 days and automatically deleting other data every day? And from entities that are not listed will be available history to previous cleanup?

default_config:
recorder:
  purge_keep_days: 36500
  db_url: mysql://homeassistant:xxxx@core-mariadb/homeassistant?charset=utf8mb4
  include:
    entities:
      - sensor.ts_ft002_38_t
      - sensor.ts_ft002_38_d
      - sensor.zustatek_vody_studna
      - sensor.objem_vody_studna
      - sensor.vyska_hladiny_studna
      - switch.smart_plug_7
      - sensor.aktualni_zatizeni
      - sensor.spotreba_elektriny
      - sensor.temperature_4
      - sensor.humidity_5
      - sensor.temperature_2
      - sensor.humidity_3
      - sensor.processor_temperature
      - sensor.disk_use_percent_home
      - sensor.disk_use
      - sensor.last_boot
     

if data you want its better to add influxdb to your DB. Keep mariadb for HA operation which stay put only for 14 days minimum. That way your system remain fast and agile. However influxDB can be used to perform data analysis with ease.

2 Likes

it dont work like that. What you specified here, is what entities will have history, others will not be recorded (see description in recorder ‘Configure which integrations should be included in recordings. If set, all other entities will not be recorded.’ )

1 Like

Thanks for the anwers.
Is it possible to somehow make settings with the current database to make it work as I wrote?
I’ve looked at Influxdb before, but I find it unnecessarily complicated and full of features for working with data that I wouldn’t use.
All I need is an easily available graph of temperature, for example, and the opportunity to look at history.

You can’t have the database keep data for some entities for timeframe x and other entities for timeframe y. That functionality doesn’t exist.

2 Likes

That’s not completely accurate, you can’t with HA but you can with influxdb. You can have multiple databases with different retention policies.

Nodered is probably the easiest way to accomplish this.

Yes, but the OP stated not wanting to use influxdb.

It can’t be done with the usual DB options.

1 Like

But I think it should. I even put in a feature request for this. If you agree, I’d appreciate an up-vote on this:

Thank you for your answers.

Yes, the function below is exactly what I would greatly appreciate.

1 Like

Thanks for the up-vote. But in your comment on that thread, I see that I may have another option for you.

What I do with values I need to keep for long-term analysis is simply write them to a text file. I can read it into any spreadsheet, database or analytic program for graphing, calculating or displaying it.

For example, I have one text file which contains the “on” and “off” times for each run of the burner on my oil-fired boiler. Then I have another with the daily total run-time, one line for each day.

I may have posted some of this already, but if not, and you’re interested, I could summarize how I did it (probably in a new thread, so as not to introduce too much drift here.)

I voted for that feature request back when it was created

1 Like