diff --git a/reolink/camera_api.py b/reolink/camera_api.py index 58dfab2..827e005 100644 --- a/reolink/camera_api.py +++ b/reolink/camera_api.py @@ -101,6 +101,8 @@ def __init__( self._local_link = None self._ptz_support = False + self._is_nvr = False + @property def host(self): """Return the host.""" @@ -335,9 +337,12 @@ async def get_states(self, cmd_list=None): "param": {"Alarm": {"channel": self._channel, "type": "md"}}, }, {"cmd": "GetPushV20", "action": 1, "param": {"channel": self._channel}}, - {"cmd": "GetPush", "action": 1, "param": {"channel": self._channel}}, ] + if not self._is_nvr: + # NVR would crash without this + 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: @@ -506,6 +511,7 @@ async def map_json_response(self, json_data): # pylint: disable=too-many-branch self._model = data["value"]["DevInfo"]["model"] self._channels = data["value"]["DevInfo"]["channelNum"] self._sw_version_object = SoftwareVersion(self._sw_version) + self._is_nvr = data["value"]["DevInfo"].get("exactType", "CAM") == "NVR" elif data["cmd"] == "GetHddInfo": self._hdd_info = data["value"]["HddInfo"] @@ -1024,6 +1030,9 @@ async def send_setting(self, body): ) return False + def is_nvr(self): + return self._is_nvr + async def send(self, body, param=None): """Generic send method.""" if body is None or (body[0]["cmd"] != "Login" and body[0]["cmd"] != "Logout"): @@ -1042,7 +1051,10 @@ async def send(self, body, param=None): _LOGGER.debug("send()= HTTP Request params =%s", str(param).replace(self._password, "")) json_data = await response.read() _LOGGER.debug("send HTTP Response status=%s", str(response.status)) - _LOGGER_DATA.debug("send() HTTP Response data: %s", str(json_data)) + if param.get("cmd") == "Snap": + _LOGGER_DATA.debug("send() HTTP Response data scrapped because it's too large") + else: + _LOGGER_DATA.debug("send() HTTP Response data: %s", json_data) return json_data else: @@ -1054,7 +1066,10 @@ async def send(self, body, param=None): _LOGGER.debug("send() HTTP Request body =%s", str(body).replace(self._password, "")) json_data = await response.text() _LOGGER.debug("send() HTTP Response status=%s", str(response.status)) - _LOGGER_DATA.debug("send() HTTP Response data: %s", str(json_data)) + if param.get("cmd") == "Search" and len(json_data) > 500: + _LOGGER_DATA.debug("send() HTTP Response data scrapped because it's too large") + else: + _LOGGER_DATA.debug("send() HTTP Response data: %s", json_data) return json_data except aiohttp.ClientConnectorError as conn_err: diff --git a/setup.py b/setup.py index 635b8b8..1592901 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='reolink', packages=['reolink'], - version='0.0.25', + version='0.0.26', license='MIT', description='Reolink camera package', author='fwestenberg',