Ring 2 Doorbell

Moderator: leecollings

nigels0
Posts: 221
Joined: Thursday 23 January 2014 12:43
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Ring 2 Doorbell

Post 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&param=switchlight&idx=1096&switchcmd=On’)
   sleep(1)
   urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command&param=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&param=switchlight&idx=1096&sw$
      sleep(1)
      urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command&param=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.
Last edited by nigels0 on Wednesday 19 June 2019 18:33, edited 1 time in total.
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: Ring 2 Doorbell

Post 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.
djoeney
Posts: 15
Joined: Sunday 17 May 2015 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: NL
Contact:

Re: Ring 2 Doorbell

Post 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?
Compute RPi 2 : Domoticz latest beta, Synology : Domoticz tested beta on failover system.
Peripherals RFXCOM - RFXtrx433, Z-Wave.Me ZME_UZB1 USB Stick,P1 cable on smartmeter, Logitech Harmony Hub, 3 IP camera's
jvmaanen
Posts: 13
Joined: Wednesday 01 March 2017 13:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post by jvmaanen »

That would be very useful, to switch on a dummy switch when motion is detected.
sach
Posts: 111
Joined: Wednesday 12 October 2016 14:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post 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&param=switchlight&idx=1096&switchcmd=On’)
   sleep(1)
   urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command&param=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&param=switchlight&idx=1096&sw$
      sleep(1)
      urllib2.urlopen('http://192.168.0.52:8080/json.htm?type=command&param=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? ;)
JoshDinsdale
Posts: 29
Joined: Monday 24 February 2014 14:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post 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?
JuanUil
Posts: 497
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: Ring 2 Doorbell

Post by JuanUil »

This is what I was waiting for!! Thnx very much!
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
joepadmiraal
Posts: 1
Joined: Tuesday 04 June 2019 21:53
Target OS: -
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post 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
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Ring 2 Doorbell

Post by leecollings »

Does anyone know if this would also be able to work with a Floodlight Cam?
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 »

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.
dizzeenl
Posts: 31
Joined: Wednesday 14 November 2018 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Dordrecht
Contact:

Re: Ring 2 Doorbell

Post 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?
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: Ring 2 Doorbell

Post by felix63 »

Did you install the python-ring-doorbell library? See https://github.com/tchellomello/python-ring-doorbell?
dizzeenl
Posts: 31
Joined: Wednesday 14 November 2018 23:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Dordrecht
Contact:

Re: Ring 2 Doorbell

Post by dizzeenl »

yes i did, but i forgot i used the pip3 version :(, now it works like a charm :roll:
User avatar
felix63
Posts: 244
Joined: Monday 07 December 2015 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Gouda
Contact:

Re: Ring 2 Doorbell

Post 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?
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 »

Nope.
capslocker
Posts: 3
Joined: Saturday 16 November 2019 13:24
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post 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 ?
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 »

Did anyone get this working now that Ring has MFA as requirement?

Peter
RaspberryPI
ZWave
RFXtrx433E
User avatar
clinkadink
Posts: 417
Joined: Tuesday 31 December 2019 1:15
Target OS: Linux
Domoticz version: 2020.2
Location: Swindon, UK
Contact:

Re: Ring 2 Doorbell

Post 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')
"UI is the saddle, the stirrups, & the reins. UX is the feeling you get being able to ride the horse."
migila
Posts: 4
Joined: Monday 30 March 2020 21:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ring 2 Doorbell

Post 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?
Alain
Posts: 164
Joined: Sunday 26 April 2020 5:27
Target OS: Linux
Domoticz version: 2022.1
Location: Netherlands
Contact:

Re: Ring 2 Doorbell

Post 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?
Hue | Zigbee2Mqtt | MQTT | P1 | Xiaomi | RFXCom | Modbus | Qlima | Solaredge
TP-Link | Plugwise | Thermosmart | Node-Red | Grafana | Master and 5 remote servers
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest