mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-12-02 22:28:20 +00:00
Support for new ks240 fan/light wall switch (#839)
In order to support the ks240 which has children for the fan and light components, this PR adds those modules at the parent level and hides the children so it looks like a single device to consumers. It also decides which modules not to take from the child because the child does not support them even though it say it does. It does this for now via a fixed list, e.g. `Time`, `Firmware` etc. Also adds fixtures from two versions and corresponding tests.
This commit is contained in:
@@ -139,10 +139,29 @@ class FakeSmartTransport(BaseTransport):
|
||||
|
||||
# We only support get & set device info for now.
|
||||
if child_method == "get_device_info":
|
||||
return {"result": info, "error_code": 0}
|
||||
result = copy.deepcopy(info)
|
||||
return {"result": result, "error_code": 0}
|
||||
elif child_method == "set_device_info":
|
||||
info.update(child_params)
|
||||
return {"error_code": 0}
|
||||
elif (
|
||||
# FIXTURE_MISSING is for service calls not in place when
|
||||
# SMART fixtures started to be generated
|
||||
missing_result := self.FIXTURE_MISSING_MAP.get(child_method)
|
||||
) and missing_result[0] in self.components:
|
||||
result = copy.deepcopy(missing_result[1])
|
||||
retval = {"result": result, "error_code": 0}
|
||||
return retval
|
||||
else:
|
||||
# PARAMS error returned for KS240 when get_device_usage called
|
||||
# on parent device. Could be any error code though.
|
||||
# TODO: Try to figure out if there's a way to prevent the KS240 smartdevice
|
||||
# calling the unsupported device in the first place.
|
||||
retval = {
|
||||
"error_code": SmartErrorCode.PARAMS_ERROR.value,
|
||||
"method": child_method,
|
||||
}
|
||||
return retval
|
||||
|
||||
raise NotImplementedError(
|
||||
"Method %s not implemented for children" % child_method
|
||||
|
||||
Reference in New Issue
Block a user