mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Improve supported module checks for hub children (#1188)
No devices in `fixtures/smart/child` support the `get_device_time` or `get_device_usage` methods so this PR tests for whether the device is a hub child and marks those modules/methods as not supported. This prevents features being erroneously created on child devices. It also moves the logic for getting the time from the parent module behind getting it from the child module which was masking the creation of these unsupported modules.
This commit is contained in:
@@ -23,7 +23,8 @@ class DeviceModule(SmartModule):
|
||||
"get_device_info": None,
|
||||
}
|
||||
# Device usage is not available on older firmware versions
|
||||
if self.supported_version >= 2:
|
||||
# or child devices of hubs
|
||||
if self.supported_version >= 2 and not self._device._is_hub_child:
|
||||
query["get_device_usage"] = None
|
||||
|
||||
return query
|
||||
|
@@ -83,3 +83,12 @@ class Time(SmartModule, TimeInterface):
|
||||
if region:
|
||||
params["region"] = region
|
||||
return await self.call("set_device_time", params)
|
||||
|
||||
async def _check_supported(self):
|
||||
"""Additional check to see if the module is supported by the device.
|
||||
|
||||
Hub attached sensors report the time module but do return device time.
|
||||
"""
|
||||
if self._device._is_hub_child:
|
||||
return False
|
||||
return await super()._check_supported()
|
||||
|
Reference in New Issue
Block a user