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

Ring Door Bell Camera - Not display entity_picture or video_url #10407

Closed
ntalekt opened this issue Nov 6, 2017 · 15 comments · Fixed by #10428
Closed

Ring Door Bell Camera - Not display entity_picture or video_url #10407

ntalekt opened this issue Nov 6, 2017 · 15 comments · Fixed by #10428

Comments

@ntalekt
Copy link

ntalekt commented Nov 6, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.57.2

Python release (python3 --version):
3.6.3

Component/platform:
Ring Binary Camera
@tchellomello

Description of problem:
Ring Camera won't display entity_picture or play video_url when clicked. After a restart it worked for about an hour. Could the camera not be refreshing the URL before the X-Amz-Expires expires? When trying to browse the video_url in chrome I get:

<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>3600</X-Amz-Expires>
<Expires>2017-11-06T13:42:58Z</Expires>
<ServerTime>2017-11-06T15:46:02Z</ServerTime>
<RequestId>...REDACTED...</RequestId>
<HostId>
...REDACTED...
</HostId>
</Error>

Expected:
To display image snapshot and video.

Problem-relevant configuration.yaml entries and steps to reproduce:

ffmpeg:

camera:
  - platform: ring
    ffmpeg_arguments: -pred 1 -q:v 2

Traceback (if applicable):

Additional info:

@arsaboo
Copy link
Contributor

arsaboo commented Nov 6, 2017

I am also seeing this. Occasionally, I see Image not available on the Ring Camera.

@tchellomello
Copy link
Contributor

@ntalekt thanks for reporting this. I'm going to take a look.

@ntalekt are you a premium customer subscriber from Ring Door Bell?

@ntalekt
Copy link
Author

ntalekt commented Nov 6, 2017

@tchellomello Yes, i'm a premium subscriber.

@thegame3202
Copy link
Contributor

I may be in the same boat, I'll have to double check. I'm also Premium. After a bit, I get "Image not available", but if I restart HASS it works as expected.

@thegame3202
Copy link
Contributor

Confirmed, 1 hour on the dot and you get the below from the URL, as well as "Image not available"

AccessDenied
Request has expired

@tchellomello
Copy link
Contributor

@ntalekt could you provide the HASS logs on the issue?

@tchellomello
Copy link
Contributor

tchellomello commented Nov 6, 2017

@thegame3202 @ntalekt did you guys check if the local time of your server is correct?

I'm going to verify it tonight

@ntalekt
Copy link
Author

ntalekt commented Nov 6, 2017

@tchellomello server time is correct. I'll enable debug logs and see if there is anything.

@thegame3202
Copy link
Contributor

thegame3202 commented Nov 7, 2017

@tchellomello Same here, time is correct. It seems like the debug logs think that the video is playing. Not sure what I can post since they have credentials in them:-\ Here is the start of what I believe to be the relevant line:
2017-11-06 20:08:26 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-i', 'https://ring-transcoded-videos.s3.amazonaws.com/6485

Are you not seeing this on your end? Part of that url is "expires=3600" which is 1 hour in seconds. I'm thinking it expires and doesn't generate a new link? Here is that part:
X-Amz-Expires=3600&X-Amz-Date=20171106T234233Z

If you want to tell me what to remove, credentials wise, I'm happy to post logs. Thanks!

@ntalekt
Copy link
Author

ntalekt commented Nov 7, 2017

I ran in debug for a couple hours. I see ffmpeg snatching a single frame every 3-5 seconds but I don't see the mp4, X-Amz-Credential or the X-Amz-Signature input parameter change.

2017-11-06 16:43:40 INFO (MainThread) [homeassistant.loader] Loaded camera.ring from homeassistant.components.camera.ring
2017-11-06 16:43:48 INFO (MainThread) [homeassistant.components.camera] Setting up camera.ring
2017-11-06 16:44:55 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-i', 'https://ring-transcoded-videos.s3.amazonaws.com/4235.mp4?X-Amz-Expires=3600&X-Amz-Date=20171106T234349Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=7DSA/20171106/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=3a12', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-pred', '1', '-q:v', '2', '-f', 'image2pipe', '-']
...
same haffmpeg.core grabbing one frame every 3-5 seconds
...
2017-11-06 17:44:57 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-i', 'https://ring-transcoded-videos.s3.amazonaws.com/4235.mp4?X-Amz-Expires=3600&X-Amz-Date=20171106T234349Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=7DSA/20171106/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=3a12', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-pred', '1', '-q:v', '2', '-f', 'image2pipe', '-']
...
same haffmpeg.core grabbing one frame every 3-5 seconds
...
2017-11-06 18:44:55 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-i', 'https://ring-transcoded-videos.s3.amazonaws.com/4235.mp4?X-Amz-Expires=3600&X-Amz-Date=20171106T234349Z&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=7DSA/20171106/us-east-1/s3/aws4_request&X-Amz-SignedHeaders=host&X-Amz-Signature=3a12', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-pred', '1', '-q:v', '2', '-f', 'image2pipe', '-']

@tchellomello
Copy link
Contributor

Hello guys,
I was able to reproduce the issue.

<Error>
<Code>AccessDenied</Code>
<Message>Request has expired</Message>
<X-Amz-Expires>3600</X-Amz-Expires>
<Expires>2017-11-06T23:49:25Z</Expires>
<ServerTime>2017-11-07T02:54:05Z</ServerTime>
<RequestId>064B<REDACTED></RequestId>
<HostId>
7sI7b<REDACTED>
</HostId>
</Error>

I'm investigating it now

@tchellomello
Copy link
Contributor

Guys, any of you see the entry "Updated Ring DoorBell" on your logs?

@ntalekt @thegame3202 @arsaboo

@ntalekt
Copy link
Author

ntalekt commented Nov 7, 2017

@tchellomello of course I didn't save the log... Running in debug again. I'll update shortly.

@tchellomello
Copy link
Contributor

Great news!! Troubleshooting the issue with @ntalekt we were able to find the problem.

Actually, there were 3 problems. My apologies for it.

  1. The math used to expire the URL was not working as expected and it was also causing problems if the server's time was incorrect. We simplified the formula which should work fine now.

  2. Even if a new video was detected, only the video_id was being replayed and not the URL. So the video URL would continue the same. So only restarting the HASS it would refresh.

  3. Since the URL expiration math was incorrect, the video would be with a status as Image not available for a couple of hours. Only the image would be refreshed.

We will be running the test code overnight, however if you want test it you can download it at https://gist.github.com/tchellomello/1197dc38c09c60d6b3922937de4c210f

Just create a directory custom_components/camera and then place the ring.py from the contents from the link above.

Nov 06 23:50:01 myserver.home hass[31057]: 2017-11-06 23:50:01 DEBUG (SyncWorker_8) [custom_components.camera.ring] Checking if Ring DoorBell needs to refresh video_url

<< went outside to force a new video to be captured... >>

Nov 06 23:51:31  myserver.home  hass[31057]: 2017-11-06 23:51:31 DEBUG (SyncWorker_3) [custom_components.camera.ring] Checking if Ring DoorBell needs to refresh video_url
Nov 06 23:51:32 myserver.home hass[31057]: 2017-11-06 23:51:32 INFO (SyncWorker_3) [custom_components.camera.ring] Ring DoorBell properties refreshed

Please let me know if the results..

Thank you!! mmello

@ntalekt
Copy link
Author

ntalekt commented Nov 7, 2017

@tchellomello It ran clean all night. Thanks for the quick turnaround!


2017-11-06 22:34:57 INFO (SyncWorker_0) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-06 23:20:02 INFO (SyncWorker_4) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 00:05:04 INFO (SyncWorker_9) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 00:50:08 INFO (SyncWorker_13) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 01:35:13 INFO (SyncWorker_3) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 02:20:16 INFO (SyncWorker_9) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 03:05:23 INFO (SyncWorker_10) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 03:50:26 INFO (SyncWorker_0) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 04:35:34 INFO (SyncWorker_14) [custom_components.camera.ring] Ring DoorBell properties refreshed
2017-11-07 05:20:40 INFO (SyncWorker_10) [custom_components.camera.ring] Ring DoorBell properties refreshed

@home-assistant home-assistant locked and limited conversation to collaborators Mar 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants