Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

API V20 for GetRec and firmware > 3.1 #54

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions reolink/camera_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ async def get_states(self, cmd_list=None):
{"cmd": "GetEmail", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetIsp", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetIrLights", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetRec", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetPtzPreset", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetHddInfo", "action": 1, "param": {}},
{
Expand All @@ -357,11 +356,13 @@ async def get_states(self, cmd_list=None):
"param": {"Alarm": {"channel": self._channel, "type": "md"}},
},
{"cmd": "GetPushV20", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetRecV20", "action": 1, "param": {"channel": self._channel}},
]

if not self._is_nvr and self._sw_version_object < ref_sw_version_3_1_0_0_0:
# NVR would crash without this
body.append({"cmd": "GetPush", "action": 1, "param": {"channel": self._channel}})
body.append({"cmd": "GetRec", "action": 1, "param": {"channel": self._channel}})

if cmd_list is not None:
for x, line in enumerate(body):
Expand Down Expand Up @@ -587,7 +588,11 @@ async def map_json_response(self, json_data): # pylint: disable=too-many-branch
self._recording_state = (
data["value"]["Rec"]["schedule"]["enable"] == 1
)

elif data["cmd"] == "GetRecV20":
self._recording_settings = data
self._recording_state = (
data["value"]["Rec"]["schedule"]["enable"] == 1
)
elif data["cmd"] == "GetPtzPreset":
self._ptz_presets_settings = data
for preset in data["value"]["PtzPreset"]:
Expand Down
11 changes: 8 additions & 3 deletions reolink/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@


class InvalidContentTypeError(Exception):
class ReolinkError(Exception):
pass


class InvalidContentTypeError(ReolinkError):
"""Raised when Snapshot command returns an invalid JPEG file"""
pass

class SnapshotIsNotValidFileTypeError(Exception):

class SnapshotIsNotValidFileTypeError(ReolinkError):
"""Raised when Snapshot command returns an invalid JPEG file"""
pass


class CredentialsInvalidError(Exception):
class CredentialsInvalidError(ReolinkError):
"""Raised when an API call returns a credential issue"""
pass
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='reolink',
packages=['reolink'],
version='0.0.32',
version='0.0.33',
license='MIT',
description='Reolink camera package',
author='fwestenberg',
Expand Down