class Commissioning(Cluster): """Attributes and commands for commissioning and managing a ZigBee device.""" cluster_id = 0x0015 ep_attribute = "commissioning" attributes = { # Startup Parameters 0x0000: ("short_address", t.uint16_t), 0x0001: ("extended_pan_id", t.EUI64), 0x0002: ("pan_id", t.uint16_t), 0x0003: ("channelmask", t.bitmap32), 0x0004: ("protocol_version", t.uint8_t), 0x0005: ("stack_profile", t.uint8_t), 0x0006: ("startup_control", t.enum8), 0x0010: ("trust_center_address", t.EUI64), 0x0011: ("trust_center_master_key", t.fixed_list(16, t.uint8_t)), 0x0012: ("network_key", t.fixed_list(16, t.uint8_t)), 0x0013: ("use_insecure_join", t.Bool), 0x0014: ("preconfigured_link_key", t.fixed_list(16, t.uint8_t)), 0x0015: ("network_key_seq_num", t.uint8_t), 0x0016: ("network_key_type", t.enum8), 0x0017: ("network_manager_address", t.uint16_t), # Join Parameters 0x0020: ("scan_attempts", t.uint8_t), 0x0021: ("time_between_scans", t.uint16_t), 0x0022: ("rejoin_interval", t.uint16_t), 0x0023: ("max_rejoin_interval", t.uint16_t), # End Device Parameters 0x0030: ("indirect_poll_rate", t.uint16_t), 0x0031: ("parent_retry_threshold", t.uint8_t), # Concentrator Parameters 0x0040: ("concentrator_flag", t.Bool), 0x0041: ("concentrator_radius", t.uint8_t), 0x0042: ("concentrator_discovery_time", t.uint8_t), } server_commands = { 0x0000: ("restart_device", (t.uint8_t, t.uint8_t, t.uint8_t), False), 0x0001: ("save_startup_parameters", (t.uint8_t, t.uint8_t), False), 0x0002: ("restore_startup_parameters", (t.uint8_t, t.uint8_t), False), 0x0003: ("reset_startup_parameters", (t.uint8_t, t.uint8_t), False), } client_commands = { 0x0000: ("restart_device_response", (t.uint8_t, ), True), 0x0001: ("save_startup_params_response", (t.uint8_t, ), True), 0x0002: ("restore_startup_params_response", (t.uint8_t, ), True), 0x0003: ("reset_startup_params_response", (t.uint8_t, ), True), }
class Commissioning(Cluster): """Attributes and commands for commissioning and managing a ZigBee device.""" cluster_id = 0x0015 ep_attribute = 'commissioning' attributes = { # Startup Parameters 0x0000: ('short_address', t.uint16_t), 0x0001: ('extended_pan_id', t.EUI64), 0x0002: ('pan_id', t.uint16_t), 0x0003: ('channelmask', t.uint32_t), # bitmap32 0x0004: ('protocol_version', t.uint8_t), 0x0005: ('stack_profile', t.uint8_t), 0x0006: ('startup_control', t.uint8_t), # enum8 0x0010: ('trust_center_address', t.EUI64), 0x0011: ('trust_center_master_key', t.fixed_list(16, t.uint8_t)), 0x0012: ('network_key', t.fixed_list(16, t.uint8_t)), 0x0013: ('use_insecure_join', t.Bool), 0x0014: ('preconfigured_link_key', t.fixed_list(16, t.uint8_t)), 0x0015: ('network_key_seq_num', t.uint8_t), 0x0016: ('network_key_type', t.uint8_t), # enum8 0x0017: ('network_manager_address', t.uint16_t), # Join Parameters 0x0020: ('scan_attempts', t.uint8_t), 0x0021: ('time_between_scans', t.uint16_t), 0x0022: ('rejoin_interval', t.uint16_t), 0x0023: ('max_rejoin_interval', t.uint16_t), # End Device Parameters 0x0030: ('indirect_poll_rate', t.uint16_t), 0x0031: ('parent_retry_threshold', t.uint8_t), # Concentrator Parameters 0x0040: ('concentrator_flag', t.Bool), 0x0041: ('concentrator_radius', t.uint8_t), 0x0042: ('concentrator_discovery_time', t.uint8_t), } server_commands = { 0x0000: ('restart_device', (t.uint8_t, t.uint8_t, t.uint8_t), False), 0x0001: ('save_startup_parameters', (t.uint8_t, t.uint8_t), False), 0x0002: ('restore_startup_parameters', (t.uint8_t, t.uint8_t), False), 0x0003: ('reset_startup_parameters', (t.uint8_t, t.uint8_t), False), } client_commands = { 0x0000: ('restart_device_response', (t.uint8_t, ), True), 0x0001: ('save_startup_params_response', (t.uint8_t, ), True), 0x0002: ('restore_startup_params_response', (t.uint8_t, ), True), 0x0003: ('reset_startup_params_response', (t.uint8_t, ), True), }
class MultistateValueRegular(Cluster): cluster_id = 0x0612 ep_attribute = 'bacnet_regular_multistate_value' attributes = { 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.CharacterString), 0x004f: ('object_type', t.enum16), 0x00a8: ('profile_name', t.CharacterString), } server_commands = {} client_commands = {}
class MultistateValueRegular(Cluster): cluster_id = 0x0612 ep_attribute = "bacnet_regular_multistate_value" attributes = { 0x004B: ("object_id", t.fixed_list(4, t.uint8_t)), 0x004D: ("object_name", t.CharacterString), 0x004F: ("object_type", t.enum16), 0x00A8: ("profile_name", t.CharacterString), } server_commands = {} client_commands = {}
class AnalogValueRegular(Cluster): cluster_id = 0x0606 ep_attribute = 'bacnet_regular_analog_value' attributes = { 0x0016: ('cov_increment', t.Single), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.CharacterString), 0x004f: ('object_type', t.enum16), 0x00a8: ('profile_name', t.CharacterString), } server_commands = {} client_commands = {}
class MultistateInputRegular(Cluster): cluster_id = 0x060e ep_attribute = 'bacnet_regular_multistate_input' attributes = { 0x001f: ('device_type', t.LVBytes), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.LVBytes), 0x004f: ('object_type', t.enum16), 0x00a8: ('profile_name', t.LVBytes), } server_commands = {} client_commands = {}
class AnalogValueRegular(Cluster): cluster_id = 0x0606 ep_attribute = "bacnet_regular_analog_value" attributes = { 0x0016: ("cov_increment", t.Single), 0x004B: ("object_id", t.fixed_list(4, t.uint8_t)), 0x004D: ("object_name", t.CharacterString), 0x004F: ("object_type", t.enum16), 0x00A8: ("profile_name", t.CharacterString), } server_commands = {} client_commands = {}
class MultistateOutputRegular(Cluster): cluster_id = 0x0610 ep_attribute = 'bacnet_regular_multistate_output' attributes = { 0x001f: ('device_type', t.CharacterString), 0x0028: ('feed_back_value', t.enum8), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.CharacterString), 0x004f: ('object_type', t.enum16), 0x00a8: ('profile_name', t.CharacterString), } server_commands = {} client_commands = {}
class MultistateOutputRegular(Cluster): cluster_id = 0x0610 ep_attribute = "bacnet_regular_multistate_output" attributes = { 0x001F: ("device_type", t.CharacterString), 0x0028: ("feed_back_value", t.enum8), 0x004B: ("object_id", t.fixed_list(4, t.uint8_t)), 0x004D: ("object_name", t.CharacterString), 0x004F: ("object_type", t.enum16), 0x00A8: ("profile_name", t.CharacterString), } server_commands = {} client_commands = {}
class AnalogOutputRegular(Cluster): cluster_id = 0x0604 ep_attribute = "bacnet_regular_analog_output" attributes = { 0x0016: ("cov_increment", t.Single), 0x001F: ("device_type", t.CharacterString), 0x004B: ("object_id", t.fixed_list(4, t.uint8_t)), 0x004D: ("object_name", t.CharacterString), 0x004F: ("object_type", t.enum16), 0x0076: ("update_interval", t.uint8_t), 0x00A8: ("profile_name", t.CharacterString), } server_commands = {} client_commands = {}
class AnalogOutputRegular(Cluster): cluster_id = 0x0604 ep_attribute = 'bacnet_regular_analog_output' attributes = { 0x0016: ('cov_increment', t.Single), 0x001f: ('device_type', t.CharacterString), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.CharacterString), 0x004f: ('object_type', t.enum16), 0x0076: ('update_interval', t.uint8_t), 0x00a8: ('profile_name', t.CharacterString), } server_commands = {} client_commands = {}
class BinaryValueRegular(Cluster): cluster_id = 0x060c ep_attribute = 'bacnet_regular_binary_value' attributes = { 0x000f: ('change_of_state_count', t.uint32_t), 0x0010: ('change_of_state_time', DateTime), 0x0021: ('elapsed_active_time', t.uint32_t), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.CharacterString), 0x004f: ('object_type', t.enum16), 0x0072: ('time_of_at_reset', DateTime), 0x0073: ('time_of_sc_reset', DateTime), 0x00a8: ('profile_name', t.CharacterString), } server_commands = {} client_commands = {}
class BinaryValueRegular(Cluster): cluster_id = 0x060C ep_attribute = "bacnet_regular_binary_value" attributes = { 0x000F: ("change_of_state_count", t.uint32_t), 0x0010: ("change_of_state_time", DateTime), 0x0021: ("elapsed_active_time", t.uint32_t), 0x004B: ("object_id", t.fixed_list(4, t.uint8_t)), 0x004D: ("object_name", t.CharacterString), 0x004F: ("object_type", t.enum16), 0x0072: ("time_of_at_reset", DateTime), 0x0073: ("time_of_sc_reset", DateTime), 0x00A8: ("profile_name", t.CharacterString), } server_commands = {} client_commands = {}
class BinaryInputRegular(Cluster): cluster_id = 0x0608 ep_attribute = 'bacnet_regular_binary_input' attributes = { 0x000f: ('change_of_state_count', t.uint32_t), 0x0010: ('change_of_state_time', DateTime), 0x001f: ('device_type', t.LVBytes), 0x0021: ('elapsed_active_time', t.uint32_t), 0x004b: ('object_id', t.fixed_list(4, t.uint8_t)), 0x004d: ('object_name', t.LVBytes), 0x004f: ('object_type', t.uint16_t), # enum16 0x0072: ('time_of_at_reset', DateTime), 0x0073: ('time_of_sc_reset', DateTime), 0x00a8: ('profile_name', t.LVBytes), } server_commands = {} client_commands = {}
ZDOCmd.Power_Desc_req: (NWKI, ), ZDOCmd.Simple_Desc_req: (NWKI, ("EndPoint", t.uint8_t)), ZDOCmd.Active_EP_req: (NWKI, ), ZDOCmd.Match_Desc_req: ( NWKI, ("ProfileID", t.uint16_t), ("InClusterList", t.LVList(t.uint16_t)), ("OutClusterList", t.LVList(t.uint16_t)), ), # ZDO.Complex_Desc_req: (NWKI, ), ZDOCmd.User_Desc_req: (NWKI, ), ZDOCmd.Discovery_Cache_req: (NWK, IEEE), ZDOCmd.Device_annce: (NWK, IEEE, ("Capability", t.uint8_t)), ZDOCmd.User_Desc_set: ( NWKI, ("UserDescriptor", t.fixed_list(16, t.uint8_t)), ), # Really a string ZDOCmd.System_Server_Discovery_req: (("ServerMask", t.uint16_t), ), ZDOCmd.Discovery_store_req: ( NWK, IEEE, ("NodeDescSize", t.uint8_t), ("PowerDescSize", t.uint8_t), ("ActiveEPSize", t.uint8_t), ("SimpleDescSizeList", t.LVList(t.uint8_t)), ), ZDOCmd.Node_Desc_store_req: (NWK, IEEE, ("NodeDescriptor", NodeDescriptor)), ZDOCmd.Active_EP_store_req: (NWK, IEEE, ("ActiveEPList", t.LVList(t.uint8_t))), ZDOCmd.Simple_Desc_store_req: (
CLUSTERS = { # Device and Service Discovery Server Requests 0x0000: ('NWK_addr_req', (IEEE, ('RequestType', t.uint8_t), ('StartIndex', t.uint8_t))), 0x0001: ('IEEE_addr_req', (NWKI, ('RequestType', t.uint8_t), ('StartIndex', t.uint8_t))), 0x0002: ('Node_Desc_req', (NWKI, )), 0x0003: ('Power_Desc_req', (NWKI, )), 0x0004: ('Simple_Desc_req', (NWKI, ('EndPoint', t.uint8_t))), 0x0005: ('Active_EP_req', (NWKI, )), 0x0006: ('Match_Desc_req', (NWKI, ('ProfileID', t.uint16_t), ('InClusterList', t.LVList(t.uint16_t)), ('OutClusterList', t.LVList(t.uint16_t)))), # 0x0010: ('Complex_Desc_req', (NWKI, )), 0x0011: ('User_Desc_req', (NWKI, )), 0x0012: ('Discovery_Cache_req', (NWK, IEEE)), 0x0013: ('Device_annce', (NWK, IEEE, ('Capability', t.uint8_t))), 0x0014: ('User_Desc_set', (NWKI, ('UserDescriptor', t.fixed_list(16, t.uint8_t)))), # Really a string 0x0015: ('System_Server_Discovery_req', (('ServerMask', t.uint16_t), )), 0x0016: ('Discovery_store_req', (NWK, IEEE, ('NodeDescSize', t.uint8_t), ('PowerDescSize', t.uint8_t), ('ActiveEPSize', t.uint8_t), ('SimpleDescSizeList', t.LVList(t.uint8_t)))), 0x0017: ('Node_Desc_store_req', (NWK, IEEE, ('NodeDescriptor', NodeDescriptor))), 0x0019: ('Active_EP_store_req', (NWK, IEEE, ('ActiveEPList', t.LVList(t.uint8_t)))), 0x001a: ('Simple_Desc_store_req', (NWK, IEEE, ('SimpleDescriptor', SizePrefixedSimpleDescriptor))), 0x001b: ('Remove_node_cache_req', (NWK, IEEE)), 0x001c: ('Find_node_cache_req', (NWK, IEEE)), 0x001d: ('Extended_Simple_Desc_req', (NWKI, ('EndPoint', t.uint8_t), ('StartIndex', t.uint8_t))), 0x001e: ('Extended_Active_EP_req', (NWKI, ('StartIndex', t.uint8_t))), # Bind Management Server Services Responses 0x0020: ('End_Device_Bind_req', (('BindingTarget', t.uint16_t), ('SrcAddress', t.EUI64), ('SrcEndpoint', t.uint8_t), ('ProfileID', t.uint8_t), ('InClusterList', t.LVList(t.uint8_t)), ('OutClusterList', t.LVList(t.uint8_t)))), 0x0021: ('Bind_req', (('SrcAddress', t.EUI64), ('SrcEndpoint', t.uint8_t), ('ClusterID', t.uint16_t), ('DstAddress', MultiAddress))), 0x0022: ('Unind_req', (('SrcAddress', t.EUI64), ('SrcEndpoint', t.uint8_t), ('ClusterID', t.uint16_t), ('DstAddress', MultiAddress))), # Network Management Server Services Requests # ... TODO optional stuff ...
class TypedCollection(TypeValue): @classmethod def deserialize(cls, data): self = cls() self.type, data = data[0], data[1:] python_item_type = DATA_TYPES[self.type][1] python_type = t.LVList(python_item_type) self.value, data = python_type.deserialize(data) return self, data DATA_TYPES = { 0x00: ("No data", None, None), 0x08: ("General", t.fixed_list(1, t.uint8_t), Discrete), 0x09: ("General", t.fixed_list(2, t.uint8_t), Discrete), 0x0A: ("General", t.fixed_list(3, t.uint8_t), Discrete), 0x0B: ("General", t.fixed_list(4, t.uint8_t), Discrete), 0x0C: ("General", t.fixed_list(5, t.uint8_t), Discrete), 0x0D: ("General", t.fixed_list(6, t.uint8_t), Discrete), 0x0E: ("General", t.fixed_list(7, t.uint8_t), Discrete), 0x0F: ("General", t.fixed_list(8, t.uint8_t), Discrete), 0x10: ("Boolean", t.Bool, Discrete), 0x18: ("Bitmap", t.bitmap8, Discrete), 0x19: ("Bitmap", t.bitmap16, Discrete), 0x1A: ("Bitmap", t.bitmap24, Discrete), 0x1B: ("Bitmap", t.bitmap32, Discrete), 0x1C: ("Bitmap", t.bitmap40, Discrete), 0x1D: ("Bitmap", t.bitmap48, Discrete), 0x1E: ("Bitmap", t.bitmap56, Discrete),
(IEEE, ('RequestType', t.uint8_t), ('StartIndex', t.uint8_t)), ZDOCmd.IEEE_addr_req: (NWKI, ('RequestType', t.uint8_t), ('StartIndex', t.uint8_t)), ZDOCmd.Node_Desc_req: (NWKI, ), ZDOCmd.Power_Desc_req: (NWKI, ), ZDOCmd.Simple_Desc_req: (NWKI, ('EndPoint', t.uint8_t)), ZDOCmd.Active_EP_req: (NWKI, ), ZDOCmd.Match_Desc_req: (NWKI, ('ProfileID', t.uint16_t), ('InClusterList', t.LVList(t.uint16_t)), ('OutClusterList', t.LVList(t.uint16_t))), # ZDO.Complex_Desc_req: (NWKI, ), ZDOCmd.User_Desc_req: (NWKI, ), ZDOCmd.Discovery_Cache_req: (NWK, IEEE), ZDOCmd.Device_annce: (NWK, IEEE, ('Capability', t.uint8_t)), ZDOCmd.User_Desc_set: (NWKI, ('UserDescriptor', t.fixed_list(16, t.uint8_t))), # Really a string ZDOCmd.System_Server_Discovery_req: (('ServerMask', t.uint16_t), ), ZDOCmd.Discovery_store_req: (NWK, IEEE, ('NodeDescSize', t.uint8_t), ('PowerDescSize', t.uint8_t), ('ActiveEPSize', t.uint8_t), ('SimpleDescSizeList', t.LVList(t.uint8_t))), ZDOCmd.Node_Desc_store_req: (NWK, IEEE, ('NodeDescriptor', NodeDescriptor)), ZDOCmd.Active_EP_store_req: (NWK, IEEE, ('ActiveEPList', t.LVList(t.uint8_t))), ZDOCmd.Simple_Desc_store_req: (NWK, IEEE, ('SimpleDescriptor', SizePrefixedSimpleDescriptor)), ZDOCmd.Remove_node_cache_req: (NWK, IEEE), ZDOCmd.Find_node_cache_req: (NWK, IEEE), ZDOCmd.Extended_Simple_Desc_req: (NWKI, ('EndPoint', t.uint8_t), ('StartIndex', t.uint8_t)), ZDOCmd.Extended_Active_EP_req: (NWKI, ('StartIndex', t.uint8_t)),
class TypedCollection(TypeValue): @classmethod def deserialize(cls, data): self = cls() self.type, data = data[0], data[1:] python_item_type = DATA_TYPES[self.type][1] python_type = t.LVList(python_item_type) self.value, data = python_type.deserialize(data) return self, data DATA_TYPES = { 0x00: ('No data', None, None), 0x08: ('General', t.fixed_list(1, t.uint8_t), Discrete), 0x09: ('General', t.fixed_list(2, t.uint8_t), Discrete), 0x0a: ('General', t.fixed_list(3, t.uint8_t), Discrete), 0x0b: ('General', t.fixed_list(4, t.uint8_t), Discrete), 0x0c: ('General', t.fixed_list(5, t.uint8_t), Discrete), 0x0d: ('General', t.fixed_list(6, t.uint8_t), Discrete), 0x0e: ('General', t.fixed_list(7, t.uint8_t), Discrete), 0x0f: ('General', t.fixed_list(8, t.uint8_t), Discrete), 0x10: ('Boolean', t.Bool, Discrete), 0x18: ('Bitmap', t.bitmap8, Discrete), 0x19: ('Bitmap', t.bitmap16, Discrete), 0x1a: ('Bitmap', t.bitmap24, Discrete), 0x1b: ('Bitmap', t.bitmap32, Discrete), 0x1c: ('Bitmap', t.bitmap40, Discrete), 0x1d: ('Bitmap', t.bitmap48, Discrete), 0x1e: ('Bitmap', t.bitmap56, Discrete),
0x0001: ('IEEE_addr_req', (NWKI, ('RequestType', t.uint8_t), ('StartIndex', t.uint8_t))), 0x0002: ('Node_Desc_req', (NWKI, )), 0x0003: ('Power_Desc_req', (NWKI, )), 0x0004: ('Simple_Desc_req', (NWKI, ('EndPoint', t.uint8_t))), 0x0005: ('Active_EP_req', (NWKI, )), 0x0006: ('Match_Desc_req', (NWKI, ('ProfileID', t.uint16_t), ('InClusterList', t.LVList(t.uint16_t)), ('OutClusterList', t.LVList(t.uint16_t)))), # 0x0010: ('Complex_Desc_req', (NWKI, )), 0x0011: ('User_Desc_req', (NWKI, )), 0x0012: ('Discovery_Cache_req', (NWK, IEEE)), 0x0013: ('Device_annce', (NWK, IEEE, ('Capability', t.uint8_t))), 0x0014: ('User_Desc_set', (NWKI, ('UserDescriptor', t.fixed_list(16, t.uint8_t)))), # Really a string 0x0015: ('System_Server_Discovery_req', (('ServerMask', t.uint16_t), )), 0x0016: ('Discovery_store_req', (NWK, IEEE, ('NodeDescSize', t.uint8_t), ('PowerDescSize', t.uint8_t), ('ActiveEPSize', t.uint8_t), ('SimpleDescSizeList', t.LVList(t.uint8_t)))), 0x0017: ('Node_Desc_store_req', (NWK, IEEE, ('NodeDescriptor', NodeDescriptor))), 0x0019: ('Active_EP_store_req', (NWK, IEEE, ('ActiveEPList', t.LVList(t.uint8_t)))), 0x001a: ('Simple_Desc_store_req', (NWK, IEEE, ('SimpleDescriptor', SizePrefixedSimpleDescriptor))), 0x001b: ('Remove_node_cache_req', (NWK, IEEE)), 0x001c: ('Find_node_cache_req', (NWK, IEEE)), 0x001d: ('Extended_Simple_Desc_req', (NWKI, ('EndPoint', t.uint8_t), ('StartIndex', t.uint8_t))),