How to get rid of entities when ESPHOME config changed and an entity is no longer there?

That is something that I did not try.

It might be that ESPhome stores some info in the NVmemory on the ESP and this causes entities not to fully vanish although they are not existing in the config anymore.

I will try with one ESPhome device to completely zero out the device (need to figure how) and then program the same setup.

For what it’s worth, I seem to be having the same problem.

Status of the entity shows as ā€œunavailableā€. It’s last seen 2 days ago and can’t delete it.

Aaannnd I’m another one with the same problem. Zombie entities on two ESP devices that haven’t been in the config for a long time (multiple firmware updates and HA restarts in between), with no (simple) way to remove them from Home Assistant.

[EDIT]
Where are the contents of the ā€œdiagnostic informationā€ that you can download for an esphome device coming from? The entity that shouldn’t exist anymore is still listed in there.

1 Like

This worked for me.

  • Remove the integration from the YAML file.

  • Recompile and reload device.

  • Restart HA

I faced this issue today, and the only way to fix it was to completely remove the integration entry and add it again. Reloading, reflashing, nothing works.

@petro, you seem to be neglecting this issue. The issue clearly exists, even if it’s difficult to reproduce from scratch. Proof that there’s no such entity in the device is that the workaround above works. Otherwise, the entity would be back after integration load.

Yes, I, the guy describing how this works, am neglecting the issue.

Ok, sorry. I had the impression you were neglecting the issue by blaming the user’s ESPHome configuration.

I will write an issue against HA core once I’m able to reproduce it again. Thank you.

Fwiw, I also have this issue but only on an old input number entity. The input number is grayed out and doesn’t allow input, but shows up on the device page with its delete button grayed out in its settings.

I’ve cleaned build files, reloaded esphome integration, restarted ha/esp device, deactivated the esphome device, waited and the delete button always stays grayed out. Downloading the diagnostic data shows that the input number is still listed as an entity even though it has been deleted from the yaml for about a month, nothing uses it, it isn’t referenced anywhere in Hass and it is unusable as it’s displayed.

I have so many automations, scripts and frontend cards using the device that I absolutely do not want to delete the device and do it all over again.

From my point of view, it seems to be an esphome issue of storing the entity entry (not it’s data) somewhere in its internal state. I’m assuming the actual data is a null pntr or something as the entity itself is greyed out and unusable, but obviously something in esphome firmware is referencing it as an entry.

I just came across this topic because I was having the same issue with my old ā€œHuman Readable Uptimeā€ text sensors which I removed because I had replaced them with the new uptime timestamp sensors.

I tried everything detailed in this post and other stuff I found but unfortunately nothing worked in my case.

What actually worked was the following:

  1. Stop Home Assistant.
  2. Remove all the text_sensor occurrences from the .storage/core.entity_registry file.
  3. Remove the text_sensor dictionary or replace it with "text_sensor": [], in all the .storage/esphome.* files.
  4. Start Home Assistant.

BTW, I used the following commands to find out the affected files in the config directory:
find . -type f -exec grep -H "text_sensor" {} \;

1 Like

Nice, I’ll try this tonight. At least we know there’s a bug somewhere in esphome.

Your info sent me in the right direction. I had to edit core.device_registry, core.entity_registry and the esphome.xxxxxxxx file to remove all references to the esphome input_number. After a HASS host system reboot, I could then select the entities and the delete button was no longer greyed out! All sorted!

I have this same issue by making a switch entity internal: true.

The entity remains in HA and cannot be deleted, despite integration reloads and HA reboots.

What do…?

Just delete the esphome node and it again, profit! :rocket:

Did you delete the esphome node and at it again? :arrows_counterclockwise:

Simplest thing to do, always worked for me and doesn’t even take 30 seconds :muscle:

Nothing get’s deleted if you remove a esphome node (beside the node itself obviously!). The moment you add it again everything is (still) there - even the history. :chart_with_upwards_trend:

One if the greatest things about ESPHome is that it is hardware agnostic :trophy:

1 Like

No, I didn’t want to delete the ESPHome node because I had changed entity names, icons and other stuff and I didn’t want to loose that customization.

Thanks, this does work.

I expected deleting it to break everything else but as you mention, it doesnt. So this is a safe workaround

1 Like

I highly suggest to rather don’t have this type customization done in HA but instead use the power of ESPHome for it! :rocket:

name: My customized Temperature Name # custom name
unit_of_measurement: "°C" # custom unit
icon: "mdi:water-percent" # custom icon
accuracy_decimals: 1 # custom accuracy

That way changing a device is nothing but a 1 minute job and everything continues like you are used to. :ok_hand:

It’s truly a blessing esphome works like this, for other types of devices (matter, zigbee?) you might waste an full hour fixing the aftermath after (only) changing a device… :mantelpiece_clock:

The non-deleting entities are hitting me again.

There IS a bug in HA or ESPhome. Is there already a bug report somewhere in github?

Did you create one when I told you to back in October 2023 or did you just ignore me like usual?

Thanks for getting personal.
You where the one that always told me in the beginning that it’s my fault.
If you already mentioned to open a ticket, I missed that.

NOW i am ignoring you.

If you reread the post history, you got upset with me trying to help you and made it personal long before this reply. I was just providing information and attempted to guide you to creating an issue however you tried to claim I was blaming you for doing things wrong when I was just explaining how it currently works.

:man_shrugging:

Sorry for getting frustrated and getting personal, but this isn’t the first time you’ve gotten upset with me like this.

Yep, I replied to your post, so you got the notification.

Anyways, did some digging to see if felipecrs was able to reproduce the issue and create one, it does not look like he did. So I’d say that there is no issue for this currently. It would be great if someone could create the issue and provide all the details.