def run_test(loop): plm = MockPLM(loop) target = bytearray() target.append(0x01) target.append(0x0d) device = create(plm, '112233', target[0], target[1], None) assert device.id == '112233' assert isinstance(device, DimmableLightingControl)
def test_create_device_from_bytearray(): """Test create device from byte array.""" plm = MockPLM() target = bytearray() target.append(0x01) target.append(0x0d) device = insteonplm.devices.create(plm, '112233', target[0], target[1], None) assert device.id == '112233' assert isinstance(device, DimmableLightingControl)
def run_test(loop): mockPLM = MockPLM(loop) address = '1a2b3c' device = insteonplm.devices.create(mockPLM, address, 0x01, 0x0d, 0x44) mockPLM.devices[address] = device # Send the ON command. This should be sent directly to the PLM device.states[0x01].on() yield from asyncio.sleep(.1, loop=loop) # Send the OFF command. This should wait in queue until the # Direct ACK timeout device.states[0x01].off() yield from asyncio.sleep(.1, loop=loop) # ACK the ON command msgreceived = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff, flags=0x00, acknak=MESSAGE_ACK) mockPLM.message_received(msgreceived) asyncio.sleep(.1, loop=loop) _LOGGING.debug('Assert that the ON command is the command in the PLM') assert mockPLM.sentmessage == StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff, flags=0x00).hex # Sleep until the Direct ACK time out should expire yield from asyncio.sleep(DIRECT_ACK_WAIT_TIMEOUT + .2, loop=loop) # Confirm that the OFF command made it to the PLM assert mockPLM.sentmessage == StandardSend( address, COMMAND_LIGHT_OFF_0X13_0X00).hex
async def run_test(loop): mockPLM = MockPLM(loop) linkcode = 0x01 group = 0x00 address = '112233' cat = 0x02 subcat = 0x39 firmware = 0x44 # Create OutletLinc device = insteonplm.devices.create(mockPLM, address, cat, subcat, firmware) # Start the process with an All-Link complete message with # the IM as a controller of Group 0x00 msg = AllLinkComplete(linkcode, group, address, cat, subcat, firmware) device.receive_message(msg) await asyncio.sleep(.1, loop=loop) # The device should start linking based on the groups in # self.states assert mockPLM.sentmessage == StandardSend( device.address, COMMAND_ENTER_LINKING_MODE_0X09_NONE, cmd2=0x01).hex msg = StandardSend(device.address, COMMAND_ENTER_LINKING_MODE_0X09_NONE, cmd2=0x01, acknak=MESSAGE_ACK) device.receive_message(msg) await asyncio.sleep(.1, loop=loop) # Confirm that the link attempt to group 0x01 completed msg = AllLinkComplete(0x00, 0x01, address, cat, subcat, firmware) device.receive_message(msg) await asyncio.sleep(.1, loop=loop) # The device should then start linking to group 0x02 assert mockPLM.sentmessage == StandardSend( device.address, COMMAND_ENTER_LINKING_MODE_0X09_NONE, cmd2=0x02).hex await asyncio.sleep(1, loop=loop) # Confirm that the link attempt to group 0x02 completed msg = AllLinkComplete(0x00, 0x01, address, cat, subcat, firmware) device.receive_message(msg) await asyncio.sleep(.1, loop=loop) # The device will now attempt to read the ALDB msg = ExtendedSend(address, COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00, userdata=Userdata()) msg.set_checksum() assert mockPLM.sentmessage == msg.hex # Send a dummy ALDB record as a high water mark to end the process msg = ExtendedReceive( address, '111111', commandtuple=COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00, userdata=Userdata({ 'd1': 0, 'd2': 0x01, 'd3': 0xff, 'd4': 0x77, 'd5': 0, 'd6': 0, 'd7': 0, 'd8': 0, 'd9': 0, 'd10': 0, 'd11': 0, 'd12': 0, 'd13': 0, 'd14': 0x3b })) device.receive_message(msg) await asyncio.sleep(1, loop=loop)
def test_create_device(): """Test create device.""" plm = MockPLM() device = insteonplm.devices.create(plm, '112233', 0x01, 0x0d, None) assert device.id == '112233' assert isinstance(device, DimmableLightingControl)
def run_test(loop): plm = MockPLM(loop) device = create(plm, '112233', 0x01, 0x0d, None) assert device.id == '112233' assert isinstance(device, DimmableLightingControl)