From 5c272583e7bc1bfab7d2854f2a7d0fcd017ff733 Mon Sep 17 00:00:00 2001 From: Nyro Date: Sat, 17 Dec 2022 19:12:15 +0100 Subject: [PATCH] Fix current_operation when there is no operation_mode in Overkiz DHWP (#84077) Fix current_operation when there is no operation_mode --- .../domestic_hot_water_production.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py b/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py index b8a595e55e0..cdc1ae11bdd 100644 --- a/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py +++ b/homeassistant/components/overkiz/water_heater_entities/domestic_hot_water_production.py @@ -251,19 +251,21 @@ class DomesticHotWaterProduction(OverkizEntity, WaterHeaterEntity): ) @property - def current_operation(self) -> str: + def current_operation(self) -> str | None: """Return current operation ie. eco, electric, performance, ...""" if self._is_boost_mode_on: return OVERKIZ_TO_OPERATION_MODE[OverkizCommandParam.BOOST] - return OVERKIZ_TO_OPERATION_MODE[ - cast( - str, - self.executor.select_state( - OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE - ), - ) - ] + current_dwh_mode = cast( + str, + self.executor.select_state( + OverkizState.IO_DHW_MODE, OverkizState.MODBUSLINK_DHW_MODE + ), + ) + if current_dwh_mode in OVERKIZ_TO_OPERATION_MODE: + return OVERKIZ_TO_OPERATION_MODE[current_dwh_mode] + + return None async def async_set_operation_mode(self, operation_mode: str) -> None: """Set new target operation mode."""