Update smartcamera to support single get/set/do requests (#1187)

Not supported by H200 hub
This commit is contained in:
Steven B.
2024-10-24 13:11:28 +01:00
committed by GitHub
parent c839aaa1dd
commit 8ee8c17bdc
7 changed files with 505 additions and 123 deletions

View File

@@ -163,6 +163,10 @@ class SmartProtocol(BaseProtocol):
]
end = len(multi_requests)
# The SmartCameraProtocol 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
@@ -172,14 +176,12 @@ class SmartProtocol(BaseProtocol):
method = request["method"]
req = self.get_smart_request(method, request.get("params"))
resp = await self._transport.send(req)
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["result"]
return multi_result
# The SmartCameraProtocol sends requests with a length 1 as a
# multipleRequest. The SmartProtocol doesn't so will never
# raise_on_error
raise_on_error = end == 1
for batch_num, i in enumerate(range(0, end, step)):
requests_step = multi_requests[i : i + step]