Exemple #1
0
        async def assertRemaining(duration, remaining, last_power, result):
            getter = LightMessages.GetHevCycle()
            state = LightMessages.StateHevCycle(
                duration_s=duration, remaining_s=remaining, last_power=last_power
            )
            await assertResponse(getter, [state])

            getter = LightMessages.GetLastHevCycleResult()
            state = LightMessages.StateLastHevCycleResult(result=result)
            await assertResponse(getter, [state])
        await sender(msg, devices.serials, **kwargs)

        assert len(devices) > 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 "sends the messages to devices with only correct capability", sender:

        msg = ForCapability(hev=LightMessages.GetHevCycle())

        expected = {
            a19: [DeviceMessages.GetHostFirmware(), DeviceMessages.GetVersion()],
            clean: [
                DeviceMessages.GetHostFirmware(),
                DeviceMessages.GetVersion(),
                LightMessages.GetHevCycle(),
            ],
            ir: [DeviceMessages.GetHostFirmware(), DeviceMessages.GetVersion()],
        }

        await self.assertScript(sender, msg, expected=expected)

    async it "can send message to groups", sender:
Exemple #3
0
 def messages(self):
     if self.is_hev:
         return [LightMessages.GetHevCycle(), LightMessages.GetLastHevCycleResult()]
     return Skip
Exemple #4
0
        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)
        await assertResponse(getter, [state])
        assert device.attrs.power == 0