Handle when installed app has already been removed (#21595)
parent
18372ad81b
commit
1e60993aa7
|
@ -48,10 +48,20 @@ async def async_migrate_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||
"""
|
||||
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),
|
||||
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
|
||||
hass.async_create_task(
|
||||
hass.config_entries.async_remove(entry.entry_id))
|
||||
|
|
Loading…
Reference in New Issue