Package: ring-doorbell
Python Ring Door Bell is a library written for Python 3.8+
that exposes the Ring.com devices as Python objects.There is also a command line interface that is work in progress.Contributors welcome.Currently Ring.com does not provide an official API. The results of this project are merely from reverse engineering.Documentation:http://python-ring-doorbell.readthedocs.io/Installation# Installing from PyPi$pipinstallring_doorbell# Installing latest development$pipinstall\git+https://github.com/tchellomello/python-ring-doorbell@masterEvent ListenerIf you want the ring api to listen for push events from ring.com for dings and motion you
will need to install with thelistenextra:$ pip install ring_doorbell[listen]The api will then start listening for push events after you have first calledupdate_dings()orupdate_data()but only if there is a runningasyncioevent loop (which there will be if using the CLI)Using the CLIThe CLI is work in progress and currently has the following commands:Show your devices:$ ring-doorbellOr:$ ring-doorbell showList your device names (with device kind):$ ring-doorbell listEither count or download your vidoes or both:$ ring-doorbell videos --count --download-allEnable disable motion detection:$ ring-doorbell motion-detection --device-name "DEVICENAME" --on
$ ring-doorbell motion-detection --device-name "DEVICENAME" --offListen for push notifications like the ones sent to your phone:$ ring-doorbell listenList your ring groups:$ ring-doorbell groupsShow your ding history:$ ring-doorbell history --device-name "Front Door"Show your currently active dings:$ ring-doorbell dingsQuery a ring api url directly:$ ring-doorbell raw-query --url /clients_api/dings/activeRunring-doorbell--helporring-doorbellvideos--helpfor full optionsInitializing your Ring objectimportjsonimportgetpassfrompathlibimportPathfrompprintimportpprintfromring_doorbellimportRing,Authfromoauthlib.oauth2importMissingTokenErrorcache_file=Path("test_token.cache")deftoken_updated(token):cache_file.write_text(json.dumps(token))defotp_callback():auth_code=input("2FA code: ")returnauth_codedefmain():ifcache_file.is_file():auth=Auth("MyProject/1.0",json.loads(cache_file.read_text()),token_updated)else:username=input("Username: ")password=getpass.getpass("Password: ")auth=Auth("MyProject/1.0",None,token_updated)try:auth.fetch_token(username,password)exceptMissingTokenError:auth.fetch_token(username,password,otp_callback())ring=Ring(auth)ring.update_data()devices=ring.devices()pprint(devices)if__name__=="__main__":main()Listing devices linked to your account# All devicesdevices=ring.devices(){'chimes':[<RingChime:Downstairs>],'doorbots':[<RingDoorBell:FrontDoor>]}# All doorbellsdoorbells=devices['doorbots'][<RingDoorBell:FrontDoor>]# All chimeschimes=devices['chimes'][<RingChime:Downstairs>]# All stickup camsstickup_cams=devices['stickup_cams'][<RingStickUpCam:Driveway>]Playing with the attributes and functionsdevices=ring.devices()fordevinlist(devices['stickup_cams']+devices['chimes']+devices['doorbots']):dev.update_health_data()print('Address:%s'%dev.address)print('Family:%s'%dev.family)print('ID:%s'%dev.id)print('Name:%s'%dev.name)print('Timezone:%s'%dev.timezone)print('Wifi Name:%s'%dev.wifi_name)print('Wifi RSSI:%s'%dev.wifi_signal_strength)# setting dev volumeprint('Volume:%s'%dev.volume)dev.volume=5print('Volume:%s'%dev.volume)# play dev test shoundifdev.family=='chimes':dev.test_sound(kind='ding')dev.test_sound(kind='motion')# turn on lights on floodlight camifdev.family=='stickup_cams'anddev.lights:dev.lights='on'Showing door bell eventsdevices=ring.devices()fordoorbellindevices['doorbots']:# listing the last 15 events of any kindforeventindoorbell.history(limit=15):print('ID:%s'%event['id'])print('Kind:%s'%event['kind'])print('Answered:%s'%event['answered'])print('When:%s'%event['created_at'])print('--'*50)# get a event list only the triggered by motionevents=doorbell.history(kind='motion')Downloading the last video triggered by a ding or motion eventdevices=ring.devices()doorbell=devices['doorbots'][0]doorbell.recording_download(doorbell.history(limit=100,kind='ding')[0]['id'],filename='last_ding.mp4',override=True)Displaying the last video capture URLprint(doorbell.recording_url(doorbell.last_recording_id))'https://ring-transcoded-videos.s3.amazonaws.com/99999999.mp4?X-Amz-Expires=3600&X-Amz-Date=20170313T232537Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=TOKEN_SECRET/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=secret'Controlling a Light Groupgroups=ring.groups()group=groups['the-group-you-want']print(group.lights)# Prints True if lights are on, False if off# Turn on lights indefinitelygroup.lights=True# Turn off lightsgroup.lights=False# Turn on lights for 30 secondsgroup.lights=(True,30)How to contributeSee ourContributing Page.Credits && ThanksThis project was inspired and based onhttps://github.com/jeroenmoors/php-ring-api. Many thanks @jeroenmoors.A guy named MadBagger at Prism19 for his initial research (http://www.prism19.com/doorbot/second-pass-and-comm-reversing/)The creators of mitmproxy (https://mitmproxy.org/) great http and https traffic inspector@mfussenegger for his post on mitmproxy and virtualboxhttps://zignar.net/2015/12/31/sniffing-vbox-traffic-mitmproxy/To the projecthttp://www.android-x86.org/which allowed me to install Android on KVM.Many thanks to Carles Pina I Estany <carles@pina.cat> for creating the python-ring-doorbell Debian Package (https://tracker.debian.org/pkg/python-ring-doorbell).