Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cameras dict after switch set. #124

Merged
merged 3 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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