From 0efaf7efe8b71834d2ab0ad98dc9cb30ccb425df Mon Sep 17 00:00:00 2001 From: Whitney Young Date: Fri, 17 Oct 2025 09:26:27 -0700 Subject: [PATCH] OpenUV: Fix update by skipping when protection window is null (#154487) --- homeassistant/components/openuv/coordinator.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/openuv/coordinator.py b/homeassistant/components/openuv/coordinator.py index eb5970edef5..b29d272b0ec 100644 --- a/homeassistant/components/openuv/coordinator.py +++ b/homeassistant/components/openuv/coordinator.py @@ -68,7 +68,7 @@ class OpenUvCoordinator(DataUpdateCoordinator[dict[str, Any]]): 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 @@ -76,10 +76,18 @@ class OpenUvProtectionWindowCoordinator(OpenUvCoordinator): data = await super()._async_update_data() for key in ("from_time", "to_time", "from_uv", "to_uv"): - if not data.get(key): - msg = "Skipping update due to missing data: {key}" + # a key missing from the data is an error. + if key not in data: + msg = f"Update failed due to missing data: {key}" 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._process_data(data)