Skip to content

Commit

Permalink
[Python] Print data version when dumping cluster attributes (#15908)
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing authored and pull[bot] committed Jul 19, 2023
1 parent 146e865 commit 421ddc8
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/controller/python/chip/clusters/ClusterObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,29 @@ def must_use_timed_invoke(cls) -> bool:

class Cluster(ClusterObject):
'''
When send read requests with returnClusterObject=True, we will set the dataVersion property of the object.
When send read requests with returnClusterObject=True, we will set the data_version property of the object.
Otherwise the [endpoint][cluster][Clusters.DataVersion] will be set to the DataVersion of the cluster.
For data_version, we do not make it a real property so we can distinguish it with real attributes internally,
especially the TLV decoding logic. Also ThreadNetworkDiagnostics has an attribute with the same name so we
picked data_version as its name.
'''
@ChipUtility.classproperty
def dataVersion(self) -> int:
return self._dataVersion
@property
def data_version(self) -> int:
return self._data_version

def __rich_repr__(self):
'''
Override the default behavior of rich.pretty.pprint for adding the cluster data version.
'''
if self._data_version is not None:
yield "(data version)", self.data_version
for k in self.__dataclass_fields__.keys():
if k in self.__dict__:
yield k, self.__dict__[k]

def SetDataVersion(self, version: int) -> None:
self._dataVersion = version
self._data_version = version


class ClusterAttributeDescriptor:
Expand Down

0 comments on commit 421ddc8

Please sign in to comment.