Ring Device integration via MQTT w/ Video Streaming

I don’t know why Scrypted works and ring-mqtt doesn’t since they basically do the same thing, even use the same API on the back side, but the stream processing in Scrypted is significantly more advanced and it uses a native RTSP server implementation instead of gatewaying the stream via rtsp-simple-server.

However, Scrypted does one even better, it can provide a native WebRTC rebroadcast as well, which means you could pull the stream directly from Scrypted without having to gateway to RTSP and back to WebRTC as the blog above suggest.

In the end, I’m guessing you could have probably just setup a manual channel in RTSPtoWeb (or RTSPtoWebRTC) and just used that in the script with ring-mqtt, but I’m glad you managed to get it working.

If I ever get an Android TV, I guess I’ll have to play with it to see why it doesn’t work out of box, although with the changes in v5 to use WebRTC on the Ring side maybe it will work going forward. Hopefully in a few months we’ll have native WebRTC playback in HA with Ring cameras which is really the ideal scenario.

1 Like

I’ve been playing around a bit with this integration the last couple of days. And I wanted to share my experiences, first off: love this integration!. I have a running subscription with Ring, so I should be able to download the vids, and that seems to work (btw, maybe a suggestion to your manual; the downloader service should be enabled, didn’t have that at first).

What I found very important to understand is if there is a Live video, it doesn’t detect motion. I know it has been mentioned number of times before, but it is really key. Besides this, it is important to understand the motion doesn’t work separately from the ring.com app. Motion zones and motion-free schedules get respected, even from the app. Makes perfect sense, but it had to sink down a bit for me. The Live motion part comes really into play for me because I have been playing around with RTSPtothewebRTC docker container, when connected to HA, HA pushes the stream to this server and keeps it constant running.

I have 2 ring camera’s. A videodoorbell Pro2 and a spotlight cam. Both are added just fine to MQTT and with the running streaming server I managed to add both of them as a generic camera (@tsightler just a quick headsup, in your readme it still says you have to add them by adding to the config.yaml, this possibility has been removed).

The thing I cannot seem to get my head on is the ‘event-select’ and ‘event-stream’. I wanted to create the same camera card as mentioned above, want to use the event selectors too. Where does the event-stream look for the video’s. What is supposed to happen when I click the cassette? I’d imagine it should start the video corresponding with the downloaded one based on motion1 - 5, right?

The event stream is just a separate RTSP path that streams the recording of the selected event directly from the recording URL instead of streaming the live view from the camera. It really doing the same thing as downloading that recording, but instead of writing it to disk, it’s streaming the recording back as a camera so it can be viewed on demand just by connecting to the RTSP URL. To use it in HA, you just add another generic camera to HA that uses the RTSP URL ending with _event instead of _live, that’s literally all there is to it.

Effectively, for my setup, each individual Ring camera is represented by three cameras in HA, the snapshot camera, the live camera, and the event camera. The snapshot camera is an MQTT camera, so it’s automatically discovered as long as MQTT is setup, and it of course limited to only still images since MQTT can’t really do streaming, but that’s perfect for snapshots. The live and event cameras user RTSP so you need to add each camera separately and the recommended setup is the use the snapshot camera as the source for the still image URL for both the live and event cameras.

Then, when configuring the picture glance card, you just use whichever camera you want to come up when you click the picture as the “Camera Entity” of the picture glance card, and the add the other one as just as a secondary entity in the “Entities” section of the picture glance card which will give you an icon to click to bring up that camera. In my case I like the event camera to come up when I click the image, so the event camera is the “Camera Entity”, while the live camera is in the “Entities” section so I can easily access either live or selected event with just a single click.

Nothing, the cassette is just an “active” indicator to show if the event stream is currently active or not. You can use the icon to stop the stream manually, but you cannot start an event stream manually because, unlike the live stream, there’s really no reason to start an event stream if there’s nobody viewing it. On the other hand, starting a live stream manually might be useful for manually triggering a recording via an automation based on something other than a Ring device.

The event stream always plays the recording directly from the URL where it is stored on Ring’s servers, it does not play back downloaded recordings.

2 Likes

Thanks a lot for your answers! The _event camera I was missing! I can now see the latest event. I have these 3 entities for my camera’s too. I don’t seem to get how to add the still image url to my camera’s. If I try and proxy them, I’m getting a 401 unauthorized. But do you still need it, because the Generic camera integration seems to get the still image from the feed. Or does it start a live event to grap this still picture?

Right, so downloading the MP4 is just for reference / backup. I experimented a bit yesterday with the switching from motion 1 to 5 and if the ring api reports back the movie it’ll get played by the event camera so yes, thanks a lot!

You just use the URL to your HA instance with the template which pulls the image from the HA camera proxy for the snapshot camera. The template resolves to the value of the entity_picture attribute, which includes the authentication token needed for accessing the still image via the camera proxy. You can’t just hard code the URL, unless you provide a username/password, because the token changes every 5 minutes, which is why I recommend using the template to resolve the path so it will always have the current token.

If you don’t provide the still image URL I believe it starts a stream to generate the image, which is less than ideal IMO.

Great AddOn!

I’m trying to use the snapshots in an automations in order to save them on motion. I tried this by calling the following on motion, to download the image from the attribute (based on this post: Using a variable (attribute) as a url for downloading - #12 by CrouchingWorm).

service: downloader.download_file
data_template:
  url: https://192.168.2.253:8123/api/camera_proxy/camera.front_door_snapshot?token=3fa23de984a746b5a9e1cf3b06a6114100ceba5a5b8615f12bae0b05c9b2bce4
  subdir: Doorbell/May 2022/
  filename: Bell Snapshot - {{ now().strftime("%d-%m-%Y- %H.%M.%S") }}.jpg

This results in all sorts of security notifications from HA:

image

Now I understand this does not directly have to do with the AddOn, but maybe there are other of it’s users here that try to accomplish the same. The downloader is to be called after the following in an automation:

      - conditions:
          - condition: trigger
            id: doorbell_oncameramotion
        sequence:
          - service: switch.turn_on
            data: {}
            target:
              entity_id: switch.front_door_live_stream
          - service: timer.start
            data:
              duration: '00:04:00'
            target:
              entity_id: timer.front_door_camera_stream
          - service: camera.snapshot
            data:
              filename: >-
                /media/Doorbell/{{ now().strftime("%B %Y") }}/Motion Snapshot -
                {{ now().strftime("%d-%m-%Y- %H.%M.%S") }}.jpg
            target:
              entity_id: camera.03cabcc9_ring_mqtt
          - service: camera.record
            data:
              filename: >-
                /media/Doorbell/{{ now().strftime("%B %Y") }}/Motion Video - {{
                now().strftime("%d-%m-%Y- %H.%M.%S") }}.mp4
              duration: 240
            target:
              entity_id: camera.03cabcc9_ring_mqtt
      - conditions:
          - condition: trigger
            id: timer_finish
        sequence:
          - service: switch.turn_off
            data: {}
            target:
              entity_id: switch.front_door_live_stream

The later video recording works, but downloading the snapshot doesn’t. Am I missing something?

Right I agree it is less than ideal, but I can’t seem to get it to work.

Unknown error occurred is the error if I add the follwoing:

http://192.168.21.9:8123{{ states.camera.voordeur_snapshot.attributes.entity_picture }}

The IP is 100% correct and the camer.voordeur_snapshot is the correct snapshot camera.

And advise to troublwshoot the unknown error?

This is caused by a bug in the 2022.4.x releases of Home Assistant which causes HA to be unable to generate a name for a URL with a template in certain cases. I believe it should be fixed in the 2022.5 release which I think was released just today.

If you don’t want to upgrade right away a viable workaround is to add “/.” immediate after the port number in the URL so the URL above would become:

http://192.168.21.9:8123/.{{ states.camera.voordeur_snapshot.attributes.entity_picture }}

1 Like

Just did a refresh, but the docker container hasn’t been updated yet, tnx ! I’ll wait for the new version then, thanks! It’s updating now

With the /. I’m getting a error it didn’t return a valid still image.

Humpfff… with the 2022.5 it gives the same result, doesn’t return a valid still image. This worked 100% sure in the configuration.yaml config.… osi-layer 8… made a typo. Works, thanks! again!

That solved my question too. :slight_smile:

1 Like

@tsightler not sure why, but the live video feed is no longer working for me. I’m getting the error below in the logs… I’m running v4.9.1 on HA 2022.5.1

The addon is reporting that it is successfully connected, and if I double check the stream_source URL under the info sensor entity, it still matches what’s in the configuration.yaml file.

Any ideas?

Logger: homeassistant.components.stream.stream.camera.front_door_video
Source: components/stream/__init__.py:347
Integration: Stream (documentation, issues)
First occurred: 19:47:09 (25 occurrences)
Last logged: 20:39:12

Error from stream worker: Error opening stream (INVALIDDATA, Invalid data found when processing input) rtsp://xxxxxxxx-ring-mqtt:8554/xxxxxxxxxxxx_live

It’s pretty much impossible to tell from the limited information provided but you should check the UI configuration for camera since configuration.yaml is no longer a valid method for configuration the Generic Camera component of HA. I’ve tested the 4.9.1 release with 2022.5.1 and everything continues to work as expected.

Ah sorry for the lack of info. Rather then configuring via configuration.yaml, how should I be configuring the camera now?

Btw your doco still mentions using the Generic Camera component: ring-mqtt/CAMERAS.md at 3943159123e685547a673a751faf927f53bbf210 · tsightler/ring-mqtt · GitHub

@tsightler Just updated to 5.0.0 and it is phenomenal! I love the move to persistent volumes. Way easier to update settings :grin:

Thanks @IceBotYT. Using the config.json file with Docker is somewhat controversial, and I’m sure some users will prefer it while others aren’t going to like it, but, for me, it’s about maintainability. Having all install methods use the identical configuration method and state engine will significantly reduce the testing overhead for me going forward.

While I’ve done a ton of testing during the 5.0.0 development cycle, I know that you can’t have over 300 commits, not to mention the significant changes to the underlying ring-client-api, and not have some regressions, but hopefully it will stabilize over the next few months and at least most of the risk for issues is limited to camera features.

3 Likes

I just updated my docker container (haven’t done that in a while). Everything still works, which is absolutely great.

I don’t really get what’s phenomenal, and don’t get me wrong, i absolutely love this plugin/docker. But is there a change list going to 5.0.0? The changelog-hist file doesn’t mention 5.0.0.

I can see the installation procedure had changed, but the old ring-token environment value still works. Is it expected to deprecate this anytime soon?

@tsightler Dear Developer! Thx for such great update, addon for HA is work better than previous one. Snap is taken faster, just upon move and taken again after another move detected (like is native RING application), that is really big advantage in new version. No bugs found for the moment.

Regards

Alex

The changelog-hist file is for historical versions, the current version is in current changelog or on the project page you can always view the releases which include detailed changelog as well.

1 Like

I get this error on startup of 5.0.1. Doesn’t seem to cause an issue, so not raised a ticket on GitHub, but can do if needed.

2022-05-12T19:25:16.955Z ring-mqtt New location: The Mews (111111122222233333-redacted)
Register request has failed with Error=PHONE_REGISTRATION_ERROR
Retry... 1