Ring 2 Doorbell

Moderator: leecollings

PeterFleur
Posts: 32
Joined: Sunday 08 March 2015 13:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.4739
Contact:

Re: Ring 2 Doorbell

Post by PeterFleur »

You mean this one don't you? https://github.com/tchellomello/python-ring-doorbell

Peter
RaspberryPI
ZWave
RFXtrx433E
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Ring 2 Doorbell

Post by Egregius »

Yes:

# Installing latest development
$ pip install \
git+https://github.com/tchellomello/python- ... ell@master
DdeR
Posts: 1
Joined: Sunday 03 January 2021 13:23
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by DdeR »

The script works like a chime! thnx!
the script now also triggers on motion but I really just want it to trigger when the doorbell is pressed.
can someone help me get that done?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Ring 2 Doorbell

Post by Egregius »

You got a up to date screenshot? Or on old one?
Post your code please, much easier to help.
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

Hello,
First best wishes

For me pip install git+https://github.com/username/repo.git
don't working !
$ pip install git+https://github.com/username/repo.git
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip._internal import main
File "/usr/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 4, in <module>
File "/usr/share/python-wheels/requests-2.21.0-py2.py3-none-any.whl/requests/__init__.py", line 95, in <module>
File "/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
EOFError: EOF read where object expected

Idem with :
pip install git+https://github.com/tche ... ell@master
url =

Code: Select all

pip install git+https://github.com/tchellomello/python-ring-doorbell@master
an idea ?
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Ring 2 Doorbell

Post by waaren »

Doudy wrote: Sunday 10 January 2021 9:06 For me pip install git+https://github.com/username/repo.git
don't working !

an idea ?
Maybe you should use pip3 in your environment..

Code: Select all

sudo pip3 install git+https://github.com/tchellomello/python-ring-doorbell@master

Collecting git+https://github.com/tchellomello/python-ring-doorbell@master
  Cloning https://github.com/tchellomello/python-ring-doorbell (to revision master) to /tmp/pip-req-build-x631bj6a
  Running command git clone -q https://github.com/tchellomello/python-ring-doorbell /tmp/pip-req-build-x631bj6a
Collecting oauthlib<4,>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
     |████████████████████████████████| 147 kB 3.2 MB/s
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from ring-doorbell==0.6.2) (2020.5)
Collecting requests-oauthlib<2,>=1.3.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Requirement already satisfied: requests>=2.0.0 in /usr/lib/python3/dist-packages (from ring-doorbell==0.6.2) (2.25.1)
Building wheels for collected packages: ring-doorbell
  Building wheel for ring-doorbell (setup.py) ... done
  Created wheel for ring-doorbell: filename=ring_doorbell-0.6.2-py3-none-any.whl size=23087 sha256=e3a385f95e37193835878bce3a09b2102ea2a6ceada46dd79fb0f71cc4f5f242
  Stored in directory: /tmp/pip-ephem-wheel-cache-r4s8_ocd/wheels/8c/2f/dd/a1724238560e6986f002eece36e51ad9993d509ac1f6d1be75
Successfully built ring-doorbell
Installing collected packages: oauthlib, requests-oauthlib, ring-doorbell
Successfully installed oauthlib-3.1.0 requests-oauthlib-1.3.0 ring-doorbell-0.6.2
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

Hello,
I tried with pip3

Code: Select all

$ sudo pip3 install git+https://github.com/tchellomello/python-ring-doorbell@master

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.pkg_resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip._internal import main
  File "/usr/lib/python3/dist-packages/pip/_internal/__init__.py", line 19, in <module>
    from pip._vendor.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 77, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 3191, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 3175, in _call_aside
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 3204, in _initialize_master_working_set
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 574, in _build_master
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 567, in __init__
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 623, in add_entry
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2033, in find_on_path
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2103, in distributions_from_metadata
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2560, in from_location
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2935, in _reload_version
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2524, in _version_from_file
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2714, in _get_metadata
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 1416, in get_metadata_lines
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 1413, in get_metadata
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 1039: invalid continuation byte
:( :?:
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Ring 2 Doorbell

Post by waaren »

Doudy wrote: Sunday 10 January 2021 16:13 ModuleNotFoundError: No module named 'pip._vendor.pkg_resources'
Google is your friend ..
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

Hello,

I tried all fixes on this page https://stackoverflow.com/questions/494 ... -resources and it didn't work.

:?
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

I completely reinstall my SD card
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
grecof973
Posts: 24
Joined: Wednesday 26 July 2017 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by grecof973 »

someone help me to understand this script how it works ???
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

grecof973 wrote: Monday 28 June 2021 19:27 someone help me to understand this script how it works ???

That's a good idea :!: ;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

Doudy wrote: Tuesday 29 June 2021 7:11
grecof973 wrote: Monday 28 June 2021 19:27 someone help me to understand this script how it works ???
That's a good idea :!: ;)
Nobody ?
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
grecof973
Posts: 24
Joined: Wednesday 26 July 2017 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by grecof973 »

I do not know!! I see that some have succeeded, but in the end I think the script is stopped !!
I still want to try asking the developer a question on his page, maybe he doesn't read here
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

grecof973 wrote: Saturday 10 July 2021 19:48 I still want to try asking the developer a question on his page, maybe he doesn't read here
okay
Please let us know if you have any news
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
nigels0
Posts: 221
Joined: Thursday 23 January 2014 12:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Ring 2 Doorbell

Post by nigels0 »

I've just come back to this and re-installed with the new libraries - and things were busted from the original script.

Try this one now

Code: Select all

import json
import getpass
from pathlib import Path
from pprint import pprint
from ring_doorbell import Ring, Auth, RingDoorBell
from oauthlib.oauth2 import MissingTokenError
from time import sleep

import urllib.request as urllib2
#import urllib2
from datetime import datetime


cache_file = Path("/home/pi/domoticz/scripts/test_token.cache")
videopath = '/mnt/synology/Doorbell/'
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("Ring/1.0", json.loads(cache_file.read_text()), token_updated)
    else:
        username = "XXXXXXXXXXXX"
        password = "XXXXXXXXXXXX"
        auth = Auth("Ring/1.0", None, token_updated)
        try:
            auth.fetch_token(username, password)
        except MissingTokenError:
            auth.fetch_token(username, password, otp_callback())

    myring = Ring(auth)
    myring.update_data()

    devices = myring.devices()
    pprint(devices)
    doorbell = devices['doorbots'][0]
    recordings = doorbell.history(limit=100, kind='ding')
    while(True):
     myring.update_dings()
     data = myring.active_alerts()
     if data !=[]:
       urllib2.urlopen('http://192.168.10.50:8080/json.htm?type=command&param=switchlight&idx=1096&switchcmd=On')
       urllib2.urlopen('http://192.168.10.50:8080/json.htm?type=command&param=switchlight&idx=1209&switchcmd=On')
       timestamp = datetime.now().strftime("%d:%m_%H.%M.%S")
       for event in recordings:
        print('Downloading {} event recorded on {} lasting {}s'.format(
            event['kind'], event['created_at'].strftime("%d/%m/%Y at %H:%M:%S"), event['duration'])
        )
        videotime = event['created_at'].strftime("%Y%m%d_%H%M%S")
        doorbell.recording_download(
            event['id'], filename=videopath + 'Door_' + videotime + '.mp4', override=False
        )
    print('Download complete')
    
    
if __name__ == "__main__":
    main()
  
Note that you need to run this with python3 now.

note you have to change the location for the cache_file and add your own Ring username and password - and also change the video path to where you want to store the recordings.

Note that on the first run through, it will ask for a 2FA (you should have set that up previously) - enter the key then run again and it should list your devices.
grecof973
Posts: 24
Joined: Wednesday 26 July 2017 6:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by grecof973 »

Excuse me .... But can you give us a guide on how to start on this Plug-In I'm just zero on the matter, and like me others here on the forum .... It would be very welcome
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

grecof973 wrote: Tuesday 09 November 2021 22:00 Excuse me .... But can you give us a guide on how to start on this Plug-In I'm just zero on the matter, and like me others here on the forum .... It would be very welcome
It would indeed be very interesting.
For me too !
How to install completely?
At home the old version it is installed in /home/pi/domoticz/scripts/python/python-ring-doorbell-master/
How to proceed ?
Which files to modify?
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

I have tested this nex vesion.
Results :

Code: Select all

pi@raspberrypi:~/domoticz/scripts/python $ sudo python3.7 ring-doorbell.py
2FA code: xxxxxx
Traceback (most recent call last):
  File "ring-doorbell.py", line 63, in <module>
    main()
  File "ring-doorbell.py", line 38, in main
    myring.update_data()
  File "/usr/local/lib/python3.7/dist-packages/ring_doorbell/__init__.py", line 58, in update_data
    self.update_groups()
  File "/usr/local/lib/python3.7/dist-packages/ring_doorbell/__init__.py", line 99, in update_groups
    for group in data["device_groups"]:
TypeError: 'NoneType' object is not iterable
test_token.cache created
Image

:shock: For me it's Chinese! :?
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Doudy
Posts: 246
Joined: Tuesday 09 August 2016 9:09
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by Doudy »

Nobody ?
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests