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

Commit

Permalink
Merge pull request #54 from cpainchaud/main
Browse files Browse the repository at this point in the history
API V20 for GetRec and firmware > 3.1
  • Loading branch information
cpainchaud authored Oct 20, 2021
2 parents 30fe0c6 + 57ac006 commit 23de23b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
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

0 comments on commit 23de23b

Please sign in to comment.