Recreate iaqualink httpx client upon service exception (#89341)

This commit is contained in:
Florent Thoumie 2023-03-08 06:37:24 -08:00 committed by GitHub
parent 5374c70c97
commit 2ec78ae70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View file

@ -153,6 +153,7 @@ async def async_setup_entry( # noqa: C901
system.serial,
svc_exception,
)
await system.aqualink.close()
else:
cur = system.online
if cur and not prev:

View file

@ -3,6 +3,7 @@ from __future__ import annotations
from collections.abc import Awaitable
import httpx
from iaqualink.exception import AqualinkServiceException
from homeassistant.exceptions import HomeAssistantError
@ -12,5 +13,5 @@ async def await_or_reraise(awaitable: Awaitable) -> None:
"""Execute API call while catching service exceptions."""
try:
await awaitable
except AqualinkServiceException as svc_exception:
except (AqualinkServiceException, httpx.HTTPError) as svc_exception:
raise HomeAssistantError(f"Aqualink error: {svc_exception}") from svc_exception