Skip to content

Commit

Permalink
Merge pull request #124 from BaQs/ezviz_update_statuses_after_switch
Browse files Browse the repository at this point in the history
Update cameras dict after switch set.
  • Loading branch information
RenierM26 committed Jun 26, 2023
2 parents 01007c1 + ac99207 commit c4415cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions pyezviz/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,17 @@ def get_device_messages_list(
return json_output

def switch_status(
self, serial: str, status_type: int, enable: int, max_retries: int = 0
self,
serial: str,
status_type: int,
enable: int,
channel_no: int = 0,
max_retries: int = 0,
) -> bool:
"""Camera features are represented as switches. Switch them on or off."""
if max_retries > MAX_RETRIES:
raise PyEzvizError("Can't gather proper data. Max retries exceeded.")

channel_no = 0

try:
req = self._session.put(
url=f"https://{self._token['api_url']}{API_ENDPOINT_DEVICES}{serial}/{channel_no}/{enable}/{status_type}{API_ENDPOINT_SWITCH_STATUS}",
Expand Down Expand Up @@ -457,6 +460,9 @@ def switch_status(
if json_output["meta"]["code"] != 200:
raise PyEzvizError(f"Could not set the switch: Got {json_output})")

if self._cameras.get(serial):
self._cameras[serial]["switches"][status_type] = bool(enable)

return True

def switch_status_other(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='pyezviz',
version="0.2.1.5",
version="0.2.1.6",
license='Apache Software License 2.0',
author='Pierre Ourdouille',
author_email='baqs@users.github.com',
Expand Down

0 comments on commit c4415cd

Please sign in to comment.