Skip to content

Commit

Permalink
fix: fix humidifier not working on homeassistant < 2023.7
Browse files Browse the repository at this point in the history
  • Loading branch information
stackia committed Jul 13, 2023
1 parent ea5accd commit 1b17489
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions custom_components/deye_dehumidifier/humidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
MODE_BOOST,
MODE_COMFORT,
MODE_SLEEP,
HumidifierAction,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -84,14 +83,21 @@ def mode(self) -> str:
return deye_mode_to_hass_mode(self.device_state.mode)

@property
def action(self) -> HumidifierAction:
"""Return the current action."""
def action(self) -> str:
"""
Return the current action.
off/drying/idle are from `homeassistant.components.humidifier.const.HumidifierAction`
For backward compatibility, we cannot directly import them from homeassistant (which requires
homeassistant >= 2023.7)
"""
if not self.device_state.power_switch:
return HumidifierAction.OFF
return "off"
elif self.device_state.fan_running:
return HumidifierAction.DRYING
return "drying"
else:
return HumidifierAction.IDLE
return "idle"

async def async_set_mode(self, mode: str) -> None:
"""Set new working mode."""
Expand Down

0 comments on commit 1b17489

Please sign in to comment.