Re: Ring 2 Doorbell
Posted: Monday 21 December 2020 9:09
$ 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 =an idea ?Code: Select all
pip install git+https://github.com/tchellomello/python-ring-doorbell@master
Maybe you should use pip3 in your environment..Doudy wrote: ↑Sunday 10 January 2021 9:06 For me pip install git+https://github.com/username/repo.git
don't working !
an idea ?
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
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
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¶m=switchlight&idx=1096&switchcmd=On')
urllib2.urlopen('http://192.168.10.50:8080/json.htm?type=command¶m=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()
It would indeed be very interesting.
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