@@ -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 ):
@@ -261,12 +262,7 @@ def __init_subclass__(cls, *args, **kwargs) -> None:
261
262
"""Register a subclass."""
262
263
super ().__init_subclass__ (* args , ** kwargs )
263
264
# register this cluster in the ALL_CLUSTERS dict for quick lookups
264
- try :
265
- ALL_CLUSTERS [cls .id ] = cls
266
- except NotImplementedError :
267
- # handle case where the Cluster class is not (fully) subclassed
268
- # and accessing the id property throws a NotImplementedError.
269
- pass
265
+ ALL_CLUSTERS [cls .id ] = cls
270
266
271
267
@property
272
268
def data_version (self ) -> int :
@@ -300,16 +296,11 @@ class ClusterAttributeDescriptor:
300
296
def __init_subclass__ (cls , * args , ** kwargs ) -> None :
301
297
"""Register a subclass."""
302
298
super ().__init_subclass__ (* args , ** kwargs )
303
- try :
304
- if cls .standard_attribute :
305
- if cls .cluster_id not in ALL_ATTRIBUTES :
306
- ALL_ATTRIBUTES [cls .cluster_id ] = {}
307
- # register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
308
- ALL_ATTRIBUTES [cls .cluster_id ][cls .attribute_id ] = cls
309
- except NotImplementedError :
310
- # handle case where the ClusterAttribute class is not (fully) subclassed
311
- # and accessing the id property throws a NotImplementedError.
312
- pass
299
+ if cls .standard_attribute :
300
+ if cls .cluster_id not in ALL_ATTRIBUTES :
301
+ ALL_ATTRIBUTES [cls .cluster_id ] = {}
302
+ # register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
303
+ ALL_ATTRIBUTES [cls .cluster_id ][cls .attribute_id ] = cls
313
304
314
305
@classmethod
315
306
def ToTLV (cls , tag : Union [int , None ], value ):
@@ -369,6 +360,15 @@ def _cluster_object(cls) -> ClusterObject:
369
360
370
361
371
362
class ClusterEvent (ClusterObject ):
363
+ def __init_subclass__ (cls , * args , ** kwargs ) -> None :
364
+ """Register a subclass."""
365
+ super ().__init_subclass__ (* args , ** kwargs )
366
+
367
+ if cls .cluster_id not in ALL_EVENTS :
368
+ ALL_EVENTS [cls .cluster_id ] = {}
369
+ # register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
370
+ ALL_EVENTS [cls .cluster_id ][cls .event_id ] = cls
371
+
372
372
@ChipUtility .classproperty
373
373
def cluster_id (self ) -> int :
374
374
raise NotImplementedError ()
0 commit comments