mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add guard for already migrated Hue entity (#59930)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
4820acb897
commit
7161a0bf2a
@ -147,7 +147,18 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
|
|||||||
ent.unique_id,
|
ent.unique_id,
|
||||||
new_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
|
break
|
||||||
|
|
||||||
# migrate entities that are not connected to a device (groups)
|
# 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,
|
ent.unique_id,
|
||||||
new_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")
|
LOGGER.info("Migration of devices and entities to support API schema 2 finished")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user