How to include select entities in recorder.purge service call?

I want to selective remove some of the older data in the default SQLite database. I believe recorder.purge service is the correct to use. I am having trouble finding an example of the correct way to use this service to include only select entities.

That is I don’t want to remove any data other than from those select entities, and I want to keep the last seven days of data for those entities.

I have tried to call the following service, however it generates an error

service: recorder.purge
data:
  apply_filter: true
  keep_days: 7
  include:
    entities: binary_sensor.router

The error states that extra keys are not allowed @ data[‘include’]. I am not sure if this a formatting problem or I am just attempting to something in completely the wrong way.

Any assistance would be greatly appreciated.

2 Likes

You want the purge entities service: https://www.home-assistant.io/integrations/recorder/#service-purge_entities

Have a look in Developer Tools → Services for the format to use.

1 Like

Thank you for your suggestion.

I have looked at purge_entities and it doesn’t appear to have an option to retain the last seven days of data. It appears to purge all data for the selected entity.


It’s has been added.But there is no repack yet.

Did you find a way to do it?

Unfortunately no.
Documentation doesn’t provide usable example, Dev tools GUI and automation.yaml are working differently.
I gave up.