No module Published on Offcanvas position

Ring Doorbell API and storing footage

Officially Ring doesn't provide a public API so you can programmatically connect to your devices to like for example, store the recorded footage locally instead of cloud only.
Lucky for us, hard working individuals reverse engineered it all into a API that can be used with Python.

All credits to the doorbell API for Ring goes to Tchellomello, you can find it here: https://github.com/tchellomello/python-ring-doorbell
His documentation is pretty easy to follow with tons of examples on how to connect.

Sadly not all functions are working 100%. I've experienced the snapshot function wouldn't get the latest snapshot but always one that's 15 minutes behind the latest one. Maybe it will be fixed someday.
For my situation the only thing I care about is storing the footage locally on my server.

Yes you can use to API to sort of connect with any home automation, but if you expect a split second reaction on the monent someone causes a motion trigger or presses the doorbell. You are sorely mistaken.
The problem is that the API has to call the Ring servers, you cannot do this every second without getting your IP blacklisted for 24 hours or banned even if you are unlucky.
My own scripts contain the command to sleep for a few seconds before reattempting just to prevent this.
So if you want split second reactions, find another way or use IFFFT.

You can store the footage on anything you want, Windows, Linux or NAS.
In my situation i'm using a Windows 2012 R2 File server and Ubuntu Server to run the python script
I'm storing it on my windows file server because I have one. If you want to do this too, follow these instructions:

  1. Depending if you are running Active Directory or not, create a new user either in Active Directory or on the fileserver itself
  2. Connect to the fileserver and create a new folder that will contain the footage. Give this folder the following rights
    Share tab: Everyone - Full Control
    Security tab: Created user from step 1 - Modify
  3. Connect to the Linux server and create a new folder under /mnt, for example: /mnt/footage
  4. Use the following command: sudo nano /etc/fstab to edit the file that manages the diskmounts
  5. Add the following line at the bottom:
    (fileshare ex. //windowserver/fileshare$) /mnt/(folder) cifs username=windowsuser,password=windowsuserpassword,domain=DOMAIN (leave this out if you don't have a domain),uid=linuxuserloggedin,gid=linuxuserloggedin 0 0
  6. Use the following command to mount it all: sudo mount -a

Check if the network share has been mounted, try adding new folders or files to it and check it in Windows.


For the API, I've written two scripts one for when there's motion detected and one if the doorbell is pressed
Doorbell: https://github.com/MoebiusZero/Scripts/blob/main/Python/ringdoorbell.py
Motion: https://github.com/MoebiusZero/Scripts/blob/main/Python/ringmotion.py

Both are quite similiar in use. On first time use you will need to enter your Ring Account username and password.
Then run the script and 2FA will trigger, enter the 2FA in the script as well and run it again. This will create a token file to validate the current device.
You only have do this once, you don't have to do this for every script.

The important part is the loop. You only need to change a few variables to make sure the footage is stored correctly
Both scripts contain the variable storagepath. Change this to the folder you created on the linux server
Both scripts also contain the variable fileid. Change this to the folder where you are running the script from or anywhere where the script can reach
If you want to change how the video files are named, change the videofile variabel. In the scripts it's set to create the file as lastmotion or lastding_datetime.mp3

The fileid is there as a check to make sure the scripts won't go off downloading the same footage every few minutes. The scripts will create a folder with the date of today if it does not exist and put the footage in there.
It is possible you will end up with a few empty folders because that entire day will not have anyone moving or ringing your doorbell.
Feel free to add it to the script to delete empty folder or use another way. Personally, I use a powershell script on the Windows server that checks every midnight if there are empty folders and deletes them.

Siang Lim