Пример #1
0
    async def async_set_humidity(self, humidity: int) -> None:
        """Set the target humidity of the humidifier and set the mode to auto."""
        target_humidity = self.translate_humidity(humidity)
        if not target_humidity:
            return

        _LOGGER.debug("Setting the humidity to: %s", target_humidity)
        if await self._try_command(
                "Setting operation mode of the miio device failed.",
                self._device.set_target_humidity,
                target_humidity,
        ):
            self._target_humidity = target_humidity
        if (self.supported_features & SUPPORT_MODES == 0
                or AirhumidifierMiotOperationMode(self._attributes[ATTR_MODE])
                == AirhumidifierMiotOperationMode.Auto):
            self.async_write_ha_state()
            return
        _LOGGER.debug("Setting the operation mode to: Auto")
        if await self._try_command(
                "Setting operation mode of the miio device to MODE_AUTO failed.",
                self._device.set_mode,
                AirhumidifierMiotOperationMode.Auto,
        ):
            self._mode = 0
            self.async_write_ha_state()
Пример #2
0
    def speed(self):
        """Return the current speed."""
        if self._state:
            return self.MODE_MAPPING.get(
                AirhumidifierMiotOperationMode(self._state_attrs[ATTR_MODE]))

        return None
Пример #3
0
 def target_humidity(self):
     """Return the target humidity."""
     if self._state:
         return (
             self._target_humidity
             if AirhumidifierMiotOperationMode(self._mode)
             == AirhumidifierMiotOperationMode.Auto
             else None
         )
     return None
Пример #4
0
 def mode(self):
     """Return the current mode."""
     return AirhumidifierMiotOperationMode(self._mode).name