@@ -429,6 +429,7 @@ def __init__(self, transaction: AsyncReadTransaction, subscriptionId, devCtrl):
429
429
self ._onResubscriptionAttemptedCb : Callable [[SubscriptionTransaction ,
430
430
int , int ], None ] = DefaultResubscriptionAttemptedCallback
431
431
self ._onAttributeChangeCb : Callable [[TypedAttributePath , SubscriptionTransaction ], None ] = DefaultAttributeChangeCallback
432
+ self ._onRawAttributeChangeCb : Optional [Callable [[AttributePath , SubscriptionTransaction ]]] = None
432
433
self ._onEventChangeCb : Callable [[EventReadResult , SubscriptionTransaction ], None ] = DefaultEventChangeCallback
433
434
self ._onErrorCb : Callable [[int , SubscriptionTransaction ], None ] = DefaultErrorCallback
434
435
self ._readTransaction = transaction
@@ -454,6 +455,18 @@ def GetAttribute(self, path: TypedAttributePath) -> Any:
454
455
else :
455
456
return data [path .Path .EndpointId ][path .ClusterType ][path .AttributeType ]
456
457
458
+ def GetTLVAttributes (self ) -> Dict [int , Dict [int , Dict [int , Any ]]]:
459
+ '''Returns the attributes value cache in raw/tag dict value tracking
460
+ the latest state on the publisher.
461
+ '''
462
+ return self ._readTransaction ._cache .attributeTLVCache
463
+
464
+
465
+ def GetTLVAttribute (self , path : AttributePath ) -> bytes :
466
+ '''Returns a specific attribute given a AttributePath.
467
+ '''
468
+ return self ._readTransaction ._cache .attributeTLVCache [path .EndpointId ][path .ClusterId ][path .AttributeId ]
469
+
457
470
def GetEvents (self ):
458
471
return self ._readTransaction .GetAllEventValues ()
459
472
@@ -534,8 +547,14 @@ def SetAttributeUpdateCallback(self, callback: Callable[[TypedAttributePath, Sub
534
547
Sets the callback function for the attribute value change event,
535
548
accepts a Callable accepts an attribute path and the cached data.
536
549
'''
537
- if callback is not None :
538
- self ._onAttributeChangeCb = callback
550
+ self ._onAttributeChangeCb = callback
551
+
552
+ def SetRawAttributeUpdateCallback (self , callback : Callable [[AttributePath , SubscriptionTransaction ], None ]):
553
+ '''
554
+ Sets the callback function for raw attribute value change event,
555
+ accepts a Callable which accepts an attribute path and the cached data.
556
+ '''
557
+ self ._onRawAttributeChangeCb = callback
539
558
540
559
def SetEventUpdateCallback (self , callback : Callable [[EventReadResult , SubscriptionTransaction ], None ]):
541
560
if callback is not None :
@@ -553,6 +572,10 @@ def SetErrorCallback(self, callback: Callable[[int, SubscriptionTransaction], No
553
572
def OnAttributeChangeCb (self ) -> Callable [[TypedAttributePath , SubscriptionTransaction ], None ]:
554
573
return self ._onAttributeChangeCb
555
574
575
+ @property
576
+ def OnRawAttributeChangeCb (self ) -> Callable [[TypedAttributePath , SubscriptionTransaction ], None ]:
577
+ return self ._onRawAttributeChangeCb
578
+
556
579
@property
557
580
def OnEventChangeCb (self ) -> Callable [[EventReadResult , SubscriptionTransaction ], None ]:
558
581
return self ._onEventChangeCb
@@ -767,14 +790,19 @@ def _handleReportBegin(self):
767
790
def _handleReportEnd (self ):
768
791
if (self ._subscription_handler is not None ):
769
792
for change in self ._changedPathSet :
770
- try :
771
- attribute_path = TypedAttributePath (Path = change )
772
- except (KeyError , ValueError ) as err :
773
- # path could not be resolved into a TypedAttributePath
774
- LOGGER .exception (err )
775
- continue
776
- self ._subscription_handler .OnAttributeChangeCb (
777
- attribute_path , self ._subscription_handler )
793
+ if self ._subscription_handler .OnAttributeChangeCb :
794
+ try :
795
+ attribute_path = TypedAttributePath (Path = change )
796
+ except (KeyError , ValueError ) as err :
797
+ # path could not be resolved into a TypedAttributePath
798
+ LOGGER .exception (err )
799
+ continue
800
+ self ._subscription_handler .OnAttributeChangeCb (
801
+ attribute_path , self ._subscription_handler )
802
+
803
+ if self ._subscription_handler .OnRawAttributeChangeCb :
804
+ self ._subscription_handler .OnRawAttributeChangeCb (
805
+ change , self ._subscription_handler )
778
806
779
807
# Clear it out once we've notified of all changes in this transaction.
780
808
self ._changedPathSet = set ()
0 commit comments