Update Daikin config_flow with better error handling (#57069)
This commit is contained in:
parent
222a0c26e0
commit
a809f5fcf7
4 changed files with 27 additions and 13 deletions
|
@ -75,7 +75,8 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
uuid=uuid,
|
||||
password=password,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
except (asyncio.TimeoutError, ClientError):
|
||||
self.host = None
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=self.schema,
|
||||
|
@ -87,13 +88,6 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
data_schema=self.schema,
|
||||
errors={"base": "invalid_auth"},
|
||||
)
|
||||
except ClientError:
|
||||
_LOGGER.exception("ClientError")
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=self.schema,
|
||||
errors={"base": "unknown"},
|
||||
)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
_LOGGER.exception("Unexpected error creating device")
|
||||
return self.async_show_form(
|
||||
|
@ -109,6 +103,13 @@ class FlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""User initiated config flow."""
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="user", data_schema=self.schema)
|
||||
if user_input.get(CONF_API_KEY) and user_input.get(CONF_PASSWORD):
|
||||
self.host = user_input.get(CONF_HOST)
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=self.schema,
|
||||
errors={"base": "api_password"},
|
||||
)
|
||||
return await self._create_device(
|
||||
user_input[CONF_HOST],
|
||||
user_input.get(CONF_API_KEY),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue