Skip to content

Commit

Permalink
add an ALL_EVENTS
Browse files Browse the repository at this point in the history
  • Loading branch information
cecille committed Sep 18, 2024
1 parent e96ddd9 commit b121f07
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/controller/python/chip/clusters/ClusterObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ def descriptor(cls):
# These need to be separate because there can be overlap in command ids for commands and responses.
ALL_ACCEPTED_COMMANDS: typing.Dict = {}
ALL_GENERATED_COMMANDS: typing.Dict = {}
ALL_EVENTS: typing.Dict = {}


class ClusterCommand(ClusterObject):
Expand Down Expand Up @@ -369,6 +370,19 @@ def _cluster_object(cls) -> ClusterObject:


class ClusterEvent(ClusterObject):
def __init_subclass__(cls, *args, **kwargs) -> None:
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
try:
if cls.event_id not in ALL_EVENTS:
ALL_EVENTS[cls.event_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls
except NotImplementedError:
# handle case where the ClusterAttribute class is not (fully) subclassed
# and accessing the id property throws a NotImplementedError.
pass

@ChipUtility.classproperty
def cluster_id(self) -> int:
raise NotImplementedError()
Expand Down

0 comments on commit b121f07

Please sign in to comment.