Disable history for individual component/sensor?

Hi,

I have a template sensor that changes its value - which is a relatively long string extracted from the attributes of some sensor - every few seconds. As a consequence, my home-assistant.db grows large very quickly. As a workaround, I use purge_days: 2 on the recorder component. However, this prevents me from doing long-term monitoring of my other sensors.

So my question is this: is it possible to disable the recorder/history for an individual sensor (or for a specific component) only?

Thanks!

1 Like

I do not think there is a way to do what you want to do currently with built-in tools.
A good example for this would be the logger component what allows exactly this.
Although it would be nice to have this feature or at least a parameter to tell HA where to store the db file.

Another option/work-around instead of purging the whole DB would be to just remove the stored detail of the sensor in question from the DB.

You can store the DB where ever you like.

1 Like

i would write a small py to remove the sensor details and the through automation let it run at the end of every day.
you could even make an inifile that contains the entitieid’s from al the sensors you want to purge.

1 Like

Thanks for the comments. I’ll simply go with the Python script then. For the states table it will be trivial (DELETE FROM states WHERE entity_id = …), but for the events table I will have to parse the event_data field that contains a dictionary.

In case anyone is interested, this is the code I used and it seems to work:

https://gist.github.com/DavidMStraub/6f1f64f8a5f191592efe6778a37a9348

(For some I am not allowed to post when inserting the link as link)

4 Likes

Thanks for posting your solution! Appriciate it!

In case anyone runs into this old thread: this workaround is no longer necessary as excluding individual entities from being recorded is now possible.

10 Likes