Problems to connect to Gardena cloud service with the Gardena binding

Hi, I had to get a new API key from the developer site. The procedure to get it has been changed and the documention of the OpenHAB Gardena binding seems to be obsolete.
Now, the site https://developer.husqvarnagroup.cloud now asks for “Redirect URLs”. I entered “http://localhost:8080” and tried some other URLs with no success. The Gardena binding cannot connect to the Husquvaran / Gardena cloud.

What can I do? Any hint greatly appreciated.

Peter

I would like to point out that due to the change (I think API version has changed to v1.1) in the developer portal now asking for Redirect URLs new users of the Gardena binding cannot use the binding as long they do not supply a proper “Redirect URL”.
In my opinion, this renders OpenHAB’s Gardena binding useless when we do not find a solution for “Redirect URL”.

Any help / hint welcome!

First of all I am not the developer of the Gardena binding and I haven’t checked its code. I am not an expert of the Gardena API either. This means, that I can only make assumptions here. The binding has been deveoped and maintained by @gerrieg and he probably can explain better.

Currently the Gardena binding works at my site. All my Gardena things are online. I haven’t entered a redirect URL when I created a new API key some weeks ago. The site https://developer.husqvarnagroup.cloud hadn’t asked me for a redirect URL at that time. When I enter this site today, the URL “http://localhost:8080” is displayed in the upper left corner of the screen. This means, thta there must be a way to make it work without a valid redirectUrl.

The Gardena API is documented here. The README doesn’t list major modifications from V1.0 to V1.1. Husqvarna writes, that they want the clients of that API to use webhooks instead of websockets. They hope to lower the load on their service with webhooks. The webhooks require a listener on the client side to receive messages. I believe, this mechanism isn’t used by the current Gardena binding and I completely agree on that for security reasons. May the redirectURL be needed for those clients of the API only, that use webhooks?

Bodo, thank you for your detailed analysis.

In fact, everything is fine for “legacy” users as for me until one week ago. Then, I had to get a new API key from the developer’s site and suddently found the new entry “Redirect URLs”. Using “http://localhost:8080” as input I was able to get the APIkey in the usual manner. However, my openHAB cannot connect to the cloud using this key, producing an error " COMMUNICATION_ERROR Error 400 Bad Request, {“error”:“invalid_client”,“error_description”:“Client not found”,“error_code”:“client.not.found”}.
For 2 years I did no encounter any problems to connect so I assume entering “http://localhost:8080” as Redirect URL could be wrong and I am stil looking for a solution.

Edit:
“When I enter this site today, the URL “http://localhost:8080” is displayed in the upper left corner of the screen.” Do you mean this is in your brower?

“This means, thta there must be a way to make it work without a valid redirectUrl.” Sorry, I do not understand that.

Regards

I’m having similar issues today. Looks like the API has changed completely:

Gardena expects: a client ID and secret whereas the binding is sending a user/pass and grant type that is not supported

Gardena documentation:

curl -X POST -d “grant_type=client_credentials&client_id=626b4ecc-9b26-4f41-991f-bfdbaf94cc12&client_secret=xxxxxxxxxxxxxxxxxxxxx” https://api.authentication.husqvarnagroup.dev/v1/oauth2/token

Whereas the binding is sending:

https://api.authentication.husqvarnagroup.dev/v1/oauth2 /token, data: {“caseSensitive”:false,“fields”:{“client_id”:{“name”:“client_id”,“values”:[“626b4ecc-9b26-4f41-991f-bfdbaf94cc12” ]},“grant_type”:{“name”:“grant_type”,“values”:[“password”]},“username”:{“name”:“username”,“values”:[“tXxxxxxxxxxxxxxxx”] },“password”:{“name”:“password”,“values”:[“xxxxxxxxx”]}}}

Husqvarna API has been changed, so for all users which need new credentials the binding is broken. Obviously, API now requires API key AND secret. @gerrieg do you have time for a look at it?

I’m also facing issues as a new user – just wanted to let you know. I’ll be watching this thread for news. A huge thank you to the hard working developers out there; much appreciated!

fyi:

2 Likes

@gerrieg, thank you, I am now able to to connect to Gardena cloud.
Your work is much appreciated!
Peter

Apologies for asking (a potential stupid question;), but is there already a compiled .jar for this version, and where can I find it?

1 Like

https://ci.openhab.org/job/openHAB3-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons/target/openhab-addons-3.4.0-SNAPSHOT.kar

and put it in addons folder. Possibly, you need to reboot and clear openhab cache.

2 Likes

Thank you!

Hi,

can I use this also for the Husqvarna Automower?
As they have the same authentification or do I have to wait??

brgds

Hi,

thank you for fixing this issue. I tried to install the jar file, but I’m a little bit confused:

https://ci.openhab.org/job/openHAB3-Distribution/lastSuccessfulBuild/artifact/distributions/openhab-addons/target/openhab-addons-3.4.0-SNAPSHOT.kar

This link points to a “kar” file. Never heard of this file type. It is also quite big, about 350MB. Is this the right jar containing the updated gardena addon? Do I have to rename kar to jar?

Regards,
Boris.

EDIT: Ok, just realized I have to open this file with a zip program and pick the addon from repository\org\openhab\addons\bundles\org.openhab.binding.gardena\3.4.0-SNAPSHOT

1 Like

I’ve installed this new jar and deleted and recreated the application in the gardena developer site, than I added apisecret key as the new appkey. Unfortunately I still get the following error: Error 429 null, {“message”:“Limit Exceeded”}

Does anyone have and idea what do I do wrong?

Thanks in advance!

I had the same issue and recreated the application in the gardena developer site about 3 or 5 times. After several tries the bridge was online.

Hi @gerrieg

Thank you for your recent fix of the login problem. I installed the current jar and my bridge is back online. Unfortunately I have two issues with the current build, maybe you can have a look at it?

I have a mower thing. In openhab.log I found following warning message, nevertheless the battery state of the mover is displayed correctly by the item connected to the battery state channel. I don’t know what this warning message is about…

[internal.handler.GardenaThingHandler] - Value of propertyPath 'common.attributes.batteryState.value' can not be casted to Number: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')

Using the current build I have problems with german “umlaute”. This is a screenshot of my activity item of the mower. Do I have to change something in my configuration?

Best regards,
Boris

Wow, It solved the problem. Thank you!

Still: I don’t understand why did I get the limit error. It was working for months

'common.attributes.batteryState.value' can not be casted to Number: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') is reported for all Things.

There is a different thread discussing the “429: limit exceeded”, that popped up for many users just recently: