Skip to content

Commit c094b4e

Browse files
committed
Update patch to address review feedback
1 parent 2214b06 commit c094b4e

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

0001-Python-Add-untyped-attribute-callback.patch 0006-Python-Add-raw-attribute-callback.patch

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
From 512ad9e0b236a4102a19924670f3be380a8dacfe Mon Sep 17 00:00:00 2001
2-
Message-ID: <512ad9e0b236a4102a19924670f3be380a8dacfe.1716462300.git.stefan@agner.ch>
1+
From 9bc05af1e1ef2ec93336dc0eecba16b6802b6fb1 Mon Sep 17 00:00:00 2001
2+
Message-ID: <9bc05af1e1ef2ec93336dc0eecba16b6802b6fb1.1716466458.git.stefan@agner.ch>
33
From: Stefan Agner <stefan@agner.ch>
44
Date: Thu, 23 May 2024 12:48:54 +0200
5-
Subject: [PATCH] [Python] Add untyped attribute callback
5+
Subject: [PATCH] [Python] Add raw attribute callback
66

7-
Add new subscription callback which returns the untyped paths of
8-
attributes changed. This allows to subscribe to custom clusters, where
9-
the type is not part of the Cluster/Attribute types are not part of
10-
the Python library.
7+
Add new subscription callback which uses raw AttributePath as paths
8+
of changed attributes. This allows to subscribe to custom clusters,
9+
where no Cluster/Attribute types are part of the Python library.
1110

12-
Also allow t get the raw value (in tagged dict format for structs)
13-
directly from the read transaction.
11+
Also allow to get the raw Python values (in tagged dict format)
12+
directly from the subscription transaction.
1413
---
1514
.../python/chip/clusters/Attribute.py | 48 +++++++++++++++----
1615
1 file changed, 38 insertions(+), 10 deletions(-)
1716

1817
diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py
19-
index 9e46eed469..2d7196c0c2 100644
18+
index 9e46eed469..ce522bf452 100644
2019
--- a/src/controller/python/chip/clusters/Attribute.py
2120
+++ b/src/controller/python/chip/clusters/Attribute.py
2221
@@ -466,6 +466,7 @@ class SubscriptionTransaction:
2322
def __init__(self, transaction: AsyncReadTransaction, subscriptionId, devCtrl):
2423
self._onResubscriptionAttemptedCb = DefaultResubscriptionAttemptedCallback
2524
self._onAttributeChangeCb = DefaultAttributeChangeCallback
26-
+ self._onUntypedAttributeChangeCb = None
25+
+ self._onRawAttributeChangeCb = None
2726
self._onEventChangeCb = DefaultEventChangeCallback
2827
self._onErrorCb = DefaultErrorCallback
2928
self._readTransaction = transaction
@@ -54,12 +53,12 @@ index 9e46eed469..2d7196c0c2 100644
5453
- self._onAttributeChangeCb = callback
5554
+ self._onAttributeChangeCb = callback
5655
+
57-
+ def SetUntypedAttributeUpdateCallback(self, callback: Callable[[AttributePath, SubscriptionTransaction], None]):
56+
+ def SetRawAttributeUpdateCallback(self, callback: Callable[[AttributePath, SubscriptionTransaction], None]):
5857
+ '''
59-
+ Sets the callback function for untyped attribute value change event,
60-
+ accepts a Callable accepts a raw attribute path and the cached data.
58+
+ Sets the callback function for raw attribute value change event,
59+
+ accepts a Callable which accepts an attribute path and the cached data.
6160
+ '''
62-
+ self._onUntypedAttributeChangeCb = callback
61+
+ self._onRawAttributeChangeCb = callback
6362

6463
def SetEventUpdateCallback(self, callback: Callable[[EventReadResult, SubscriptionTransaction], None]):
6564
if callback is not None:
@@ -68,8 +67,8 @@ index 9e46eed469..2d7196c0c2 100644
6867
return self._onAttributeChangeCb
6968

7069
+ @property
71-
+ def OnUntypedAttributeChangeCb(self) -> Callable[[TypedAttributePath, SubscriptionTransaction], None]:
72-
+ return self._onUntypedAttributeChangeCb
70+
+ def OnRawAttributeChangeCb(self) -> Callable[[TypedAttributePath, SubscriptionTransaction], None]:
71+
+ return self._onRawAttributeChangeCb
7372
+
7473
@property
7574
def OnEventChangeCb(self) -> Callable[[EventReadResult, SubscriptionTransaction], None]:
@@ -96,8 +95,8 @@ index 9e46eed469..2d7196c0c2 100644
9695
+ self._subscription_handler.OnAttributeChangeCb(
9796
+ attribute_path, self._subscription_handler)
9897
+
99-
+ if self._subscription_handler.OnUntypedAttributeChangeCb:
100-
+ self._subscription_handler.OnUntypedAttributeChangeCb(
98+
+ if self._subscription_handler.OnRawAttributeChangeCb:
99+
+ self._subscription_handler.OnRawAttributeChangeCb(
101100
+ change, self._subscription_handler)
102101

103102
# Clear it out once we've notified of all changes in this transaction.

0 commit comments

Comments
 (0)