Ensure powerview setup is retried on 502 error (#59847)

This commit is contained in:
J. Nick Koston 2021-11-18 09:57:31 -06:00 committed by GitHub
parent a211b8ca8f
commit cc3f179796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -89,12 +89,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
(await shades.get_resources())[SHADE_DATA]
)
except HUB_EXCEPTIONS as err:
_LOGGER.error("Connection error to PowerView hub: %s", hub_address)
raise ConfigEntryNotReady from err
raise ConfigEntryNotReady(
f"Connection error to PowerView hub: {hub_address}: {err}"
) from err
if not device_info:
_LOGGER.error("Unable to initialize PowerView hub: %s", hub_address)
raise ConfigEntryNotReady
raise ConfigEntryNotReady(f"Unable to initialize PowerView hub: {hub_address}")
async def async_update_data():
"""Fetch data from shade endpoint."""

View File

@ -3,7 +3,7 @@
import asyncio
from aiohttp.client_exceptions import ServerDisconnectedError
from aiopvapi.helpers.aiorequest import PvApiConnectionError
from aiopvapi.helpers.aiorequest import PvApiConnectionError, PvApiResponseStatusError
DOMAIN = "hunterdouglas_powerview"
@ -62,7 +62,12 @@ PV_SHADE_DATA = "pv_shade_data"
PV_ROOM_DATA = "pv_room_data"
COORDINATOR = "coordinator"
HUB_EXCEPTIONS = (ServerDisconnectedError, asyncio.TimeoutError, PvApiConnectionError)
HUB_EXCEPTIONS = (
ServerDisconnectedError,
asyncio.TimeoutError,
PvApiConnectionError,
PvApiResponseStatusError,
)
LEGACY_DEVICE_SUB_REVISION = 1
LEGACY_DEVICE_REVISION = 0