Skip to content

Commit 2c75635

Browse files
wbyoungfrenck
authored andcommitted
OpenUV: Fix update by skipping when protection window is null (home-assistant#154487)
1 parent 1f03169 commit 2c75635

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

homeassistant/components/openuv/coordinator.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,26 @@ async def _async_update_data(self) -> dict[str, Any]:
6868

6969

7070
class OpenUvProtectionWindowCoordinator(OpenUvCoordinator):
71-
"""Define an OpenUV data coordinator for the protetction window."""
71+
"""Define an OpenUV data coordinator for the protection window."""
7272

7373
_reprocess_listener: CALLBACK_TYPE | None = None
7474

7575
async def _async_update_data(self) -> dict[str, Any]:
7676
data = await super()._async_update_data()
7777

7878
for key in ("from_time", "to_time", "from_uv", "to_uv"):
79-
if not data.get(key):
80-
msg = "Skipping update due to missing data: {key}"
79+
# a key missing from the data is an error.
80+
if key not in data:
81+
msg = f"Update failed due to missing data: {key}"
8182
raise UpdateFailed(msg)
8283

84+
# check for null or zero value in the data & skip further processing
85+
# of this update if one is found. this is a normal condition
86+
# indicating that there is no protection window.
87+
if not data[key]:
88+
LOGGER.warning("Skipping update due to missing data: %s", key)
89+
return {}
90+
8391
data = self._parse_data(data)
8492
data = self._process_data(data)
8593

0 commit comments

Comments
 (0)