describe "InfraredResponder": @pytest.fixture() async def device(self): device = Device( chp.ProductResponder.from_product(Products.LCM2_A19_PLUS), chp.InfraredResponder() ) async with device: device.assertAttrs(infrared=0) yield device async it "responds to infrared messages", device: await device.assertResponse( LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=0)] ) await device.assertResponse( LightMessages.SetInfrared(brightness=100), [LightMessages.StateInfrared(brightness=0)], infrared=100, ) await device.assertResponse( LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=100)], infrared=100, ) async it "doesn't respond to infrared if the product doesn't have infrared": device = Device( chp.ProductResponder.from_product(Products.LCM2_A19), chp.InfraredResponder()
, "cap": ["color", "ir", "not_chain", "not_multizone", "variable_color_temp"] } } self.maxDiff = None self.assertEqual(info, expected) self.expect_received(device1) self.expect_received(device2) self.expect_received(device3) device1.change_infrared(22) device2.change_infrared(25) device3.change_infrared(67) script = target.script(LightMessages.GetInfrared()) found = [] async for pkt, _, _ in script.run_with(finder.find(), afr): assert pkt | LightMessages.StateInfrared found.append((pkt.serial, pkt.payload.brightness)) self.expect_received(device1, LightMessages.GetInfrared) self.expect_received(device2, LightMessages.GetInfrared) self.expect_received(device3, LightMessages.GetInfrared) self.assertEqual(sorted(found) , sorted([(device1.serial, 22), (device2.serial, 25), (device3.serial, 67)]) ) found = [] async for pkt, _, _ in script.run_with(finder.find(location_name="four"), afr):
describe "Infrared": @pytest.fixture() def device(self): device = devices["ir"] assert device.cap.has_ir devices.store(device).assertAttrs(infrared=0) return device @pytest.fixture() def assertResponse(self, device, **attrs): return makeAssertResponse(device, **attrs) async it "responds to infrared messages", device, assertResponse: await assertResponse( LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=0)] ) await assertResponse( LightMessages.SetInfrared(brightness=100), [LightMessages.StateInfrared(brightness=0)], infrared=100, ) await assertResponse( LightMessages.GetInfrared(), [LightMessages.StateInfrared(brightness=100)], infrared=100, ) async it "doesn't respond to infrared if the product doesn't have infrared": device = devices["a19"] assert not device.cap.has_ir