mirror of
https://github.com/home-assistant/core.git
synced 2025-11-05 00:49:37 +00:00
OpenUV: Fix update by skipping when protection window is null (#154487)
This commit is contained in:
@@ -68,7 +68,7 @@ class OpenUvCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
|||||||
|
|
||||||
|
|
||||||
class OpenUvProtectionWindowCoordinator(OpenUvCoordinator):
|
class OpenUvProtectionWindowCoordinator(OpenUvCoordinator):
|
||||||
"""Define an OpenUV data coordinator for the protetction window."""
|
"""Define an OpenUV data coordinator for the protection window."""
|
||||||
|
|
||||||
_reprocess_listener: CALLBACK_TYPE | None = None
|
_reprocess_listener: CALLBACK_TYPE | None = None
|
||||||
|
|
||||||
@@ -76,10 +76,18 @@ class OpenUvProtectionWindowCoordinator(OpenUvCoordinator):
|
|||||||
data = await super()._async_update_data()
|
data = await super()._async_update_data()
|
||||||
|
|
||||||
for key in ("from_time", "to_time", "from_uv", "to_uv"):
|
for key in ("from_time", "to_time", "from_uv", "to_uv"):
|
||||||
if not data.get(key):
|
# a key missing from the data is an error.
|
||||||
msg = "Skipping update due to missing data: {key}"
|
if key not in data:
|
||||||
|
msg = f"Update failed due to missing data: {key}"
|
||||||
raise UpdateFailed(msg)
|
raise UpdateFailed(msg)
|
||||||
|
|
||||||
|
# check for null or zero value in the data & skip further processing
|
||||||
|
# of this update if one is found. this is a normal condition
|
||||||
|
# indicating that there is no protection window.
|
||||||
|
if not data[key]:
|
||||||
|
LOGGER.warning("Skipping update due to missing data: %s", key)
|
||||||
|
return {}
|
||||||
|
|
||||||
data = self._parse_data(data)
|
data = self._parse_data(data)
|
||||||
data = self._process_data(data)
|
data = self._process_data(data)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user