mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Update smart request parameter handling (#1061)
Changes to the smart request handling: - Do not send params if null - Drop the requestId parameter - get_preset_rules doesn't send parameters for preset component version less than 3 - get_led_info no longer sends the wrong parameters - get_on_off_gradually_info no longer sends an empty {} parameter
This commit is contained in:
@@ -119,8 +119,9 @@ class FakeSmartTransport(BaseTransport):
|
||||
async def send(self, request: str):
|
||||
request_dict = json_loads(request)
|
||||
method = request_dict["method"]
|
||||
params = request_dict["params"]
|
||||
|
||||
if method == "multipleRequest":
|
||||
params = request_dict["params"]
|
||||
responses = []
|
||||
for request in params["requests"]:
|
||||
response = self._send_request(request) # type: ignore[arg-type]
|
||||
@@ -308,12 +309,13 @@ class FakeSmartTransport(BaseTransport):
|
||||
|
||||
def _send_request(self, request_dict: dict):
|
||||
method = request_dict["method"]
|
||||
params = request_dict["params"]
|
||||
|
||||
info = self.info
|
||||
if method == "control_child":
|
||||
return self._handle_control_child(params)
|
||||
elif method == "component_nego" or method[:4] == "get_":
|
||||
return self._handle_control_child(request_dict["params"])
|
||||
|
||||
params = request_dict.get("params")
|
||||
if method == "component_nego" or method[:4] == "get_":
|
||||
if method in info:
|
||||
result = copy.deepcopy(info[method])
|
||||
if "start_index" in result and "sum" in result:
|
||||
|
Reference in New Issue
Block a user