Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion Not Triggering #42

Closed
problemss opened this issue Jun 25, 2019 · 22 comments
Closed

Motion Not Triggering #42

problemss opened this issue Jun 25, 2019 · 22 comments

Comments

@problemss
Copy link

I just finished setting this up. I can see the snapshot is updated in my camera view, but I am not getting any motion triggers. I have motion setup on the ring app, but it is not triggering my homekit motion accessory. Any ideas?

@dgreif
Copy link
Owner

dgreif commented Jun 25, 2019

The Ring api for getting new events is definitely less than ideal. If you have any other setups that are polling for events, you will definitely run into conflicts. That means if you have anything using the python library or another homebridge plugin like homebridge-platform-ring-video-doorbell, they will be competing to grab the events from Ring. It's hard to track down these issues, so you just have to know what else you have set up. Another thing you can do is pass cameraDingsPollingSeconds: 1, which will poll for events every second instead of the 5 second default. Let me know if you figure out what is causing your issues as it may help others down the road.

@problemss
Copy link
Author

I will disable the other ring python library I have setup and see if that does it.

@divemasterjm
Copy link

Happens de same to me, no other ring library but sensor doesn’t fire up, I receive notifications from ring app but no from plugin sensor

@problemss
Copy link
Author

I disabled and set to 1 second. Still not triggering. Is there any debugging I can turn on to look into it?

@dgreif
Copy link
Owner

dgreif commented Jun 26, 2019

There isn't currently any debug flags that you can turn on to see additional details, but that's something I could add. This particular issue is very hard to track down because the Ring api is very fragile. If one other client is grabbing events, you will lose the ability so see them. I'm going to look into auth sessions a little more and see if I can make it less fragile, but I can't make any promises. If you really want to debug it locally, you can add a console.log('active dings', activeDings) in node_modules/homebridge-ring-alarm/api/api.js after the line that has poolForActiveDings$.next();. This will log the array of dings fetched from the api every poll. My guess is that you will see [] every time, even when there is an event, which means the API is being pinged somewhere else and the events are being cleared before you get a chance to see them. I'll let you know if I come up with any other ideas

@divemasterjm
Copy link

Just for your info, there is a plug-in in homeassistant who works perfectly with.

@dgreif
Copy link
Owner

dgreif commented Jun 26, 2019

@divemasterjm do you have the homeassistant plugin running at the same time as the homebridge plugin? If so, that might be what's conflicting. Try turning that off and running just homebridge.

@problemss
Copy link
Author

@dgreif So i had to put the console login under if (!activeDings || !activeDings.length) { and under activeDings.forEach(activeDing => { or else the module would become unresponsive. After putting those logs in place. Only the one under !activeDings is being called, the other log never gets called, confirming your assumption that it is always empty []. I am going to try a few more things now that I have your code open and let you know if I figure anything out.

I also turned off my IFTTT triggers just in case.

@problemss
Copy link
Author

So I am in the fetchActiveDings() function

I am trying to print out the URL it is using but I am just getting this

https://api.ring.com/clients_api/dings/active?burst=false

I assume the clients_api will get replaced when the URL is actually called? Is there a way I can get the full URL so I can call it manually?

@dgreif
Copy link
Owner

dgreif commented Jun 27, 2019

@problemss that actually is the full url. Should be able to do a GET to that endpoint. Also need to include the Authorization header and I think you need 'user-agent': 'android:com.ringapp:2.0.67(423)' from previous testing, but that one might be optional.

@dgreif
Copy link
Owner

dgreif commented Jun 28, 2019

@problemss it's taken a lot of debugging and digging through other libraries, but I finally got to the root source of the issue on events not registering. It all has to do with how we are authenticating and setting up a session with Ring. I have most of the fix in place, but need to think through corner cases before I push it up. I've got a busy weekend, but I should have an update out early next week. Thanks for your patience, this was a tough one to track down!

@problemss
Copy link
Author

@dgreif that is awesome! Thank you so much! I will be out of town next week for the 4th but am excited to try the fix out when I get back! I also greatly appreciate you spreading the knowledge in the other project as well.

@odenisenko-zz
Copy link

guys. unfortunately for getting motion event we should create a session and use it.
without session no motion alert at all.

PS: dings/active?api_version=9&auth_token=zzbGBjWFcvCZKArwFQfH.

@dgreif
Copy link
Owner

dgreif commented Jun 29, 2019

@odenisenko as long as we include the hardware_id header from the session motion events work great. We don’t have to include the session auth_token, oauth authorization header is a better approach for authentication. Are you experiencing something different?

@dgreif
Copy link
Owner

dgreif commented Jun 29, 2019

@problemss I found some time to work on it this morning and I got all the session stuff finished up. Give v3.4.0 a try!

@problemss
Copy link
Author

@dgreif I am excited to try it out when I get home. I feel stupid for asking, but I assume it is just npm update home bridge-ring-alarm correct or so I have to manually replace it?

@dgreif
Copy link
Owner

dgreif commented Jun 29, 2019

@problemss you have it right. All you need to do is update the homebridge-ring-alarm npm module and restart homebridge

@problemss
Copy link
Author

@dgreif works like a charm!!!! Thank you!!

@johnsonjoshuaa
Copy link

I can also confirm the update fixed my issue with motion events not being captured. Thank you!

@dgreif
Copy link
Owner

dgreif commented Jul 1, 2019

@problemss @johnsonjoshuaa thank you both for confirming that it's working! I just released another update that should improve motion/ding alert times even more. Give v3.5.1 a try when you get a chance. It looks like Ring automatically captures a snapshot when there is an event, and HomeKit was sometimes requesting it after it was already updated. When this happened, it could take up to 30 seconds before another snapshot would be taken. This delayed the notification from Home by ~10-15 seconds, and then you would see a notification with no snapshot, which got replaced by a notification with a snapshot once a new one was available. Now I am a little smarter about how I compare snapshot timestamps, so if a snapshot was taken within the last 10 seconds before Home requests it, we use it without waiting for a new one. The end result (at least for me) is that motion alerts are delivered within ~3 seconds of when they occur, with snapshot in tow every time.

@dgreif dgreif closed this as completed Jul 1, 2019
@johnsonjoshuaa
Copy link

@dgreif Thank you for the update. I installed it and I did notice the screenshots, and notifications where much quicker. The screenshots are also usable now. I noticed prior to the update the screenshot would be delayed and not always catch what triggered the motion. After the update the 7 motion events I have triggered on all 3 devices have resulted in a usable screenshot. So from my perspective everything works great!

@dgreif
Copy link
Owner

dgreif commented Jul 1, 2019

@johnsonjoshuaa I appreciate the feedback and testing. Glad to hear it's working well! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants