WTH can't I delete old and unused entities?

(I think I know the answer to this one - makes re-adding stuff complicated)

But I tried to get my partner to set up a trial HA instance when I saw it was WTH month and this quickly arose - I remember the same problem when I first started.

That being said. I once re-added a mobile app and still have 66 entities there and hidden from the last one.

1 Like

All unused entities can be deleted. If they are orphaned, an delete button appears on each entity.

Also, when looking at the table/list of entities you can filter on those and multi select them, deleting them at bulk.

1 Like

@frenck How do you filter on these entities in the entities list?

I have added another question (WTH why can't we filter entities and devices lists) asking for exactly that ability.
I have several “orphaned” entities which I am unable to delete - not sure if it is maybe because they are referenced in a display somewhere so not “unused”.

From memory this was changed a few months back, so selecting an unwanted entity now results in a “This entity does not have a unique ID, therefore its settings cannot be managed from the UI. " error message. The " Customizing entities” page which is linked to the error message assumes that the entity can be edited.

I can delete the device, but the extra entities which I created with it do not get removed. Recreating the device results in multiple entities with the same name and a trailing sequence number.

So, how can we now delete unused entities ?

There are file in the config/.storage where those data are saved.
Like core.entities_registry
But handle with care!

Sadly, when I look at my file, I even see empty ‘entities’. Looks a bit messy. They should ,perhaps during startup, remove those ‘empty’ entities, and clean up that file…

Thanks Stefan,

TL;DR: I was actually creating the same entity name in 2 places.

In my /config/.storage/core.entity_registry I see only the new entities (with entity_id has a _2 suffix), but not the other entries.

      {
        "aliases": [],
        "area_id": null,
        "capabilities": null,
        "config_entry_id": "cbf83fc72f1d75101383cb5411318600",
        "device_class": null,
        "device_id": "7efcf2c32fdd50b5a981310fd7c1fcc8",
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "sensor.pc191ha_107_voltage_2",
        "hidden_by": null,
        "icon": null,
        "id": "2bf39d2f06251d05adc8bb99afb86b1c",
        "has_entity_name": false,
        "name": null,
        "options": {},
        "original_device_class": "voltage",
        "original_icon": null,
        "original_name": "pc191ha-107_voltage",
        "platform": "localtuya",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "local_7lmHRoyxlLzIeXTRCFo8_20",
        "unit_of_measurement": "V"
      },
      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "options": [
            "on",
            "off",
            "memory"
          ]
        },

Are you perhaps thinking of the “deleted_devices” section in core.device_registry ?

DOH !!! bangs head !

I can’t delete the entities, because they are created in configuration.yaml ! I followed the instructions in LocalTuya integration documentation for creating sensors from the attributes returned by the switch, like so …

      #  
      pc191ha_107_voltage:
        value_template: >-
          {{ float(state_attr('switch.pc191ha_107', 'voltage') | default(0, true)) }}
        unit_of_measurement: 'V'
      pc191ha_107_current:
        value_template: >-
          {{ float(state_attr('switch.pc191ha_107', 'current') | default(0, true)) }}
        unit_of_measurement: 'mA'
      pc191ha_107_current_consumption:
        value_template: >-
          {{ float(state_attr('switch.pc191ha_107', 'current_consumption') | default(0, true)) / 1000 | round(1) }}
        unit_of_measurement: 'W'

For a while i was also adding number entities for current, voltage when adding the device in the LocalTuya integration.

And I just discovered that the localTuya Integration now allows adding “sensor” entities when creating the device … so guess what I was trying (without commenting out the section in configuration.yaml).

1 Like

@frenck - I know this thread is a bit old, but for me this is a never-ending-chain of frustration that orphaned entities often cannot be deleted in a orderly manner.
I have several entities listed in the ZHA integration that are orphaned. Reloading the integration or restarting HA doesn’t remove them. If I select them and choose delete, it just tells me:

You can only delete 0 of the 8 entities. The others require the integration to stop providing them, and sometimes a Home Assistant restart is needed.

And do not know how to make ZHA stop providing these entities. The device they once belonged to is long gone, so what can I do?

(BTW - I’m on HAOS 2024.10)