OpenUV: Fix update by skipping when protection window is null (#154487)

This commit is contained in:
Whitney Young
2025-10-17 09:26:27 -07:00
committed by GitHub
parent 55643f0632
commit 0efaf7efe8

View File

@@ -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)