mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-26 22:52:55 +00:00
Add Device.supports_module() and stop querying HomeKit for iot devices (#1808)
Some legacy iot firmware stops responding when an unsupported module follows `system` in a request, which made every update time out once the HomeKit query was added. This stops querying HomeKit in `update()` for IOT devices and adds `Device.supports_module()` API to allow checking if some module is supported by the device.
This commit is contained in:
@@ -47,7 +47,6 @@ Devices support different functionality that are exposed via
|
||||
|
||||
>>> for module_name in dev.modules:
|
||||
... print(module_name)
|
||||
homekit
|
||||
Energy
|
||||
schedule
|
||||
usage
|
||||
@@ -264,6 +263,10 @@ class Device(ABC):
|
||||
def modules(self) -> ModuleMapping[Module]:
|
||||
"""Return the device modules."""
|
||||
|
||||
async def supports_module(self, module: ModuleName[Module] | str) -> bool:
|
||||
"""Return True if the device supports the module, may query the device."""
|
||||
return module in self.modules
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_on(self) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user