How to delete sensor entity that was defined in the configuration.yaml before?

I was playing around for a bit with the configuration.yaml and created some custom sensors. After i removed them from the configuration.yaml they are still listed as entities. I cannot delete them, because they are marked as read only. What did I do wrong?

1 Like

Did you reload the configuration or restarted HA?

In my case, I did both.
It is a template fan.

Giving the sensors a unique_id resolved the problem, after that you are able to delete them.

2 Likes

Hi. Can you explain the steps to add a unique_id to sensors in the configuration.yaml file. I am trying to use the EyezON integration and am unable to delete sensors once they are created.

1 Like

Would indeed be nice if you would share a how to. And not only ask for help and not providing it.

1 Like

I would like to know this as well. I was trying to debug an issue and had to set up a duplicate sensor in yaml and now I see no way to delete it. It also has a different ID, and there is still no option to delete. It’s just a dead entity in home assistant.

It might not be “dead” if you have any “references” to it, in i.e scripts/automations/ Cards in your UI !

I figured it out.

It is mostly as simple as what DeepHyperspace said, but there are crucial steps that were not clear.

You do need to add “unique_id” along with the “device_id” of the sensor you want to remove to your sensor yaml. Then restart Home Assistant. When you click the settings gear of the sensor entity, you will notice it allows you to name your entity and also set the room. But you will also notice that a Delete button shows up, but it is grayed out. This is because the sensor is managed in yaml. But apparently the unique_id field also partially registers the entity in the Home Assistant database as a proper entity instance with supporting properties. So next step is now to again remove that sensor from the yaml and restart Home Assistant again. Now when search for the entity, you will see an error that entity is not found, but if you open up the settings of the entity, the Delete button is now available and can be clicked to delete the offending entity from Home Assistant.

Totally intuitive, I know.

Cheers!

3 Likes