Esempio n. 1
0
def ChangeCleanCycle(*, enable, duration_s=0, duration=None, **kwargs):
    """
    Returns a valid message that will either start or stop the cleaning (HEV)
    cycle of devices used against it.

    When a cycle is started, if the duration_s=0 or is not provided, the default
    duration will be used.

    For example:

    .. code-block:: python

        await target.send(ChangeCleanCycle(enable=True), ["d073d5000001", "d073d5000001"])

    Options are:

        enable - boolean (required)
            Pass True to start a cleaning cycle or False to stop a cycle in progress

        duration_s - integer (optional)
            Only used if enable=True. Specifies the duration (in seconds) for
            the cleaning cycle. If not specified, the default duration will be
            used. Default duration can be set using target:set_clean_config and
            returned using target_get_clean_config
    """
    if duration is not None:
        raise ProgrammerError("Duration needs to be specified as duration_s")

    return ForCapability(hev=LightMessages.SetHevCycle(
        enable=enable,
        duration_s=duration_s,
        ack_required=True,
        res_required=False,
    ))
Esempio n. 2
0
            assert got == {
                light1.serial: (True, {"hev_status": Skip}),
                clean.serial: (
                    True,
                    {
                        "hev_status": {
                            "current": {"active": False},
                            "last": {"result": LightLastHevCycleResult.NONE},
                        }
                    },
                ),
            }

        async it "works when hev is on", sender, m:
            assert clean.attrs.power == 0
            await sender(LightMessages.SetHevCycle(enable=True, duration_s=20), clean.serial)
            assert clean.attrs.clean_details.enabled
            assert clean.attrs.clean_details.duration_s == 20
            assert clean.attrs.clean_details.last_result is LightLastHevCycleResult.BUSY

            got = await self.gather(sender, [clean.serial, light1.serial], "hev_status")
            assert got == {
                light1.serial: (True, {"hev_status": Skip}),
                clean.serial: (
                    True,
                    {
                        "hev_status": {
                            "current": {
                                "active": True,
                                "duration_s": 20,
                                "remaining": 20,
Esempio n. 3
0
        for device in devices:
            if device not in expected:
                assert False, f"No expectation for {device.serial}"

        for device, msgs in expected.items():
            assert device in devices
            devices.store(device).assertIncoming(*msgs, ignore=[DiscoveryMessages.GetService])
            devices.store(device).clear()

    async it "starts a clean cycle", sender:
        expected = {
            light1: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.SetHevCycle(enable=True, duration_s=7200),
            ],
            light2: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.SetHevCycle(enable=True, duration_s=7200),
            ],
            light3: [DeviceMessages.GetHostFirmware(), DeviceMessages.GetVersion()],
        }
        await self.run_and_compare(
            sender, ChangeCleanCycle(enable=True, duration_s=7200), expected=expected
        )

    async it "stops a clean cycle", sender:
        expected = {
            light1: [
Esempio n. 4
0
 async def start(enable, duration):
     setter = LightMessages.SetHevCycle(
         enable=enable, duration_s=duration, res_required=False
     )
     await assertResponse(setter, True)
Esempio n. 5
0
        getter = LightMessages.GetHevCycleConfiguration()
        state = LightMessages.StateHevCycleConfiguration(indication=False, duration_s=7200)
        await assertResponse(getter, [state])
        assert device.attrs.clean_details.indication is False
        assert device.attrs.clean_details.default_duration_s == 7200

        getter = LightMessages.GetLightPower()
        state = DeviceMessages.StatePower(level=0)
        await assertResponse(getter, [state])
        assert device.attrs.power == 0
        getter = DeviceMessages.GetPower()
        state = DeviceMessages.StatePower(level=0)
        await assertResponse(getter, [state])
        assert device.attrs.power == 0

        setter = LightMessages.SetHevCycle(enable=True, duration_s=0, res_required=False)
        await assertResponse(setter, True)
        getter = LightMessages.GetHevCycle()
        state = LightMessages.StateHevCycle(duration_s=7200, remaining_s=7200, last_power=0)
        await assertResponse(getter, [state])
        assert device.attrs.clean_details.enabled is True
        assert device.attrs.clean_details.duration_s == 7200
        assert device.attrs.clean_details.remaining_s == 7200
        assert device.attrs.clean_details.last_result is LightLastHevCycleResult.BUSY
        assert device.attrs.clean_details.indication is False
        assert device.attrs.clean_details.default_duration_s == 7200

        # Reports as on even though it's actually not
        assert device.attrs.power == 0
        getter = DeviceMessages.GetPower()
        state = DeviceMessages.StatePower(level=0xFFFF)