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:
Steven B.
2024-10-23 16:17:27 +01:00
committed by GitHub
parent 048c84d72c
commit cd0a74ca96
4 changed files with 32 additions and 3 deletions

View File

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

View File

@@ -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()