Skip to content

Commit

Permalink
Ensure recording extension does not get changed when toggeling record…
Browse files Browse the repository at this point in the history
…ing enabled
  • Loading branch information
starkillerOG committed Dec 9, 2024
1 parent d78bd43 commit 7ceb97a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions reolink_aio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4488,10 +4488,17 @@ async def set_recording(self, channel: int | None, enable: bool) -> None:
if channel not in self._channels:
raise InvalidParameterError(f"set_recording: no camera connected to channel '{channel}'")

await self.get_state(cmd="GetRec")
if channel not in self._recording_settings:
raise NotSupportedError(f"set_recording: recording on camera {self.camera_name(channel)} is not available")

params = self._recording_settings[channel]
if self.api_version("GetRec") >= 1:
body = [{"cmd": "SetRecV20", "action": 0, "param": {"Rec": {"scheduleEnable": on_off, "schedule": {"channel": channel}}}}]
params["Rec"]["scheduleEnable"] = on_off
body = [{"cmd": "SetRecV20", "action": 0, "param": params}]
else:
body = [{"cmd": "SetRec", "action": 0, "param": {"Rec": {"schedule": {"enable": on_off, "channel": channel}}}}]
params["Rec"]["schedule"]["enable"] = on_off
body = [{"cmd": "SetRec", "action": 0, "param": params}]

await self.send_setting(body)

Expand Down

0 comments on commit 7ceb97a

Please sign in to comment.