From 750e849f09b86fb245aef07ce3cbc00101d460fc Mon Sep 17 00:00:00 2001 From: RogerSelwyn Date: Fri, 26 Sep 2025 11:35:04 +0100 Subject: [PATCH] Protect against last_comms being None (#149366) Co-authored-by: Joost Lekkerkerker --- homeassistant/components/geniushub/entity.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/geniushub/entity.py b/homeassistant/components/geniushub/entity.py index 24917ab5e95e..e47bb59c3d39 100644 --- a/homeassistant/components/geniushub/entity.py +++ b/homeassistant/components/geniushub/entity.py @@ -77,10 +77,10 @@ class GeniusDevice(GeniusEntity): async def async_update(self) -> None: """Update an entity's state data.""" - if "_state" in self._device.data: # only via v3 API - self._last_comms = dt_util.utc_from_timestamp( - self._device.data["_state"]["lastComms"] - ) + if (state := self._device.data.get("_state")) and ( + last_comms := state.get("lastComms") + ) is not None: # only via v3 API + self._last_comms = dt_util.utc_from_timestamp(last_comms) class GeniusZone(GeniusEntity):