diff --git a/homeassistant/components/zwave_js/humidifier.py b/homeassistant/components/zwave_js/humidifier.py index b94c7a8e2a3622..44d7bc19bbb19b 100644 --- a/homeassistant/components/zwave_js/humidifier.py +++ b/homeassistant/components/zwave_js/humidifier.py @@ -150,10 +150,9 @@ def __init__( @property def is_on(self) -> bool | None: """Return True if entity is on.""" - return int(self._current_mode.value) in [ - self.entity_description.on_mode, - HumidityControlMode.AUTO, - ] + if (value := self._current_mode.value) is None: + return None + return int(value) in [self.entity_description.on_mode, HumidityControlMode.AUTO] def _supports_inverse_mode(self) -> bool: return ( @@ -163,7 +162,9 @@ def _supports_inverse_mode(self) -> bool: async def async_turn_on(self, **kwargs: Any) -> None: """Turn on device.""" - mode = int(self._current_mode.value) + if (value := self._current_mode.value) is None: + return + mode = int(value) if mode == HumidityControlMode.OFF: new_mode = self.entity_description.on_mode elif mode == self.entity_description.inverse_mode: @@ -175,7 +176,9 @@ async def async_turn_on(self, **kwargs: Any) -> None: async def async_turn_off(self, **kwargs: Any) -> None: """Turn off device.""" - mode = int(self._current_mode.value) + if (value := self._current_mode.value) is None: + return + mode = int(value) if mode == HumidityControlMode.AUTO: if self._supports_inverse_mode(): new_mode = self.entity_description.inverse_mode @@ -191,7 +194,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: @property def target_humidity(self) -> int | None: """Return the humidity we try to reach.""" - if not self._setpoint: + if not self._setpoint or self._setpoint.value is None: return None return int(self._setpoint.value)