Ring Binding [3.2.0;4.0.0)

@morph166955 I’m trying to get 2FA to work with the binding, but no luck so far.

I fill in the account name and password in the account thing, then I get a text message with the 6 digit verification code. I then fill this in, hit save, and get a 401 unauthorized message in the log. Am I doing this in the correct order?

I’m using 4.0.0.202305082032 on OH 4 build 3490.

2023-06-12 15:13:12.703 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Initializing Ring Account handler
2023-06-12 15:13:12.703 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Initializing AbstractRingHandler
2023-06-12 15:13:12.704 [INFO ] [hab.binding.ring.internal.RestClient] - Creating Ring client for API version 11 on endPoint https://api.ring.com
2023-06-12 15:13:12.704 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Logging in with refresh token: NULL
2023-06-12 15:13:12.704 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - getAuthenticatedProfile U:NOTEMPTY - P:NOTEMPTY - R:NULL - 2:NULL - H:NOTEMPTY
2023-06-12 15:13:12.704 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - get_oauth_token NOTEMPTY - NOTEMPTY - NULL
2023-06-12 15:13:12.705 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - get_oauth_token - refreshToken null or empty NULL
2023-06-12 15:13:13.158 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient get_oauth_token: https://oauth.ring.com/oauth/token, response code: 412, message Precondition Failed.
2023-06-12 15:13:13.159 [DEBUG] [ing.ring.handler.AbstractRingHandler] - AuthenticationException when initializing Ring Account handlerTwo factor authentication enabled, enter code
2023-06-12 15:13:43.145 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Initializing Ring Account handler
2023-06-12 15:13:43.146 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Initializing AbstractRingHandler
2023-06-12 15:13:43.147 [INFO ] [hab.binding.ring.internal.RestClient] - Creating Ring client for API version 11 on endPoint https://api.ring.com
2023-06-12 15:13:43.147 [DEBUG] [ing.ring.handler.AbstractRingHandler] - Logging in with refresh token: NULL
2023-06-12 15:13:43.148 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - getAuthenticatedProfile U:NOTEMPTY - P:NOTEMPTY - R:NULL - 2:NOTEMPTY - H:NOTEMPTY
2023-06-12 15:13:43.148 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - getAuthenticatedProfile - valid 2fa - run getAuthCode
2023-06-12 15:13:43.148 [DEBUG] [hab.binding.ring.internal.RestClient] - RestClient - getAuthCode A:NOTEMPTY - U:NOTEMPTY - P:NOTEMPTY - H:NOTEMPTY
2023-06-12 15:13:43.328 [INFO ] [hab.binding.ring.internal.RestClient] - RestApi getAuthCode: https://oauth.ring.com/oauth/token, response code: 401, message Unauthorized.
2023-06-12 15:13:43.329 [DEBUG] [ing.ring.handler.AbstractRingHandler] - AuthenticationException when initializing Ring Account handlerInvalid username or password.

That looks ok. Are you text or UI based config? Any weird characters in the password? I use the authenticator app so not sure if there is a difference between the text and app.

Anyone else having this issue?

I’m using GUI based. My password is generated by the Google generator - it could well have characters that cause a problem. Is there a list of allowed/disallowed characters? Which ones are a problem? I suppose I can try a simple password for testing, but I would need a strong password for normal use.

I’m not 100% sure of what they accept. Quotes could potentially cause issues so I personally avoid them in passwords.

For mine, since I use the app, i put username, password, and 2fa all in at the same time and hit go. You may be hitting the timeout (I think its like 60 seconds)?

The password I have works fine for Ring - I can login without any problem. What I don’t know is whether OH munges some on the way through. I do this quickly, much less than 60 seconds, so I don’t believe a timeout is the issue. Probably 10 to 15 seconds to get the code, type it in, and hit the save button in OH.

Maybe I can try using the authenticator app as you are doing. I’ll take a look.

@jswim788 Funny enough I was setting up my ring environment with openHAB yesterday and ran into 100% the same problem. I also have MFA setup (via DUO).

I have changed my password to a password with only alpha-num characters and a safe special character and the setup worked straight away.

@morph166955 thanks for looking into that binding - I am not a developer, but I would assume that the issue is related to automatically html encoding data on the fly or something like that. Typical characters that would be auto-encoded would be for exmaple ", or < and >

Finally got a chance to follow up on this.

I removed the marketplace addon and downloaded the .jar file at the top of this thread to the addons folder, and I’m still seeing the same error:

2023-06-16 08:09:01.341 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:09:07.135 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:09:17.644 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:09:23.901 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:09:34.527 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:10:07.164 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:10:22.891 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:10:34.120 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:10:39.353 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:11:06.670 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:15:43.925 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:16:16.583 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2
2023-06-16 08:17:04.060 [ERROR] [hab.binding.ring.internal.RestClient] - RingVideo: Unable to create folder /etc/openhab2/html/ring/video, cannot download.: /etc/openhab2

Here is the bundle I’m running:

openhab> bundle:list | grep -i ring
314 │ Active │  80 │ 4.0.0.202305151551     │ openHAB Add-ons :: Bundles :: Ring Binding
openhab>          

I restarted openHAB, which didn’t change anything.

The path where video’s download can be changed to anything you want. That path was just the original path when it was developed.

Go into the Ring Thing Account and click advance. See the path area:

Best, Jay

Changed it to /etc/openhab/html/ring/video from /etc/openhab2/html/ring/video, and now it works.

I’m not sure how what was there go there in the first place. Perhaps I played around with an early version and it stuck. Regardless, thanks for the tip.

I’d have to go dig out the code, but I believe it pulls it from one of the OH variables. Also once it sets then it holds in the thing config.

That worked for me too. Something is wrong with the special character handling in either the binding or OH.

Once the PR clears on my other binding I’m going to pull the cli interpreter into this one (it’s a copy/paste at that point). After that’s in, I may pull the 2fa into a channel so that it can be sent directly instead of as part of the thing config. It doesn’t make sense to me to have a one time use code as a thing config. I’d even consider pulling the password in to see if it resolves the special character problem. We ultimately use a login token anyway so there isn’t any particular reason to store the password either once the token is generated.

Is there a way to get the same ‘person detected’ in the binding that I see with the Ring app? I notice that “the kind of event” channel shows motion detection which is often some leaves on a branch near my door which the Ring app ignores. I would prefer to get notified only when a person is detected, not just motion. Is that possible?

I don’t see why we can’t as long as we’re getting that in the json. I don’t have a camera with that capability. If you can put the binding into trace, trigger two events (one motion, one person) and send me the two examples I can try to figure out what we need to pull out to adjust the alert.

Does this binding also supports motion/door sensor?

Thanks.

Is it a standalone device or part of the alarm?

Yes, I have a Ring Base Station, motion, contact sensor and an extender. When I scan for devices nothing is found. Oh and I was able to connect(ONLINE) Ring Account Binding Thing.

The alarm isnt supported yet. It uses a completely different websocket connection. I don’t have one so development isn’t the easiest. I may add it once we get merged in.

For @everyone watching this thread, I’m going to be posting a major update in the next few days. I’ve been hammering through several of the issues and features that have been lingering in the ether. I want everyone to note, there are several breaking changes. Again, SEVERAL BREAKING CHANGES.

The most severe at this point is that I’m officially moving the account thing to be a bridge. This is the preferred way to handle this structure now (it didn’t exist in the 2.5 days when the binding was created). Because of this, you will need to rebuild your things. You’re welcome to leave your item names the same so you don’t break rules/persistence/etc. But you will have to change the links to the channels/things. I’ll post more on this later.

Secondly, authentication is being handled a little differently as well. The troublesome refresh token has been moved out of the thing configuration so text based configs are now fixed. Also, as the username/password/2fa are effectively irrelevant once the token is generated, I’ve made a second mechanism for entering them via the karaf CLI. This way, your credentials are never stored where someone could in theory grab them later. Again, more to come on this.

Finally, a few annoying bugs (like the random thing that was setting /etc/openhab2 as the default video folder) have been found and crushed.

I’ll do a more formal list out once I get a solid jar, just making sure everyone sees that the next update WILL HAVE BREAKING CHANGES.

1 Like

First thank you!

I’m assuming this will still work under OH 3.2? I’m seeing a lot of github posts on 4.x around the Ring binding.

Best, Jay