mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add None guard for zwave_js humidifier entity (#69667)
* Add None guard for humidifier entity is_on * Add guards in more places * Update homeassistant/components/zwave_js/humidifier.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
parent
fa13a243d4
commit
c70c9ac341
@ -150,10 +150,9 @@ class ZWaveHumidifier(ZWaveBaseEntity, HumidifierEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
return int(self._current_mode.value) in [
|
if (value := self._current_mode.value) is None:
|
||||||
self.entity_description.on_mode,
|
return None
|
||||||
HumidityControlMode.AUTO,
|
return int(value) in [self.entity_description.on_mode, HumidityControlMode.AUTO]
|
||||||
]
|
|
||||||
|
|
||||||
def _supports_inverse_mode(self) -> bool:
|
def _supports_inverse_mode(self) -> bool:
|
||||||
return (
|
return (
|
||||||
@ -163,7 +162,9 @@ class ZWaveHumidifier(ZWaveBaseEntity, HumidifierEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn on device."""
|
"""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:
|
if mode == HumidityControlMode.OFF:
|
||||||
new_mode = self.entity_description.on_mode
|
new_mode = self.entity_description.on_mode
|
||||||
elif mode == self.entity_description.inverse_mode:
|
elif mode == self.entity_description.inverse_mode:
|
||||||
@ -175,7 +176,9 @@ class ZWaveHumidifier(ZWaveBaseEntity, HumidifierEntity):
|
|||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off device."""
|
"""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 mode == HumidityControlMode.AUTO:
|
||||||
if self._supports_inverse_mode():
|
if self._supports_inverse_mode():
|
||||||
new_mode = self.entity_description.inverse_mode
|
new_mode = self.entity_description.inverse_mode
|
||||||
@ -191,7 +194,7 @@ class ZWaveHumidifier(ZWaveBaseEntity, HumidifierEntity):
|
|||||||
@property
|
@property
|
||||||
def target_humidity(self) -> int | None:
|
def target_humidity(self) -> int | None:
|
||||||
"""Return the humidity we try to reach."""
|
"""Return the humidity we try to reach."""
|
||||||
if not self._setpoint:
|
if not self._setpoint or self._setpoint.value is None:
|
||||||
return None
|
return None
|
||||||
return int(self._setpoint.value)
|
return int(self._setpoint.value)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user