Skip to content

Allow deriving from SmartModule without being registered #1189

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

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from all 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
8 changes: 5 additions & 3 deletions kasa/smart/smartmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def __init__(self, device: SmartDevice, module: str):
self._error_count = 0

def __init_subclass__(cls, **kwargs):
name = getattr(cls, "NAME", cls.__name__)
_LOGGER.debug("Registering %s", cls)
cls.REGISTERED_MODULES[name] = cls
# We only want to register submodules in a modules package so that
# other classes can inherit from smartmodule and not be registered
if cls.__module__.split(".")[-2] == "modules":
_LOGGER.debug("Registering %s", cls)
cls.REGISTERED_MODULES[cls.__name__] = cls

def _set_error(self, err: Exception | None):
if err is None:
Expand Down
Loading