Ring Device integration via MQTT w/ Video Streaming

Bypass mode basically just emulates what is possible in the Ring app, but, when enabled, automatically bypasses any contact sensors or zones that are faulted when the arming action is attempted (unlike the app which prompts you to confirm bypass, in this case, setting bypass mode to own IS the confirmation that you want bypass).

Zones that are not faulted at the time of arming are not bypasses so, in the scenario you describe, if there is an active bypass on the zone with the window, and then a door on another zone is tripped, the alarm should still go off because that is a different sensor that is not bypassed.

Trying to add GitHub - tsightler/ring-mqtt-ha-addon: Hassio addon for the ring-mqtt script via custom repository in HACS. Get ā€œRepostitory structure for master is not compliantā€. I am fairly new to HA, so Iā€™m sure itā€™s something Iā€™m doing wrong. Any pointers?

I donā€™t know why people keep trying to add this to HACS, this addon has nothing to do with HACS so yes, attempting to add it there will definitely only create an error. This is a Home Assistant addon, so simply add the repository to the native addon store.

1 Like

As a new user, I think itā€™s because a vast majority of the tutorials push HACS to the point that us newbies donā€™t even realize there is another way (that is more integrated, of course).

As soon as you mentioned it, the ā€œDUHā€ light bulb went off over my head. Thanks!

Interesting. I guess I always saw HACS as something very different, a way to add custom components and UI extensions without having to manually do the work. An addon is neither of these things, but I can see how that might be confusing to a new HA user for sure. Does HACS actually support including addons these days? Maybe I should put a note at the top of the readme that says itā€™s not a HACS addon.

Nope, strictly an ID10T error on my part. For us newbies, HACS = add custom stuff. Just a mindset to get out of on our part.

Hey tsightler, any chance of adding battery level sensor to battery powered ring doorbell camera (unless its something I am doing wrong). The ring addon exposed it but since I switched over to exclusively your addon for all devices it seems to be missing. Thanks :slight_smile:

For a battery camera the battery state should be available as an attribute of the info sensor for the camera, the same place where wireless network and signal level are displayed. The specific attribute is ā€œbatteryLevelā€. Are you not seeing this?

Unfortunately I donā€™t have a battery camera so I canā€™t test this myself, but Iā€™ve never had anyone else as for this, and I assume it would be a common request, so Iā€™ve always just assumed it must be there.

I just wanted to give you an atta boy and ask a question or 2. You should be proud of your complete work. As in you did not have to code all the hints in the log file which I have found most helpful. As well as the simplicity of the config file and of course the 2fa. Job well done.

FWIW I just added the new wall solar light and get battery status, motion, as well as turn it on and off :slight_smile:
Curious though, how often does it poll or get the battery info? Seems random to me. Not you of course, but I have yet to get over 36% battery charge.

And a camera question please. Does it just keep one picture in MQTT? As in there is no say 10 last pics or I do not need to worry about it filling up my SD card. There is no time for the picture or history.

I have snapshot mode set to all but I think it must be a ring thing, it will not take a picture unless motion is activated. In My case that is only in Away mode. In the ring app I have live mode enabled for all 3. Disarmed, Home, and Away.

Thanks again,
Grey

For cameras the battery data is part of the Info sensor. This sensor data is updated by polling the device which calls the getHealth() function of ring-client-api. This function returns the same data as selecting ā€œDevice Healthā€ in the cameraā€™s settings within the Ring app (youā€™ll see the data in the info sensor is exactly the same, although presented slightly differently).

The code polls getHealth() every 5 minutes, however this just makes the call to the Ring server API and I donā€™t know the interval or algorithm that Ring uses to poll camera health and actually update itā€™s data, however, the poll time is reported in the info sensor under the LastUpdate property. This should match the same time as ā€œLast Health Checkā€ in the Ring app. As far as I can tell, thereā€™s no way to force Ring to perform a Health Check so itā€™s at the mercy of how often Ringā€™s servers do this, which, from what I can tell, is approximately every 60-180 minutes, usually around 60-90 minutes.

The most recent image is stored in memory, so itā€™s not going to fill up any SD card or anything. For images taken from the livestream (required for battery based cameras during motion) it did temporarily write an AVC video stream to a temporary file, but even this was written to tmpfs, so it was still in RAM. However, the most recent version no longer requires a temporary file as I figured out how to parse the MJPEG stream in realtime and extract a single, full, JPEG image directly from the stream (I say I figured it out, but really I must give credit to the pipe2jpeg package which I now use for this). Only the most recent image is kept in memory.

Unfortunately, motion notifications must be enabled to be able to take snapshots, this is a Ring limitation.

Thanks for the feedback!
Anyway to get the time of the snapshot for the camera?
Grey

The camera entity includes a timestamp attribute for the most recent snapshot in Unix epoch format.

I see it now, HA had a battery level entity with old integration, didnā€™t look there, thanks.

One query on the snapshot (battery powered doorbell - image from motion notification), the image is always distorted (every image has this exact same distortion). Some way to fix it? Its like the bottom 2/3 of image is always this blur.

Thanks! It looks fine in the image sent by official ring app ios notification.

Unfortunately Ring does not allow 3rd party applications access to the webhooks required to get the URL for the images that are sent as part of notifications so thereā€™s currently no way for this project to get those. Iā€™m hopeful this may change in the future as I know itā€™s something the author of ring-client-api is interested in implementing as it will help the Ring Homebridge plugin as well, but I have no idea when or if it will ever happen.

So, for battery cameras, since Ring does not allow them to take snapshots while they are recording, the only option left is to attempt to get an image from a motion event is to attempt to capture it from the livestream. Unfortunately, you seem to be getting a bad stream and thus a bad image, but I have no idea why. In my own testing Iā€™ve seen this maybe 2-3% of the time, but certainly nowhere like every time, and with 4.5.5 and the bump to ring-client-api 9.18.0, which improved the reliability of live streams, Iā€™ve only seen it once in a few hundred images.

Maybe bandwidth or different routers might cause this to be worse, thatā€™s the only thing I can think of, but I donā€™t know what you could possibly do about it other than simply disable the feature.

OK thanks. I caught an image yesterday which was not distorted so it isnā€™t every time, but I suspect its much higher than 2 or 3 in 100 as I am noticing it a lot in HA (current image right now is again just all distortion of the image). Maybe I could count.

So I appreciate this isnā€™t the other Ring plugin, but how does that one get an image (although when you clicked it, it played the video so I guess it was a frame from the entire recording)? I ask because I feel like Iā€™d not significantly noticed this behaviour before (I switched because the ding errors were annoying me), do you grab actually from the camera itself or from Ring cloud after its been uploaded to the cloud, curious what you mean by ā€˜liveā€™ stream? Guess Iā€™m trying to understand bandwidth between the camera and my router or we are talking about bandwidth on the wan? I dont have the fastest internet but its up there for the UK at least.

But I do know the connection to the camera over wifi isnt the best. Its one of the first generations of these doorbells which they later improved with 5ghz in current models (router is only 5 meters away but signal strength isnt great - even though my phone in same position is fine). Thanks.

It doesnā€™t really help anything to count, I donā€™t really know what I could do about it anyway. I just start a stream and grab an image from it, thatā€™s it. If the stream is unreliable thereā€™s nothing I can do about it as Iā€™m not in control of the stream.

The native HA integration works completely differently, although admittedly I donā€™t use it, so Iā€™m not an expert to speak to itā€™s functions, however, I believe that it does not even attempt to show a current image, it just waits for the recording to finish and for Ringā€™s servers to finish processing the stream and then simply plays back the already processes stream. That means you donā€™t get an image until a minute or more after the motion event.

The goal of this integration is to provide an image as soon after then motion event as possible. I have 5 cameras, for me it works very reliably. During development there were also other testers that provided feedback and, while there were some reports of sporadic bad images, it was not something that happened regularly.

Streams donā€™t happen directly between the camera and the device, the connection has to go from camera, to Ring servers, then a SIP session is established between ring-mqtt and Ring servers, so the stream is to the cloud and back. Typically stream issues are related to upload bandwidth (either from camera over wireless to internet, or internet itself).

Note that Iā€™m not saying thereā€™s something wrong with your setup, Iā€™m just theorizing why it might be more reliable for me (and others that have tested) while not being as reliable for you. I have 1Gb fiber connection and mostly newer cameras. Two of my cameras use wired ethernet and the other three have quite strong wireless connections so it may ramp up the UDP stream quickly. Perhaps if bandwidth is slightly more limited the initial stream is slower to establish and thus more likely that that single frame Iā€™m pulling is bad or incomplete.

But really, I donā€™t know what I could do about it as all I do is request a stream. I donā€™t have any way to know if the stream is good or bad, if an image is good or bad, etc. I know that the author of ring-client-api is aware of some stream issues and itā€™s something heā€™s working to improve, so maybe over time it just goes away.

However, in the mean time, feel free to just disable this feature and just use interval based snapshots.

Thanks for explanation. I suspect it is the cameras connection that is flakey causing it then if you are trying to grab it immediately. To be honest the doorbell is a piece of crap, trying to answer a notification most of the time whoever was there ringing the bell has left already so Iā€™d be more amazed if you were able to get a real time image from it. I only really use it in HA because it happens to already stuck to the door, and why not.

And thanks as ever for continuing to support HA and devices you dont even use yourself. Hope Iā€™m not discouraging you!

One of the reasons I was so hesitant to add support for camera snapshots is because I knew the battery cameras would be a pain to support. In the first versions the battery cameras just didnā€™t update snapshots on motion since they are restricted from being able to take snapshots while they are recording. However, people wanted a motion snap so I wrote this feature to start a live stream and grab the frame, but I suspected it would not be 100% reliable.

Hopefully Ring will eventually give 3rd party tools access to the notification webhooks interface so we can just grab the snapshot from the notification, that would be the best option.

I wonder if I let the stream run for a second or two before grabbing the image if that would help, maybe Iā€™m just catching it too quickly for the older cameras. But in general, Iā€™m not a fan of Ringā€™s battery cameras, they are just too restricted and underpowered for me.

I think you are getting too fast the image, since last update i cant see any movement in the snapshot, before i had more reliable snapshots.