|
|
@@ -44,13 +44,14 @@ class TuyaLocalHumidifier(TuyaLocalEntity, HumidifierEntity):
|
|
|
"""
|
|
|
super().__init__()
|
|
|
dps_map = self._init_begin(device, config)
|
|
|
- self._humidity_dps = dps_map.pop("humidity", None)
|
|
|
- self._mode_dps = dps_map.pop("mode", None)
|
|
|
- self._switch_dps = dps_map.pop("switch", None)
|
|
|
+ self._current_humidity_dp = dps_map.pop("current_humidity", None)
|
|
|
+ self._humidity_dp = dps_map.pop("humidity", None)
|
|
|
+ self._mode_dp = dps_map.pop("mode", None)
|
|
|
+ self._switch_dp = dps_map.pop("switch", None)
|
|
|
self._init_end(dps_map)
|
|
|
|
|
|
self._support_flags = 0
|
|
|
- if self._mode_dps:
|
|
|
+ if self._mode_dp:
|
|
|
self._support_flags |= HumidifierEntityFeature.MODES
|
|
|
|
|
|
@property
|
|
|
@@ -71,63 +72,69 @@ class TuyaLocalHumidifier(TuyaLocalEntity, HumidifierEntity):
|
|
|
def is_on(self):
|
|
|
"""Return whether the switch is on or not."""
|
|
|
# If there is no switch, it is always on if available
|
|
|
- if self._switch_dps is None:
|
|
|
+ if self._switch_dp is None:
|
|
|
return self.available
|
|
|
- return self._switch_dps.get_value(self._device)
|
|
|
+ return self._switch_dp.get_value(self._device)
|
|
|
|
|
|
async def async_turn_on(self, **kwargs):
|
|
|
"""Turn the switch on"""
|
|
|
- await self._switch_dps.async_set_value(self._device, True)
|
|
|
+ await self._switch_dp.async_set_value(self._device, True)
|
|
|
|
|
|
async def async_turn_off(self, **kwargs):
|
|
|
"""Turn the switch off"""
|
|
|
- await self._switch_dps.async_set_value(self._device, False)
|
|
|
+ await self._switch_dp.async_set_value(self._device, False)
|
|
|
+
|
|
|
+ @property
|
|
|
+ def current_humidity(self):
|
|
|
+ """Return the current humidity if available."""
|
|
|
+ if self._current_humidity_dp:
|
|
|
+ return self._current_humidity_dp.get_value(self._device)
|
|
|
|
|
|
@property
|
|
|
def target_humidity(self):
|
|
|
"""Return the currently set target humidity."""
|
|
|
- if self._humidity_dps is None:
|
|
|
+ if self._humidity_dp is None:
|
|
|
raise NotImplementedError()
|
|
|
- return self._humidity_dps.get_value(self._device)
|
|
|
+ return self._humidity_dp.get_value(self._device)
|
|
|
|
|
|
@property
|
|
|
def min_humidity(self):
|
|
|
"""Return the minimum supported target humidity."""
|
|
|
- if self._humidity_dps is None:
|
|
|
+ if self._humidity_dp is None:
|
|
|
return None
|
|
|
- r = self._humidity_dps.range(self._device)
|
|
|
+ r = self._humidity_dp.range(self._device)
|
|
|
return DEFAULT_MIN_HUMIDITY if r is None else r["min"]
|
|
|
|
|
|
@property
|
|
|
def max_humidity(self):
|
|
|
"""Return the maximum supported target humidity."""
|
|
|
- if self._humidity_dps is None:
|
|
|
+ if self._humidity_dp is None:
|
|
|
return None
|
|
|
- r = self._humidity_dps.range(self._device)
|
|
|
+ r = self._humidity_dp.range(self._device)
|
|
|
return DEFAULT_MAX_HUMIDITY if r is None else r["max"]
|
|
|
|
|
|
async def async_set_humidity(self, humidity):
|
|
|
- if self._humidity_dps is None:
|
|
|
+ if self._humidity_dp is None:
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
- await self._humidity_dps.async_set_value(self._device, humidity)
|
|
|
+ await self._humidity_dp.async_set_value(self._device, humidity)
|
|
|
|
|
|
@property
|
|
|
def mode(self):
|
|
|
"""Return the current preset mode."""
|
|
|
- if self._mode_dps is None:
|
|
|
+ if self._mode_dp is None:
|
|
|
raise NotImplementedError()
|
|
|
- return self._mode_dps.get_value(self._device)
|
|
|
+ return self._mode_dp.get_value(self._device)
|
|
|
|
|
|
@property
|
|
|
def available_modes(self):
|
|
|
"""Return the list of presets that this device supports."""
|
|
|
- if self._mode_dps is None:
|
|
|
+ if self._mode_dp is None:
|
|
|
return None
|
|
|
- return self._mode_dps.values(self._device)
|
|
|
+ return self._mode_dp.values(self._device)
|
|
|
|
|
|
async def async_set_mode(self, mode):
|
|
|
"""Set the preset mode."""
|
|
|
- if self._mode_dps is None:
|
|
|
+ if self._mode_dp is None:
|
|
|
raise NotImplementedError()
|
|
|
- await self._mode_dps.async_set_value(self._device, mode)
|
|
|
+ await self._mode_dp.async_set_value(self._device, mode)
|