Put modules back on children for wall switches (#881)

Puts modules back on the children for `WallSwitches` (i.e. ks240) and
makes them accessible from the `modules` property on the parent.
This commit is contained in:
Steven B
2024-04-29 17:34:20 +01:00
committed by GitHub
parent 6724506fab
commit cb11b36511
8 changed files with 80 additions and 47 deletions

View File

@@ -15,6 +15,7 @@ from .emeterstatus import EmeterStatus
from .exceptions import KasaException
from .feature import Feature
from .iotprotocol import IotProtocol
from .module import Module
from .protocol import BaseProtocol
from .xortransport import XorTransport
@@ -72,7 +73,6 @@ class Device(ABC):
self._last_update: Any = None
self._discovery_info: dict[str, Any] | None = None
self.modules: dict[str, Any] = {}
self._features: dict[str, Feature] = {}
self._parent: Device | None = None
self._children: Mapping[str, Device] = {}
@@ -111,6 +111,11 @@ class Device(ABC):
"""Disconnect and close any underlying connection resources."""
await self.protocol.close()
@property
@abstractmethod
def modules(self) -> Mapping[str, Module]:
"""Return the device modules."""
@property
@abstractmethod
def is_on(self) -> bool: