diff --git a/reolink/camera_api.py b/reolink/camera_api.py index 3f25430..d16425b 100644 --- a/reolink/camera_api.py +++ b/reolink/camera_api.py @@ -382,7 +382,7 @@ async def get_states(self, cmd_list=None): try: json_data = json.loads(response) - await self.map_json_response(json_data) + self.map_json_response(json_data) return True except (TypeError, json.JSONDecodeError) as e: _LOGGER.debug( @@ -412,7 +412,7 @@ async def get_settings(self): try: json_data = json.loads(response) - await self.map_json_response(json_data) + self.map_json_response(json_data) return True except (TypeError, json.JSONDecodeError): _LOGGER.debug( @@ -439,7 +439,7 @@ async def get_motion_state(self): self._motion_state = False return self._motion_state - await self.map_json_response(json_data) + self.map_json_response(json_data) except (TypeError, json.JSONDecodeError): self.clear_token() self._motion_state = False @@ -463,12 +463,29 @@ async def get_ai_state(self): ) return self._ai_state - await self.map_json_response(json_data) + self.map_json_response(json_data) except (TypeError, json.JSONDecodeError): self.clear_token() return self._ai_state + async def get_all_motion_states(self): + """Fetch All motions states at once (regular + AI).""" + body = [{"cmd": "GetMdState", "action": 0, "param": {"channel": self._channel}}, + {"cmd": "GetAiState", "action": 0, "param": {"channel": self._channel}}] + + response = await self.send(body) + json_data = json.loads(response) + + if json_data is None: + _LOGGER.error( + "Unable to get All Motion States at IP %s", self._host + ) + self._motion_state = False + return self._motion_state + + self.map_json_response(json_data) + async def get_still_image(self): """Get the still image.""" param = {"cmd": "Snap", "channel": self._channel} @@ -514,7 +531,7 @@ async def get_vod_source(self, filename: str): return stream_source - async def map_json_response(self, json_data): # pylint: disable=too-many-branches + 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 diff --git a/setup.py b/setup.py index a3534f8..684dd97 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='reolink', packages=['reolink'], - version='0.0.36', + version='0.0.37', license='MIT', description='Reolink camera package', author='fwestenberg',