Extend ZHA attribute diagnostic information (#123199)

* Include full attribute representation in in data

* Extend attribute diagnostics for zha
This commit is contained in:
Joakim Plate 2024-08-10 19:25:21 +02:00 committed by GitHub
parent 0558c85b5d
commit f53da62026
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 30 deletions

View File

@ -7,7 +7,7 @@ from importlib.metadata import version
from typing import Any from typing import Any
from zha.application.const import ( from zha.application.const import (
ATTR_ATTRIBUTE_NAME, ATTR_ATTRIBUTE,
ATTR_DEVICE_TYPE, ATTR_DEVICE_TYPE,
ATTR_IEEE, ATTR_IEEE,
ATTR_IN_CLUSTERS, ATTR_IN_CLUSTERS,
@ -158,27 +158,13 @@ def get_endpoint_cluster_attr_data(zha_device: Device) -> dict:
def get_cluster_attr_data(cluster: Cluster) -> dict: def get_cluster_attr_data(cluster: Cluster) -> dict:
"""Return cluster attribute data.""" """Return cluster attribute data."""
unsupported_attributes = {}
for u_attr in cluster.unsupported_attributes:
try:
u_attr_def = cluster.find_attribute(u_attr)
unsupported_attributes[f"0x{u_attr_def.id:04x}"] = {
ATTR_ATTRIBUTE_NAME: u_attr_def.name
}
except KeyError:
if isinstance(u_attr, int):
unsupported_attributes[f"0x{u_attr:04x}"] = {}
else:
unsupported_attributes[u_attr] = {}
return { return {
ATTRIBUTES: { ATTRIBUTES: {
f"0x{attr_id:04x}": { f"0x{attr_id:04x}": {
ATTR_ATTRIBUTE_NAME: attr_def.name, ATTR_ATTRIBUTE: repr(attr_def),
ATTR_VALUE: attr_value, ATTR_VALUE: cluster.get(attr_def.name),
} }
for attr_id, attr_def in cluster.attributes.items() for attr_id, attr_def in cluster.attributes.items()
if (attr_value := cluster.get(attr_def.name)) is not None
}, },
UNSUPPORTED_ATTRIBUTES: unsupported_attributes, UNSUPPORTED_ATTRIBUTES: cluster.unsupported_attributes,
} }

View File

@ -161,8 +161,20 @@
'in_clusters': dict({ 'in_clusters': dict({
'0x0500': dict({ '0x0500': dict({
'attributes': dict({ 'attributes': dict({
'0x0000': dict({
'attribute': "ZCLAttributeDef(id=0x0000, name='zone_state', type=<enum 'ZoneState'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=True, is_manufacturer_specific=False)",
'value': None,
}),
'0x0001': dict({
'attribute': "ZCLAttributeDef(id=0x0001, name='zone_type', type=<enum 'ZoneType'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=True, is_manufacturer_specific=False)",
'value': None,
}),
'0x0002': dict({
'attribute': "ZCLAttributeDef(id=0x0002, name='zone_status', type=<flag 'ZoneStatus'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=True, is_manufacturer_specific=False)",
'value': None,
}),
'0x0010': dict({ '0x0010': dict({
'attribute_name': 'cie_addr', 'attribute': "ZCLAttributeDef(id=0x0010, name='cie_addr', type=<class 'zigpy.types.named.EUI64'>, access=<ZCLAttributeAccess.Read|Write: 3>, mandatory=True, is_manufacturer_specific=False)",
'value': list([ 'value': list([
50, 50,
79, 79,
@ -174,27 +186,41 @@
0, 0,
]), ]),
}), }),
'0x0011': dict({
'attribute': "ZCLAttributeDef(id=0x0011, name='zone_id', type=<class 'zigpy.types.basic.uint8_t'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=True, is_manufacturer_specific=False)",
'value': None,
}), }),
'endpoint_attribute': 'ias_zone',
'unsupported_attributes': dict({
'0x0012': dict({ '0x0012': dict({
'attribute_name': 'num_zone_sensitivity_levels_supported', 'attribute': "ZCLAttributeDef(id=0x0012, name='num_zone_sensitivity_levels_supported', type=<class 'zigpy.types.basic.uint8_t'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=False, is_manufacturer_specific=False)",
'value': None,
}), }),
'0x0013': dict({ '0x0013': dict({
'attribute_name': 'current_zone_sensitivity_level', 'attribute': "ZCLAttributeDef(id=0x0013, name='current_zone_sensitivity_level', type=<class 'zigpy.types.basic.uint8_t'>, access=<ZCLAttributeAccess.Read|Write: 3>, mandatory=False, is_manufacturer_specific=False)",
'value': None,
}), }),
}), }),
'endpoint_attribute': 'ias_zone',
'unsupported_attributes': list([
18,
'current_zone_sensitivity_level',
]),
}), }),
'0x0501': dict({ '0x0501': dict({
'attributes': dict({ 'attributes': dict({
'0xfffd': dict({
'attribute': "ZCLAttributeDef(id=0xFFFD, name='cluster_revision', type=<class 'zigpy.types.basic.uint16_t'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=True, is_manufacturer_specific=False)",
'value': None,
}),
'0xfffe': dict({
'attribute': "ZCLAttributeDef(id=0xFFFE, name='reporting_status', type=<enum 'AttributeReportingStatus'>, access=<ZCLAttributeAccess.Read: 1>, mandatory=False, is_manufacturer_specific=False)",
'value': None,
}),
}), }),
'endpoint_attribute': 'ias_ace', 'endpoint_attribute': 'ias_ace',
'unsupported_attributes': dict({ 'unsupported_attributes': list([
'0x1000': dict({ 4096,
}), 'unknown_attribute_name',
'unknown_attribute_name': dict({ ]),
}),
}),
}), }),
}), }),
'out_clusters': dict({ 'out_clusters': dict({