diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index d3d810149ce5dd..4127ead64c3083 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -1838,6 +1838,14 @@ def whole_node_runner(self: MatterBaseTest, *args, **kwargs): EndpointCheckFunction = typing.Callable[[Clusters.Attribute.AsyncReadTransaction.ReadResponse, int], bool] +def get_cluster_from_attribute(attribute: ClusterObjects.ClusterAttributeDescriptor) -> ClusterObjects.Cluster: + return ClusterObjects.ALL_CLUSTERS[attribute.cluster_id] + + +def get_cluster_from_command(command: ClusterObjects.ClusterCommand) -> ClusterObjects.Cluster: + return ClusterObjects.ALL_CLUSTERS[command.cluster_id] + + def _has_cluster(wildcard, endpoint, cluster: ClusterObjects.Cluster) -> bool: try: return cluster in wildcard.attributes[endpoint] @@ -1870,7 +1878,7 @@ def has_cluster(cluster: ClusterObjects.ClusterObjectDescriptor) -> EndpointChec def _has_attribute(wildcard, endpoint, attribute: ClusterObjects.ClusterAttributeDescriptor) -> bool: - cluster = getattr(Clusters, attribute.__qualname__.split('.')[-3]) + cluster = get_cluster_from_attribute(attribute) try: attr_list = wildcard.attributes[endpoint][cluster][cluster.Attributes.AttributeList] return attribute.attribute_id in attr_list