Unique id change resulting in lost sensor


I have always used unique_id:s with my sensor name as id, but yesterday I was enlighted by a video that visual studio code can generate those id:s randomly, any it is probably the correct way to do it.

Now that I have changed all of my unique id:s to random generated ones via VSC, the sensor values are lost in HA. Any way to edit registry or what else to do? Revert to my unique_id with sensor names…?

Restore your last snapshot backup.

Thanks, I know, but are there any way to stick with the random unique_id:s?

Solved! By changing unique id:s there are a duplicate sensor with generated in core.entity_registry, by deleting the 2:nd sensor everything works.

Now I have to plow through the registry and do all the deletings.


You appear to have created “busy work” for yourself in the interests of following some video’s questionable advice.

The only requirement for a unique_id is that it be unique. The same is true for entity_id. If you base the unique_id on the entity_id, mission accomplished.

Beyond that, unique_id isn’t used anywhere except by Home Assistant for housekeeping purposes so the appearance of its value is unimportant. If some are random numbers, and/or random strings, and/or based on entity_id, it doesn’t matter at all, as long as they are individually unique; none is “more correct” than the other.