1
- From 749cd076e35127092efa8f680902bebf8967389d Mon Sep 17 00:00:00 2001
1
+ From 0f6dc07cb5c20d89b7e51342a32a73d58dd91b7d Mon Sep 17 00:00:00 2001
2
2
From: Stefan Agner <stefan@agner.ch>
3
3
Date: Thu, 23 May 2024 12:48:54 +0200
4
4
Subject: [PATCH] Add raw attribute callback
@@ -14,18 +14,18 @@ directly from the subscription transaction.
14
14
1 file changed, 38 insertions(+), 10 deletions(-)
15
15
16
16
diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py
17
- index 9e46eed469..ce522bf452 100644
17
+ index 4d5bc1d17a..cb7bdb0bc4 100644
18
18
--- a/src/controller/python/chip/clusters/Attribute.py
19
19
+++ b/src/controller/python/chip/clusters/Attribute.py
20
- @@ -466 ,6 +466 ,7 @@ class SubscriptionTransaction:
21
- def __init__(self, transaction: AsyncReadTransaction, subscriptionId, devCtrl):
22
- self._onResubscriptionAttemptedCb = DefaultResubscriptionAttemptedCallback
23
- self._onAttributeChangeCb = DefaultAttributeChangeCallback
24
- + self._onRawAttributeChangeCb = None
25
- self._onEventChangeCb = DefaultEventChangeCallback
26
- self._onErrorCb = DefaultErrorCallback
20
+ @@ -429 ,6 +429 ,7 @@ class SubscriptionTransaction:
21
+ self._onResubscriptionAttemptedCb: Callable[[SubscriptionTransaction,
22
+ int, int], None] = DefaultResubscriptionAttemptedCallback
23
+ self._onAttributeChangeCb: Callable[[TypedAttributePath, SubscriptionTransaction], None] = DefaultAttributeChangeCallback
24
+ + self._onRawAttributeChangeCb: Optional[Callable[[AttributePath, SubscriptionTransaction]]] = None
25
+ self._onEventChangeCb: Callable[[EventReadResult, SubscriptionTransaction], None] = DefaultEventChangeCallback
26
+ self._onErrorCb: Callable[[int, SubscriptionTransaction], None] = DefaultErrorCallback
27
27
self._readTransaction = transaction
28
- @@ -491 ,6 +492 ,18 @@ class SubscriptionTransaction:
28
+ @@ -454 ,6 +455 ,18 @@ class SubscriptionTransaction:
29
29
else:
30
30
return data[path.Path.EndpointId][path.ClusterType][path.AttributeType]
31
31
@@ -44,7 +44,7 @@ index 9e46eed469..ce522bf452 100644
44
44
def GetEvents(self):
45
45
return self._readTransaction.GetAllEventValues()
46
46
47
- @@ -564 ,8 +577 ,14 @@ class SubscriptionTransaction:
47
+ @@ -534 ,8 +547 ,14 @@ class SubscriptionTransaction:
48
48
Sets the callback function for the attribute value change event,
49
49
accepts a Callable accepts an attribute path and the cached data.
50
50
'''
@@ -61,7 +61,7 @@ index 9e46eed469..ce522bf452 100644
61
61
62
62
def SetEventUpdateCallback(self, callback: Callable[[EventReadResult, SubscriptionTransaction], None]):
63
63
if callback is not None:
64
- @@ -583 ,6 +602 ,10 @@ class SubscriptionTransaction:
64
+ @@ -553 ,6 +572 ,10 @@ class SubscriptionTransaction:
65
65
def OnAttributeChangeCb(self) -> Callable[[TypedAttributePath, SubscriptionTransaction], None]:
66
66
return self._onAttributeChangeCb
67
67
@@ -72,15 +72,15 @@ index 9e46eed469..ce522bf452 100644
72
72
@property
73
73
def OnEventChangeCb(self) -> Callable[[EventReadResult, SubscriptionTransaction], None]:
74
74
return self._onEventChangeCb
75
- @@ -785 ,14 +808 ,19 @@ class AsyncReadTransaction:
76
-
75
+ @@ -767 ,14 +790 ,19 @@ class AsyncReadTransaction:
76
+ def _handleReportEnd(self):
77
77
if (self._subscription_handler is not None):
78
78
for change in self._changedPathSet:
79
79
- try:
80
80
- attribute_path = TypedAttributePath(Path=change)
81
81
- except (KeyError, ValueError) as err:
82
82
- # path could not be resolved into a TypedAttributePath
83
- - logging.getLogger(__name__) .exception(err)
83
+ - LOGGER .exception(err)
84
84
- continue
85
85
- self._subscription_handler.OnAttributeChangeCb(
86
86
- attribute_path, self._subscription_handler)
@@ -89,7 +89,7 @@ index 9e46eed469..ce522bf452 100644
89
89
+ attribute_path = TypedAttributePath(Path=change)
90
90
+ except (KeyError, ValueError) as err:
91
91
+ # path could not be resolved into a TypedAttributePath
92
- + logging.getLogger(__name__) .exception(err)
92
+ + LOGGER .exception(err)
93
93
+ continue
94
94
+ self._subscription_handler.OnAttributeChangeCb(
95
95
+ attribute_path, self._subscription_handler)
@@ -101,5 +101,5 @@ index 9e46eed469..ce522bf452 100644
101
101
# Clear it out once we've notified of all changes in this transaction.
102
102
self._changedPathSet = set()
103
103
- -
104
- 2.45.2
104
+ 2.47.0
105
105
0 commit comments