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:
Teemu R.
2026-10-24 16:22:33 +02:00
committed by GitHub
parent e29864bfdc
commit 30f5e4a1b9
6 changed files with 130 additions and 18 deletions

View File

@@ -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: