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

Camera not responding #38

Closed
OABsoftware opened this issue Jun 23, 2019 · 31 comments
Closed

Camera not responding #38

OABsoftware opened this issue Jun 23, 2019 · 31 comments
Labels
bug Something isn't working

Comments

@OABsoftware
Copy link

OABsoftware commented Jun 23, 2019

Hi there.
First of all: you're developing a great plugin! I just installed the latest version with snapshot support.
My doorbell is a first generation Ring Video Doorbell, that makes a new snapshot only if the previous one was made at least 10 minutes ago (i.e. one snapshot every 10 minutes max).
So the current implementation of refreshSnapshot() in ring-camera.ts causes a problem.
If there is motion detected within 10 minutes after the previous motion was detected, this implementation results in a not-responding camera...

@dgreif
Copy link
Owner

dgreif commented Jun 23, 2019

@OABsoftware that is a really interesting issue! I assumed they were keeping every version up-to-date on firmware since they have so many for sale, but it makes sense that they would let the first gen slide a little. A couple things I need before I can implement a fix:

  • Is this snapshot issue documented anywhere? I haven't seen anything about this in the existing ring codebases that I dug through while writing this one.
  • I need to know the kind value for that older model. You can find this in the Model field if you open the settings for the camera in the Home app.
  • A screenshot of what it looks like when it stops responding, just so I can make sure it's different from the live stream not responding.
  • What do you think we should do when it fails to fetch the new snapshot? Keep trying for 10 minutes, or just display the previous snapshot?

@dgreif dgreif added the bug Something isn't working label Jun 23, 2019
@OABsoftware
Copy link
Author

OABsoftware commented Jun 24, 2019

To answer your questions:

  • I don't know if the max of 1 snapshot per 10 minutes is documented anywhere. What I do know is that I see the same behavior in the Ring app: it won't show a recent snapshot until the previous snapshot is at least 10 minutes old.

  • The kind value is "doorbell_v3".

  • Hmm, I already made a number of modifications in the code, so taking a screenshot is a bit difficult now. But trust me, I understand the difficulty of converting a SIP stream to an RTSP one :-). We're talking about the snapshot here.

  • I changed the implementation of the refreshSnapshot() method to this:

            const timeLatest = new Date().getTime() - 10 * 60 * 1000;
            var timestamp = yield this.updateTimestamp();
            var attempt = 0;
            while(timestamp > 0 && timestamp < timeLatest && attempt <= 15)
            {
                attempt++;
                yield util_1.delay(1000);
                
                timestamp = yield this.updateTimestamp();
            }
            return timestamp;

@divemasterjm
Copy link

same here

@dgreif
Copy link
Owner

dgreif commented Jun 25, 2019

@OABsoftware I modified the refreshSnapshot method to try for 10 minutes for doorbell_v3 devices. I debated for a while about going with the approach you have above and decided against it. My goal is to make sure that the timestamp you see in HomeKit is accurate to when the snapshot was taken so that users can be confident they are seeing an accurate image. If we simply return after 15 attempts without erroring, an outdated snapshot will be downloaded from Ring, but will be displayed as current in Home. With my approach, the snapshot will update when it is able and will always have an accurate time marker in HomeKit. I'm happy to discuss further if you think my approach is incorrect. Otherwise, please give v3.2.2 a try and see how it works for your device. Thanks for letting me know about this issue, and for the detail on what's causing it!

@OABsoftware
Copy link
Author

@dgreif I agree it's better that the user sees a valid age of the snapshot in the Home app.
But in the current implementation (version 3.7.0) I only get a fresh snapshot in the Home app once every 30 minutes...

@divemasterjm
Copy link

divemasterjm commented Jul 3, 2019 via email

@dgreif
Copy link
Owner

dgreif commented Jul 3, 2019

@OABsoftware @divemasterjm I really want to get you guys the best fix for this that I can. The camera itself is limiting how frequently new snapshots can be taken. Would you prefer I always hand you the latest snapshot, even though the timestamp in Home won't match when it was actually taken? I'm open to any other suggestions...

@divemasterjm
Copy link

divemasterjm commented Jul 3, 2019 via email

@divemasterjm
Copy link

divemasterjm commented Jul 3, 2019 via email

@dgreif
Copy link
Owner

dgreif commented Jul 3, 2019

@OABsoftware @divemasterjm give v3.7.1 a try. I have it set to try for 5 seconds to get a new snapshot, falling back on the stale snapshot if that times out. Sorry I don't have a better solution, but this is definitely a drawback of that particular camera model.

@divemasterjm
Copy link

It works!!!, now the user experience is much better, thanks for your help. I didn’t try rich notifications yet.

@OABsoftware
Copy link
Author

@dgreif Yes, this works. But 5 seconds is a bit short, e.g. if you have a low bandwidth internet connection (like I do).

@divemasterjm
Copy link

divemasterjm commented Jul 4, 2019 via email

@dgreif
Copy link
Owner

dgreif commented Jul 5, 2019

@OABsoftware I was fairly intentional about use 5 seconds because I wanted it to fail fast if there is no new snapshot. Every second that it waits for a new snapshot is another second that HomeKit waits to send out the notification for motion/doorbell press because it is waiting for the snapshot. I could have it wait 15 or 20 seconds, but that means your notifications will be delayed that long if there is no new snapshot available. Does that make sense, or do you think it would be worth it to wait a little longer in case it is in the process of uploading the snapshot? If we wait, how long is reasonable?

@OABsoftware
Copy link
Author

@dgreif Well, as I wrote earlier, I'm on a rather low-bandwidth internet connection (8 mbps down, 800 kbps up).
Your (great) plugin hammers the Ring dings/active service every 5 seconds to check if the doorbell was pressed (and indeed, that is the only way to find out).
If it was pressed, the plugin sends a request to the Ring servers to tell my doorbell to upload a snapshot.
In my situation the snapshots/timestamps service gets called at least 5 times before a new snapshot is available (I modified your code so that the service is called once per 1000 milliseconds instead of 2000).
And than that snapshot is downloaded by the plugin and uploaded again to APNS.
So, before I see the snapshot in a notification on my phone, it is at least 10 seconds old.
In my opinion adding a few seconds more is not too much of a problem, because the snapshot is (too) old anyway.

I also see something else happen.
When the doorbell is pressed, I first receive a text-only notification from my Home app, and a couple of seconds later that notification is replaced by one that includes the snapshot.

You could add a optional configuration item in which the user can specify how long the plugin should try to get the snapshot.

@rgerr
Copy link

rgerr commented Jul 14, 2019

To be clear, this ‘10 minute snapshot’ issue, is only on the first generation Ring doorbell? I currently have the first generation, but want to receive snapshots on my iPhone when the actual Ring button is pushed.

@dgreif
Copy link
Owner

dgreif commented Jul 14, 2019

It’s an issue on all battery powered cameras (see #64 for more detail on that). I released an update last night that should cover all of them. It’s possible you are on one that wasn’t assuming slow snapshots for your model

@dgreif
Copy link
Owner

dgreif commented Jul 15, 2019

@OABsoftware I rewrote the logic around snapshot timing and it should work much better for your situation now. If the current snapshot is < 10 minutes old, it will be used immediately without waiting for a new one at all. If the current snapshot is > 10 minutes old it will wait ~30 seconds for the snapshot to update, falling back to the stale snapshot after that. Give it a try with v4.0.7

@rgerr
Copy link

rgerr commented Jul 16, 2019

Is this also the issue with newer Rings?

@dgreif
Copy link
Owner

dgreif commented Jul 16, 2019

@rgerr can you be more specific? The new Ring Door View Cam is battery powered, so it has 10 minute snapshot refreshes.

@rgerr
Copy link

rgerr commented Jul 16, 2019

I have the Ring doorbell, first Version (doorbell_v3) hardwired. So it is not on battery. How does the snapshot interval work in that case?

@dgreif
Copy link
Owner

dgreif commented Jul 16, 2019

@rgerr that is a great question! All of my cameras as wired only so I haven't been able to test it out. Could you try opening your Ring app periodically and seeing how frequently you can get snapshots from that camera? Just open the app and look at the camera photo, without going into live view. It will either be every 30 seconds that it refreshes or 10 minutes, so it should be pretty obvious.

@rgerr
Copy link

rgerr commented Jul 16, 2019

I will try this out later today, thanks for the tip. Another question, will the experience be better with a Ring 2 doorbell? Faster snapshots e.g.?

@dgreif
Copy link
Owner

dgreif commented Jul 16, 2019

The Ring Doorbell 2 has a battery as well, but can be hardwired. I'm guessing it will function the same as the regular Doorbell. I have a Doorbell Pro, which can only be hardwired, and it has 30 second snapshots. I am really interested to see what you find with the hardwired Doorbell, thanks for looking into it!

@rgerr
Copy link

rgerr commented Jul 16, 2019

Definitly not a 30 sec interval on the original Ring with snapshots. Checked it for over 15 minutes and it updates only once, after the suspected 10 minutes, unfortunatly.

@dgreif
Copy link
Owner

dgreif commented Jul 22, 2019

@OABsoftware @rgerr how have snapshots been on your battery cameras? If everything seems good we can get this issue closed

@rgerr
Copy link

rgerr commented Jul 22, 2019

As mentioned above, once every 10 minutes. Too bad. :(

@dgreif
Copy link
Owner

dgreif commented Jul 22, 2019

@rgerr unfortunately I can't make them refresh more frequently. My main question is whether or not the are showing up reliably (even if they are stale by a few minutes)

@rgerr
Copy link

rgerr commented Jul 23, 2019

No, not so much. Probaly 50% of the time I get a snapshot, and half of the time it is a old snapshot. The connection should not be a problem, i have 100/100 down/up and the Ring doorbell is 2m from the nearest access point. Also, I completely turned of the motion detection so that Ring will not update the snapshot when motion is detected. Therefor it should only update when the doorbell is pressed. But as I mentioned, snapshots hardly come through. And when they do, they’re not from when the actual doorbell was pressed.

@dgreif
Copy link
Owner

dgreif commented Jul 27, 2019

@rgerr give snapshots a try in v4.3.2. They now return immediately for battery cameras so they will most likely always be stale, but they should show up 100% of the time. Let me know how it works for you.

@dgreif
Copy link
Owner

dgreif commented Jul 28, 2019

I think I have the snapshot logic as good as it can get for now. If anyone has spefic feedback, feel free to open a new GitHub issue. Thanks everyone who tested out my updates along the way!

@dgreif dgreif closed this as completed Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants