Comments (5)
@tsightler I think you have a really good understanding of how everything is currently exposed, nice work! There is definitely a subtle difference between the doorbell presses and the motion events. For motion, I'm leaving the dings around for 65 seconds, and allowing for overlap between events. This is to prevent multiple motion events triggering in my homebridge plugin if there is constant motion for 2+ minutes. Whether that is right or not..that's up for debate. No one has gotten this deep into the code to have a discussion with.
Doorbell presses on the other hand, I handle as a singular event. Every time the doorbell is pressed (aka a ding
with kind: 'ding'
happens), I want to know about it and tell my homebridge plugin to create an event. This event is exposed via camera.onDoorbellPressed
. From the homebridge perspective there is no duration to these events. They occur, and a notification pops via HomeKit. Unlike motion, there is no long lived status that say the doorbell is currently pressed or not pressed. That's my rational behind my implementation, but I have no idea if MQTT works the same way. If you need long-lived doorbell events, you can copy the implementation from onMotionDetected
. Something like this:
import { distinctUntilChanged, map, publishReplay, refCount } from 'rxjs/operators'
const camera = cameras[0]
const onActiveDoorbellPress = camera.onActiveDings.pipe(
map(dings => dings.some(ding => ding.motion || ding.kind === 'motion')),
distinctUntilChanged(),
publishReplay(1),
refCount()
)
The downside for you here is you will need to add rxjs
as a dependency in your repo to get those operators. Let me know what you decide on the single event vs long-lived doorbell press boolean. I can add onActiveDoorbellPress
(or whatever you think it should be called) if you decide you want to go that route.
from ring.
So i guess my opinion is probably colored by the way the Ring component for Home Assistant behaves and how the Ring app behaves.
Based on what it seems, dings have a duration as they even have a duration property. The Home Assistant component seems to use this as the duration of the ding, whether motion or doorbell press. It seems the ding duration is 180 seconds and thats the behavior I feel like i see in both Home Assistant component and the Ring app, both a ding and motion are dismissed after 3 minutes.
However, i haven't really looked at the code for Home Assistant, I'm mostly inferring based on observed behavior and the fact that it seems to match the duration field on the ding. I'll look at the actual code when i get back to my computer.
I have no real issue coding this behavior into my script, but i was somewhat thinking the API might make it easier to consume in a standard way. I'll investigate it a little more though because i could be completely wrong.
from ring.
@tsightler thanks for the additional background info. I looked at the dings a little bit and it looks like you are correct, the expires_in
field is ~180 for both motion and doorbell presses. The only hesitation I have about this is that my gut tells me the 180s is an expiration for the SIP connection details (although I have seen other threads that say those expire in ~15s). It might be worth doing some testing to see what the smallest time gap is you can get between two motion events on a single camera. I agree that it is worth adding it to the API if we decide that 180s is the actual duration of the events from Ring's perspective, and it's an easy change on my end. Unfortunately I'm going to be fairly tied up until the middle of next week. Let me know if you get a chance to test out the Ring events and see how long there is between them.
from ring.
I've tried to test this and, at least on my devices, (I have a Doorbell Pro, a Floodlight cam, and two Stickup Cams) it seems like I can only get a "ding" every 60 seconds at most. If I ring the doorbell over and over I don't get a new event until ~60 seconds and the same with motion.
After playing with this a little it turns out I was able to write a pretty simple function that gives me the behavior I want just by subscribing to onNewDing, so perhaps this is not big deal.
However, I did verify that the Home Assistant seems to use the full 180 seconds for a "ding", here's some event log output from my Home Assistant install for doorbell press events:
8:35 PM Front Doorbell Ding turned off
8:32 PM Front Doorbell Ding turned on
7:37 PM Front Doorbell Ding turned off
7:34 PM Front Doorbell Ding turned on
11:42 AM Front Doorbell Ding turned off
11:39 AM Front Doorbell Ding turned on
And a similar output for motion events:
8:47 PM Front Doorbell Motion turned off
8:44 PM Front Doorbell Motion turned on
7:37 PM Front Doorbell Motion turned off
7:34 PM Front Doorbell Motion turned on
6:56 PM Front Doorbell Motion turned off
6:53 PM Front Doorbell Motion turned on
Additional doorbot or motion dings seems just extend the time vs create new events. It was mostly this behavior that I was attempting to emulate, but now that I've worked out how to do it simply and flexibly, I'm less sure if that's how the API should behave, it's just how the Home Assistant Ring component behaves. I'll certainly leave this to your judgement.
from ring.
Thanks for the in-depth testing! Since the real ring api seems to follow a 60 second lifetime, I think I’ll stick with that. Good to know how home assistant handles it too.
from ring.
Related Issues (20)
- failed to reach ring server HOT 1
- Ring allows MyQ Garage Openers to be added on their Platform- Could We Control It From there? HOT 1
- Notifications issue HOT 5
- Can't get camera's to show up in home app HOT 3
- mp4 on Windows but not on Linux HOT 4
- When debug=true, show more details about refresh token failures HOT 2
- Toggle to always allow the bypass of sensors? HOT 3
- Error Loading Homebridge-Ring plugin on Hoobs HOT 5
- sudden 403 on location.getSecurityPanel() location.getDevices() HOT 4
- Streaming in HomeKit on iPhone/iPad HOT 2
- myQ Integration HOT 1
- Alarm triggered when using Apple Home intercom HOT 2
- Front door Ring doorbell motion pop up notifications no longer show up on Apple TV 4K HOT 5
- Difference in quality between Ring Camera (getSnapshot) and video search HOT 1
- brief delay in HomePods chime when pressing intercom button HOT 3
- Live Streaming of camera fails after HomeKit architecture upgrade HOT 6
- RIng Server Failure with latest Node.JS HOT 1
- Ring Homebridge camera becomes non-responsive at Apple TV after ~ 5 minutes. HOT 4
- Ring Intercom HOT 1
- Trouble recording video to file or live streaming on an M1 Mac Mini HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ring.