From d1d47144b943e4c5165b4853a1ed816f2a0d7c62 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Mon, 21 Aug 2023 22:17:13 -0400 Subject: [PATCH 1/3] Set urgent before early returns --- src/controller/python/chip/clusters/Attribute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 4572065e3df501..308ffe9d8a9349 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -173,6 +173,7 @@ class EventPath: def __init__(self, EndpointId: int = None, Cluster=None, Event=None, ClusterId=None, EventId=None, Urgent=None): self.EndpointId = EndpointId + self.Urgent = Urgent if Cluster is not None: # Wildcard read for a specific cluster if (Event is not None) or (ClusterId is not None) or (EventId is not None): @@ -189,7 +190,6 @@ def __init__(self, EndpointId: int = None, Cluster=None, Event=None, ClusterId=N return self.ClusterId = ClusterId self.EventId = EventId - self.Urgent = Urgent def __str__(self) -> str: return f"{self.EndpointId}/{self.ClusterId}/{self.EventId}/{self.Urgent}" From 8c618d99e1f82c77a23f08e0c7a4c715543a5b4d Mon Sep 17 00:00:00 2001 From: cecille Date: Tue, 22 Aug 2023 10:31:10 -0400 Subject: [PATCH 2/3] Fix case where urgent isn't specified --- src/controller/python/chip/ChipDeviceCtrl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 55a325fa8d3432..22a9610cb7d2eb 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -1019,7 +1019,10 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[ event = pathTuple[1] else: raise ValueError("Unsupported Attribute Path") - urgent = pathTuple[-1] + if len(pathTuple) > 2: + urgent = pathTuple[-1] + else: + urgent = 0 return ClusterAttribute.EventPath( EndpointId=endpoint, Cluster=cluster, Event=event, Urgent=urgent) From fd7bcf284fa801819f539d5391bc31ca574d10a5 Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Tue, 22 Aug 2023 20:18:47 -0400 Subject: [PATCH 3/3] pythonify this thing. Why use many line, when few line do trick. --- src/controller/python/chip/ChipDeviceCtrl.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 22a9610cb7d2eb..22ae11cda65a78 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -1019,10 +1019,7 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[ event = pathTuple[1] else: raise ValueError("Unsupported Attribute Path") - if len(pathTuple) > 2: - urgent = pathTuple[-1] - else: - urgent = 0 + urgent = bool(pathTuple[-1]) if len(pathTuple) > 2 else False return ClusterAttribute.EventPath( EndpointId=endpoint, Cluster=cluster, Event=event, Urgent=urgent)