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 #44 from cpainchaud/main
Browse files Browse the repository at this point in the history
fix Push state for non AI cameras
  • Loading branch information
cpainchaud authored Sep 30, 2021
2 parents 1ce6d9e + 101fb64 commit a713f52
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
24 changes: 15 additions & 9 deletions reolink/camera_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,10 @@ async def get_states(self, cmd_list=None):
"action": 1,
"param": {"Alarm": {"channel": self._channel, "type": "md"}},
},
{"cmd": "GetPushV20", "action": 1, "param": {"channel": self._channel}},
{"cmd": "GetPush", "action": 1, "param": {"channel": self._channel}},
]

if self._sw_version_object is not None and self._sw_version_object > ref_sw_version_3_0_0_0_0:
body.append({"cmd": "GetPushV20", "action": 1, "param": {"channel": self._channel}})
else:
body.append({"cmd": "GetPush", "action": 1, "param": {"channel": self._channel}})

if cmd_list is not None:
for x, line in enumerate(body):
if line["cmd"] not in cmd_list:
Expand Down Expand Up @@ -485,6 +482,10 @@ async def get_vod_source(self, filename: str):

async def map_json_response(self, json_data): # pylint: disable=too-many-branches
"""Map the JSON objects to internal objects and store for later use."""

push_data = None
pushv20_data = None

for data in json_data:
try:
if data["code"] == 1: # -->Error, like "ability error"
Expand Down Expand Up @@ -530,12 +531,10 @@ async def map_json_response(self, json_data): # pylint: disable=too-many-branch
self._ftp_state = data["value"]["Ftp"]["schedule"]["enable"] == 1

elif data["cmd"] == "GetPush":
self._push_settings = data
self._push_state = data["value"]["Push"]["schedule"]["enable"] == 1
push_data = data

elif data["cmd"] == "GetPushV20":
self._push_settings = data
self._push_state = data["value"]["Push"]["enable"] == 1
pushv20_data = data

elif data["cmd"] == "GetEnc":
self._enc_settings = data
Expand Down Expand Up @@ -583,6 +582,13 @@ async def map_json_response(self, json_data): # pylint: disable=too-many-branch
_LOGGER.error(traceback.format_exc())
continue

if pushv20_data is not None:
self._push_settings = pushv20_data
self._push_state = pushv20_data["value"]["Push"]["enable"] == 1
elif push_data is not None:
self._push_settings = push_data
self._push_state = push_data["value"]["Push"]["schedule"]["enable"] == 1

async def login(self):
"""Login and store the session ."""
if self.session_active:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
setup(
name = 'reolink',
packages = ['reolink'],
version = '0.0.23',
version = '0.0.24',
license='MIT',
description = 'Reolink camera package',
author = 'fwestenberg',
Expand Down

0 comments on commit a713f52

Please sign in to comment.