File tree 1 file changed +14
-0
lines changed
src/controller/python/chip/clusters
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,7 @@ def descriptor(cls):
214
214
# These need to be separate because there can be overlap in command ids for commands and responses.
215
215
ALL_ACCEPTED_COMMANDS : typing .Dict = {}
216
216
ALL_GENERATED_COMMANDS : typing .Dict = {}
217
+ ALL_EVENTS : typing .Dict = {}
217
218
218
219
219
220
class ClusterCommand (ClusterObject ):
@@ -369,6 +370,19 @@ def _cluster_object(cls) -> ClusterObject:
369
370
370
371
371
372
class ClusterEvent (ClusterObject ):
373
+ def __init_subclass__ (cls , * args , ** kwargs ) -> None :
374
+ """Register a subclass."""
375
+ super ().__init_subclass__ (* args , ** kwargs )
376
+ try :
377
+ if cls .event_id not in ALL_EVENTS :
378
+ ALL_EVENTS [cls .event_id ] = {}
379
+ # register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
380
+ ALL_EVENTS [cls .cluster_id ][cls .event_id ] = cls
381
+ except NotImplementedError :
382
+ # handle case where the ClusterAttribute class is not (fully) subclassed
383
+ # and accessing the id property throws a NotImplementedError.
384
+ pass
385
+
372
386
@ChipUtility .classproperty
373
387
def cluster_id (self ) -> int :
374
388
raise NotImplementedError ()
You can’t perform that action at this time.
0 commit comments