Page 1 of 5
Ring 2 Doorbell
Posted: Monday 26 November 2018 22:44
by nigels0
I’ve connected my Ring 2 doorbell with Domoticz by using a python library from here:
https://github.com/tchellomello/python-ring-doorbell
I have a dummy doorbell switch set up called doorbell (in this case idx 1096) and I use a python app running continually (as a service) to poll for a push on the doorbell
Code: Select all
from ring_doorbell import Ring
from time import sleep
import urllib2
ringUsername='MyUsername’
ringPassword='MyPassword'
myring = Ring(ringUsername,ringPassword)
# Now loop infinitely
while(1):
data = myring.doorbells[0].check_alerts()
if data==True:
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&switchcmd=On’)
sleep(1)
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&switchcmd=Off’)
# Loop around
sleep(1)
The library has other functions, but I only needed to register the doorbell push with Domoticz
For info how to start this python script as a service have a butchers at:
https://www.raspberrypi-spy.co.uk/2015/ ... g-systemd/
It's possible to grab the video with
Code: Select all
from ring_doorbell import Ring
from time import sleep
import urllib2
from datetime import datetime
ringUsername='myUsername'
ringPassword='myPassword'
myring = Ring(ringUsername,ringPassword)
doorbell = myring.doorbells[0]
# Now loop infinitely
while(1):
data = doorbell.check_alerts()
if data==True:
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&sw$
sleep(1)
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&sw$
timestamp = datetime.now().strftime("%d:%m_%H.%M.%S")
doorbell.recording_download(doorbell.history(limit=100, kind='ding')[0]['id'],
filename='/mnt/synology/Doorbell/'+timestamp+'.mp4',override=True)
sleep(1)
but I'm finding that I'm getting the last video - not the current one. I've tried a pause for 40 seconds, but then no file is written.
Re: Ring 2 Doorbell
Posted: Friday 30 November 2018 17:53
by felix63
Very useful post, thank you! By the way if you already have PM2 running you can simply add this script to PM2 to make sure its running all the time.
Re: Ring 2 Doorbell
Posted: Sunday 09 December 2018 22:03
by djoeney
Thanks for sharing, this is very helpful to create a action based on on trigger. Is it possible to switch on a dummy switch when motion is detected?
Re: Ring 2 Doorbell
Posted: Friday 28 December 2018 15:03
by jvmaanen
That would be very useful, to switch on a dummy switch when motion is detected.
Re: Ring 2 Doorbell
Posted: Wednesday 23 January 2019 22:15
by sach
nigels0 wrote: ↑Monday 26 November 2018 22:44
I’ve connected my Ring 2 doorbell with Domoticz by using a python library from here:
https://github.com/tchellomello/python-ring-doorbell
I have a dummy doorbell switch set up called doorbell (in this case idx 1096) and I use a python app running continually (as a service) to poll for a push on the doorbell
Code: Select all
from ring_doorbell import Ring
from time import sleep
import urllib2
ringUsername='MyUsername’
ringPassword='MyPassword'
myring = Ring(ringUsername,ringPassword)
# Now loop infinitely
while(1):
data = myring.doorbells[0].check_alerts()
if data==True:
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&switchcmd=On’)
sleep(1)
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&switchcmd=Off’)
# Loop around
sleep(1)
The library has other functions, but I only needed to register the doorbell push with Domoticz
For info how to start this python script as a service have a butchers at:
https://thepihut.com/blogs/raspberry-pi ... 937476d22b
It's possible to grab the video with
Code: Select all
from ring_doorbell import Ring
from time import sleep
import urllib2
from datetime import datetime
ringUsername='myUsername'
ringPassword='myPassword'
myring = Ring(ringUsername,ringPassword)
doorbell = myring.doorbells[0]
# Now loop infinitely
while(1):
data = doorbell.check_alerts()
if data==True:
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&sw$
sleep(1)
urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command¶m=switchlight&idx=1096&sw$
timestamp = datetime.now().strftime("%d:%m_%H.%M.%S")
doorbell.recording_download(doorbell.history(limit=100, kind='ding')[0]['id'],
filename='/mnt/synology/Doorbell/'+timestamp+'.mp4',override=True)
sleep(1)
but I'm finding that I'm getting the last video - not the current one. I've tried a pause for 40 seconds, but then no file is written.
Nice work, but shame I have no idea how to implement.
Only function i'm really after is to create a switch to turn my floodlight lights on and off.
Can then add this to imperihome to control from my wallmounted kitchen tablet.
Would you be able to help me achieve this?
Re: Ring 2 Doorbell
Posted: Tuesday 02 April 2019 10:13
by JoshDinsdale
Just implemented this with my newly installed Ring Doorbell 1 and works really nicely.
According to the python-ring-doorbell code, the check_alerts function is triggered by both doorbell pushes and motion events which is good to know. However, does anyone know if there is a way to separate these so we could trigger two seperate switches in Domoticz?
Re: Ring 2 Doorbell
Posted: Tuesday 02 April 2019 16:35
by JuanUil
This is what I was waiting for!! Thnx very much!
Re: Ring 2 Doorbell
Posted: Wednesday 05 June 2019 8:01
by joepadmiraal
This looks great.
Can you tell me a bit about the response time you ar seeing?
So how much time does it take before you see your switch flipped in Domoticz after someone presses the doorbell?
Thanks,
Joep
Re: Ring 2 Doorbell
Posted: Wednesday 19 June 2019 15:34
by leecollings
Does anyone know if this would also be able to work with a Floodlight Cam?
Re: Ring 2 Doorbell
Posted: Wednesday 19 June 2019 18:30
by nigels0
joepadmiraal wrote: ↑Wednesday 05 June 2019 8:01
This looks great.
Can you tell me a bit about the response time you ar seeing?
So how much time does it take before you see your switch flipped in Domoticz after someone presses the doorbell?
Thanks,
Joep
I'm seeing about 1-2 sec delay - so hardly noticeable.
Re: Ring 2 Doorbell
Posted: Tuesday 02 July 2019 12:49
by dizzeenl
Hy,
im not so familiar with python jet and get constantly syntax errors and "no module named ring_doorbell" when using the script above in my python folder of domoticz
is there an step-by-step guide for this somewhere?
Re: Ring 2 Doorbell
Posted: Tuesday 02 July 2019 13:19
by felix63
Did you install the python-ring-doorbell library? See
https://github.com/tchellomello/python-ring-doorbell?
Re: Ring 2 Doorbell
Posted: Tuesday 02 July 2019 22:52
by dizzeenl
yes i did, but i forgot i used the pip3 version
, now it works like a charm
Re: Ring 2 Doorbell
Posted: Monday 12 August 2019 18:08
by felix63
nigels0 wrote: ↑Monday 26 November 2018 22:44
I’ve connected my Ring 2 doorbell with Domoticz by using a python library from here:
<knip>
but I'm finding that I'm getting the last video - not the current one. I've tried a pause for 40 seconds, but then no file is written.
Did you ever find a workaround for this?
Re: Ring 2 Doorbell
Posted: Wednesday 14 August 2019 18:21
by nigels0
Nope.
Re: Ring 2 Doorbell
Posted: Saturday 16 November 2019 13:26
by capslocker
Hi all
I am looking to buy a Ring doorbell. If I understand correct, this script allows to record video when someone rings ?
Re: Ring 2 Doorbell
Posted: Sunday 31 May 2020 15:56
by PeterFleur
Did anyone get this working now that Ring has MFA as requirement?
Peter
Re: Ring 2 Doorbell
Posted: Saturday 27 June 2020 23:52
by clinkadink
PeterFleur wrote: ↑Sunday 31 May 2020 15:56
Did anyone get this working now that Ring has MFA as requirement?
Yes, it works with 2FA. The first time you run the script, it prompts you for your 2FA code (received via email/text). Once entered, Ring adds your device to the trusted section of your Ring.com account.
nigels0 wrote: ↑Monday 26 November 2018 22:44
but I'm finding that I'm getting the last video - not the current one. I've tried a pause for 40 seconds, but then no file is written.
A slightly late response ... but it may help others. That's because you are only selecting one event from the history. Look at your code below, you have "[0]" which is only every selecting the first event in your list of events.
Code: Select all
doorbell.recording_download(
doorbell.history(limit=100, kind='ding')[0]['id'], filename='/mnt/synology/Doorbell/'+timestamp+'.mp4',override=True
)
Try this ...
Code: Select all
videopath = '/home/clinkadink/ring/'
recordings = doorbell.history(limit=100, kind='ding')
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 + 'ring_video_' + videotime + '.mp4', override=False
)
print('Download complete')
Re: Ring 2 Doorbell
Posted: Monday 27 July 2020 13:52
by migila
I got lot's of error's. I think i fixed them but the following i can't seem to fix. I'm not known with programming. I first had an error "SyntaxError: Non ASCII character" Then i had the next error: SyntaxError EOL while scanning string literal. Then the next error: Module not found: urllib2
The last error i don't seem to fix:
TypError: __init__() takes 2 positional arguments but 3 were given
How can i solve this?
Re: Ring 2 Doorbell
Posted: Wednesday 05 August 2020 19:19
by Alain
For the life of me, I can't work this out. I got the installation part done, but then when I get to "Initializing your ring object" I have no idea how to proceed. Where do I put that script? Do I run it once?