Open lichtteil opened 3 years ago
At the moment i don't know how this can be done automated. Homeassistant saves all registered entitys in _"/config/.storage/core.entityregistry". With this change in the unique ID a new entry per sensor will be generated with a different unique_id (HA thinks this will be a new entry, while the old entry is orphaned)
e. g. Entry for temperature with old unique_id format (my sensor is called airdata)
{ "entity_id": "sensor.airdata_humidity", "config_entry_id": null, "device_id": null, "area_id": null, "unique_id": "airdata Humidity", "platform": "local_luftdaten", "name": null, "icon": null, "disabled_by": null, "capabilities": null, "supported_features": 0, "device_class": "humidity", "unit_of_measurement": "%", "original_name": "airdata Humidity", "original_icon": null }
After the update the new entry would look like this:
{ "entity_id": "sensor.airdata_humidity_2", "config_entry_id": null, "device_id": null, "area_id": null, "unique_id": "airdata-BME280_humidity", "platform": "local_luftdaten", "name": null, "icon": null, "disabled_by": null, "capabilities": null, "supported_features": 0, "device_class": "humidity", "unit_of_measurement": "%", "original_name": "airdata Humidity", "original_icon": null }
Alternatively you could edit _"/config/.storage/core.entityregistry" but i think this is a bad idea to directly edit a HA file... This i haven't tested and would be a hassle for the most users
With e13069a84eb7d6778a8bae674e450736285b8c2c we introduced a new way of building the unique entity id. To prevent errors and confusion when updating component we need to add either a BIG warning and explanation or better a migration function that takes care of old entity IDs. Maybe we can set the new unique ID and at the same time use the existing ID as a customizer option of the entity.
@JoachimEngelmann do you have any idea on how we could do this? I was reading about the Hass entity registry but I'm a bit lost.