davglass / doorbot

Ring.com Doorbell API
Other
317 stars 55 forks source link

Get incoming ring? #2

Closed niftylettuce closed 6 years ago

niftylettuce commented 7 years ago

Would be cool to get the API endpoint for an incoming ring, figure it out @davglass 😆

davglass commented 7 years ago

You can, but you have to poll for it:

ring.authenticate(email, password, (e, token) => {
    console.log(e, token);
    const check = () => {
        console.log('Checking for ring activity..');
        ring.dings(token, (e, json) => {
            console.log(e, json);
        });
    };
    setInterval(check, 30 * 1000);
    check();
});

That should return a chunk of JSON that includes the event id which you can use to get the video stream.

suhajdab commented 7 years ago

Thanks for this npm module! Works like a charm! I tried getting the video stream for incoming, but I get a Error: API returned Status Code 404 when I use the event id for getting the recording.

jugaltheshah commented 7 years ago

Sorry for replying to an old thread. You might also be able to use something like Tasker and a plugin (https://play.google.com/store/apps/details?id=com.joaomgcd.autonotification) to intercept the Ring notification on Android. When you detect the notification, fire off a web request to a server that's listening, and have it check the feed. A bit clunky and involved, but you wouldn't have to poll!

asantaga commented 7 years ago

@suhajdab, BTW the reason why you cant get the incoming video stream (via recordings) is because the recording isnt available for about 30-60seconds after the ring.. Im guessing the bell records, then uploads to AWS where the recordings are held

ghost commented 7 years ago

Im thinking this issue could be closed right? its pretty much closed?

davglass commented 7 years ago

It would still be nice to get the incoming ring. IIRC they use the SIP protocol to answer the ring. Not sure how to do that at the moment and I haven't had time to reverse engineer their api to do it. I'm also not sure if when you answer a call from one place will that stop anyone else from answering it. I just haven't played enough with the real time part of it yet. My use was to archive footage as well as use it to check battery/wifi status for external monitoring.

ghost commented 7 years ago

Davglass, https://github.com/davglass/doorbot/issues/1 covers the querying of the SIP. I found a lot of useful discussion on the python version of the ring api.. I got it working using the blink SIP client but the sip stream only works for 30s or so.. alas I dont have an immediate usecase for this so I stopped R&D

aniceberg commented 6 years ago

Any idea why Ring is returning this:

Checking for ring activity..
null []

instead of the JSON with the event id?

davglass commented 6 years ago

@aniceberg That means there wasn't an event in that check. It needs to poll for them. If the json contains data then there was a ring.

aniceberg commented 6 years ago

@davglass Thanks!

Got this from an event:

null [ { id: 1234913551677183000,
id_str: '1234913551677183223',
state: 'ringing',
protocol: 'sip',
doorbot_id: 1234567,
doorbot_description: 'Front Door',
device_kind: 'lpd_v1',
motion: false,
snapshot_url: '',
kind: 'ding',
sip_server_ip: '12.34.56.78',
sip_server_port: 15063,
sip_server_tls: true,
sip_session_id: '5kadceg027l7n-12345678docili',
sip_from: 'sip:7654321@ring.com',
sip_to: 'sip:5kadceg027l7n-12345678docili@12.34.56.78:15064;transport=tls',
audio_jitter_buffer_ms: 300,
video_jitter_buffer_ms: 300,
sip_endpoints: null,
expires_in: 150,
now: 1512680593.68837,
optimization_level: 1,
sip_token: '2533d5b27a85537e664c83eeab48a576705046d0b9e327dabbde1aefb960b472',
sip_ding_id: '6496913551677183223' } ]

Can you recommend a tool or two that could parse this information and initiate a SIP session with these inputs to bring up a live video feed on a web page?

davglass commented 6 years ago

Technically it should be possible, I've just not had the time to work on it lately.. I still have a box of their gear that I need to get installed too, but life happens ya know :(

mrose17 commented 6 years ago

i think that this is now a duplicate of https://github.com/davglass/doorbot/issues/1