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

Fix get snapshot based on comments #196

Merged
merged 1 commit into from Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions ring_doorbell/doorbot.py
Expand Up @@ -424,13 +424,13 @@ def get_snapshot(self, retries=3, delay=1):
"""Take a snapshot and download it"""
url = SNAPSHOT_TIMESTAMP_ENDPOINT
payload = {"doorbot_ids": [self._attrs.get("id")]}
self._ring.query(url)
self._ring.query(url, method="POST", json=payload)
request_time = time.time()
for _ in range(retries):
time.sleep(delay)
response = self._ring.query(url, method="POST", json=payload).json()
if response["timestamps"][0]["timestamp"] / 1000 > request_time:
return self._ring.query(
SNAPSHOT_ENDPOINT.format(self._attrs.get("id"))
SNAPSHOT_ENDPOINT.format(self._attrs.get("id"), raw=True)
).content
return False