mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Improve setup retry logic to handle inconsistent powerview hub availability (#38249)
This commit is contained in:
parent
2b0914994d
commit
56186a3d75
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user