mirror of
https://github.com/micahqcade/custom_vesync.git
synced 2025-02-14 19:19:00 +01:00
improve consts and mode naming. (#14)
This commit is contained in:
parent
fab77a025a
commit
00d4d5a846
@ -13,6 +13,9 @@ VS_NUMBERS = "numbers"
|
|||||||
VS_BINARY_SENSORS = "binary_sensors"
|
VS_BINARY_SENSORS = "binary_sensors"
|
||||||
VS_MANAGER = "manager"
|
VS_MANAGER = "manager"
|
||||||
|
|
||||||
|
VS_MODE_AUTO = "auto"
|
||||||
|
VS_MODE_MANUAL = "manual"
|
||||||
|
|
||||||
DEV_TYPE_TO_HA = {
|
DEV_TYPE_TO_HA = {
|
||||||
"LV-PUR131S": "fan",
|
"LV-PUR131S": "fan",
|
||||||
"Core200S": "fan",
|
"Core200S": "fan",
|
||||||
|
@ -4,7 +4,7 @@ import logging
|
|||||||
from homeassistant.components.humidifier import HumidifierEntity
|
from homeassistant.components.humidifier import HumidifierEntity
|
||||||
from homeassistant.components.humidifier.const import (
|
from homeassistant.components.humidifier.const import (
|
||||||
MODE_AUTO,
|
MODE_AUTO,
|
||||||
MODE_BOOST,
|
MODE_NORMAL,
|
||||||
MODE_SLEEP,
|
MODE_SLEEP,
|
||||||
SUPPORT_MODES,
|
SUPPORT_MODES,
|
||||||
)
|
)
|
||||||
@ -14,16 +14,14 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .common import VeSyncDevice, is_humidifier
|
from .common import VeSyncDevice, is_humidifier
|
||||||
from .const import DOMAIN, VS_DISCOVERY, VS_HUMIDIFIERS
|
from .const import DOMAIN, VS_DISCOVERY, VS_HUMIDIFIERS, VS_MODE_AUTO, VS_MODE_MANUAL
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
MAX_HUMIDITY = 80
|
MAX_HUMIDITY = 80
|
||||||
MIN_HUMIDITY = 30
|
MIN_HUMIDITY = 30
|
||||||
|
|
||||||
MODE_MANUAL = "manual"
|
MODES = [MODE_AUTO, MODE_NORMAL, MODE_SLEEP]
|
||||||
|
|
||||||
MODES = [MODE_AUTO, MODE_BOOST, MODE_SLEEP]
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -92,13 +90,13 @@ 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"] == MODE_AUTO:
|
if self.smarthumidifier.details["mode"] == VS_MODE_AUTO:
|
||||||
return MODE_AUTO
|
return MODE_AUTO
|
||||||
if self.smarthumidifier.details["mode"] == MODE_MANUAL:
|
if self.smarthumidifier.details["mode"] == VS_MODE_MANUAL:
|
||||||
return (
|
return (
|
||||||
MODE_SLEEP
|
MODE_SLEEP
|
||||||
if self.smarthumidifier.details["mist_level"] == 1
|
if self.smarthumidifier.details["mist_level"] == 1
|
||||||
else MODE_BOOST
|
else MODE_NORMAL
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -153,10 +151,12 @@ 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 != MODE_AUTO:
|
if mode == MODE_AUTO:
|
||||||
self.smarthumidifier.set_mist_level(1 if mode == MODE_SLEEP else 2)
|
self.smarthumidifier.set_humidity_mode(VS_MODE_AUTO)
|
||||||
else:
|
else:
|
||||||
self.smarthumidifier.set_humidity_mode(mode)
|
self.smarthumidifier.set_mist_level(
|
||||||
|
1 if mode == MODE_SLEEP else 2
|
||||||
|
) # this sets manual mode at the same time.
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def turn_on(
|
def turn_on(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user