Ignore smartthings storage on fresh install (#98418)

* Ignore smartthings storage on fresh install

* Also unload existing things when going for clean install

* Rename param

* Fix tests
This commit is contained in:
Paulus Schoutsen 2023-08-14 22:39:05 -04:00 committed by GitHub
parent e3438baf49
commit ced4af1e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 7 deletions

View file

@ -50,6 +50,7 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self.installed_app_id = None
self.refresh_token = None
self.location_id = None
self.endpoints_initialized = False
async def async_step_import(self, user_input=None):
"""Occurs when a previously entry setup fails and is re-initiated."""
@ -57,7 +58,11 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_user(self, user_input=None):
"""Validate and confirm webhook setup."""
await setup_smartapp_endpoint(self.hass)
if not self.endpoints_initialized:
self.endpoints_initialized = True
await setup_smartapp_endpoint(
self.hass, len(self._async_current_entries()) == 0
)
webhook_url = get_webhook_url(self.hass)
# Abort if the webhook is invalid