Exemplo n.º 1
0
    def get_zones(self, start_index=0, end_index=255):
        buf = []
        bufs = []

        for i, zone in enumerate(self.device.attrs.zones):
            if i < start_index or i > end_index:
                continue

            if len(buf) == 8:
                bufs.append(buf)
                buf = []

            buf.append((i, zone))

        if buf:
            bufs.append(buf)

        for buf in bufs:
            if len(buf) == 1:
                yield MultiZoneMessages.StateZone(
                    zones_count=len(self.device.attrs.zones),
                    zone_index=buf[0][0],
                    **buf[0][1].as_dict(),
                )
                continue

            yield MultiZoneMessages.StateMultiZone(
                zones_count=len(self.device.attrs.zones),
                zone_index=buf[0][0],
                colors=[b.as_dict() for _, b in buf],
            )
Exemplo n.º 2
0
                chp.Color(6, 0.6, 0.5, 3500),
                chp.Color(7, 0.6, 0.7, 3500),
                chp.Color(8, 0.8, 0.7, 3500),
                chp.Color(9, 0.8, 0.9, 3500),
                chp.Color(10, 1.0, 0.9, 3500),
            ]
            async with self.make_device(
                Products.LCM2_Z, chp.Firmware(2, 77, 1543215651000000000), zones
            ) as device:
                device.assertAttrs(zones_effect=MultiZoneEffectType.OFF, zones=zones)

                await device.assertResponse(
                    MultiZoneMessages.GetColorZones(start_index=0, end_index=255),
                    [
                        MultiZoneMessages.StateMultiZone(
                            zones_count=11, zone_index=0, colors=zones[0:8]
                        ),
                        MultiZoneMessages.StateMultiZone(
                            zones_count=11, zone_index=8, colors=zones[8:]
                        ),
                    ],
                )
                await device.assertResponse(
                    MultiZoneMessages.SetColorZones(
                        start_index=7,
                        end_index=8,
                        hue=100,
                        saturation=0,
                        brightness=0.1,
                        kelvin=6500,
                    ),