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

Fixed RingDoorBell.get_snapshot() and added download #218

Merged
merged 5 commits into from
Jan 18, 2021
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
5 changes: 4 additions & 1 deletion ring_doorbell/doorbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def connection_status(self):
"""Return connection status."""
return self._attrs.get("alerts").get("connection")

def get_snapshot(self, retries=3, delay=1):
def get_snapshot(self, retries=3, delay=1, filename="snapshot.jpg"):
"""Take a snapshot and download it"""
url = SNAPSHOT_TIMESTAMP_ENDPOINT
payload = {"doorbot_ids": [self._attrs.get("id")]}
Expand All @@ -440,4 +440,7 @@ def get_snapshot(self, retries=3, delay=1):
return self._ring.query(
SNAPSHOT_ENDPOINT.format(self._attrs.get("id"), raw=True)
).content
with open(filename, "wb") as jpg:
jpg.write(snapshot)
return True
return False