Skip to content

Commit

Permalink
retry failed camera snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-or committed Jul 25, 2023
1 parent 8de9131 commit 2040cd7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion custom_components/hikvision_next/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ async def stream_source(self) -> str | None:

async def async_camera_image(self, width: int | None = None, height: int | None = None) -> bytes | None:
"""Return a still image response from the camera."""
return await self.isapi.get_camera_image(self.stream_info, width, height)
data = await self.isapi.get_camera_image(self.stream_info, width, height)
if data.startswith(b'<?xml '):
# retry if got XML error response
data = await self.isapi.get_camera_image(self.stream_info, width, height)
return data

0 comments on commit 2040cd7

Please sign in to comment.