diff --git a/homeassistant/components/hunterdouglas_powerview/__init__.py b/homeassistant/components/hunterdouglas_powerview/__init__.py index 3df895c94ce..3f78726bf30 100644 --- a/homeassistant/components/hunterdouglas_powerview/__init__.py +++ b/homeassistant/components/hunterdouglas_powerview/__init__.py @@ -112,22 +112,30 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): try: async with async_timeout.timeout(10): device_info = await async_get_device_info(pv_request) + + async with async_timeout.timeout(10): + rooms = Rooms(pv_request) + room_data = _async_map_data_by_id((await rooms.get_resources())[ROOM_DATA]) + + async with async_timeout.timeout(10): + scenes = Scenes(pv_request) + scene_data = _async_map_data_by_id( + (await scenes.get_resources())[SCENE_DATA] + ) + + async with async_timeout.timeout(10): + shades = Shades(pv_request) + shade_data = _async_map_data_by_id( + (await shades.get_resources())[SHADE_DATA] + ) except HUB_EXCEPTIONS: _LOGGER.error("Connection error to PowerView hub: %s", hub_address) raise ConfigEntryNotReady + if not device_info: _LOGGER.error("Unable to initialize PowerView hub: %s", hub_address) raise ConfigEntryNotReady - rooms = Rooms(pv_request) - room_data = _async_map_data_by_id((await rooms.get_resources())[ROOM_DATA]) - - scenes = Scenes(pv_request) - scene_data = _async_map_data_by_id((await scenes.get_resources())[SCENE_DATA]) - - shades = Shades(pv_request) - shade_data = _async_map_data_by_id((await shades.get_resources())[SHADE_DATA]) - async def async_update_data(): """Fetch data from shade endpoint.""" async with async_timeout.timeout(10): diff --git a/homeassistant/components/hunterdouglas_powerview/const.py b/homeassistant/components/hunterdouglas_powerview/const.py index e69fe319c0f..e83a9d8945b 100644 --- a/homeassistant/components/hunterdouglas_powerview/const.py +++ b/homeassistant/components/hunterdouglas_powerview/const.py @@ -2,6 +2,7 @@ import asyncio +from aiohttp.client_exceptions import ServerDisconnectedError from aiopvapi.helpers.aiorequest import PvApiConnectionError DOMAIN = "hunterdouglas_powerview" @@ -64,7 +65,7 @@ PV_SHADE_DATA = "pv_shade_data" PV_ROOM_DATA = "pv_room_data" COORDINATOR = "coordinator" -HUB_EXCEPTIONS = (asyncio.TimeoutError, PvApiConnectionError) +HUB_EXCEPTIONS = (ServerDisconnectedError, asyncio.TimeoutError, PvApiConnectionError) LEGACY_DEVICE_SUB_REVISION = 1 LEGACY_DEVICE_REVISION = 0