mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Return empty data when OpenUV API call fails (#83089)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> fixes undefined
This commit is contained in:
parent
4a56461d3c
commit
ee0fbae2ca
@ -32,10 +32,10 @@ class InvalidApiKeyMonitor:
|
|||||||
|
|
||||||
async def async_increment(self) -> None:
|
async def async_increment(self) -> None:
|
||||||
"""Increment the counter."""
|
"""Increment the counter."""
|
||||||
LOGGER.debug("Invalid API key response detected (number %s)", self._count)
|
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
self._count += 1
|
self._count += 1
|
||||||
if self._count > self.DEFAULT_FAILED_API_CALL_THRESHOLD:
|
if self._count > self.DEFAULT_FAILED_API_CALL_THRESHOLD:
|
||||||
|
LOGGER.info("Starting reauth after multiple failed API calls")
|
||||||
self._reauth_flow_manager.start_reauth()
|
self._reauth_flow_manager.start_reauth()
|
||||||
|
|
||||||
async def async_reset(self) -> None:
|
async def async_reset(self) -> None:
|
||||||
@ -114,10 +114,11 @@ class OpenUvCoordinator(DataUpdateCoordinator):
|
|||||||
"""Fetch data from OpenUV."""
|
"""Fetch data from OpenUV."""
|
||||||
try:
|
try:
|
||||||
data = await self.update_method()
|
data = await self.update_method()
|
||||||
except InvalidApiKeyError:
|
except InvalidApiKeyError as err:
|
||||||
await self._invalid_api_key_monitor.async_increment()
|
await self._invalid_api_key_monitor.async_increment()
|
||||||
|
raise UpdateFailed(str(err)) from err
|
||||||
except OpenUvError as err:
|
except OpenUvError as err:
|
||||||
raise UpdateFailed(f"Error during protection data update: {err}") from err
|
raise UpdateFailed(str(err)) from err
|
||||||
|
|
||||||
await self._invalid_api_key_monitor.async_reset()
|
await self._invalid_api_key_monitor.async_reset()
|
||||||
return cast(dict[str, Any], data["result"])
|
return cast(dict[str, Any], data["result"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user