Ring MQTT Save captured snapshots

Hi

I just got my Ring MQTT up (GitHub - tsightler/ring-mqtt: Ring devices to MQTT Bridge) It is taking snapshots ever n second that update nicely on the dashboard.
However, is there any way I can store these snapshots? The snapshot is available as an entitity in mosquitto broker. (First time using MQTT in HA). If I can’t store them, does that mean I can’t use them in my notifications? Currently using calling snapshot service on the ring camera, which is useless since its the first frame of the last event.

Also, there is an entity switch for livestream. I set up a generic camera in config.yaml like so

camera:
  - platform: ring
  - platform: generic
    name: Front Porch Video
    still_image_url: http://homeassistant:8123{{ states.camera.inngangsdor_snapshot.attributes.entity_picture }}
    stream_source: rtsp://<WhatToInsertHere>:8554/switch.inngangsdor_live_stream 

Any pointers on what more that needs to be done or if config is wrong?
Followed the guide for ring mqtt as best as I could.

Here is an automation I use to save the snapshot and send to my firetv. It checks the difference between when the automation was triggered and the timestamp of the snapshot to make sure it has updated. It waits up to 15 seconds for the snapshot to update. If the snapshot doesn’t update it sends a message without an image. If the snapshot updates it then saves it locally and sends it to the firetv. I am sure there are better ways but this has been working for me.

alias: Notify Motion Front Doorbell
description: ''
trigger:
  - type: motion
    platform: device
    device_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    entity_id: binary_sensor.front_doorbell_camera_motion
    domain: binary_sensor
condition: []
action:
  - wait_template: >-
      {{
      as_timestamp((state_attr("automation.notify_motion_front_doorbell",
      "last_triggered"))) - (state_attr("camera.front_doorbell_camera_snapshot",
      "timestamp" )) < 3 and
      as_timestamp((state_attr("automation.notify_motion_front_doorbell",
      "last_triggered"))) - (state_attr("camera.front_doorbell_camera_snapshot",
      "timestamp" )) > -15 }}
    timeout: '00:00:15'
    continue_on_timeout: true
  - choose:
      - conditions:
          - condition: template
            value_template: '{{ not wait.completed }}'
        sequence:
          - service: notify.firetv_cube_global
            data:
              data:
                color: black
                duration: 5
                fontsize: large
                interrupt: 0
                position: top-right
                transparency: 50%
              title: Home Assistant
              message: Motion detected at the front doorbell camera.
    default:
      - service: camera.snapshot
        entity_id: camera.front_doorbell_camera_snapshot
        data:
          filename: >-
            /config/www/tmp/{{
            as_local((state_attr("automation.notify_motion_front_doorbell",
            "last_triggered"))).strftime("%Y%m%d-%H.%M.%S")
            }}_front_doorbell.jpg
      - service: notify.firetv_cube_global
        data:
          data:
            color: black
            duration: 5
            fontsize: large
            interrupt: 0
            position: bottom-right
            transparency: 50%
            file:
              path: >-
                /config/www/tmp/{{
                as_local((state_attr("automation.notify_motion_front_doorbell",
                "last_triggered"))).strftime("%Y%m%d-%H.%M.%S")
                }}_front_doorbell.jpg
          title: Home Assistant
          message: Motion detected at the front doorbell camera.
mode: single

Here is the simple automation Im working on:

alias: Front door notification
description: ''
trigger:
  - type: motion
    platform: device
    device_id: 0daf537485fb00c0ef5059e61977d2e4
    entity_id: binary_sensor.inngangsdor_motion_2
    domain: binary_sensor
condition: []
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - service: camera.snapshot
    target:
      entity_id:
        - camera.inngangsdor_snapshot
    data:
      filename: /media/camera.png
  - service: notify.all_devices
    data:
      message: Person at front door!
      data:
        image: /media/local/camera.png
mode: single

I have also tested using a tmp folder, dont recall why I swapped to media. But shouldnt I see the camera.png file in the media folder, the way I do it? (The notification has the snapshot). For now it will just overwrite(Which is ok for testing), but I cant see any actual file in the folder.

image

For the stream source look at the attributes for the info sensor and it should help you determine what you need to use. So in my case it is something like…

 
Entity
sensor.front_doorbell_camera_info
 
batteryLevel: '97'
firmwareStatus: Up to Date
lastUpdate: '2021-11-24T18:52:10Z'
wirelessNetwork: xxxxxxx
wirelessSignal: -50
stream_Source: rtsp://a98c085d-ring-mqtt:8554/xxxxxxxxxxxx_live
still_Image_URL: >-
  https://homeassistant:8123{{ states.camera.front_doorbell
  camera_snapshot.attributes.entity_picture }}
friendly_name: Front Doorbell Camera Info
icon: mdi:information-outline
device_class: timestamp
1 Like

In your example you are looking in /config/media but it looks like you are saving to /media. Do you have another media folder at the same level as /config? I do see the images in my /config/www/tmp/ using camera.snapshot service in my automation.

Thank you! Stream is working now!

Im currently still on my 30 day free trial on ring. Do you know if the live stream will still work after that?

Now I just gotta work some more on the snapshot saving.

Would you use the generic camera stream and take snapshot from, or use the snapshot from ring mqtt? (Which is triggered by motion also).

If I remember correctly there is some issues by having the stream on all the time?

No, no media folder at same level as config.
I will try the method you are using with the same folders.

Any idea on why the livestream is turning itself on about 1min after I turn it off?

When it is constantly on I do not get any notifications from Ring or motion detection on it.

Do you add the camera to Home Assistant and enable the option to preload stream? I believe if you enable that option it will cause the stream to stay on

This is from the ring-mqtt camera info…

Q) Streams keep starting all the time even when I’m not viewing anything
A) In Home Assistant, do not use the “Preload Stream” option and make sure the Camera View setting in the Picture Glance card is set to “auto” instead of “live”. Otherwise the card will attempt to start streams in the background for faster startup when you bring up the card.

The preload is disabled and set to auto and I still experienced the issue. The live stream still stays on.
Current workaround for me is having and automation that triggers when the live stream switch goes on, wait 2 min, then turn it off again.

I am not sure about the preload settings on my spouse’s phone, if that can make any difference.

I have never had an issue where it continuously triggers the live stream. I know after viewing a live stream in HA it stays up for around 5 minutes before stopping live streaming but that doesn’t sound like what you are describing.

Q) Why do streams keep running for 5+ minutes after viewing them in Home Assistant
A) Home Assistant keeps streams running in the background for ~5 minutes even when they are no longer viewed. It’s always possible to stop streams manually using the stream switch.

If it is the 5 minutes that HA keeps the stream running I solved this by just adding the switch for the live stream to the picture glance card. After a live view I use the switch to stop the stream. This is what my picture card looks like.

To answer your other questions…

I use the snapshot camera from mqtt since using the live stream results in the issue you are experiencing. The Ring cameras do not send motion notifications when live streaming.

I pay for the subscription since I also have the alarm system. However, my understanding is you will still be able to use live view but will not have access to any recorded events.

Thank you for your answers.

I tried with the live stream switch on the picture glance card, but experienced that it still went on again afterwards. Also if I forget to turn it off, its nice to have ‘automagicly’ off after 2 min. I will rarely watch the live stream more than 2 min in a run.