Skip to content

Update the snapshot download method to use more reliable endpoint - #528

Open
reeve wants to merge 2 commits into
python-ring-doorbell:masterfrom
reeve:reeve-fix-shapshots
Open

reeve wants to merge 2 commits into
python-ring-doorbell:masterfrom
reeve:reeve-fix-shapshots

Conversation

@reeve

@reeve reeve commented Jun 10, 2026

Copy link
Copy Markdown

Resolves #527

This PR replaces the implementation of async_get_snapshot with a call to the same snapshot endpoint used by ring-mqtt. This endpoint essentially does a search query, you can pass in a "must be after" timestamp, and if an image already exists that is younger than that it will be returned. Otherwise, if the force flag is set, a new image will be generated on the fly and returned, provided the timeout doesn't elapse. This removes the need to make multiple API calls, and the fail/retry logic of the old method.

I wasn't sure how you like to handle API changes (as the parameters are quite different given this code works differently) - I elected to mark the old one deprecated and create a whole new method. But if you prefer to just replace the old one with the same name and flag a breaking change in the release notes I'm happy to make that update. I also added some basic tests.

LMK if you have questions/comments :)

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
If you are the author of this PR, please leave a comment if you want to keep it open. Also, please rebase your PR onto the latest dev branch to ensure that it's up to date with the latest changes.
Thank you for your contribution!

@github-actions github-actions Bot added the stale Stale PRs and Issues label Sep 9, 2026
@thomasgregg

Copy link
Copy Markdown

Thanks for putting this together — this is the missing upstream piece for home-assistant/core#155796.

I pulled this branch and tested it locally on Python 3.9.6. The endpoint change and snapshot tests work, but the branch currently cannot import on Python 3.9 because warnings.deprecated is unavailable there, while this project supports Python 3.9 and includes it in the CI matrix.

Changing the import to the already-required compatibility package fixes it:

from typing_extensions import deprecated

With that change, the complete test suite passes on Python 3.9: 41 passed. The focused snapshot test also passes. It would be great to rebase/update this PR so the more reliable snapshot method can land; I am happy to prepare a replacement or follow-up PR if that would be easier.

Comment thread ring_doorbell/doorbot.py Resolved
@github-actions github-actions Bot removed the stale Stale PRs and Issues label Sep 12, 2026
Fix for python 3.9

Co-authored-by: Thomas Gregg <thomas@gregg.de>
@reeve

reeve commented Sep 12, 2026

Copy link
Copy Markdown
Author

Hey @thomasgregg ! Thanks for looking over this. I accepted your change into the PR, looks like it should be mergable as-is (the last change on master looks to be older than the PR). LMK if anyone needs anything else from me!

@thomasgregg

Copy link
Copy Markdown

Thanks, Adam. The updated PR is mergeable and the tests pass. @sdb9696, when you have a chance, could you review this? It is the remaining upstream dependency for home-assistant/core#155796.

@thomasgregg

Copy link
Copy Markdown

Hi @joostlek. You prepared the latest ring-doorbell release, and this PR is currently mergeable but waiting for a maintainer review. Would you be able to review it or point us to someone with merge access? It unblocks home-assistant/core#155796.

AMoo-Miki added a commit to AMoo-Miki/python-ring-cameras that referenced this pull request Oct 9, 2026
Upstream python-ring-doorbell has had no merges for months; this takes
what its open pull requests offer, adapted to this fork:

- WebRTC: _close() no longer awaits its own reader task when the stream
  closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534).
- New RingDoorBell.async_take_snapshot(): one request that returns a
  stored snapshot newer than max_age or captures a fresh one, via the
  endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods
  are unchanged.
- Outdoor Cam Plus reports a battery from its health data when it says
  either way, so plug-in variants no longer get one; a camera whose
  battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked).
- Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen),
  Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3,
  Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and
  Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550).

Co-authored-by: Niels Haagsman <haagsman@gmail.com>
Co-authored-by: Adam Reeve <adam@adamreeve.com>
Co-authored-by: danielcolquitt <daniel@colquitt.xyz>
Co-authored-by: Tom Roberts <tom@tomroberts.co.uk>
Co-authored-by: ben79 <benjaminfearnley@gmail.com>
Co-authored-by: Aaron Wolen <aaron@wolen.com>
Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki added a commit to AMoo-Miki/python-ring-cameras that referenced this pull request Oct 9, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork:

- WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534).
- New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged.
- Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked).
- Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550).

Co-authored-by: Niels Haagsman <haagsman@gmail.com>
Co-authored-by: Adam Reeve <adam@adamreeve.com>
Co-authored-by: danielcolquitt <daniel@colquitt.xyz>
Co-authored-by: Tom Roberts <tom@tomroberts.co.uk>
Co-authored-by: ben79 <benjaminfearnley@gmail.com>
Co-authored-by: Aaron Wolen <aaron@wolen.com>
Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki added a commit to AMoo-Miki/python-ring-cameras that referenced this pull request Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork:

- WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534).
- New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged.
- Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked).
- Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550).

Co-authored-by: Niels Haagsman <haagsman@gmail.com>
Co-authored-by: Adam Reeve <adam@adamreeve.com>
Co-authored-by: danielcolquitt <daniel@colquitt.xyz>
Co-authored-by: Tom Roberts <tom@tomroberts.co.uk>
Co-authored-by: ben79 <benjaminfearnley@gmail.com>
Co-authored-by: Aaron Wolen <aaron@wolen.com>
Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki added a commit to AMoo-Miki/python-ring-cameras that referenced this pull request Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork:

- WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534).
- New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged.
- Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked).
- Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550).

Co-authored-by: Niels Haagsman <haagsman@gmail.com>
Co-authored-by: Adam Reeve <adam@adamreeve.com>
Co-authored-by: danielcolquitt <daniel@colquitt.xyz>
Co-authored-by: Tom Roberts <tom@tomroberts.co.uk>
Co-authored-by: ben79 <benjaminfearnley@gmail.com>
Co-authored-by: Aaron Wolen <aaron@wolen.com>
Co-authored-by: Yoan <yoan.cousin@proton.me>
AMoo-Miki added a commit to AMoo-Miki/python-ring-cameras that referenced this pull request Oct 16, 2026
Upstream python-ring-doorbell has had no merges for months; this takes what its open pull requests offer, adapted to this fork:

- WebRTC: _close() no longer awaits its own reader task when the stream closes from inside it (upstream python-ring-doorbell#548, python-ring-doorbell#534).
- New RingDoorBell.async_take_snapshot(): one request that returns a stored snapshot newer than max_age or captures a fresh one, via the endpoint ring-mqtt uses (upstream python-ring-doorbell#528). Existing snapshot methods are unchanged.
- Outdoor Cam Plus reports a battery from its health data when it says either way, so plug-in variants no longer get one; a camera whose battery died reports nothing and keeps it (upstream python-ring-doorbell#538, reworked).
- Device kinds: Battery Doorbell Pro 4K, Wired Doorbell Plus (2nd Gen), Wired Doorbell (doorbell_tahoe), Doorbell (2nd Gen) cocoa_doorbell_v3, Indoor Cam Plus, Spotlight Cam Pro 4K, Elite Cam 140/360 4K and Chime (2nd Gen) (upstream python-ring-doorbell#553, python-ring-doorbell#539, python-ring-doorbell#536, python-ring-doorbell#531, python-ring-doorbell#550).

Co-authored-by: Niels Haagsman <haagsman@gmail.com>
Co-authored-by: Adam Reeve <adam@adamreeve.com>
Co-authored-by: danielcolquitt <daniel@colquitt.xyz>
Co-authored-by: Tom Roberts <tom@tomroberts.co.uk>
Co-authored-by: ben79 <benjaminfearnley@gmail.com>
Co-authored-by: Aaron Wolen <aaron@wolen.com>
Co-authored-by: Yoan <yoan.cousin@proton.me>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

async_get_snapshot doesn't seem to work well with battery cams (fix incoming)

2 participants