mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Handle when installed app has already been removed (#21595)
This commit is contained in:
parent
18372ad81b
commit
1e60993aa7
@ -48,10 +48,20 @@ async def async_migrate_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||||||
"""
|
"""
|
||||||
from pysmartthings import SmartThings
|
from pysmartthings import SmartThings
|
||||||
|
|
||||||
# Delete the installed app
|
# Remove the installed_app, which if already removed raises a 403 error.
|
||||||
api = SmartThings(async_get_clientsession(hass),
|
api = SmartThings(async_get_clientsession(hass),
|
||||||
entry.data[CONF_ACCESS_TOKEN])
|
entry.data[CONF_ACCESS_TOKEN])
|
||||||
await api.delete_installed_app(entry.data[CONF_INSTALLED_APP_ID])
|
installed_app_id = entry.data[CONF_INSTALLED_APP_ID]
|
||||||
|
try:
|
||||||
|
await api.delete_installed_app(installed_app_id)
|
||||||
|
except ClientResponseError as ex:
|
||||||
|
if ex.status == 403:
|
||||||
|
_LOGGER.exception("Installed app %s has already been removed",
|
||||||
|
installed_app_id)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
_LOGGER.debug("Removed installed app %s", installed_app_id)
|
||||||
|
|
||||||
# Delete the entry
|
# Delete the entry
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_remove(entry.entry_id))
|
hass.config_entries.async_remove(entry.entry_id))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user