From 1129036a997f7719d38cdbd807461bb96e4b6aec Mon Sep 17 00:00:00 2001 From: tianfeng-yang <130436698+tianfeng-yang@users.noreply.github.com> Date: Fri, 9 Jun 2023 09:08:25 +0800 Subject: [PATCH] [Python] AttributeReadResult export dataversion (#26943) * [Python] export dataversion field * dataversion does not need a default value * fix CI --- src/controller/python/chip/ChipDeviceCtrl.py | 2 +- src/controller/python/chip/clusters/Attribute.py | 1 + src/controller/python/chip/interaction_model/delegate.py | 1 + src/test_driver/openiotsdk/integration-tests/common/utils.py | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 7982e3f644911c..d9f3eab9a5a6a5 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -1158,7 +1158,7 @@ def ZCLReadAttribute(self, cluster, attribute, nodeid, endpoint, groupid, blocki nodeid, [(endpoint, attributeType)])) path = ClusterAttribute.AttributePath( EndpointId=endpoint, Attribute=attributeType) - return im.AttributeReadResult(path=im.AttributePath(nodeId=nodeid, endpointId=path.EndpointId, clusterId=path.ClusterId, attributeId=path.AttributeId), status=0, value=result[endpoint][clusterType][attributeType]) + return im.AttributeReadResult(path=im.AttributePath(nodeId=nodeid, endpointId=path.EndpointId, clusterId=path.ClusterId, attributeId=path.AttributeId), status=0, value=result[endpoint][clusterType][attributeType], dataVersion=result[endpoint][clusterType][ClusterAttribute.DataVersion]) def ZCLWriteAttribute(self, cluster: str, attribute: str, nodeid, endpoint, groupid, value, dataVersion=0, blocking=True): req = None diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 4eab3700fac7c5..382279bccaf15f 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -266,6 +266,7 @@ class AttributeWriteRequest(AttributeDescriptorWithEndpoint): @dataclass class AttributeReadResult(AttributeStatus): Data: Any = None + DataVersion: int = 0 @dataclass diff --git a/src/controller/python/chip/interaction_model/delegate.py b/src/controller/python/chip/interaction_model/delegate.py index f5aa54c89dbef7..4c52cabf1a767a 100644 --- a/src/controller/python/chip/interaction_model/delegate.py +++ b/src/controller/python/chip/interaction_model/delegate.py @@ -92,6 +92,7 @@ class AttributeReadResult: path: AttributePath status: int value: 'typing.Any' + dataVersion: int @dataclass diff --git a/src/test_driver/openiotsdk/integration-tests/common/utils.py b/src/test_driver/openiotsdk/integration-tests/common/utils.py index 52b52839a6b21b..1a93d27a988865 100644 --- a/src/test_driver/openiotsdk/integration-tests/common/utils.py +++ b/src/test_driver/openiotsdk/integration-tests/common/utils.py @@ -221,7 +221,8 @@ def read_zcl_attribute(devCtrl, cluster: str, attribute: str, nodeId: int, endpo EndpointId=endpoint, Attribute=attributeObj) res = IM.AttributeReadResult(path=IM.AttributePath(nodeId=nodeId, endpointId=path.EndpointId, clusterId=path.ClusterId, - attributeId=path.AttributeId), status=0, value=result[endpoint][clusterObj][attributeObj]) + attributeId=path.AttributeId), status=0, value=result[endpoint][clusterObj][attributeObj], + dataVersion=result[endpoint][clusterObj][ClusterAttribute.DataVersion]) except exceptions.ChipStackException as ex: log.error("An exception occurred during processing ZCL attribute: {}".format(str(ex)))