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 start_all_linking(self, linkcode, group, address=None): """Start the All-Linking process with the IM and device.""" _LOGGING.info('Starting the All-Linking process') if address: linkdevice = self.plm.devices[Address(address).id] if not linkdevice: linkdevice = create(self.plm, address, None, None) _LOGGING.info('Attempting to link the PLM to device %s. ', address) self.plm.start_all_linking(linkcode, group) asyncio.sleep(.5, loop=self.loop) linkdevice.enter_linking_mode(group=group) else: _LOGGING.info('Starting All-Linking on PLM. ' 'Waiting for button press') self.plm.start_all_linking(linkcode, group) yield from asyncio.sleep(self.wait_time, loop=self.loop) _LOGGING.info('%d devices added to the All-Link Database', len(self.plm.devices)) yield from asyncio.sleep(.1, loop=self.loop)
def run_test(loop): mockPLM = MockPLM(loop) address = '1a2b3c' device = 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
def run_test(loop): plm = MockPLM(loop) device = create(plm, '112233', 0x01, 0x0d, None) assert device.id == '112233' assert isinstance(device, DimmableLightingControl)