All Projects → tchellomello → Python Ring Doorbell

tchellomello / Python Ring Doorbell

Licence: lgpl-3.0
Python Ring Door Bell is a library written in Python 3 that exposes the Ring.com devices as Python objects.

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects
python27
39 projects

Projects that are alternatives of or similar to Python Ring Doorbell

Home assistant
My personal Home Assistant setup - Running on a HassOS VM.
Stars: ✭ 270 (-23.3%)
Mutual labels:  home-automation
Homegenie
HomeGenie, the open source, programmable, home automation server for smart connected devices and applications
Stars: ✭ 313 (-11.08%)
Mutual labels:  home-automation
Harmony Api
🗼 A simple server allowing you to query/control multiple local Harmony Home Hubs over HTTP or MQTT
Stars: ✭ 345 (-1.99%)
Mutual labels:  home-automation
Awesome Smarthome
Curated list of awesome SmartHome/Home Automation things (open and leaving users in control)
Stars: ✭ 274 (-22.16%)
Mutual labels:  home-automation
Esphome
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Stars: ✭ 4,324 (+1128.41%)
Mutual labels:  home-automation
Hoobs
Build your Smart Home with HOOBS. Connect over 2,000 Accessories to your favorite Ecosystem.
Stars: ✭ 325 (-7.67%)
Mutual labels:  home-automation
Homeassistantconfiguration
Home Assistant Config. For more info see link:
Stars: ✭ 260 (-26.14%)
Mutual labels:  home-automation
Sonoff Homeassistant
Firmware for ESP8266 based itead Sonoff switches for use with HomeAssistant
Stars: ✭ 354 (+0.57%)
Mutual labels:  home-automation
Hap
Swift implementation of the Homekit Accessory Protocol
Stars: ✭ 309 (-12.22%)
Mutual labels:  home-automation
Home Automation
Raspberry Pi 3 based home automation with NodeJS and React Native.
Stars: ✭ 3,395 (+864.49%)
Mutual labels:  home-automation
Kmansonoff
Firmware for ESP8266 based itead Sonoff switches for use with HomeAssistant / mqtt
Stars: ✭ 282 (-19.89%)
Mutual labels:  home-automation
Miflora
☘️🌡🌼🥀🏡 Mi Flora Plant sensor Python package
Stars: ✭ 291 (-17.33%)
Mutual labels:  home-automation
Http Shortcuts
Android app to create home screen shortcuts that trigger arbitrary HTTP requests
Stars: ✭ 329 (-6.53%)
Mutual labels:  home-automation
Smartthings
Samsung SmartThings SmartApps and Device Handlers
Stars: ✭ 270 (-23.3%)
Mutual labels:  home-automation
Bruh3 Home Assistant Configuration
(OBSOLETE) BRUH3 Home Assistant Configuration
Stars: ✭ 347 (-1.42%)
Mutual labels:  home-automation
Fauxmo
Emulated Belkin WeMo devices that work with the Amazon Echo
Stars: ✭ 262 (-25.57%)
Mutual labels:  home-automation
Pyatv
A python client library for the Apple TV
Stars: ✭ 322 (-8.52%)
Mutual labels:  home-automation
Freedomotic
Open IoT Framework
Stars: ✭ 354 (+0.57%)
Mutual labels:  home-automation
Majordomo
Home automation platform
Stars: ✭ 352 (+0%)
Mutual labels:  home-automation
Home Assistantconfig
🏠 Home Assistant configuration & Documentation for my Smart House. Write-ups, videos, part lists, and links throughout. Be sure to ⭐ it. Updated FREQUENTLY!
Stars: ✭ 3,687 (+947.44%)
Mutual labels:  home-automation

===================== Python Ring Door Bell

.. image:: https://badge.fury.io/py/ring-doorbell.svg :target: https://badge.fury.io/py/ring-doorbell

.. image:: https://travis-ci.org/tchellomello/python-ring-doorbell.svg?branch=master :target: https://travis-ci.org/tchellomello/python-ring-doorbell

.. image:: https://coveralls.io/repos/github/tchellomello/python-ring-doorbell/badge.svg?branch=master :target: https://coveralls.io/github/tchellomello/python-ring-doorbell?branch=master

.. image:: https://img.shields.io/pypi/pyversions/ring-doorbell.svg :target: https://pypi.python.org/pypi/ring-doorbell

Python Ring Door Bell is a library written for Python 3.6+ that exposes the Ring.com devices as Python objects.

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/ <http://python-ring-doorbell.readthedocs.io/>_

Installation

.. code-block:: bash

# Installing from PyPi
$ pip install ring_doorbell

# Installing latest development
$ pip install \
    git+https://github.com/tchellomello/[email protected]

Initializing your Ring object

.. code-block:: python

import json
import getpass
from pathlib import Path
from pprint import pprint

from ring_doorbell import Ring, Auth
from oauthlib.oauth2 import MissingTokenError


cache_file = Path("test_token.cache")


def token_updated(token):
    cache_file.write_text(json.dumps(token))


def otp_callback():
    auth_code = input("2FA code: ")
    return auth_code


def main():
    if cache_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)
        except MissingTokenError:
            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

.. code-block:: python

# All devices
devices = ring.devices()
{'chimes': [<RingChime: Downstairs>],
'doorbots': [<RingDoorBell: Front Door>]}

# All doorbells
doorbells = devices['doorbots']
[<RingDoorBell: Front Door>]

# All chimes
chimes = devices['chimes']
[<RingChime: Downstairs>]

# All stickup cams
stickup_cams = devices['stickup_cams']
[<RingStickUpCam: Driveway>]

Playing with the attributes and functions

.. code-block:: python

devices = ring.devices()
for dev in list(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 volume
    print('Volume:     %s' % dev.volume)
    dev.volume = 5
    print('Volume:     %s' % dev.volume)

    # play dev test shound
    if dev.family == 'chimes':
        dev.test_sound(kind = 'ding')
        dev.test_sound(kind = 'motion')

    # turn on lights on floodlight cam
    if dev.family == 'stickup_cams' and dev.lights:
        dev.lights = 'on'

Showing door bell events

.. code-block:: python

devices = ring.devices()
for doorbell in devices['doorbots']:

    # listing the last 15 events of any kind
    for event in doorbell.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 motion
    events = doorbell.history(kind='motion')

Downloading the last video triggered by ding

.. code-block:: python

devices = 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 URL

.. code-block:: python

print(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 Group

.. code-block:: python

groups = ring.groups()
group = groups['the-group-you-want']

print(group.lights)
# Prints True if lights are on, False if off

# Turn on lights indefinitely
group.lights = True

# Turn off lights
group.lights = False

# Turn on lights for 30 seconds
group.lights = (True, 30)

How to contribute

See CONTRIBUTING.rst

Credits && Thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].