Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an ALL_EVENTS maps in symmetry to ALL_ATTRIBUTES #35661

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved
"""Register a subclass."""
super().__init_subclass__(*args, **kwargs)
try:
if cls.cluster_id not in ALL_EVENTS:
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
ALL_EVENTS[cls.cluster_id] = {}
# register this clusterattribute in the ALL_ATTRIBUTES dict for quick lookups
ALL_EVENTS[cls.cluster_id][cls.event_id] = cls
except NotImplementedError:
cecille marked this conversation as resolved.
Show resolved Hide resolved
# 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
Loading