From 57bd8a7a4a2416c92f5faf20700ae96ccc70a04a Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Mon, 17 Jan 2022 19:38:19 +0200 Subject: [PATCH] Fix webostv YAML migration failure if the entity is removed (#64290) * Fix webostv YAML migration failure if the entity is removed * Update homeassistant/components/webostv/__init__.py Co-authored-by: Martin Hjelmare * use new entity_id for unique_id update Co-authored-by: Martin Hjelmare --- homeassistant/components/webostv/__init__.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/webostv/__init__.py b/homeassistant/components/webostv/__init__.py index d5335c4fdcd..634dca3b48c 100644 --- a/homeassistant/components/webostv/__init__.py +++ b/homeassistant/components/webostv/__init__.py @@ -166,8 +166,20 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: else: break + ent_reg = entity_registry.async_get(hass) + if not ( + new_entity_id := ent_reg.async_get_entity_id( + Platform.MEDIA_PLAYER, DOMAIN, key + ) + ): + _LOGGER.debug( + "Not updating webOSTV Smart TV entity %s unique_id, entity missing", + entity_id, + ) + return + uuid = client.hello_info["deviceUUID"] - ent_reg.async_update_entity(entity_id, new_unique_id=uuid) + ent_reg.async_update_entity(new_entity_id, new_unique_id=uuid) await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT},