Hello,
I had a running ESPHome - HomeAssistant configuration where ESPHome reads a dallas temparature sensor and the resulting graph is shown in Home Assistant.
Unfortunately, the sensor died and only sends a constant value. Thus I tried to replace the sensor.
But whatever I do, Home Assistant always creates a new entity.
So the original sensor had entity ID
sensor.temperature_1
The new sensor has now entity ID
sensor.temperature_1_1
How do I configure ESPHome/Home Assistant in a way, that replacing a sensor does not change the entity ID on Home Assistant side.
Yes, I did restart the whole home assistant server.
Uh, when I reviewed the settings on Home Assistant side for answering your question, I found some thing strange. I can see the following thing on Home Assistant Entity table:
The new sensor has following settings:
Name: Temperatur Wärmespeicher 1
Entity ID: sensor.temperatur_warmespeicher_1
Status: -
I can see current sensor data when opening this entity
The old sensor has following settings:
Name: Temperatur Wärmespeicher 1
Entity ID: sensor.temperatur_warmwasser_1
Status: -
I can not see any data when opening the entity. It only shows “This entity is not available”
So the entity ID is different for both. So when looking to my ESPHome sensor config, one sensor takes the sensor name as entity id, the other takes a part of the sensor id.
So I’m just wondering if I have messed up something when developing the ESPHome sensor script. And how Home Assistant identifies a sensor.
My main goal is, when changing a hardware sensor, I do not want to have a new entity ID in Home Assistant, so that a sensor replacement does never change the entity where the data are log. So I would have one graph showing the original data from the old sensor and then continues showing the data of the new sensor.
So what attributes finally identifies a sensor to Home Assistant? Is is the name or the id of a dallas sensor?
There may have been a change in how ESPHome creates the entity_id from the sensors. I’m not sure of that but I can see that happening with the way HA wants to change things like that. But it could very well also be a change in your ESPHome config (tho it doesn’t sound like it from your description).
If you open the settings of the old entity and open the advanced drop down at the bottom does it not offer an option to delete the entity?
if so then you can delete it there and then rename the new entity_id to the same as the old entity_id.
If something such as this happens (entity name extended by a “_1” because of the name aready did exist I do it this way.
Settings > Devices&Services > Entites
remove the old entry which is very likely unknown or missing or such like and therefore can be removed/deleted.
Then click onto the one with the unwanted “_1” at it’s end and simply rename the entity_id in the opened window (settings tab) by removing the “_1”. Press update and that’s it.
2 things to consider:
first keep Ronnies hint in mind, each Dallas got a unique id
second … keep yourself from defining names ending with “_1”
Simply because HA adds a “_1” if not being able to use the defined name if already being taken.
And it gets pretty hard to find out which one ought to end with _1 and which one accidently was given the _1 by HA.