Ring Device integration via MQTT w/ Video Streaming

Ring experienced an outage this morning. Restarting ring-mqtt after the service outage was resolved should re-authenticate.

2 Likes

Thanks - maybe a future enhancement request could prompt to check status and restart if token error exists? (I will likely never forget, but others could run into issues)

Regardless appreciate the response and color. Itā€™s a great add on!

Where are you suggesting this prompt should be? The message in the log is already highlighted in yellow and suggest ā€œtrying again laterā€, which basically means restart although I agree itā€™s a little nebulous (not my wording, comes from the underlying API). The ring-mqtt process itself has no direct communication or integration with HA so Iā€™m not sure how I could prompt for anything there.

Ideally the connection should re-establish after an outage, which it does for many such issues (youā€™d be surprised how many outages there actually are that go completely unlogged on the Ring status page), but itā€™s exceedingly difficult to cover every possible case and test for this. Probably I should force a restart of the addon if devices stay in offline state for X number of minutes, but as itā€™s a fairly rare occurrence, and itā€™s already possible to just create an automation to do this, itā€™s not really high on my list to resolve.

Thanks - thatā€™s a great tip (I didnā€™t consider that automation, and agree easy enough for users to setup)

Regarding the prompt, my thinking was maybe change copy in logs from:

Refresh token is not valid. Unable to authenticate with Ring servers. See Refresh Tokens Ā· dgreif/ring Wiki Ā· GitHub

To

Refresh token is not valid. Unable to authenticate with Ring servers. See Refresh Tokens Ā· dgreif/ring Wiki Ā· GitHub. Note: This error can also occur when Ring servers are down. Please restart add-on after back up and running.

However it sounds like we may not have control over copy or this issue is so rare itā€™s not worth the trouble.

But that was the idea to help othersā€¦ (if I missed other copy suggesting to restart add on in the logs I apologize - I copy and pasted quickly)

I can possibly add additional information, but Iā€™ve found that most people donā€™t read anything that I put there anyway! :slight_smile:

Regardless, Iā€™ll consider it for future versions.

2 Likes

Ha - yea thatā€™s probably not a problem we can solve :slight_smile:

Have a nice night!

Hopefully this hasnā€™t been asked, if it has my apologies. I use geofencing/proximity in HA to control things, We have a Ring stickup camera to watch a puppy when we are away, Iā€™d like to disable notifications on this camera when we are home and enable when we are away, is this possible? Iā€™ve looked and not seen any way to accomplish this. Thanks in advance.

You can set this with arming home and away mode. This is done with the native ring app and can be activated trough ha. Or! Just enable it all the time and uninstall the ring app and only send notifications when away.

Iā€™ve been arming home/away with HA for quite awhile, Iā€™ll have to figure out turning off a certain camera notification as well. Thanks

I donā€™t have very much options in the Ring app for this.

With the status Home or Away I can either enable or disable motion detection and live image. Both I want to have enabled in all situations. When Iā€™m at home and upstairs (home office) I donā€™t have a clear sight to my backyard garden, so I want to have this enabled all the times.

My backyard I do have a motion schedule, if thatā€™s enabled and thus it doesnā€™t detect motion because of the schedule I donā€™t get any notifications. Not from the Ring app but also not from HA. It just doesnā€™t trigger the motion. So in order to steer this entirely by HA you cannot use motion schedules and, I guess, setting modes doesnā€™t make any sense. Maybe there is a way to enable or disable a motion schema through the APIā€™s?

Iā€™m thinking of removing my Ring app entirely from my phone or at least disabling the notifications all together. Only thing I do want to receive is when some is actually pressing the doorbell. That cannot be solved by HA, no bi-directional audio at pressent. So if someone can shine some light on this, very much appriciated!

==

One other question though. With HA I let HA grap an image from the Snapshot camera when there is either motion or a doorbell press. This often is too late thus with little of no person at all on the camera image. This obviously is because it grabs the image but the image is only updated once every 15 secs (right? default value).

Isnā€™t there a way to push the image which the Ring app uses to a mobile device? Because letting the image grab from the live camera it could get into conflict with the Ring app and Iā€™m getting a lot of images not being available. @tsightler what is your best practice to achieve this?

One other question though. With HA I let HA grap an image from the Snapshot camera when there is either motion or a doorbell press. This often is too late thus with little of no person at all on the camera image. This obviously is because it grabs the image but the image is only updated once every 15 secs (right? default value).

Isnā€™t there a way to push the image which the Ring app uses to a mobile device? Because letting the image grab from the live camera it could get into conflict with the Ring app and Iā€™m getting a lot of images not being available. @tsightler what is your best practice to achieve this?

Iā€™m sorry, but I have no idea what you are asking. If you have a Ring Protect Plan and are using 5.x with push notifications, then the image will be the same one in the Ring app, so just send it as part of the notification. There is not requirement to use the live stream for this case. If you donā€™t have a Ring Protect Plan and have a low-power camera (battery or the cheaper Doorbell Wired) then there is no option because they canā€™t snapshot while recording so pulling an image from the live stream is as good as it gets. For all others, you just send the snapshot image since it will be within 1 second of the event.

As far as how to handle notification in HA vs Ring app or whatever, thatā€™s really up to each individual to figure out based on their prefernces, I donā€™t have any kind of best practice becase believe it or not, I still just use the Ring app. I didnā€™t create ring-mqtt with any expectation to be a replacement for the Ring app, itā€™s just a way to get the events into HA so I can do a few simple automations. Iā€™m not a very heavy HA user at all, I donā€™t use any notifications in HA, just some simply automations and a few dashboards, so those types of questions are better asked of people that are heavier HA users.

1 Like

Then I guess Iā€™m doing something wrong. Or it is just a complete lack of knowledge. I do have a Rint Protect Plan and am using the latest version of docker 5.0.2 I believe. Iā€™m not using low-power devices, all devices Iā€™m using are wired. Iā€™m using the following automation blueprint to send snapshots to my device:

blueprint:
  name: Send a camera snapshot when doorbell was activated
  description: 'This automation blueprint creates a camera snapshot when the doorbell
    was activated and sends a notification to your phone with the picture.

    '
  domain: automation
  input:
    binary_sensor:
      name: Push button
      description: Entity representing a physical push button (which restores its
        position when released). It must emit a square signal on press. This automation
        is triggered by its falling edge.
      selector:
        entity:
          domain: binary_sensor
    camera:
      name: Camera
      description: The camera which creates the snapshot
      selector:
        entity:
          domain: camera
    notify_device:
      name: Device to notify
      description: Device needs to run the official Home Assistant app to receive
        notifications
      selector:
        device:
          integration: mobile_app
    is_ios:
      name: Is it an iOS device?
      description: Toggle if your selected device runs iOS, default is Android
      selector:
        boolean: {}
      default: false
    notification_title:
      name: Notification title (Optional)
      description: 'Default: "DingDong!"'
      default: The Doorbell was activated!
    notification_message:
      name: Notification message (Optional)
      description: 'Default: "{{ binary_sensor_name }} was activated!"'
      default: '{{ binary_sensor_name }} was activated!'
    delay:
      name: Delay (Optional)
      description: Wait before creating camera snapshot
      default: ''
      selector:
        number:
          min: 0.0
          max: 60.0
          unit_of_measurement: seconds
          mode: slider
          step: 1.0
  source_url: https://gist.github.com/aceindy/d43b3a3237194e9846b18e0132de303b
trigger:
  platform: state
  entity_id: !input 'binary_sensor'
  from: 'off'
  to: 'on'
variables:
  binary_sensor: !input 'binary_sensor'
  binary_sensor_name: '{{ states[binary_sensor].name }}'
  camera: !input 'camera'
  notify_device: !input 'notify_device'
  is_ios: !input 'is_ios'
  notification_title: !input 'notification_title'
  notification_message: !input 'notification_message'
  delay: !input 'delay'
  snapshot_create_file_path: /config/www/tmp/snapshot_{{ states[camera].object_id
    }}.jpg
  snapshot_access_file_path: '{{ snapshot_create_file_path | replace(''/config/www'',''/local'')
    }}'
action:
- delay: '{{ delay }}'
- service: camera.snapshot
  entity_id: !input 'camera'
  data:
    filename: '{{ snapshot_create_file_path }}'
- device_id: !input 'notify_device'
  domain: mobile_app
  type: notify
  title: '{{ notification_title }}'
  message: '{{ notification_message }}'
  data: '{% set android_data = {"image": "%s"} | format(snapshot_access_file_path)
    %} {% set ios_data = {"attachment": {"url": "%s", "content_type": "JPEG"}} | format(snapshot_access_file_path)
    %} {{ ios_data if is_ios else android_data }}'

Since Iā€™m getting different snaphots compared to the ring app and the snapshot there seems to be something different, should I look for another way of doing this? And reading your last sentence, maybe you just donā€™t know, thatā€™s also fine as well! If you do have a nice suggestion; much appriciated.

Are you getting the correct images on the snapshot camera in the HA UI? If not then it doesnā€™t really make sense to talk about the automation as it will never work and you should open discussion on the project page to determine why ring-mqtt is unable to retrieve the notification image via UUID in your case (this should be in the logs).

If you are getting the correct image in the HA UI, but not in the notification, then itā€™s probably just a matter of triggering on the correct event. I canā€™t tell how much delay you have above, but Iā€™d personally probably not trigger on motion event, but rather on timestamp of the image with a condition that motion event is in ā€œonā€ state. Other users have shared their working notification automations above as well as on the projects Github page as well, so thereā€™s really nothing I can add regarding that.

I honestly never checked before what happens on the HA UI because I almost never look at it. But now I did and theyā€™re the same.

The following picture is from the ring app on my phone:

The following picture is from the HA app, both getting send through notification but also on the HA UI.

As you can see on the second which is from the HA app, the guy isnā€™t even at the doorbell. So I guess the image is ā€˜oldā€™ which getā€™s send to HA.

There are no errors in the HA logs regarding this automation nor for the camera entry.

The logs on docker seem just fine, note: these arenā€™t from the same time as the pictures are.

2022-07-04T18:25:00.157Z ring-mqtt [Voordeur] Requesting an updated interval snapshot
2022-07-04T18:25:00.163Z ring-mqtt [Fietsen] Requesting an updated interval snapshot
2022-07-04T18:25:00.710Z ring-mqtt [Fietsen] Successfully retrieved updated snapshot
2022-07-04T18:25:00.710Z ring-mqtt [Fietsen] ring/u1hrxc-4o007-0/camera/587a623477b1/snapshot/image <binary_image_data>
2022-07-04T18:25:00.711Z ring-attr [Fietsen] ring/u1hrxc-4o007-0/camera/587a623477b1/snapshot/attributes {"timestamp":1656959101}
2022-07-04T18:25:00.714Z ring-mqtt [Voordeur] Successfully retrieved updated snapshot
2022-07-04T18:25:00.714Z ring-mqtt [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/snapshot/image <binary_image_data>
2022-07-04T18:25:00.715Z ring-attr [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/snapshot/attributes {"timestamp":1656959101}
2022-07-04T18:25:30.160Z ring-mqtt [Voordeur] Requesting an updated interval snapshot
2022-07-04T18:25:30.164Z ring-mqtt [Fietsen] Requesting an updated interval snapshot
2022-07-04T18:25:30.567Z ring-mqtt [Voordeur] Successfully retrieved updated snapshot
2022-07-04T18:25:30.567Z ring-mqtt [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/snapshot/image <binary_image_data>

I will open a issue on the project page. Thanks.

Logs of interval snapshots arenā€™t very useful for troubleshooting motion snapshot. When a motion event is detected there will be specific logging messages regarding the retrieval of the motion snapshot which will indicate exactly how the motion snapshot is retrieved. It will indicate one of the following:

Requesting motion snapshot using notification image UUID

Requesting an updated motion snapshot

Motion snapshot needed but notification did not contain image UUID and battery cameras are unable to snapshot while recording

Only the first method is able to retrieve the specific image used in the notification (the same as the Ring app). The second method will request the camera to take a snapshot manually, and the third option will return a stale snapshot since battery and low-power cameras like the Doorbell Wired are unable to snapshot while recording. The first option will only work if rich notification are enabled in the Ring app.

1 Like
2022-07-04T19:16:54.291Z ring-mqtt [Voordeur] Received motion push notification, expires in 180 seconds
2022-07-04T19:16:54.291Z ring-mqtt [Voordeur] Requesting motion snapshot using notification image UUID: 72fce8fb-d192-41d1-a07f-d58e484087ff:32263120
2022-07-04T19:16:54.291Z ring-mqtt [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/motion/state ON
2022-07-04T19:16:54.292Z ring-attr [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/motion/attributes {"lastMotion":1656962214,"lastMotionTime":"2022-07-04T19:16:54Z","personDetected":false,"motionDetectionEnabled":true}
2022-07-04T19:16:54.811Z ring-mqtt [Voordeur] Successfully retrieved updated snapshot
2022-07-04T19:16:54.812Z ring-mqtt [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/snapshot/image <binary_image_data>
2022-07-04T19:16:54.812Z ring-attr [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/snapshot/attributes {"timestamp":1656962215}
2022-07-04T19:16:55.749Z ring-mqtt [Voordeur] Received ding push notification, expires in 180 seconds
2022-07-04T19:16:55.749Z ring-mqtt [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/ding/state ON
2022-07-04T19:16:55.749Z ring-attr [Voordeur] ring/u1hrxc-4o007-0/camera/3ce1a1b06608/ding/attributes {"lastDing":1656962215,"lastDingTime":"2022-07-04T19:16:55Z"}

This is the log, it first detects motion and then registers the ding press. The image from HA is when iā€™m opening the door, the ring image is an image from me actually pressing the doorbell. I can supply the photos if needed.


My apologies, as stated in the documentation, there is no updated image on doorbell press, only at motion. So I need to read more carefully next time, thanks @tsightler for clearing things up!

Actionable notification advice

@tsightler I wanted to first of all thank you for this amazing add-on. Iā€™ve been using it for a long time and it has become one of my favorite addons, extremely stable and the features you have added over time have really hit the nail on the head of what is needed. It took me a while to figure out the whole live vs event and how to get them working, but after reading the docs a few times I got everything up and working perfectly.

Iā€™ve had an iOS actionable notification working for sometime, but something is not 100% and Iā€™m looking for a way to make it perfect.
The use case is as follows (and I try to mimic behavior of the regular ring app) - someone rings front door (powered ring door bell elite) or front gate (powered ring doorbell pro) - I receive a push message to my iOS devices that says ā€œSomeone at the doorā€ and has three actions - 1. open the door (via a strike lock with a shelly device), 2. Announce on Alexas in the house that someone should get the door, 3. open ring app on phone so I can talk to the person.
All this works fine, the only issue is Iā€™ve been passing it the snapshot as the image (which you can see when long clicking on the push) - the problem is sometimes this snapshot is older than the ding so I donā€™t get to see who is at the door.
The way the ring app push works if you long click on it, you get a few second video (maybe 3 seconds) from when the person rung the bell and this is very accurate. This is essentially what Iā€™d like to pass as well, so the question is what should I pass as an image? The event stream? Iā€™m not sure it will be ready yet and that stream is much longer than a few secondsā€¦ In addition, what if another event (motion) happens before I get to the push messageā€¦Iā€™m wondering what the ring app is sending in their push message.
Any help would be greatly appreciated

With current ring-mqtt Iā€™d say that the image will always be older than the ding since ring-mqtt does not support sending an image on ding, only on motion thus, in almost all cases that I can think of, motion will be detected before a ding. I guess there could be some scenario where motion detection is disabled, but it doesnā€™t matter, because this wouldnā€™t count as a motion event and thereā€™s no updated snapshot based on dings today.

Regarding the few second video, I donā€™t think thereā€™s any chance of getting that. I have no idea where it comes from as Iā€™ve never seen this behavior, perhaps it is IOS specific, I have an Andriod phone and I canā€™t reproduce. My gut says perhaps itā€™s a link to a transcoded image because I donā€™t see how they could send it in the notification itself, but someone would need to investigate that with a reverse proxy unless thereā€™s similar behavior in the web app.

Thanks for the response! I agree with you that definitely the motion will be prior to the ding and possibly to early. Is there any way at some point in the future to add a ā€œding_snapshotā€ to ring-mqtt as a feature at some point? that would be great for this.
Regarding the video Iā€™m surprised they donā€™t have it in android - I think I have an old android lying around which I will try. I must say, you guys are missing out - this is the main way I use my ring today (which is why I wanted to mimic it in HA so I could do actions as well). Its uber helpful with both lock screen and on the watch, as you long click and get to see who is there, without having to open the app, all at a glance. From the way the ā€œvideoā€ looks I think they are capturing 5 quick snapshots at a much lower res and then creating possibly a GIF and its sent with the push. I donā€™t think the push is pulling the video from a server or anywhere.
If in the future ring-mqtt would support a ding snapshot or ā€œsnapshotsā€ this could be replicated.
Thanks again for a superb add-on

1 Like

Is there any way at some point in the future to add a ā€œding_snapshotā€ to ring-mqtt as a feature at some point?

Maybe at some point in the future, now that push notifications are supported. Prior to push notifications it didnā€™t really make sense as the significant majority of users seem to have battery/low-power doorbells which canā€™t take snapshots while recording anyway and, since motion events generally cause the camera to start recording, it wasnā€™t possible to get a snapshot from the ding easily.

However, I donā€™t really have much time for this project right now, and quite honestly, have low motivation to add more stuff to it as itā€™s met my goals long ago. I mean, itā€™s freely available, you can modify it to do whatever you want, and I do consider PRā€™s when they are submitted.

From the way the ā€œvideoā€ looks I think they are capturing 5 quick snapshots at a much lower res and then creating possibly a GIF and its sent with the push

No rich media is sent with the push notification from Ring, itā€™s just simple JSON that includes properties with the location/device/event ID, the detection type (ding/motion), person detection, and the UUID of the snapshot image. The app that receives this push then has to retrieve any rich media from Ring API. For ring-mqtt you will see in the logs where the snapshot image is retrieved using the UUID from the push notification, for a phone/device, itā€™s the Ring app that has to process the push and retrieves the rich media components from the Ring API servers to generate the local notification.

1 Like