mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-18 21:18:56 +01:00
fix mode selection and display for humidifier Dual 200S (#2)
This commit is contained in:
parent
f36fc12a73
commit
d2f06b0607
@ -2,7 +2,12 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.humidifier import HumidifierEntity
|
from homeassistant.components.humidifier import HumidifierEntity
|
||||||
from homeassistant.components.humidifier.const import SUPPORT_MODES
|
from homeassistant.components.humidifier.const import (
|
||||||
|
MODE_AUTO,
|
||||||
|
MODE_BOOST,
|
||||||
|
MODE_SLEEP,
|
||||||
|
SUPPORT_MODES,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
@ -16,6 +21,10 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
MAX_HUMIDITY = 80
|
MAX_HUMIDITY = 80
|
||||||
MIN_HUMIDITY = 30
|
MIN_HUMIDITY = 30
|
||||||
|
|
||||||
|
MODE_MANUAL = "manual"
|
||||||
|
|
||||||
|
MODES = [MODE_AUTO, MODE_BOOST, MODE_SLEEP]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -68,7 +77,7 @@ class VeSyncHumidifierHA(VeSyncDevice, HumidifierEntity):
|
|||||||
@property
|
@property
|
||||||
def available_modes(self):
|
def available_modes(self):
|
||||||
"""Return the available mist modes."""
|
"""Return the available mist modes."""
|
||||||
return self.device.config_dict["mist_modes"]
|
return MODES
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
@ -83,8 +92,14 @@ class VeSyncHumidifierHA(VeSyncDevice, HumidifierEntity):
|
|||||||
@property
|
@property
|
||||||
def mode(self):
|
def mode(self):
|
||||||
"""Get the current preset mode."""
|
"""Get the current preset mode."""
|
||||||
if self.smarthumidifier.details["mode"] in self.available_modes:
|
if self.smarthumidifier.details["mode"] == MODE_AUTO:
|
||||||
return self.smarthumidifier.details["mode"]
|
return MODE_AUTO
|
||||||
|
if self.smarthumidifier.details["mode"] == MODE_MANUAL:
|
||||||
|
return (
|
||||||
|
MODE_SLEEP
|
||||||
|
if self.smarthumidifier.details["mist_level"] == 1
|
||||||
|
else MODE_BOOST
|
||||||
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -138,10 +153,8 @@ class VeSyncHumidifierHA(VeSyncDevice, HumidifierEntity):
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
"{mode} is not one of the valid available modes: {self.available_modes}"
|
"{mode} is not one of the valid available modes: {self.available_modes}"
|
||||||
)
|
)
|
||||||
if mode == "manual":
|
if mode != MODE_AUTO:
|
||||||
self.smarthumidifier.set_mist_level(
|
self.smarthumidifier.set_mist_level(1 if mode == MODE_SLEEP else 2)
|
||||||
self.smarthumidifier.details["mist_level"]
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.smarthumidifier.set_humidity_mode(mode)
|
self.smarthumidifier.set_humidity_mode(mode)
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user