Hi All,
I’ve quite limited Python experience, but I’ve spent some time to add a parameter to recorder, which lets you specify entities to keep when it’s running a purge. So using this, you could set your purge duration to say 7 days, and still keep things like temperatures in the database forever.
Please take a look at this commit, which contains the changes: Implement Entities to Keep in Recorder · KiLLeRRaT/home-assistant@4db4d66 · GitHub
Here is an example of the configuration.yaml file using this new param:
recorder:
db_url: "mssql+pyodbc://User:Pass@ip/homeassistant_dev?charset=utf8;DRIVER={FreeTDS};Port=1433;autocommit=True;"
purge_keep_days: 1
keep_entities:
- person.albert_gouws
- sun.sun
auto_purge: false
Note that auto_purge
is false
above, I’ve just been using the purge service to test this.
I call the purge service from the dev tools using the following:
service: recorder.purge
data:
keep_entities:
- person.albert_gouws
- sun.sun
apply_filter: true
Someone smart should be able to extend this, to introduce a level under my keep_entities
, so that you can specify an entity, and a duration for that entity. It should be quite easy to then just update the SQL queries I’ve got in place there to take into account the duration you’d want to keep it for.
Anyone keen to look at my code, and basically wrote snippets of what I need to update to support this? Or if you’re keen, just do it and create a PR into mine, and we can then submit it as a PR together into the Core project.
Cheers!