Skip to content

Commit

Permalink
Increase AquaCell timeout and handle timeout exception properly (home…
Browse files Browse the repository at this point in the history
…-assistant#125263)

* Increase timeout and add handling of timeout exception

* Raise update failed instead of config entry error
  • Loading branch information
Jordi1990 authored Sep 4, 2024
1 parent 505df84 commit 199a4b7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/aquacell/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def async_step_user(
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"
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/aquacell/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def _async_update_data(self) -> 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
Expand All @@ -72,7 +72,7 @@ async def _async_update_data(self) -> 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}
Expand Down
1 change: 1 addition & 0 deletions tests/components/aquacell/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async def test_full_flow(
("exception", "error"),
[
(ApiException, "cannot_connect"),
(TimeoutError, "cannot_connect"),
(AuthenticationFailed, "invalid_auth"),
(Exception, "unknown"),
],
Expand Down

0 comments on commit 199a4b7

Please sign in to comment.