def _register_messages(self): cool_set_point_status = StandardReceive.template( address=self._address, commandtuple=COMMAND_THERMOSTAT_COOL_SET_POINT_STATUS_0X71_NONE, flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, False), ) self._message_callbacks.add(cool_set_point_status, self._status_message_received) ext_status_recd = ExtendedReceive.template( commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00, cmd2=0x02, userdata=Userdata.template({"d1": 0x01}), ) self._message_callbacks.add(ext_status_recd, self._ext_status_received)
def _register_messages(self): temp_msg = StandardReceive.template( commandtuple=COMMAND_THERMOSTAT_TEMPERATURE_STATUS_0X6E_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE, None), ) self._message_callbacks.add(temp_msg, self._temp_received) ext_status_recd = ExtendedReceive.template( commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00, cmd2=0x02, userdata=Userdata.template({"d1": 0x01}), ) self._message_callbacks.add(ext_status_recd, self._ext_status_received)
def run_test(loop): """Asyncio coroutine to actually run the test.""" plm = MockPLM(loop) address = '1a2b3c' target = bytearray([0x00, 0x00, 0x01]) cmd2 = 0x01 cat = 0x10 subcat = 0x00 product_key = 0x00 description = 'Generic Security, Heath and Safety Device' model = '' callbacks = MockCallbacks() device = SecurityHealthSafety(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device device.states[0x01].register_updates(callbacks.callbackmethod1) msg = StandardReceive( address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=cmd2, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == cmd2 device = SecurityHealthSafety(plm, address, cat, subcat, product_key, description, model) device.states[0x01].register_updates(callbacks.callbackmethod1) msg = StandardReceive( address, target, COMMAND_LIGHT_OFF_0X13_0X00, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0x00
def run_test(loop): """Asyncio test to run.""" plm = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cat = 0x01 subcat = 0x04 product_key = None description = 'SwitchLinc Dimmer (1000W)' model = '2476DH' device = DimmableLightingControl(plm, address, cat, subcat, product_key, description, model) assert device.address.hex == address assert device.cat == cat assert device.subcat == subcat assert device.product_key == 0x00 # Product key should not be None assert device.description == description assert device.model == model assert device.id == address plm.devices[device.address.hex] = device callbacks = MockCallbacks() device.states[0x01].register_updates(callbacks.callbackmethod1) device.async_refresh_state() yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X00, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x08, 'cmd2': 0x27 }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X00) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0x27
def run_test(loop): """Asyncio test.""" plm = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cat = 0x01 subcat = 0x2e product_key = 0x00 description = 'FanLinc Dual Band' model = '2475F' device = DimmableLightingControl_2475F(plm, address, cat, subcat, product_key, description, model) plm.devices[device.address.hex] = device callbacks = MockCallbacks() device.states[0x02].register_updates(callbacks.callbackmethod1) device.states[0x02].async_refresh_state() yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_NONE, cmd2=0x03, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x08, 'cmd2': 0x27 }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_NONE, cmd2=0x03) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0x27
def __init__(self, address, target, commandtuple, cmd2=None, flags=0x00): """Init the StandardReceive message class.""" if commandtuple.get('cmd1') is not None: cmd1 = commandtuple['cmd1'] cmd2out = commandtuple['cmd2'] else: raise ValueError if cmd2 is not None: cmd2out = cmd2 if cmd2out is None: raise ValueError self._address = Address(address) self._target = Address(target) self._messageFlags = MessageFlags(flags) # self._messageFlags.extended = 0 self._cmd1 = cmd1 self._cmd2 = cmd2out
def __init__(self, address, target, commandtuple, userdata, cmd2=None, flags=0x10): """Init the ExtendedRecieve message class.""" if commandtuple.get("cmd1", None) is not None: cmd1 = commandtuple["cmd1"] cmd2out = commandtuple["cmd2"] else: raise ValueError if cmd2 is not None: cmd2out = cmd2 if cmd2out is None: raise ValueError self._address = Address(address) self._target = Address(target) self._messageFlags = MessageFlags(flags) # self._messageFlags.extended = 1 self._cmd1 = cmd1 self._cmd2 = cmd2out self._userdata = Userdata(userdata)
def __init__(self, address, commandtuple, cmd2=None, flags=0x00, acknak=None): """Init the StandardSend message class.""" if commandtuple.get('cmd1', None) is not None: cmd1 = commandtuple['cmd1'] cmd2out = commandtuple['cmd2'] else: raise ValueError if cmd2 is not None: cmd2out = cmd2 if cmd2out is None: raise ValueError self._address = Address(address) self._messageFlags = MessageFlags(flags) self._messageFlags.extended = 0 self._cmd1 = cmd1 self._cmd2 = cmd2out self._acknak = self._setacknak(acknak)
def test_messageType(): """Test message flags match the expected message type.""" direct = MessageFlags(MESSAGE_TYPE_DIRECT_MESSAGE << 5) direct_ack = MessageFlags(MESSAGE_TYPE_DIRECT_MESSAGE_ACK << 5) all_link_cleanup = MessageFlags(MESSAGE_TYPE_ALL_LINK_CLEANUP << 5) all_link_cleanup_ack = MessageFlags(MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK << 5) broadcast = MessageFlags(MESSAGE_TYPE_BROADCAST_MESSAGE << 5) direct_nak = MessageFlags(MESSAGE_TYPE_DIRECT_MESSAGE_NAK << 5) all_link_broadcast = MessageFlags(MESSAGE_TYPE_ALL_LINK_BROADCAST << 5) all_link_cleanup_nak = MessageFlags(MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK << 5) assert direct.messageType == MESSAGE_TYPE_DIRECT_MESSAGE assert direct.isDirect assert direct_ack.messageType == MESSAGE_TYPE_DIRECT_MESSAGE_ACK assert direct_ack.isDirectACK assert all_link_cleanup.messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP assert all_link_cleanup.isAllLinkCleanup assert ( all_link_cleanup_ack.messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK) assert all_link_cleanup_ack.isAllLinkCleanupACK assert broadcast.messageType == MESSAGE_TYPE_BROADCAST_MESSAGE assert broadcast.isBroadcast assert direct_nak.messageType == MESSAGE_TYPE_DIRECT_MESSAGE_NAK assert direct_nak.isDirectNAK assert all_link_broadcast.messageType == MESSAGE_TYPE_ALL_LINK_BROADCAST assert all_link_broadcast.isAllLinkBroadcast assert ( all_link_cleanup_nak.messageType == MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK) assert all_link_cleanup_nak.isAllLinkCleanupNAK
def template(cls, address=None, target=None, commandtuple={}, cmd2=-1, flags=None): """Create a message template used for callbacks.""" msgraw = bytearray([0x02, cls._code]) msgraw.extend(bytes(cls._receivedSize)) msg = StandardReceive.from_raw_message(msgraw) cmd1 = commandtuple.get('cmd1') cmd2out = commandtuple.get('cmd2') if cmd2 is not -1: cmd2out = cmd2 msg._address = Address(address) msg._target = Address(target) msg._messageFlags = MessageFlags(flags) msg._cmd1 = cmd1 msg._cmd2 = cmd2out return msg
def template(cls, address=None, commandtuple={}, cmd2=-1, flags=None, acknak=None): """Create a message template for use in callbacks.""" msgraw = bytearray([0x02, cls._code]) msgraw.extend(bytes(cls._receivedSize)) msg = StandardSend.from_raw_message(msgraw) cmd1 = commandtuple.get('cmd1', None) cmd2out = commandtuple.get('cmd2', None) if cmd2 is not -1: cmd2out = cmd2 msg._address = Address(address) msg._messageFlags = MessageFlags(flags) msg._cmd1 = cmd1 msg._cmd2 = cmd2out msg._acknak = acknak return msg
def run_test(loop): plm = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cmd2 = 0x04 cat = 0x10 subcat = 0x00 product_key = 0x00 description = 'Generic Security, Heath and Safety Device' model = '' callbacks = MockCallbacks() device = SecurityHealthSafety_2982_222(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device device.states[0x01].register_updates(callbacks.callbackmethod1) msg = StandardReceive( address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=cmd2, flags=MessageFlags.create(MESSAGE_FLAG_BROADCAST_0X80, 0, 0, 0)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0x6f
async def run_test(loop): """Asyncio test method.""" plm = MockPLM(loop) callbacks = MockCallbacks() address = '1a2b3c' target = '4d5e6f' cat = 0x02 subcat = 0x0d product_key = None description = 'ToggleLinc Relay' model = '2466S' device = SwitchedLightingControl_2663_222(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device assert device.address.hex == address assert device.cat == cat assert device.subcat == subcat assert device.product_key == 0x00 # Product key should not be None assert device.description == description assert device.model == model assert device.id == address device.states[0x01].register_updates(callbacks.callbackmethod1) device.states[0x02].register_updates(callbacks.callbackmethod2) device.states[0x01].on() await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff) assert plm.sentmessage == sentmsg.hex receivedmsg = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x09, 'cmd2': 0xff }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0xff device.states[0x02].on() await asyncio.sleep(.1, loop=loop) receivedmsg = ExtendedSend(address, COMMAND_LIGHT_ON_0X11_NONE, {'d1': 0x02}, cmd2=0xff, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x09, 'cmd2': 0xff }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) sentmsg = ExtendedSend(address, COMMAND_LIGHT_ON_0X11_NONE, {'d1': 0x02}, cmd2=0xff) sentmsg.set_checksum() assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue2 == 0xff device.states[0x01].off() await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_OFF_0X13_0X00) assert plm.sentmessage == sentmsg.hex receivedmsg = StandardSend(address, COMMAND_LIGHT_OFF_0X13_0X00, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x09, 'cmd2': 0x00 }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_OFF_0X13_0X00) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0x00 device.states[0x02].off() await asyncio.sleep(.1, loop=loop) receivedmsg = ExtendedSend(address, COMMAND_LIGHT_OFF_0X13_0X00, {'d1': 0x02}, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, { 'cmd1': 0x09, 'cmd2': 0x00 }, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) sentmsg = ExtendedSend(address, COMMAND_LIGHT_OFF_0X13_0X00, {'d1': 0x02}) sentmsg.set_checksum() assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue2 == 0x00
def test_extended(): """Test the extended flag.""" assert MessageFlags(0x10).extended == 1 assert MessageFlags(0x10).isExtended
def _register_messages(self): template_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_on_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_off_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_STOP_MANUAL_CHANGE_0X18_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_instant_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_INSTANT_CHANGE_0X21_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) self._message_callbacks.add(template_on_broadcast, self._on_message_received) self._message_callbacks.add(template_on_fast_broadcast, self._on_message_received) self._message_callbacks.add(template_off_broadcast, self._off_message_received) self._message_callbacks.add(template_off_fast_broadcast, self._off_message_received) self._message_callbacks.add(template_manual_broadcast, self._manual_change_received) self._message_callbacks.add(template_instant_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_off_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_on_broadcast, self._manual_change_received)
def __init__(self, address, statename, group, send_message_method, message_callbacks, defaultvalue=None): """Initalize the DimmableSwitch Class.""" super().__init__(address, statename, group, send_message_method, message_callbacks, defaultvalue) self._updatemethod = self._send_status_request self.log.debug('Registering callbacks for DimmableSwitch device %s', self._address.human) template_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None)) template_on_fast_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None)) template_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_off_fast_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_manual_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_STOP_MANUAL_CHANGE_0X18_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_instant_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_INSTANT_CHANGE_0X21_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_manual_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_manual_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=None) template_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_on_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_off_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_STOP_MANUAL_CHANGE_0X18_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_instant_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_INSTANT_CHANGE_0X21_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) self._message_callbacks.add(template_on_cleanup, self._on_message_received) self._message_callbacks.add(template_on_fast_cleanup, self._on_message_received) self._message_callbacks.add(template_off_cleanup, self._off_message_received) self._message_callbacks.add(template_off_fast_cleanup, self._off_message_received) self._message_callbacks.add(template_manual_cleanup, self._manual_change_received) self._message_callbacks.add(template_instant_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_off_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_on_cleanup, self._manual_change_received) self._message_callbacks.add(template_on_broadcast, self._on_message_received) self._message_callbacks.add(template_on_fast_broadcast, self._on_message_received) self._message_callbacks.add(template_off_broadcast, self._off_message_received) self._message_callbacks.add(template_off_fast_broadcast, self._off_message_received) self._message_callbacks.add(template_manual_broadcast, self._manual_change_received) self._message_callbacks.add(template_instant_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_off_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_on_broadcast, self._manual_change_received)
def test_eq(): """Test comarision for equality.""" flag1 = MessageFlags(0x80) flag2 = MessageFlags(0x25) flag3 = MessageFlags(0x27) flag4 = MessageFlags(0x16) flag5 = MessageFlags(0x37) flag6 = MessageFlags(0x6f) pattern1 = MessageFlags.template(MESSAGE_TYPE_BROADCAST_MESSAGE, 0) pattern2 = MessageFlags.template(MESSAGE_TYPE_BROADCAST_MESSAGE, None) pattern3 = MessageFlags.template(None, 0) pattern4 = MessageFlags.template(None, 1) pattern5 = MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0) pattern6 = MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 1) pattern7 = MessageFlags.template(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, None) assert flag1.matches_pattern(pattern1) assert not flag2.matches_pattern(pattern1) assert not flag3.matches_pattern(pattern1) assert not flag4.matches_pattern(pattern1) assert not flag5.matches_pattern(pattern1) assert not flag6.matches_pattern(pattern1) assert flag1.matches_pattern(pattern2) assert not flag2.matches_pattern(pattern2) assert not flag3.matches_pattern(pattern2) assert not flag4.matches_pattern(pattern2) assert not flag5.matches_pattern(pattern2) assert not flag6.matches_pattern(pattern2) assert flag1.matches_pattern(pattern3) assert flag2.matches_pattern(pattern3) assert flag3.matches_pattern(pattern3) assert not flag4.matches_pattern(pattern3) assert not flag5.matches_pattern(pattern3) assert flag6.matches_pattern(pattern3) assert not flag1.matches_pattern(pattern4) assert not flag2.matches_pattern(pattern4) assert not flag3.matches_pattern(pattern4) assert flag4.matches_pattern(pattern4) assert flag5.matches_pattern(pattern4) assert not flag6.matches_pattern(pattern4) assert not flag1.matches_pattern(pattern5) assert flag2.matches_pattern(pattern5) assert flag3.matches_pattern(pattern5) assert not flag4.matches_pattern(pattern5) assert not flag5.matches_pattern(pattern5) assert not flag6.matches_pattern(pattern5) assert not flag1.matches_pattern(pattern6) assert not flag2.matches_pattern(pattern6) assert not flag3.matches_pattern(pattern6) assert not flag4.matches_pattern(pattern6) assert flag5.matches_pattern(pattern6) assert not flag6.matches_pattern(pattern6) assert not flag1.matches_pattern(pattern7) assert flag2.matches_pattern(pattern7) assert flag3.matches_pattern(pattern7) assert not flag4.matches_pattern(pattern7) assert flag5.matches_pattern(pattern7) assert not flag6.matches_pattern(pattern7)
def _run_test(loop): """Test on/off sensor.""" plm = MockPLM(loop) address = '1a2b3c' cat = 0x10 subcat = 0x00 product_key = 0x00 description = 'Generic Security, Heath and Safety Device' model = '' callbacks = MockCallbacks() device = SecurityHealthSafety_2852_222(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device device.states[0x01].register_updates(callbacks.callbackmethod1) device.states[0x02].register_updates(callbacks.callbackmethod2) device.states[0x04].register_updates(callbacks.callbackmethod4) # Test Dry message received msg = StandardReceive( address=address, target=bytearray([0x00, 0x00, 0x01]), commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x01, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 1 assert callbacks.callbackvalue2 == 0 assert callbacks.callbackvalue4 == 0x11 # Test wet message received msg = StandardReceive( address=address, target=bytearray([0x00, 0x00, 0x02]), commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x02, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0 assert callbacks.callbackvalue2 == 1 assert callbacks.callbackvalue4 == 0x13 # Test dry heartbeat received msg = StandardReceive( address=address, target=bytearray([0x00, 0x00, 0x04]), commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x04, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 1 assert callbacks.callbackvalue2 == 0 # Test wet heartbeat received msg = StandardReceive( address=address, target=bytearray([0x00, 0x00, 0x04]), commandtuple={'cmd1': 0x13, 'cmd2': 0x04}, flags=MessageFlags.create(MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 3, 3)) plm.message_received(msg) yield from asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0 assert callbacks.callbackvalue2 == 1 assert callbacks.callbackvalue4 == 0x13
def _register_messages(self): """Register messages to listen for.""" template_on_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_fast_on_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_off_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_fast_off_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_on_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_manual_off_group = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None) template_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) template_fast_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) template_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) template_fast_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) template_manual_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) template_manual_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group) self._message_callbacks.add(template_on_group, self._on_message_received) self._message_callbacks.add(template_fast_on_group, self._on_message_received) self._message_callbacks.add(template_off_group, self._off_message_received) self._message_callbacks.add(template_fast_off_group, self._off_message_received) self._message_callbacks.add(template_manual_on_group, self._manual_change_received) self._message_callbacks.add(template_manual_off_group, self._manual_change_received) self._message_callbacks.add(template_on_cleanup, self._on_message_received) self._message_callbacks.add(template_fast_on_cleanup, self._on_message_received) self._message_callbacks.add(template_off_cleanup, self._off_message_received) self._message_callbacks.add(template_fast_off_cleanup, self._off_message_received) self._message_callbacks.add(template_manual_on_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_off_cleanup, self._manual_change_received)
async def run_test(loop): """Asyncio test method.""" plm = MockPLM(loop) callbacks = MockCallbacks() address = '1a2b3c' cat = 0x02 subcat = 0x0d product_key = None description = 'ToggleLinc Relay' model = '2466S' device = SwitchedLightingControl_2663_222(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device assert device.address.hex == address assert device.cat == cat assert device.subcat == subcat assert device.product_key == 0x00 # Product key should not be None assert device.description == description assert device.model == model assert device.id == address device.states[0x01].register_updates(callbacks.callbackmethod1) device.states[0x02].register_updates(callbacks.callbackmethod2) receivedmsg = StandardReceive(address, '000001', COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x66, flags=MessageFlags.create( MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0xff receivedmsg = StandardReceive(address, '000001', COMMAND_LIGHT_OFF_0X13_0X00, flags=MessageFlags.create( MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue1 == 0x00 receivedmsg = StandardReceive(address, '000002', COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x66, flags=MessageFlags.create( MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue2 == 0xff receivedmsg = StandardReceive(address, '000002', COMMAND_LIGHT_OFF_0X13_0X00, flags=MessageFlags.create( MESSAGE_TYPE_ALL_LINK_BROADCAST, 0, 2, 3)) plm.message_received(receivedmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.callbackvalue2 == 0x00
async def run_test(loop): """Asyncio test.""" class fanLincStatus(): """Callback class to capture sensor changes.""" lightOnLevel = None fanOnLevel = None # pylint: disable=unused-argument def device_status_callback1(self, device_id, state, value): """Callback method to capture light changes.""" self.lightOnLevel = value # pylint: disable=unused-argument def device_status_callback2(self, device_id, state, value): """Callback method to capture fan changes.""" self.fanOnLevel = value mockPLM = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cat = 0x01 subcat = 0x2e product_key = 0x00 description = 'FanLinc Dual Band' model = '2475F' callbacks = fanLincStatus() device = DimmableLightingControl_2475F(mockPLM, address, cat, subcat, product_key, description, model) mockPLM.devices[device.address.hex] = device assert device.states[0x01].name == 'lightOnLevel' assert device.states[0x02].name == 'fanOnLevel' device.states[0x01].register_updates(callbacks.device_status_callback1) device.states[0x02].register_updates(callbacks.device_status_callback2) device.states[0x01].async_refresh_state() await asyncio.sleep(.1, loop=loop) ackmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X00, acknak=MESSAGE_ACK) statusmsg = StandardReceive( address, target, {'cmd1': 0xdf, 'cmd2': 0x55}, flags=MessageFlags.create(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) mockPLM.message_received(ackmsg) await asyncio.sleep(.1, loop=loop) mockPLM.message_received(statusmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.lightOnLevel == 0x55 device.states[0x02].async_refresh_state() await asyncio.sleep(.1, loop=loop) ackmsg = StandardSend(address, {'cmd1': 0x19, 'cmd2': 0x03}, flags=0x00, acknak=MESSAGE_ACK) statusmsg = StandardReceive( address, target, {'cmd1': 0xab, 'cmd2': 0x77}, flags=MessageFlags.create(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) mockPLM.message_received(ackmsg) await asyncio.sleep(.1, loop=loop) mockPLM.message_received(statusmsg) await asyncio.sleep(.1, loop=loop) assert callbacks.lightOnLevel == 0x55 assert callbacks.fanOnLevel == 0x77
def run_test(loop): """Asyncio test run.""" plm = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cat = 0x07 subcat = 0x00 product_key = 0x00 description = 'I/O Linc' model = '2450' callbacks = MockCallbacks() device = SensorsActuators_2450(plm, address, cat, subcat, product_key, description, model) plm.devices[address] = device assert device.states[0x01].name == 'openClosedRelay' assert device.states[0x02].name == 'openClosedSensor' device.states[0x01].register_updates(callbacks.callbackmethod1) device.states[0x02].register_updates(callbacks.callbackmethod2) device.async_refresh_state() yield from asyncio.sleep(.1, loop=loop) # First state sentmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X00) assert plm.sentmessage == sentmsg.hex receivedmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X00, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x55, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0)) plm.message_received(receivedmsg) yield from asyncio.sleep(.3, loop=loop) assert callbacks.callbackvalue1 == 0xff # Second state receivedmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01, acknak=MESSAGE_ACK) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) receivedmsg = StandardReceive(address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x33, flags=MessageFlags.create( MESSAGE_TYPE_BROADCAST_MESSAGE, 0)) plm.message_received(receivedmsg) yield from asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0xff assert callbacks.callbackvalue2 == 1
def __init__(self, address, statename, group, send_message_method, message_callbacks, defaultvalue=None): """Initialize the LeakSensorDry state.""" super().__init__(address, statename, group, send_message_method, message_callbacks, defaultvalue) self._dry_wet_callbacks = [] template_dry_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=self._group, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_BROADCAST_MESSAGE, None)) template_wet_broadcast = StandardReceive.template( commandtuple={ 'cmd1': 0x13, 'cmd2': self._group }, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_BROADCAST_MESSAGE, None)) template_dry_all_link = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=self._group, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_wet_all_link = StandardReceive.template( commandtuple={ 'cmd1': 0x13, 'cmd2': self._group }, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None)) template_dry_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, cmd2=self._group, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None)) template_wet_cleanup = StandardReceive.template( commandtuple={ 'cmd1': 0x13, 'cmd2': self._group }, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None)) self._message_callbacks.add(template_dry_broadcast, self._dry_message_received) self._message_callbacks.add(template_wet_broadcast, self._wet_message_received) self._message_callbacks.add(template_dry_all_link, self._dry_message_received) self._message_callbacks.add(template_wet_all_link, self._wet_message_received) self._message_callbacks.add(template_dry_cleanup, self._dry_message_received) self._message_callbacks.add(template_wet_cleanup, self._wet_message_received)
async def run_test(loop): """Asyncio test to run.""" plm = MockPLM(loop) address = '1a2b3c' target = '4d5e6f' cat = 0x01 subcat = 0x04 product_key = None description = 'SwitchLinc Dimmer (1000W)' model = '2476DH' device = DimmableLightingControl(plm, address, cat, subcat, product_key, description, model) assert device.address.hex == address assert device.cat == cat assert device.subcat == subcat assert device.product_key == 0x00 # Product key should not be None assert device.description == description assert device.model == model assert device.id == address plm.devices[device.address.hex] = device callbacks = MockCallbacks() device.states[0x01].register_updates(callbacks.callbackmethod1) device.states[0x01].on() await asyncio.sleep(.1, loop=loop) plm.message_received(StandardSend( address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff, acknak=MESSAGE_ACK)) await asyncio.sleep(.1, loop=loop) plm.message_received(StandardReceive( address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff, flags=MessageFlags.create( MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3))) await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0xff device.states[0x01].off() await asyncio.sleep(.1, loop=loop) recievedmsg = StandardSend(address, COMMAND_LIGHT_OFF_0X13_0X00, acknak=MESSAGE_ACK) plm.message_received(recievedmsg) await asyncio.sleep(.1, loop=loop) recievedmsg = StandardReceive( address, target, COMMAND_LIGHT_OFF_0X13_0X00, flags=MessageFlags.create(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(recievedmsg) await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_OFF_0X13_0X00) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0x00 device.states[0x01].set_level(0x55) await asyncio.sleep(.1, loop=loop) recievedmsg = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x55, acknak=MESSAGE_ACK) plm.message_received(recievedmsg) await asyncio.sleep(.1, loop=loop) recievedmsg = StandardReceive( address, target, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x55, flags=MessageFlags.create(MESSAGE_TYPE_DIRECT_MESSAGE_ACK, 0, 2, 3)) plm.message_received(recievedmsg) await asyncio.sleep(.1, loop=loop) sentmsg = StandardSend(address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0x55) assert plm.sentmessage == sentmsg.hex assert callbacks.callbackvalue1 == 0x55
def _register_messages(self): _LOGGER.debug("Registering callbacks for DimmableSwitch device %s", self._address.human) template_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_on_fast_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_off_fast_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_manual_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_STOP_MANUAL_CHANGE_0X18_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_instant_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_INSTANT_CHANGE_0X21_NONE, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_manual_off_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_manual_on_cleanup = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_CLEANUP, None), cmd2=self._group, ) template_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_0X11_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), ) template_on_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_ON_FAST_0X12_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), ) template_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_0X13_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) template_off_fast_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_OFF_FAST_0X14_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) template_manual_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_STOP_MANUAL_CHANGE_0X18_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) template_instant_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_INSTANT_CHANGE_0X21_NONE, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) template_manual_off_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_OFF_0X22_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) template_manual_on_broadcast = StandardReceive.template( commandtuple=COMMAND_LIGHT_MANUALLY_TURNED_ON_0X23_0X00, address=self._address, target=bytearray([0x00, 0x00, self._group]), flags=MessageFlags.template(MESSAGE_TYPE_ALL_LINK_BROADCAST, None), cmd2=None, ) self._message_callbacks.add(template_on_cleanup, self._manual_change_received) self._message_callbacks.add(template_on_fast_cleanup, self._manual_change_received) self._message_callbacks.add(template_off_cleanup, self._manual_change_received) self._message_callbacks.add(template_off_fast_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_cleanup, self._manual_change_received) self._message_callbacks.add(template_instant_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_off_cleanup, self._manual_change_received) self._message_callbacks.add(template_manual_on_cleanup, self._manual_change_received) self._message_callbacks.add(template_on_broadcast, self._on_message_received) self._message_callbacks.add(template_on_fast_broadcast, self._on_message_received) self._message_callbacks.add(template_off_broadcast, self._off_message_received) self._message_callbacks.add(template_off_fast_broadcast, self._off_message_received) self._message_callbacks.add(template_manual_broadcast, self._manual_change_received) self._message_callbacks.add(template_instant_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_off_broadcast, self._manual_change_received) self._message_callbacks.add(template_manual_on_broadcast, self._manual_change_received)