mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Drop < 0.97 Huawei LTE sensor unique id migration workaround (#29060)
This commit is contained in:
parent
9dc63419c4
commit
f504ac8c65
@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
|
|||||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
DEVICE_CLASS_SIGNAL_STRENGTH,
|
||||||
DOMAIN as SENSOR_DOMAIN,
|
DOMAIN as SENSOR_DOMAIN,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import entity_registry
|
|
||||||
|
|
||||||
from . import HuaweiLteBaseEntity
|
from . import HuaweiLteBaseEntity
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -170,23 +169,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
HuaweiLteSensor(router, key, item, SENSOR_META.get((key, item), {}))
|
HuaweiLteSensor(router, key, item, SENSOR_META.get((key, item), {}))
|
||||||
)
|
)
|
||||||
|
|
||||||
# Pre-0.97 unique id migration. Old ones used the device serial number
|
|
||||||
# (see comments in HuaweiLteData._setup_lte for more info), as well as
|
|
||||||
# had a bug that joined the path str with periods, not the path components,
|
|
||||||
# resulting e.g. *_device_signal.sinr to end up as
|
|
||||||
# *_d.e.v.i.c.e._.s.i.g.n.a.l...s.i.n.r
|
|
||||||
entreg = await entity_registry.async_get_registry(hass)
|
|
||||||
for entid, ent in entreg.entities.items():
|
|
||||||
if ent.platform != DOMAIN:
|
|
||||||
continue
|
|
||||||
for sensor in sensors:
|
|
||||||
oldsuf = ".".join(f"{sensor.key}.{sensor.item}")
|
|
||||||
if ent.unique_id.endswith(f"_{oldsuf}"):
|
|
||||||
entreg.async_update_entity(entid, new_unique_id=sensor.unique_id)
|
|
||||||
_LOGGER.debug(
|
|
||||||
"Updated entity %s unique id to %s", entid, sensor.unique_id
|
|
||||||
)
|
|
||||||
|
|
||||||
async_add_entities(sensors, True)
|
async_add_entities(sensors, True)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user