Skip to content

Commit

Permalink
Merge pull request #218 from kvntng17/add-snapshot-download
Browse files Browse the repository at this point in the history
Fixed RingDoorBell.get_snapshot() and added download
  • Loading branch information
tchellomello committed Jan 18, 2021
2 parents 9488d57 + fde54a8 commit ee04f66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ring_doorbell/doorbot.py
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

0 comments on commit ee04f66

Please sign in to comment.