Add guard for already migrated Hue entity (#59930)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>pull/60058/head
parent
4820acb897
commit
7161a0bf2a
|
@ -147,7 +147,18 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
|
|||
ent.unique_id,
|
||||
new_unique_id,
|
||||
)
|
||||
ent_reg.async_update_entity(ent.entity_id, new_unique_id=sensor.id)
|
||||
try:
|
||||
ent_reg.async_update_entity(
|
||||
ent.entity_id, new_unique_id=sensor.id
|
||||
)
|
||||
except ValueError:
|
||||
# assume edge case where the entity was already migrated in a previous run
|
||||
# which got aborted somehow and we do not want
|
||||
# to crash the entire integration init
|
||||
LOGGER.warning(
|
||||
"Skip migration of %s because it already exists",
|
||||
ent.entity_id,
|
||||
)
|
||||
break
|
||||
|
||||
# migrate entities that are not connected to a device (groups)
|
||||
|
@ -170,5 +181,14 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
|
|||
ent.unique_id,
|
||||
new_unique_id,
|
||||
)
|
||||
ent_reg.async_update_entity(ent.entity_id, new_unique_id=new_unique_id)
|
||||
try:
|
||||
ent_reg.async_update_entity(ent.entity_id, new_unique_id=new_unique_id)
|
||||
except ValueError:
|
||||
# assume edge case where the entity was already migrated in a previous run
|
||||
# which got aborted somehow and we do not want
|
||||
# to crash the entire integration init
|
||||
LOGGER.warning(
|
||||
"Skip migration of %s because it already exists",
|
||||
ent.entity_id,
|
||||
)
|
||||
LOGGER.info("Migration of devices and entities to support API schema 2 finished")
|
||||
|
|
Loading…
Reference in New Issue