Reolink continue setup when internet blocked (#110888)

This commit is contained in:
starkillerOG 2024-02-19 20:53:18 +01:00 committed by GitHub
parent 3e5329d463
commit aa9f0f5734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -100,10 +100,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
async with asyncio.timeout(host.api.timeout * (RETRY_ATTEMPTS + 2)):
try:
return await host.api.check_new_firmware()
except (ReolinkError, asyncio.exceptions.CancelledError) as err:
task = asyncio.current_task()
if task is not None:
task.uncancel()
except ReolinkError as err:
if starting:
_LOGGER.debug(
"Error checking Reolink firmware update at startup "
@ -133,15 +130,16 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
update_interval=FIRMWARE_UPDATE_INTERVAL,
)
# Fetch initial data so we have data when entities subscribe
try:
# If camera WAN blocked, firmware check fails, do not prevent setup
await asyncio.gather(
results = await asyncio.gather(
device_coordinator.async_config_entry_first_refresh(),
firmware_coordinator.async_config_entry_first_refresh(),
return_exceptions=True,
)
except ConfigEntryNotReady:
# If camera WAN blocked, firmware check fails, do not prevent setup
# so don't check firmware_coordinator exceptions
if isinstance(results[0], BaseException):
await host.stop()
raise
raise results[0]
hass.data.setdefault(DOMAIN, {})[config_entry.entry_id] = ReolinkData(
host=host,