Increase AquaCell timeout and handle timeout exception properly (#125263)
* Increase timeout and add handling of timeout exception * Raise update failed instead of config entry errorpull/125420/head
parent
84c204a7b3
commit
5c2073481d
|
@ -56,7 +56,7 @@ class AquaCellConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
refresh_token = await api.authenticate(
|
||||
user_input[CONF_EMAIL], user_input[CONF_PASSWORD]
|
||||
)
|
||||
except ApiException:
|
||||
except (ApiException, TimeoutError):
|
||||
errors["base"] = "cannot_connect"
|
||||
except AuthenticationFailed:
|
||||
errors["base"] = "invalid_auth"
|
||||
|
|
|
@ -56,7 +56,7 @@ class AquacellCoordinator(DataUpdateCoordinator[dict[str, Softener]]):
|
|||
so entities can quickly look up their data.
|
||||
"""
|
||||
|
||||
async with asyncio.timeout(10):
|
||||
async with asyncio.timeout(30):
|
||||
# Check if the refresh token is expired
|
||||
expiry_time = (
|
||||
self.refresh_token_creation_time
|
||||
|
@ -72,7 +72,7 @@ class AquacellCoordinator(DataUpdateCoordinator[dict[str, Softener]]):
|
|||
softeners = await self.aquacell_api.get_all_softeners()
|
||||
except AuthenticationFailed as err:
|
||||
raise ConfigEntryError from err
|
||||
except AquacellApiException as err:
|
||||
except (AquacellApiException, TimeoutError) as err:
|
||||
raise UpdateFailed(f"Error communicating with API: {err}") from err
|
||||
|
||||
return {softener.dsn: softener for softener in softeners}
|
||||
|
|
|
@ -79,6 +79,7 @@ async def test_full_flow(
|
|||
("exception", "error"),
|
||||
[
|
||||
(ApiException, "cannot_connect"),
|
||||
(TimeoutError, "cannot_connect"),
|
||||
(AuthenticationFailed, "invalid_auth"),
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue