コード例 #1
0
 def service_set_dyson_speed(self, dyson_speed: str) -> None:
     """Handle the service to set dyson speed."""
     if dyson_speed not in SPEED_LIST_DYSON:
         raise ValueError(f'"{dyson_speed}" is not a valid Dyson speed')
     _LOGGER.debug("Set exact speed to %s", dyson_speed)
     speed = FanSpeed(f"{int(dyson_speed):04d}")
     self.set_dyson_speed(speed)
コード例 #2
0
    def set_dyson_speed(self, speed: str = None) -> None:
        """Set the exact speed of the purecool fan."""
        from libpurecool.const import FanSpeed

        _LOGGER.debug("Set exact speed for fan %s", self.name)

        fan_speed = FanSpeed('{0:04d}'.format(int(speed)))
        self._device.set_fan_speed(fan_speed)
コード例 #3
0
ファイル: fan.py プロジェクト: mduran80/core
    def set_speed(self, speed: str) -> None:
        """Set the speed of the fan. Never called ??."""
        _LOGGER.debug("Set fan speed to: %s", speed)

        if speed == FanSpeed.FAN_SPEED_AUTO.value:
            self._device.set_configuration(fan_mode=FanMode.AUTO)
        else:
            fan_speed = FanSpeed(f"{int(speed):04d}")
            self._device.set_configuration(fan_mode=FanMode.FAN, fan_speed=fan_speed)
コード例 #4
0
 def set_speed(self, command):
     speed = int(command.get('value'))
     if speed < 0 or speed > 11:
         LOGGER.error('Invalid speed selection {}'.format(speed))
     elif speed == 0:
         self.device.set_configuration(fan_mode=FanMode.OFF)
     elif speed == 11:
         self.device.set_configuration(fan_mode=FanMode.AUTO)
     else:
         self.device.set_configuration(fan_speed=FanSpeed("%04d" % speed))
コード例 #5
0
 def set_speed(self, command):
     speed = int(command.get('value'))
     if speed < 0 or speed > 11:
         LOGGER.error('Invalid speed selection {}'.format(speed))
     elif speed == 0:
         self.device.turn_off()
     elif speed == 11:
         self.device.enable_auto_mode()
     else:
         self.device.set_fan_speed(FanSpeed("%04d" % speed))
コード例 #6
0
ファイル: fan.py プロジェクト: pkrolkgp/home-assistant
    def set_speed(self, speed: str) -> None:
        """Set the speed of the fan. Never called ??."""
        from libpurecool.const import FanSpeed, FanMode

        _LOGGER.debug("Set fan speed to: %s", speed)

        if speed == FanSpeed.FAN_SPEED_AUTO.value:
            self._device.set_configuration(fan_mode=FanMode.AUTO)
        else:
            fan_speed = FanSpeed("{0:04d}".format(int(speed)))
            self._device.set_configuration(fan_mode=FanMode.FAN, fan_speed=fan_speed)
コード例 #7
0
 def turn_on(self, speed: str = None, **kwargs) -> None:
     """Turn on the fan."""
     _LOGGER.debug("Turn on fan %s with speed %s", self.name, speed)
     if speed:
         if speed == FanSpeed.FAN_SPEED_AUTO.value:
             self._device.set_configuration(fan_mode=FanMode.AUTO)
         else:
             fan_speed = FanSpeed(f"{int(speed):04d}")
             self._device.set_configuration(fan_mode=FanMode.FAN,
                                            fan_speed=fan_speed)
     else:
         # Speed not set, just turn on
         self._device.set_configuration(fan_mode=FanMode.FAN)
コード例 #8
0
    def turn_on(self, speed: str = None, **kwargs) -> None:
        """Turn on the fan."""
        from libpurecool.const import FanSpeed

        _LOGGER.debug("Turn on fan %s", self.name)

        if speed is not None:
            if speed == FanSpeed.FAN_SPEED_AUTO.value:
                self._device.enable_auto_mode()
            else:
                fan_speed = FanSpeed('{0:04d}'.format(int(speed)))
                self._device.set_fan_speed(fan_speed)
        else:
            self._device.turn_on()
コード例 #9
0
    def turn_on(self, speed: str = None, **kwargs) -> None:
        """Turn on the fan."""
        from libpurecool.const import FanSpeed, FanMode

        _LOGGER.debug("Turn on fan %s with speed %s", self.name, speed)
        if speed:
            if speed == FanSpeed.FAN_SPEED_AUTO.value:
                self._device.set_configuration(fan_mode=FanMode.AUTO)
            else:
                fan_speed = FanSpeed('{0:04d}'.format(int(speed)))
                self._device.set_configuration(fan_mode=FanMode.FAN,
                                               fan_speed=fan_speed)
        else:
            # Speed not set, just turn on
            self._device.set_configuration(fan_mode=FanMode.FAN)
コード例 #10
0
            "enable_frontal_direction",
            [],
        ),
        (
            SERVICE_SET_FLOW_DIRECTION_FRONT,
            {ATTR_FLOW_DIRECTION_FRONT: False},
            "disable_frontal_direction",
            [],
        ),
        (SERVICE_SET_TIMER, {ATTR_TIMER: 0}, "disable_sleep_timer", []),
        (SERVICE_SET_TIMER, {ATTR_TIMER: 10}, "enable_sleep_timer", [10]),
        (
            SERVICE_SET_DYSON_SPEED,
            {ATTR_DYSON_SPEED: "4"},
            "set_fan_speed",
            [FanSpeed("0004")],
        ),
    ],
)
@pytest.mark.parametrize("device", [DysonPureCool], indirect=True)
async def test_custom_services_purecool(
    hass: HomeAssistant,
    device: DysonPureCool,
    service: str,
    service_data: dict,
    command: str,
    command_args: list,
) -> None:
    """Test custom services of a PureCool fan."""
    await hass.services.async_call(
        DOMAIN,
コード例 #11
0
    def set_dyson_speed(self, speed: str = None) -> None:
        """Set the exact speed of the purecool fan."""
        _LOGGER.debug("Set exact speed for fan %s", self.name)

        fan_speed = FanSpeed(f"{int(speed):04d}")
        self._device.set_fan_speed(fan_speed)