Beispiel #1
0
def SetCleanConfig(*, indication, duration_s, duration=None, **kwargs):
    """
    Returns a valid message that will set the default clean cycle configuration
    for the device.

    For example:

    .. code-block:: python

        await target.send(SetCleanConfig(indication=True), ["d073d5000001", "d073d5000001"])

    The options are:

    indication - boolean - default False
        whether to run a short flashing indication at the end of the HEV cycle.

    duration_s - seconds - default 7200 seconds
        duration in seconds for a cleaning cycle, if no duration provided.
    """
    if duration is not None:
        raise ProgrammerError("Duration needs to be specified as duration_s")

    return ForCapability(hev=LightMessages.SetHevCycleConfiguration(
        indication=bool(indication),
        duration_s=duration_s,
        ack_required=True,
        res_required=False,
    ))
Beispiel #2
0
    describe "HEVConfigPlan":

        async it "can get hev config", sender:
            got = await self.gather(sender, [clean.serial, light1.serial], "hev_config")
            assert got == {
                light1.serial: (True, {"hev_config": Skip}),
                clean.serial: (
                    True,
                    {"hev_config": {"duration_s": 7200, "indication": False}},
                ),
            }

            sender.gatherer.clear_cache()
            await sender(
                LightMessages.SetHevCycleConfiguration(duration_s=600, indication=False),
                clean.serial,
            )

            got = await self.gather(sender, [clean.serial, light1.serial], "hev_config")
            assert got == {
                light1.serial: (True, {"hev_config": Skip}),
                clean.serial: (
                    True,
                    {"hev_config": {"duration_s": 600, "indication": False}},
                ),
            }

    describe "CapabilityPlan":

        async it "gets the power", sender:
Beispiel #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 "sets the default config", sender:
        expected = {
            light1: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.SetHevCycleConfiguration(indication=True, duration_s=3600),
            ],
            light2: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.SetHevCycleConfiguration(indication=True, duration_s=3600),
            ],
            light3: [DeviceMessages.GetHostFirmware(), DeviceMessages.GetVersion()],
        }
        await self.run_and_compare(
            sender, SetCleanConfig(indication=True, duration_s=3600), expected=expected
        )


describe "ChangeCleanCycle":
Beispiel #4
0
        assert device.attrs.power == 0xFFFF

    async it "can change default duration", device, assertResponse, m:
        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

        setter = LightMessages.SetHevCycleConfiguration(indication=True, duration_s=69420)
        state = LightMessages.StateHevCycleConfiguration(indication=True, duration_s=69420)
        await assertResponse(setter, [state])

        setter = LightMessages.SetHevCycle(enable=True, duration_s=0, res_required=False)
        await assertResponse(setter, True)
        assert device.attrs.clean_details.enabled is True
        assert device.attrs.clean_details.duration_s == 69420
        assert device.attrs.clean_details.remaining_s == 69420
        assert device.attrs.clean_details.last_result is LightLastHevCycleResult.BUSY
        assert device.attrs.clean_details.indication is True
        assert device.attrs.clean_details.default_duration_s == 69420

    async it "can interrupt a cycle", device, assertResponse, m:

        async def start(enable, duration):