Merge branch 'master' into feat/smartcam_passthrough

This commit is contained in:
Steven B.
2024-12-16 13:07:09 +00:00
committed by GitHub
6 changed files with 204 additions and 47 deletions

View File

@@ -185,18 +185,18 @@ class SmartProtocol(BaseProtocol):
multi_result: dict[str, Any] = {}
smart_method = "multipleRequest"
end = len(requests)
# The SmartCamProtocol sends requests with a length 1 as a
# multipleRequest. The SmartProtocol doesn't so will never
# raise_on_error
raise_on_error = end == 1
multi_requests = [
{"method": method, "params": params} if params else {"method": method}
for method, params in requests.items()
if method not in FORCE_SINGLE_REQUEST
]
end = len(multi_requests)
# The SmartCamProtocol sends requests with a length 1 as a
# multipleRequest. The SmartProtocol doesn't so will never
# raise_on_error
raise_on_error = end == 1
# Break the requests down as there can be a size limit
step = self._multi_request_batch_size
if step == 1:
@@ -287,7 +287,9 @@ class SmartProtocol(BaseProtocol):
resp = await self._transport.send(
self.get_smart_request(method, params)
)
self._handle_response_error_code(resp, method, raise_on_error=False)
self._handle_response_error_code(
resp, method, raise_on_error=raise_on_error
)
multi_result[method] = resp.get("result")
return multi_result