ring-doorbell-intercom


Namering-doorbell-intercom JSON
Version 0.7.3 PyPI version JSON
download
home_pagehttps://github.com/michael-oknov/python-ring-doorbell
SummaryA Python library to communicate with Ring Door Bell (https://ring.com/)
upload_time2023-08-15 19:21:47
maintainer
docs_urlNone
authorMichael Oknov
requires_python
licenseLGPLv3+
keywords ring door bell home automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =====================
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

*Looking for maintainers* 


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/python-ring-doorbell@master


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
-----------------

* This project was inspired and based on https://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 virtualbox https://zignar.net/2015/12/31/sniffing-vbox-traffic-mitmproxy/
* To the project http://www.android-x86.org/ which allowed me to install Android on KVM.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/michael-oknov/python-ring-doorbell",
    "name": "ring-doorbell-intercom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ring,door bell,home automation",
    "author": "Michael Oknov",
    "author_email": "michael.oknov@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/64/54/4edf62e2d9728ab4d5f6e53772605f400d17586b10a090b30e739db5840c/ring_doorbell_intercom-0.7.3.tar.gz",
    "platform": null,
    "description": "=====================\nPython Ring Door Bell\n=====================\n\n.. image:: https://badge.fury.io/py/ring-doorbell.svg\n    :target: https://badge.fury.io/py/ring-doorbell\n\n.. image:: https://travis-ci.org/tchellomello/python-ring-doorbell.svg?branch=master\n    :target: https://travis-ci.org/tchellomello/python-ring-doorbell\n\n.. image:: https://coveralls.io/repos/github/tchellomello/python-ring-doorbell/badge.svg?branch=master\n    :target: https://coveralls.io/github/tchellomello/python-ring-doorbell?branch=master\n\n.. image:: https://img.shields.io/pypi/pyversions/ring-doorbell.svg\n    :target: https://pypi.python.org/pypi/ring-doorbell\n\n*Looking for maintainers* \n\n\nPython Ring Door Bell is a library written for Python 3.6+\nthat exposes the Ring.com devices as Python objects.\n\n*Currently Ring.com does not provide an official API. The results of this project are merely from reverse engineering.*\n\nDocumentation: `http://python-ring-doorbell.readthedocs.io/ <http://python-ring-doorbell.readthedocs.io/>`_\n\n\nInstallation\n------------\n\n.. code-block:: bash\n\n    # Installing from PyPi\n    $ pip install ring_doorbell\n\n    # Installing latest development\n    $ pip install \\\n        git+https://github.com/tchellomello/python-ring-doorbell@master\n\n\nInitializing your Ring object\n-----------------------------\n\n.. code-block:: python\n\n    import json\n    import getpass\n    from pathlib import Path\n    from pprint import pprint\n\n    from ring_doorbell import Ring, Auth\n    from oauthlib.oauth2 import MissingTokenError\n\n\n    cache_file = Path(\"test_token.cache\")\n\n\n    def token_updated(token):\n        cache_file.write_text(json.dumps(token))\n\n\n    def otp_callback():\n        auth_code = input(\"2FA code: \")\n        return auth_code\n\n\n    def main():\n        if cache_file.is_file():\n            auth = Auth(\"MyProject/1.0\", json.loads(cache_file.read_text()), token_updated)\n        else:\n            username = input(\"Username: \")\n            password = getpass.getpass(\"Password: \")\n            auth = Auth(\"MyProject/1.0\", None, token_updated)\n            try:\n                auth.fetch_token(username, password)\n            except MissingTokenError:\n                auth.fetch_token(username, password, otp_callback())\n\n        ring = Ring(auth)\n        ring.update_data()\n\n        devices = ring.devices()\n        pprint(devices)\n\n\n    if __name__ == \"__main__\":\n        main()\n\n\nListing devices linked to your account\n--------------------------------------\n\n.. code-block:: python\n\n    # All devices\n    devices = ring.devices()\n    {'chimes': [<RingChime: Downstairs>],\n    'doorbots': [<RingDoorBell: Front Door>]}\n\n    # All doorbells\n    doorbells = devices['doorbots']\n    [<RingDoorBell: Front Door>]\n\n    # All chimes\n    chimes = devices['chimes']\n    [<RingChime: Downstairs>]\n\n    # All stickup cams\n    stickup_cams = devices['stickup_cams']\n    [<RingStickUpCam: Driveway>]\n\nPlaying with the attributes and functions\n-----------------------------------------\n.. code-block:: python\n\n    devices = ring.devices()\n    for dev in list(devices['stickup_cams'] + devices['chimes'] + devices['doorbots']):\n        dev.update_health_data()\n        print('Address:    %s' % dev.address)\n        print('Family:     %s' % dev.family)\n        print('ID:         %s' % dev.id)\n        print('Name:       %s' % dev.name)\n        print('Timezone:   %s' % dev.timezone)\n        print('Wifi Name:  %s' % dev.wifi_name)\n        print('Wifi RSSI:  %s' % dev.wifi_signal_strength)\n\n        # setting dev volume\n        print('Volume:     %s' % dev.volume)\n        dev.volume = 5\n        print('Volume:     %s' % dev.volume)\n\n        # play dev test shound\n        if dev.family == 'chimes':\n            dev.test_sound(kind = 'ding')\n            dev.test_sound(kind = 'motion')\n\n        # turn on lights on floodlight cam\n        if dev.family == 'stickup_cams' and dev.lights:\n            dev.lights = 'on'\n\n\nShowing door bell events\n------------------------\n.. code-block:: python\n\n    devices = ring.devices()\n    for doorbell in devices['doorbots']:\n\n        # listing the last 15 events of any kind\n        for event in doorbell.history(limit=15):\n            print('ID:       %s' % event['id'])\n            print('Kind:     %s' % event['kind'])\n            print('Answered: %s' % event['answered'])\n            print('When:     %s' % event['created_at'])\n            print('--' * 50)\n\n        # get a event list only the triggered by motion\n        events = doorbell.history(kind='motion')\n\n\nDownloading the last video triggered by ding\n--------------------------------------------\n.. code-block:: python\n\n    devices = ring.devices()\n    doorbell = devices['doorbots'][0]\n    doorbell.recording_download(\n        doorbell.history(limit=100, kind='ding')[0]['id'],\n                         filename='last_ding.mp4',\n                         override=True)\n\n\nDisplaying the last video capture URL\n-------------------------------------\n.. code-block:: python\n\n    print(doorbell.recording_url(doorbell.last_recording_id))\n    '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'\n\nControlling a Light Group\n-------------------------\n.. code-block:: python\n\n    groups = ring.groups()\n    group = groups['the-group-you-want']\n\n    print(group.lights)\n    # Prints True if lights are on, False if off\n\n    # Turn on lights indefinitely\n    group.lights = True\n\n    # Turn off lights\n    group.lights = False\n\n    # Turn on lights for 30 seconds\n    group.lights = (True, 30)\n\nHow to contribute\n-----------------\nSee CONTRIBUTING.rst\n\n\nCredits && Thanks\n-----------------\n\n* This project was inspired and based on https://github.com/jeroenmoors/php-ring-api. Many thanks @jeroenmoors.\n* A guy named MadBagger at Prism19 for his initial research (http://www.prism19.com/doorbot/second-pass-and-comm-reversing/)\n* The creators of mitmproxy (https://mitmproxy.org/) great http and https traffic inspector\n* @mfussenegger for his post on mitmproxy and virtualbox https://zignar.net/2015/12/31/sniffing-vbox-traffic-mitmproxy/\n* To the project http://www.android-x86.org/ which allowed me to install Android on KVM.\n",
    "bugtrack_url": null,
    "license": "LGPLv3+",
    "summary": "A Python library to communicate with Ring Door Bell (https://ring.com/)",
    "version": "0.7.3",
    "project_urls": {
        "Homepage": "https://github.com/michael-oknov/python-ring-doorbell"
    },
    "split_keywords": [
        "ring",
        "door bell",
        "home automation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64544edf62e2d9728ab4d5f6e53772605f400d17586b10a090b30e739db5840c",
                "md5": "990e1e26960ad5b6d344a872315f774a",
                "sha256": "9e8621f40ef5e3224c35f2477fd5fecdfb90472c828d0848f572e8a877b27959"
            },
            "downloads": -1,
            "filename": "ring_doorbell_intercom-0.7.3.tar.gz",
            "has_sig": false,
            "md5_digest": "990e1e26960ad5b6d344a872315f774a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23908,
            "upload_time": "2023-08-15T19:21:47",
            "upload_time_iso_8601": "2023-08-15T19:21:47.792696Z",
            "url": "https://files.pythonhosted.org/packages/64/54/4edf62e2d9728ab4d5f6e53772605f400d17586b10a090b30e739db5840c/ring_doorbell_intercom-0.7.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-15 19:21:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "michael-oknov",
    "github_project": "python-ring-doorbell",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "ring-doorbell-intercom"
}
        
Elapsed time: 0.31892s