---
title: "Find and remove unavailable entities"
description: "How to find the unavailable entities in Home Assistant, delete the ones no integration provides anymore, and clean up what still used them."
canonical_url: "https://spook.boo/remove-unavailable-entities"
---
# Find and remove unavailable entities

> How to find the unavailable entities in Home Assistant, delete the ones no integration provides anymore, and clean up what still used them.

In Home Assistant, go to **Settings** > **Devices & services** > **Entities**, filter on the status **Not provided** only, select them all, and choose **Delete selected**. Those are the entities no integration provides anymore. Check first that all your integrations started: one that failed leaves its entities looking not provided too. An entity that is only **Unavailable** still belongs to a working integration: bring its device back, or delete the device.

Spook adds an action that deletes every entity that is no longer provided in one go, a repair for the entities a removed custom integration left behind, and repairs that tell you which automations, scripts and dashboards still use what you deleted.

## Unavailable, or no longer provided?

Home Assistant has two kinds of unavailable entity. Only one of them can be deleted.

- **Unavailable.** The integration still has the entity, but cannot reach the device right now. A dead battery, a plug somebody pulled out, a lamp switched off at the wall. When the device comes back, so does the entity. Delete it, and the integration adds it straight back.
- **Not provided.** No integration provides the entity anymore. The device was removed or replaced, or the integration stopped making that entity after an update. Home Assistant keeps the entity and its settings, in case it comes back. Open one, and it says: "This entity is no longer being provided by the ... integration. If the entity is no longer in use, delete it in settings."

![A garage door contact that no integration provides anymore, opened, with Home Assistant's message that it is no longer being provided by the garage_sensors integration.](https://spook.boo/images/screenshots/en/light/entity-not-provided.webp)

An entity nothing provides anymore. Its state says unavailable, the message says why.

The second kind is what piles up over the years. Those are the ones to remove.

## Find unavailable entities

1. Go to **Settings** > **Devices & services**, and open the **Entities** tab. Or use this button:<br>[![Open your Home Assistant instance and show your entities.](https://my.home-assistant.io/badges/entities.svg)](https://my.home-assistant.io/redirect/entities/)
2. Select **Filters**, and open **Status**.
3. Clear **Enabled**. Home Assistant ticks it by default, and it keeps every other entity in the list.
4. Pick **Not provided** for the entities no integration provides anymore. Pick **Unavailable** for every entity that cannot be reached right now.

Rather have a list? Go to **Settings** > Tools > **Template**, and paste one of these.

Every entity that is unavailable right now:

```jinja
{{ states | selectattr('state', 'eq', 'unavailable') | map(attribute='entity_id') | list }}
```

Only the ones no integration provides anymore:

```jinja
{{ states | selectattr('attributes.restored', 'defined') | map(attribute='entity_id') | list }}
```

Disabled entities are in neither list. They have no state at all, so they are not unavailable either.

Lots of unavailable entities of one device? Then it is the device that is gone, not the entities. Spook's [unavailable devices card](https://spook.boo/unavailable-devices-card) lists those, one row per device, longest gone first.

## Delete entities that are no longer provided

Check **Settings** > **Devices & services** first. An integration that failed to start leaves all of its entities looking not provided, while nothing is wrong with them. Fix or reload that integration before you delete anything.

1. In the **Entities** tab, filter on **Not provided** only, like above.
2. Select **Enter selection mode**, and then the box at the top of the list. That selects them all.
3. Open the menu with the three dots, and select **Delete selected**.
4. Confirm.

![The entities page filtered on Not provided, with three garage sensors selected and Delete selected ringed in the menu.](https://spook.boo/images/screenshots/en/light/entities-not-provided.webp)

Filtered on **Not provided**, all selected, and **Delete selected** in the menu.

Home Assistant only deletes what it can: entities no integration provides, and helpers you made in the UI. Anything else in the selection stays, and it tells you how many it can delete. Filtered on **Not provided**, that is everything you selected.

## Entities of a custom integration you removed

Take a custom integration out of `custom_components`, and its entities stay behind, not provided, for good. Nothing in Home Assistant points them out.

Spook does. It raises the [Entities of an unknown integration](https://spook.boo/homeassistant#entities-of-an-unknown-integration) repair, with the entities the missing integration left behind. Still using it? Install it again. Done with it? Delete those entities, like above.

Set the integration up in the UI? Then its entry stays behind on the integrations page too, and the repair leaves its entities to that entry. Delete the entry, and its entities go with it.

![The Entities of an unknown integration repair for garage_sensors, listing the three entities it left behind.](https://spook.boo/images/screenshots/en/light/repair-unknown-integration-entities.webp)

The repair names the integration Home Assistant cannot find, and what it left behind.

## Delete all unavailable entities at once

Spook adds the [Delete all orphaned entities](https://spook.boo/entities#delete-all-orphaned-entities) action: `homeassistant.delete_all_orphaned_entities`. It deletes every entity that is no longer provided, in one go, from a script or an automation. Same rule as the button in Home Assistant: an entity that is only unavailable stays. A disabled entity stays too, as it has no state to go by.

```yaml
action: homeassistant.delete_all_orphaned_entities
```

To run it once:

1. Make sure every integration you care about is running. Check **Settings** > **Devices & services** for one that failed to load.
2. [Open the action in your Home Assistant](https://my.home-assistant.io/redirect/developer_call_service/?service=homeassistant.delete_all_orphaned_entities).
3. Select **Perform action**.

There is no undo, and no list to check first. Put it in an automation that runs on a schedule only if all your integrations start reliably. One that fails at the wrong moment takes its entities with it.

![The Actions tool with Delete all orphaned entities 👻 picked, ready to run.](https://spook.boo/images/screenshots/en/light/action-homeassistant-delete-all-orphaned-entities.webp)

**Delete all orphaned entities** in the Actions tool. There is nothing to fill in.

## When the entity is still provided

An entity that is unavailable, and not marked as not provided, cannot be deleted on its own. The integration would add it back. Three ways out:

- **The device is gone for good.** Open the device, and select **Delete** in its menu. Not every integration offers that. When it does not, the integration's own documentation says how to remove a device, often in the app of the device's maker.
- **The whole integration is gone.** Delete the integration entry under **Settings** > **Devices & services**. Its devices and entities go with it.
- **It is off on purpose.** A Christmas tree in July. Disable the device or the entity instead. Home Assistant stops tracking it, and it no longer shows up as unavailable. Need that from an automation? [Spook's actions](https://spook.boo/entities#disable-an-entity) do it.

## Check what still used them

Deleting an entity does not change the automations, scripts and dashboards that used it. Home Assistant runs them without complaining, and the step with the missing entity does nothing.

Spook notices. Every automation, script, scene and dashboard that refers to an entity that no longer exists gets a repair in your repairs dashboard, like [Unknown referenced entities](https://spook.boo/automation#unknown-referenced-entities). Open it, and it shows what is missing and where. New to repairs? [Fix your first repair](https://spook.boo/fix-your-first-repair) walks you through one.

## Clear their history

A deleted entity leaves its history behind in the database. That history does nothing for you anymore, and takes up space.

- **Long-term statistics.** Spook raises the [Orphaned long-term statistics](https://spook.boo/recorder#orphaned-long-term-statistics) repair for statistics no entity belongs to anymore, and clears them for you from the repair.
- **Recorded states.** The [List all orphaned database entities](https://spook.boo/entities#list-all-orphaned-database-entities) action, `homeassistant.list_orphaned_database_entities`, lists every entity the database still holds history for, and that has no state right now. Its page has a script that purges that history right after. That list also holds entities that are only disabled, and those of an integration that did not start. Check it before you purge: there is no undo.

## Know when something drops off

Cleaning up once is good. Hearing about it when it happens is better.

- The [unavailable devices card and badge](https://spook.boo/unavailable-devices-card) show the devices that dropped off, on your dashboard, and are gone when everything is there.
- The [Entity came back](https://spook.boo/other-features#entity-came-back) trigger, `spook.recovered`, fires when an entity returns after a real absence. The [Entity fell silent](https://spook.boo/other-features#entity-fell-silent) trigger, `spook.stale`, catches the sensor that stopped reporting without ever going unavailable.


## Sitemap

See the full [sitemap](https://spook.boo/sitemap.md) for all pages.
