From e03eb238e208c572ab0e5366d9a70881b053a9b7 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Mon, 22 Aug 2022 09:03:32 +0200 Subject: [PATCH] Protect against an exception in Shelly climate platform (#77102) Check if state in HVACMode --- homeassistant/components/shelly/climate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/shelly/climate.py b/homeassistant/components/shelly/climate.py index 453d67f39a7..a3f42c4a928 100644 --- a/homeassistant/components/shelly/climate.py +++ b/homeassistant/components/shelly/climate.py @@ -188,7 +188,10 @@ class BlockSleepingClimate( def hvac_mode(self) -> HVACMode: """HVAC current mode.""" if self.device_block is None: - return HVACMode(self.last_state.state) if self.last_state else HVACMode.OFF + if self.last_state and self.last_state.state in list(HVACMode): + return HVACMode(self.last_state.state) + return HVACMode.OFF + if self.device_block.mode is None or self._check_is_off(): return HVACMode.OFF