def rx_encrypted(rx_encrypted_short, rx_encrypted_long, command_class_serializer): def inner(command_name: str, class_id=None, /, **kwargs): command = make_command(class_id or Security1.class_id, command_name, Security1.class_version, **kwargs) command_data = command_class_serializer.to_bytes(command) if len(command_data) <= 26: rx_encrypted_short(command_data) else: rx_encrypted_long(command_data)
def rx(controller, node, command_class, command_class_serializer): def inner(name: str, class_id=None, /, **kwargs): command = make_command(class_id or command_class.class_id, name, command_class.class_version, **kwargs) data = command_class_serializer.to_bytes(command) node.handle_command(source_id=1, command=data) assert controller.pop() == { 'messageType': 'ACK', 'message': { 'destination': {'homeId': 123, 'nodeId': 1}, 'source': {'homeId': 123, 'nodeId': 2} } }
def tx(controller, command_class, command_class_serializer): def inner(name: str, class_id=None, destination_id=1, /, **kwargs): command = make_command(class_id or command_class.class_id, name, command_class.class_version, **kwargs) data = command_class_serializer.to_bytes(command) assert controller.pop() == { 'messageType': 'APPLICATION_COMMAND', 'message': { 'destination': {'homeId': 123, 'nodeId': destination_id}, 'source': {'homeId': 123, 'nodeId': 2}, 'command': data } }
from network.protocol import make_command COMMAND_CLASS_BASIC_1 = [([0x20, 0x01, 0x01], make_command(0x20, 'BASIC_SET', 1, value=1)), ([0x20, 0x02], make_command(0x20, 'BASIC_GET', 1)), ([0x20, 0x03, 0x01], make_command(0x20, 'BASIC_REPORT', 1, value=1))] COMMAND_CLASS_SWITCH_BINARY_1 = [ ([0x25, 0x01, 0x01], make_command(0x25, 'SWITCH_BINARY_SET', 1, value=1)), ([0x25, 0x02], make_command(0x25, 'SWITCH_BINARY_GET', 1)), ([0x25, 0x03, 0x01], make_command(0x25, 'SWITCH_BINARY_REPORT', 1, value=1)) ] COMMAND_CLASS_SWITCH_BINARY_2 = [ ([0x25, 0x01, 0x01, 0x02], make_command(0x25, 'SWITCH_BINARY_SET', 2, value=1, duration=2)), ([0x25, 0x02], make_command(0x25, 'SWITCH_BINARY_GET', 2)), ([0x25, 0x03, 0x01, 0x02, 0x03], make_command(0x25, 'SWITCH_BINARY_REPORT', 2, current_value=1, target_value=2, duration=3)) ]
def make_command(cls, command_name: str, **kwargs) -> Command: return make_command(cls.class_id, command_name, cls.class_version, **kwargs)
from network.protocol import make_command from tools import make_object COMMAND_CLASS_ASSOCIATION_1 = [ ([0x85, 0x01, 0x01, 0x02, 0x03], make_command(0x85, 'ASSOCIATION_SET', 1, group_id=0x01, node_ids=[0x02, 0x03])), ([0x85, 0x02, 0x01], make_command(0x85, 'ASSOCIATION_GET', 1, group_id=0x01)), ([0x85, 0x03, 0x01, 0x02, 0x03, 0x04, 0x05], make_command(0x85, 'ASSOCIATION_REPORT', 1, group_id=0x01, max_nodes_supported=0x02, reports_to_follow=0x03, node_ids=[0x04, 0x05])), ([0x85, 0x04, 0x01, 0x02, 0x03], make_command(0x85, 'ASSOCIATION_REMOVE', 1, group_id=0x01, node_ids=[0x02, 0x03])), ([0x85, 0x05], make_command(0x85, 'ASSOCIATION_GROUPINGS_GET', 1)), ([0x85, 0x06, 0x01],
from network.protocol import make_command from tools import make_object COMMAND_CLASS_MULTI_CHANNEL_3 = [ ([0x60, 0x07], make_command(0x60, 'MULTI_CHANNEL_END_POINT_GET', 3)), ([0x60, 0x08, 0x80, 0x01], make_command(0x60, 'MULTI_CHANNEL_END_POINT_REPORT', 3, dynamic=True, identical=False, endpoints=0x01)), ([0x60, 0x09, 0x01], make_command(0x60, 'MULTI_CHANNEL_CAPABILITY_GET', 3, endpoint=0x01)), ([0x60, 0x0A, 0x81, 0x01, 0x02, 0x03, 0x04], make_command(0x60, 'MULTI_CHANNEL_CAPABILITY_REPORT', 3, dynamic=True, endpoint=0x01, generic_device_class=0x01, specific_device_class=0x02, command_class_ids=[0x03, 0x04])), ([0x60, 0x0B, 0x01, 0x02], make_command(0x60, 'MULTI_CHANNEL_END_POINT_FIND', 3, generic_device_class=0x01, specific_device_class=0x02)), ([0x60, 0x0C, 0x01, 0x02, 0x03, 0x04, 0x05],