Is there a bulk delete for unavaliable entities?

ive noticed ive built up alot of unavaliable sensors that were never deleted when i removed stuff… so i manually clicking on each one and delete… but i got like hundreds so its time consumming… i did try the purge entitys in the action page and did like sensor.* and chose all the Unavailables but that didnt work either

but is there something i can just tell HA delete all Unavailables or unknowns and then it just gets recreated on its own when things come back online

i currently use the auto entities card and look for unknown and unavaliable and slowly delete one and a time

and majority of them didnt delete
as they labeled like
sensor.temperature_2
sensor.temperature_3
sensor.temperature_4

as example and really i only have
sensor.temperature
so trying to force it all delete and then whatever templates i have will re create on its own at boot up

You can go to Settings > Devices and services > Entities then use the filter at the very left of the top of the table and filter by Status > Not Provided and it’ll show you all entities no longer being provided. Then close the filter area and the next icon over is a select, you can select all from the top of the table. Next in the upper right of the screen click the 3-dot menu and the last option is Delete selected.

Edit: Sorry just caught the ‘unavailable and unknown’ part, those sensors are likely still being provided by an integration and will therefore repopulate on startup. You’d have to look into the integrations providing them.

1 Like

so i tried the devices and services as you mentioned… that didnt show any unavaliables…

when i do the auto entieis… say its for the weather. and it adds _2 _3 as example at the end… well those i have to manually remove… as i dont have a weather.example_2 and ive renamed like weather.example to weather.example_this_one and it never deleted etc… i also seen devices that no longer have an intergration like old vizio tv i had well its not part of the intergration but still in there… its like uninstalling applications in windows it always leave left over junk u gotta manually delete

is there a python script like for Set State to delete Entities that can do looks like 1000 of these unavliables and do it in a few seconds… i figure i could just delete a database too qucker and then just reboot and it be fixed but im sure not that simple lol

and usually if the intergration is still using the entities you wouldnt get the Red Delete option it be normally grayed out… till you delete a template etc to be able to get the delete option

You could try the spook integration .
It has a function to delete orphaned devices and entities.

1 Like

Not exactly the same…my HA shows 50/100 unavailable entities but 0 orphaned.
Example of my unavailable are a bunch old esphome integration entities which never went online again (esphome powered off) or a plug that I just pulled out of the wall after x-mas. The devices are stil configured but the entities are all ‘unavailable’
EDIT: I also have no (!) answer on how to solve this… the _2, _3, _4 should be resolved by the integration which should properly delete things imo

@WallyR so i did install the spook… and rebooted and did the delete all orphanes and i tried a re reboot… but it never deleted them still there still have to click each one and delete… found old Tplink switchs that ive removed or renamed… and the old names are still there orphaned but the spook didnt delete them… but rebooting the spook found bunch of other issues so maybe it will fix it once i fix those errors like groups or broken automation… and then maybe i can clean the orpaned files out but right now it cant… like my weather intergration it wont delete the orphaned
i got like 4
today_max
today_max_1
today_max_2

and wont delete them… if i could delete the database that all the enttits are in but not the settings/devices page then that be a total purge

as i hoping with all this extra junk maybe HA will boot faster too as its so slow and i figure the unavliables causes it

Sometimes we users see an entity as orphaned, but HA still have a link somehow.
Sometimes the link just have to be to the integration and not to the specific device entry in the integration, which means you might remove a TP-link switch, but if you keep the integration for another TP-link switch, then entities from the first one still have a parent entry to link to.

@WallyR
ah ok i ended up being able to delete them i think all of them i removed majority of my intergrations i ran the spooky home assistant delete orphanes… i let it sit 10 min then ran it again… waited 10 min t hen a clean reboot i ran spooky again waited 10 min and did a reboot one more time and that seemed to cleaned it… least the auto entities for unknown/ and unavailable cards i made didnt take more then a minute to generate… was quickjer and not locking up HA… they just didnt wanna delete but they out now…

i had ice storm here in ontario canada so i just got power back today from saturday so sorry for the delay

Spook can do only a limited amount, I think it stalls/breaks at 1000 but forgot.
I run it periodically via automation. However, still… lots of my unavailables are not orphaned alike what Spook detects

@vingerha

so its a good thing to run it on automation like what once a week?

ya i noticed even though i finally got the spook to delete there bunch but it doesnt stall/break at the moment cuz that was annoying and i running it as a vm so figured it be faster then a raspberry pi…
but it did help alot in the end saved me from doijng like a 1000 clicking each one and hit the delete and it locks up cuz auto entities for those unavliables… i still gota fix a few things it detects at boot up like some of my dashboards have no longer needed entities… so easy to fix… i was hoping it would boot faster but didnt see much of a boot up improvement but maybe…

but least i finding stuff i didnt know was not working right it even detects my automations with no longer used entities which is nice so i fixed that… so very handy tool even if it has a limited amount

Good to hear you worked it out.
Your manual option was not to select one nd hit delete. HA have an option for multi select and then action.
I think it is the second icon in the top bar on the overview page.

@WallyR
i dont see that option under Overiew Dashboard… all i was doing orginalyl with the auto entities click each one then goto the Settings and then click the Red Delete word if it had it enabled… and that was soooooo time consuming

but if tthere is a quicker way can you show pics… but ya least i got majority gone through spooky… but they were sure klingons they didnt wanna let go like a nasty cold lol

When I look at my overview of entities or devices (Settings → Devices & services → devices/entities), then I have a icon to the right of the filters button in the top bar.
It is an icon that consists of a square a line and then a check mark and a line.
Clicking that one will enable multi select, so you can click the different lines.
When you ar done selecting then there is a new select available at the top called action, where you can choose delete.

@WallyR ah i was looking at the overview dashboard not the entities tab under settings/devices so i did the filter for unavaliable and to select all check box and i found the 3 dots to delete… wish i had that a first… but the bunch left i see are like from templates i guess so those deletes are grayed out… but i least know how to do that in the future… and the spooky one… so i have options to de clutter… i was always thinking the developer tools/statstics page is what fixed things as it has a fix issue buttons on some

but least i know more now then i did before lol