MisterWil / abodepy

A thin Python wrapper for the Abode alarm API
MIT License
49 stars 17 forks source link

Add support for camera snapshots #85

Open arroyoj opened 2 years ago

arroyoj commented 2 years ago

First of all, @MisterWil, thanks for releasing this great library to interact with the Abode API.

I recently added a camera to my Abode system and noticed that in the official Abode app, it is possible to see a preview snapshot image from the camera without taking an image capture that gets recorded to the timeline. Looking in the web app, there is an integrations/v1/camera/[uuid]/snapshot URL that allows retrieving the current snapshot image as a base64-encoded string. The web app uses these snapshots (converted to a data url) as a preview on the live video page.

This PR adds support for retrieving a snapshot image from an Abode camera, modeled on the existing AbodeCamera.capture() interface. The image can either be stored to a file, similar to a captured image, or returned as a base64-encoded data url for easy use in a web app. I only have an Abode Cam 2 (thanks @kevdliu for adding support), so I have not been able to test whether this Abode API works the same for older cameras. I would appreciate further testing by users with other camera versions to make sure it is fully compatible.

This PR also increases the required versions for flake8-docstrings and pydocstyle in the test suite since the previously pinned versions are incompatible with the latest flake8.

kevdliu commented 2 years ago

Unfortunately I don't think @MisterWil is active anymore :(

Do you use Home Assistant by any chance? This change would be super beneficial for the Home Assistant Abode integration. The current integration does not take a snapshot in real-time when a snapshot is requested by HA and instead just retrieves the latest snapshot from the timeline. I tried modifying the integration to take a snapshot in real-time but was unaware that the endpoint I used also creates a snapshot on the timeline and thus generating a ton of unnecessary events on the timeline. I ended up having to revert my change since it was causing too much spam. This change would solve that problem!

arroyoj commented 2 years ago

@kevdliu, no, I don't use Home Assistant. You're more than welcome to take the code for HA, though. Maybe the snapshot endpoint can be integrated into HA outside of abodepy? I find the snapshot endpoint much easier to use, since it gives you the image data directly, instead of having to first trigger the image capture and then download it.

It's too bad abodepy doesn't seem to be maintained any more. Maybe someone in the HA community would be interested in forking it if it is getting used there?

jaraco commented 1 year ago

Please consider contributing this to jaraco/jaraco.abode.