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:

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: