Delete all orphaned entities not working
What version of Spook are you using?
v3.1.0
What version of Home Assistant are you using?
2024.8.3
The problem
Hi, Action > "Home Assistant Core Integration: List all orphaned database entities 👻" Give me 185 entites :
` count: 185 entities:
- button.withee_reinitialiser_le_filtre
- sensor.withee_surface_du_nettoyage_courant
- sensor.tasmota_last_restart_time
- time.withee_fin_npd
- switch.withee_child_lock
- sensor.omg_esp32_ble_sys_ip
- sensor.withee_temps_de_sechage_de_la_serpilliere_restant
- cover.esprts_test_cover
- binary_sensor.withee_penurie_d_eau
- switch.withee_ne_pas_deranger
`
When i use : "Home Assistant Core Integration: Delete all orphaned entities 👻" action is OK I restart many time, but entities are still here
Anything in the logs? Paste it here!
No response
I am experiencing the same thing. I just installed spooky for the first time for this reason specifically. Sad to see it isn't working.
Agreed, it has no effect here.
yes, same for me. Trying to delete 770 orphaned entities but nothing happens.
I came here with the same issue:
The action homeassistant.delete_all_orphaned_entities does not delete the entities listed from action homeassistant.list_orphaned_database_entities.
However the script example here: https://spook.boo/entities (find it under: "Script to remove entities from database") works perfectly for me.
I came here with the same issue:
The action
homeassistant.delete_all_orphaned_entitiesdoes not delete the entities listed from actionhomeassistant.list_orphaned_database_entities.However the script example here: https://spook.boo/entities (find it under: "Script to remove entities from database") works perfectly for me.
I tried the script. I first had to reduce the number of entities it was trying to use because the template size was too large. At 1000 entities at a time I received no error but nothing happened. At 100 entities it worked... until I'd gone through about 700 entities and then it too stopped working.
That makes me think that whatever is making it fail silently (maybe a problem removing a particular entity) is also causing the delete orphaned entities action to fail silently.
Edit: I take that back as I was eventually able to remove all the orphaned entities. But it took many multiple passes over the same entities.
I'm having the same exact issues as above; tried running the script but it doesn't seem to be doing anything.
Home Assistant Versions
- Core
- 2024.11.1
- Supervisor
- 2024.11.2
- Operating System
- 13.2
- Frontend
- 20241106.2
the script contains
action: recorder.purge_entities
which is a very time consuming action. Allow it to run for several minutes, in big data bases even hours.
Can someone confirm if the action works, but perhaps takes some time? Wondering if I need to manually make a script or not...
Thanks :)
I believe the action is in fact broken. I didn't have that many orphaned entities, only 165, but the delete all orphaned entities action still did nothing. But getting the list and then calling recorder.purge_entities on that list myself worked fine.
Sorry, this seems to be working fine
This action does: Home Assistant Core Integration: List all orphaned database entities 👻
It does not clean up orphaned entities, it cleans up history.
../Frenck
I think there may be a misunderstanding, the original issue is about the action "Home Assistant Core Integration: Delete all orphaned entities 👻" not the list action.
Agreed: homeassistant.delete_all_orphaned_entities doesn't delete any entities. Would be surprised if that's expected behavior.
@frenck Could you clarify the intended behavior of "Home Assistant Core Integration: Delete all orphaned entities 👻"? I'm wondering if the original issue was misread because the poster started by mentioning the "List all" action. However, that was only because they were using that to show that the "Delete all" was not working.
The documentation says that the "Delete all action does the following":
Mass clean up your Home Assistant by deleting all orphaned entities in one go.
Orphaned entities are entities that are no longer claimed by an integration. This can happen when an integration is removed or when an integration is no longer working. Home Assistant considers an entity only orphaned if it has been unclaimed since the last restart of Home Assistant.
The poster was using the "List all orphaned" action to show that "Delete all orphaned" was not deleting the orphaned entities
This issue is mixing up the state machine/registries and database. Those are different things.
If you don't understand the difference between these two methods, you probably shouldn't use them.
../Frenck
Then I suppose this is a documentation issue. I know for my part, I follow these steps:
- Run the action
homeassistant.list_orphaned_database_entitiesand note entities in the list - Try running
homeassistant.delete_all_orphaned_entities - Run
homeassistant.list_orphaned_database_entitiesagain and compare the results
And in step 3 I get the same entities I got in step 1. Restarting Home Assistant doesn't help. I run the script to remove entities here and then run step 1 and the entities are gone.
I'm assuming based on your abrupt message above this means homeassistant.list_orphaned_database_entities operates on the database and homeassistant.delete_all_orphaned_entities only operates on the state machine/registries. The documentation does not state that these actions are so limited and probably should clarify this distinction if you'd like your users to know about these limitations.
@ejpenney
Thank you for this. Same exact issue here. I was trying to clean up orphaned entities and getting the same results as you.
I'd agree this is a documentation issue if "delete all orphaned entities" doesn't actually do that.
For anyone else struggling with this, once you've used the "list_orphaned_database_entries" to ensure you do indeed want to delete everything it returns, create a script with the following YAML and run it.
alias: Delete orphaned database entities
sequence:
- action: homeassistant.list_orphaned_database_entities
response_variable: orphaned
- action: recorder.purge_entities
target:
entity_id: |
{{ orphaned.entities }}
data:
keep_days: 0
mode: single
from: https://spook.boo/entities/#list-all-orphaned-database-entities - under "Script to remove entities from database"
@ejpenney For anyone else struggling with this, once you've used the "list_orphaned_database_entries" to ensure you do indeed want to delete everything it returns, create a script with the following YAML and run it.
Thank you, this script ends with this error on my side:
template: Template output exceeded maximum size of 262144 characters
So, question is, how to limit the output of the first action?