mirror of https://github.com/simbaja/ha_gehome.git
- updated dehumidifier to handle target precision
- updated dehumidifier sensor value conversion
This commit is contained in:
parent
7feecd3e37
commit
d3cae05e93
|
@ -15,6 +15,7 @@ from ..entities import (
|
|||
GeErdPropertySensor,
|
||||
GeErdSwitch,
|
||||
ErdOnOffBoolConverter,
|
||||
GeDehumidifierFanSpeedSensor,
|
||||
GeDehumidifier
|
||||
)
|
||||
|
||||
|
@ -30,7 +31,7 @@ class DehumidifierApi(ApplianceApi):
|
|||
|
||||
dhum_entities = [
|
||||
GeErdSwitch(self, ErdCode.AC_POWER_STATUS, bool_converter=ErdOnOffBoolConverter(), icon_on_override="mdi:power-on", icon_off_override="mdi:power-off"),
|
||||
GeErdSensor(self, ErdCode.AC_FAN_SETTING, icon_override="mdi:fan"),
|
||||
GeDehumidifierFanSpeedSensor(self, ErdCode.AC_FAN_SETTING, icon_override="mdi:fan"),
|
||||
GeErdSensor(self, ErdCode.DHUM_CURRENT_HUMIDITY),
|
||||
GeErdSensor(self, ErdCode.DHUM_TARGET_HUMIDITY),
|
||||
GeErdPropertySensor(self, ErdCode.DHUM_MAINTENANCE, "empty_bucket", device_class_override="problem"),
|
||||
|
|
|
@ -10,7 +10,8 @@ from gehomesdk import ErdCodeType, ErdOnOff
|
|||
from ...const import DOMAIN
|
||||
from ...devices import ApplianceApi
|
||||
from .ge_entity import GeEntity
|
||||
from .options_converter import OptionsConverter
|
||||
|
||||
DEFAULT_TARGET_PRECISION = 5
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -25,7 +26,8 @@ class GeHumidifier(GeEntity, HumidifierEntity, metaclass=abc.ABCMeta):
|
|||
target_humidity_erd_code: ErdCodeType,
|
||||
current_humidity_erd_code: ErdCodeType,
|
||||
range_min: int,
|
||||
range_max: int
|
||||
range_max: int,
|
||||
target_precision = DEFAULT_TARGET_PRECISION
|
||||
):
|
||||
super().__init__(api)
|
||||
self._device_class = device_class
|
||||
|
@ -34,6 +36,7 @@ class GeHumidifier(GeEntity, HumidifierEntity, metaclass=abc.ABCMeta):
|
|||
self._current_humidity_erd_code = current_humidity_erd_code
|
||||
self._range_min = range_min
|
||||
self._range_max = range_max
|
||||
self._target_precision = target_precision
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
|
@ -72,19 +75,23 @@ class GeHumidifier(GeEntity, HumidifierEntity, metaclass=abc.ABCMeta):
|
|||
return self._device_class
|
||||
|
||||
async def async_set_humidity(self, humidity: int) -> Coroutine[Any, Any, None]:
|
||||
if self.target_humidity == humidity:
|
||||
# round to target precision
|
||||
target = round(humidity / self._target_precision) * self._target_precision
|
||||
|
||||
# if it's the same, just exit
|
||||
if self.target_humidity == target:
|
||||
return
|
||||
|
||||
_LOGGER.debug(f"Setting Target Humidity from {self.target_humidity} to {humidity}")
|
||||
_LOGGER.debug(f"Setting Target Humidity from {self.target_humidity} to {target}")
|
||||
|
||||
# make sure we're on
|
||||
if not self.is_on:
|
||||
await self.async_turn_on()
|
||||
|
||||
# set the mode
|
||||
# set the target humidity
|
||||
await self.appliance.async_set_erd_value(
|
||||
self._target_humidity_erd_code,
|
||||
humidity,
|
||||
target,
|
||||
)
|
||||
|
||||
async def async_turn_on(self):
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
from .dehumidifier import GeDehumidifier
|
||||
from .dehumidifier import GeDehumidifier
|
||||
from .dehumidifier_fan_speed_sensor import GeDehumidifierFanSpeedSensor
|
|
@ -0,0 +1,8 @@
|
|||
from ..common import GeErdBinarySensor
|
||||
|
||||
class GeCcmPotNotPresentBinarySensor(GeErdBinarySensor):
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return True if entity is not pot present."""
|
||||
return not self._boolify(self.appliance.get_erd_value(self.erd_code))
|
||||
|
Loading…
Reference in New Issue