Add warm mist number entity to compatible devices (600S) (#29)

* add warm mist number entity

* fix typos.

* Rename to warm mist.
This commit is contained in:
Vincent Le Bourlot 2022-07-04 10:23:26 +02:00 committed by GitHub
parent 48c7cf580e
commit cdbb0b8294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,12 +44,10 @@ def _setup_entities(devices, async_add_entities):
entities = [] entities = []
for dev in devices: for dev in devices:
if is_humidifier(dev.device_type): if is_humidifier(dev.device_type):
entities.extend( ext = (VeSyncHumidifierMistLevelHA(dev), VeSyncHumidifierTargetLevelHA(dev))
( if dev.warm_mist_feature:
VeSyncHumidifierMistLevelHA(dev), ext = (*ext, VeSyncHumidifierWarmthLevelHA(dev))
VeSyncHumidifierTargetLevelHA(dev), entities.extend(ext)
)
)
elif is_air_purifier(dev.device_type): elif is_air_purifier(dev.device_type):
entities.extend((VeSyncFanSpeedLevelHA(dev),)) entities.extend((VeSyncFanSpeedLevelHA(dev),))
else: else:
@ -175,6 +173,49 @@ class VeSyncHumidifierMistLevelHA(VeSyncHumidifierNumberEntity):
self.device.set_mist_level(int(value)) self.device.set_mist_level(int(value))
class VeSyncHumidifierWarmthLevelHA(VeSyncHumidifierNumberEntity):
"""Representation of the warmth level of a VeSync humidifier."""
@property
def unique_id(self):
"""Return the ID of this device."""
return f"{super().unique_id}-warm-mist"
@property
def name(self):
"""Return the name of the device."""
return f"{super().name} warm mist"
@property
def value(self):
"""Return the warmth level."""
return self.device.details["warm_mist_level"]
@property
def min_value(self) -> float:
"""Return the minimum mist level."""
return self.device.config_dict["warm_mist_levels"][0]
@property
def max_value(self) -> float:
"""Return the maximum mist level."""
return self.device.config_dict["warm_mist_levels"][-1]
@property
def step(self) -> float:
"""Return the steps for the mist level."""
return 1.0
@property
def extra_state_attributes(self):
"""Return the state attributes of the humidifier."""
return {"warm mist levels": self.device.config_dict["warm_mist_levels"]}
def set_value(self, value):
"""Set the mist level."""
self.device.set_warm_level(int(value))
class VeSyncHumidifierTargetLevelHA(VeSyncHumidifierNumberEntity): class VeSyncHumidifierTargetLevelHA(VeSyncHumidifierNumberEntity):
"""Representation of the target humidity level of a VeSync humidifier.""" """Representation of the target humidity level of a VeSync humidifier."""