def fake_device(self): return FakeDevice( "d073d5000001", chp.default_responders( Products.LCM2_A19, label="kitchen", firmware=chp.Firmware(2, 80, 1337), group_uuid="aa", group_label="g1", group_updated_at=42, location_uuid="bb", location_label="l1", location_updated_at=56, ), )
class V: serials = ["d073d5000001", "d073d5000002", "d073d5000003"] d1 = FakeDevice(serials[0], chp.default_responders(Products.LCM3_TILE)) d2 = FakeDevice(serials[1], chp.default_responders(Products.LCM2_Z, zones=[])) d3 = FakeDevice( serials[2], chp.default_responders( Products.LCM2_A19, firmware=chp.Firmware(2, 80, 1337), group_uuid="aa", group_label="g1", group_updated_at=42, location_uuid="bb", location_label="l1", location_updated_at=56, ), ) @hp.memoized_property def devices(s): return [s.d1, s.d2, s.d3]
from photons_messages import MultiZoneEffectType, TileEffectType from photons_transport.fake import FakeDevice from photons_products import Products from delfick_project.errors_pytest import assertRaises describe "default_responders": async it "has defaults": device = FakeDevice("d073d5000001", chp.default_responders()) await device.start() assert device.attrs.vendor_id == 1 assert device.attrs.product_id == 27 assert device.attrs.firmware == chp.Firmware(0, 0, 0) assert device.attrs.color == chp.Color(0, 1, 1, 3500) assert device.attrs.power == 0 assert device.attrs.group_uuid == "" assert device.attrs.group_label == "" assert device.attrs.group_updated_at == 0 assert device.attrs.location_uuid == "" assert device.attrs.location_label == "" assert device.attrs.location_updated_at == 0 assert not any(isinstance(r, chp.ZonesResponder) for r in device.responders) assert not any(isinstance(r, chp.MatrixResponder) for r in device.responders) assert not any(isinstance(r, chp.InfraredResponder) for r in device.responders)
super().compare_received(expected, keep_duplicates=keep_duplicates) def expect_no_set_messages(self): assert not any([ m for m in self.received if m.__class__.__name__.startswith("Set") ]) a19_1 = FakeDevice( "d073d5000001", chp.default_responders( Products.LCM2_A19, label="kitchen", power=0, color=chp.Color(0, 1, 1, 2500), firmware=chp.Firmware(2, 75, 1521690429), ) + [CollectionResponder(group=group_one, location=location_one)], ) a19_2 = FakeDevice( "d073d5000002", chp.default_responders( Products.LCM2_A19, label="bathroom", power=65535, color=chp.Color(100, 1, 1, 2500), firmware=chp.Firmware(2, 75, 1521690429), ) + [CollectionResponder(group=group_two, location=location_one)], ) color1000 = FakeDevice(
zeroColor = chp.Color(0, 0, 0, 3500) zones1 = [chp.Color(i, 1, 1, 3500) for i in range(30)] zones2 = [chp.Color(90 - i, 1, 1, 3500) for i in range(6)] zones3 = [chp.Color(300 - i, 1, 1, 3500) for i in range(16)] light1 = FakeDevice( "d073d5000001", chp.default_responders( Products.LCM3_TILE, power=0, label="bob", infrared=100, color=chp.Color(100, 0.5, 0.5, 4500), firmware=chp.Firmware(3, 50, 1548977726000000000), ), ) light2 = FakeDevice( "d073d5000002", chp.default_responders( Products.LMB_MESH_A21, power=65535, label="sam", infrared=0, color=chp.Color(200, 0.3, 1, 9000), firmware=chp.Firmware(2, 2, 1448861477000000000), ), )
type=TileEffectType.FLAME, parameters={}, palette=[chp.Color(0, 0, 0, 3500)] ), [], ) describe "ZonesResponder": def make_device(self, enum, firmware, zones=None): return Device( chp.ProductResponder.from_product(enum, firmware), chp.ZonesResponder(zones=zones), ) async it "complains if you try to set too many zones": zones = [chp.Color(0, 0, 0, 0)] * 83 with assertRaises(PhotonsAppError, "Can only have up to 82 zones!"): async with self.make_device(Products.LCM1_Z, chp.Firmware(0, 0, 0), zones): pass async it "doesn't respond if we aren't a multizone device": async with self.make_device(Products.LCMV4_A19_COLOR, chp.Firmware(0, 0, 0)) as device: assert "zones_effect" not in device.attrs assert "zones" not in device.attrs await device.assertResponse(MultiZoneMessages.GetMultiZoneEffect(), []) await device.assertResponse( MultiZoneMessages.SetMultiZoneEffect.empty_normalise( type=MultiZoneEffectType.MOVE, parameters={} ), [], )