From 69553754f4877265955603ab3e0b693e5cf5ceaf Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 9 Jun 2020 09:09:38 -0400 Subject: [PATCH 1/4] Fixed RingDoorBell.get_snapshot() - was getting 405 Client Error before because it looks like the endpoint (https://api.ring.com/clients_api/snapshots/timestamps?api_version=9) no longer accepts GET requests. Changed the initial snapshot request to a POST request --- ring_doorbell/doorbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ring_doorbell/doorbot.py b/ring_doorbell/doorbot.py index a12fe38..09f3097 100644 --- a/ring_doorbell/doorbot.py +++ b/ring_doorbell/doorbot.py @@ -424,7 +424,7 @@ 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) From dd1d0c26556eaedb7ed69eff0529f0ea95851b27 Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Tue, 9 Jun 2020 09:16:19 -0400 Subject: [PATCH 2/4] Fixed RingDoorBell.get_snapshot() --- ring_doorbell/doorbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ring_doorbell/doorbot.py b/ring_doorbell/doorbot.py index 09f3097..08a219e 100644 --- a/ring_doorbell/doorbot.py +++ b/ring_doorbell/doorbot.py @@ -420,7 +420,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, filename="snapshot.jpg", retries=3, delay=1): """Take a snapshot and download it""" url = SNAPSHOT_TIMESTAMP_ENDPOINT payload = {"doorbot_ids": [self._attrs.get("id")]} @@ -430,7 +430,10 @@ def get_snapshot(self, retries=3, delay=1): 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 = self._ring.query( SNAPSHOT_ENDPOINT.format(self._attrs.get("id")) ).content + with open(filename, "wb") as jpg: + jpg.write(snapshot) + return True return False From 5a35d8587dbbde97bcc5e5aae8a8b344ac2867f8 Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Sun, 17 Jan 2021 23:22:48 -0500 Subject: [PATCH 3/4] Update doorbot.py --- ring_doorbell/doorbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ring_doorbell/doorbot.py b/ring_doorbell/doorbot.py index 08a219e..743d198 100644 --- a/ring_doorbell/doorbot.py +++ b/ring_doorbell/doorbot.py @@ -420,7 +420,7 @@ def connection_status(self): """Return connection status.""" return self._attrs.get("alerts").get("connection") - def get_snapshot(self, filename="snapshot.jpg", 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")]} From fde54a8bf0d8749b2a161b9fefc63ffbe74d2efb Mon Sep 17 00:00:00 2001 From: Marcelo Moreira de Mello Date: Sun, 17 Jan 2021 23:30:52 -0500 Subject: [PATCH 4/4] Update doorbot.py --- ring_doorbell/doorbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ring_doorbell/doorbot.py b/ring_doorbell/doorbot.py index f594041..df84201 100644 --- a/ring_doorbell/doorbot.py +++ b/ring_doorbell/doorbot.py @@ -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, filename="snapshot.jpg",): + 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")]}