mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-19 19:22:55 +00:00
Add fixtures for KH100, KE100 and KE110 and simulate TRV states (#1726)
This PR adds fixture files for: - KH100 (UK), hardware 1.0, firmware 1.7.5 - KE100 (UK), hardware 1.0, firmware 2.15.0 - KE110 (EU), hardware 1.0, firmware 1.4.0 The fixtures were collected from physical devices and anonymized for use in development and testing. The KE110 fixture is a new device model and has been added to the appropriate fixture category. This also improves test suite by adding TRV state simulation to allow tests pass on fixtures that report a non-heating state. --------- Co-authored-by: Teemu Rytilahti <tpr@iki.fi>
This commit is contained in:
@@ -410,6 +410,7 @@ class FakeSmartTransport(BaseTransport):
|
||||
return {"result": result, "error_code": 0}
|
||||
elif child_method == "set_device_info":
|
||||
info.update(child_params)
|
||||
self._update_trv_states(info)
|
||||
return {"error_code": 0}
|
||||
elif child_method == "set_preset_rules":
|
||||
return self._set_child_preset_rules(info, child_params)
|
||||
@@ -447,6 +448,24 @@ class FakeSmartTransport(BaseTransport):
|
||||
|
||||
raise NotImplementedError(f"Method {child_method} not implemented for children")
|
||||
|
||||
def _update_trv_states(self, info: dict) -> None:
|
||||
"""Simulate TRV heating state after a device info update.
|
||||
|
||||
The device heats when frost protection is off and the target temperature
|
||||
exceeds the current temperature.
|
||||
"""
|
||||
if "trv_states" not in info:
|
||||
return
|
||||
should_heat = not info.get("frost_protection_on", False) and info.get(
|
||||
"target_temp", 0
|
||||
) > info.get("current_temp", 0)
|
||||
trv_states = set(info["trv_states"])
|
||||
if should_heat:
|
||||
trv_states.add("heating")
|
||||
else:
|
||||
trv_states.discard("heating")
|
||||
info["trv_states"] = list(trv_states)
|
||||
|
||||
def _get_on_off_gradually_info(self, info: dict, params: dict | None):
|
||||
if self.components["on_off_gradually"] == 1:
|
||||
info["get_on_off_gradually_info"] = {"enable": True}
|
||||
@@ -722,6 +741,10 @@ class FakeSmartTransport(BaseTransport):
|
||||
"resetConsumablesTime", # vacuum special actions
|
||||
]:
|
||||
return {"error_code": 0}
|
||||
elif method == "set_device_info":
|
||||
info["get_device_info"].update(params)
|
||||
self._update_trv_states(info["get_device_info"])
|
||||
return {"error_code": 0}
|
||||
elif method[:3] == "set":
|
||||
target_method = f"get{method[3:]}"
|
||||
# Some vacuum commands do not have a getter
|
||||
|
||||
Reference in New Issue
Block a user