Skip to content

Commit

Permalink
Add rspCode -9 to baichuan fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
starkillerOG committed Nov 30, 2024
1 parent 6f2cb1b commit 1d445fd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions reolink_aio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ def construct_capabilities(self, warnings=True) -> None:
if (self.api_version("supportAudioFileList", channel) > 0) or (not self.is_nvr and self.api_version("supportAudioFileList") > 0):
if self.api_version("supportAutoReply", channel) > 0 or (not self.is_nvr and self.api_version("supportAutoReply") > 0):
self._capabilities[channel].add("quick_reply")
self._capabilities[channel].add("play_quick_reply") # Baichuan fallback
self._capabilities[channel].add("play_quick_reply") # Baichuan fallback
elif self.api_version("supportAudioPlay", channel) > 0 or self.api_version("supportQuickReplyPlay", channel) > 0:
self._capabilities[channel].add("play_quick_reply")

Expand Down Expand Up @@ -5573,10 +5573,10 @@ async def send_chunk(
retry_cmd = []
retry_idxs = []
for idx, cmd_data in enumerate(json_data):
if cmd_data["code"] != 0 and cmd_data.get("error", {}).get("rspCode", 0) in [-12, -13, -17]:
if cmd_data["code"] != 0:
cmd = body[idx]
# check if baichuan has a fallback function
if retry > 0 and cmd.get("cmd") in self.baichuan.cmd_funcs:
if retry > 0 and cmd.get("cmd") in self.baichuan.cmd_funcs and cmd_data.get("error", {}).get("rspCode", 0) in [-9, -12, -13, -17]:
func = self.baichuan.cmd_funcs[cmd["cmd"]]
args = cmd.get("param", {})
try:
Expand All @@ -5588,9 +5588,10 @@ async def send_chunk(
_LOGGER.debug("Baichuan fallback succeeded for %s", cmd.get("cmd"))
json_data[idx]["Baichuan_fallback_succes"] = True
continue
# add to the list of cmds to retry
retry_cmd.append(cmd)
retry_idxs.append(idx)
if cmd_data.get("error", {}).get("rspCode", 0) in [-12, -13, -17]:
# add to the list of cmds to retry
retry_cmd.append(cmd)
retry_idxs.append(idx)
if retry_cmd and retry > 0:
_LOGGER.debug(
"cmd %s: returned response code %s/%s, retrying in 1.0 s",
Expand Down

0 comments on commit 1d445fd

Please sign in to comment.