python-ring-doorbell
python-ring-doorbell copied to clipboard
timestamp check on get_snapshot
Hi everyone, thanks for this great contribution! I keep getting a False response from this check which made me wonder why is check even needed?
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: #<<<------This line
return self._ring.query(SNAPSHOT_ENDPOINT.format(self._attrs.get("id"))).content
In any case, seems that the snapshot is a cached image, i am not able to get a fresh image all the time. What I am trying to do is to setup a face recognition system on the ring device. So instead of "someone is at your door" alert, you would get "Mom is at your door", and similar benefits. The first issue is that I have to poll the API for new events And the second issue is that I cannot get a new snapshot when I want it, but that system takes a snapshot every 10 minutes or so, and I can only get the last one, not take one on demand
Very cool application idea with the image recognition! Latency would be important for near real time functionality indeed.
I also get False with get_snapshot
.
I figured out the only way I can get this working is to (1) update the first query, and (2) comment out the 'timestamp' line.
Granted, the snapshots are often a few minutes old. But for now, its better than nothing.
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, method="POST", json=payload) <--- updated this line
for _ in range(retries):
time.sleep(delay)
self._ring.query(url, method="POST", json=payload).json()
#if response["timestamps"][0]["timestamp"] / 1000 > request_time: <--- commented out this line
return self._ring.query(
SNAPSHOT_ENDPOINT.format(self._attrs.get("id"), raw=True)
).content
return False
There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs. Please make sure to update to the latest ring_doorbell version and check if that solves the issue. Thank you for your contributions.