Recorder.purge_entities removed entities I didn't want to be removed

Why recorder.purge_entities service run against only one of the devices removed states of all other devices?

I have installed a Solarman integration and wanted to purge entities created by it. So I went to Developer Tools > Services, chose Recorder: Purge entities and picked up Solarman integration in the blue Device picker.

Called the service and also states of all of my other devices got purged. There is no history for any entity, only long term statistics for those ones where statistics should be maintained is available.

Yaml of my service call is below.

service: recorder.purge_entities
data:
  domains: []
  entity_globs: []
  keep_days: 0
target:
  device_id: af176ba74178560e3328f5516c008e2a

What have I done wrong?

You specified a device_id. That is not one of entity_id, domains or entity_globs, so all entities were purged as per the documentation:

https://www.home-assistant.io/integrations/recorder/#service-purge_entities

Tom, Your help on the forum is absolutely invaluable :slight_smile:
Thank’s a lot.

Note: The entity_id is only optional when used in automations.yaml or scripts.yaml . When using the UI to call this service then it is mandatory to specify at least one entity_id using the Target Picker or via YAML mode.

So UI prevents me from purging all entities incidentally, unless I pick up a random Device (and leave Entity and Domains data fields empty expecting to purge all Entities and Domains but in the scope of this Device only).
Then UI allows me to call recorder.purge_entities and unconsciously purge all entities.

Or I am missing something again?

Yeah I don’t think the UI should allow you to select a device id. Only an entity ID, domain or entity_glob (issue). Or it should support device_ids as well (feature request).

You should report the new issue here:

I have added an issue:

2 Likes