Garmin - control your Homey with your Garmin watch

Hi Ronny,

It’s -400 Error.
Then it says HTTP access error, error 417

Kind regards

Zsolt

Here it says: login to Homey … to many requests …Error -2

And it keeps trying to log in

@Wout-1976 @Zsolt_Kozma
I made some changes to prevent the “too many requests” error (Garmin allows only 3 parallel requests, perhaps less on newer devices) and force a re-auth on auth errors. I hope that will fix your issue. It would be nice if you can check it.
@Zsolt: If the widget can’t login at startup, you should get again the auth screen on the mobile automatically to reauth. :crossed_fingers:

Hi Ronny, I removed the app from my watch and downloaded it again. I went through the auth. page on my phone, allowed everything, but nothing has changed. Still -400 error, then HTTP access error 417.

What Homey user are you using? Owner, user or guest?

Owner

Kind regards

Zsolt

I reproduced the issue on a fenix7s. But all is ok on my 6xpro and in the simulator. I guess these newer devices are handling http responses in another way. Bad, that I can’t reproduce on the PC.
I have to do some debugging on the watch. This will need some time.

1 Like

Same with Epix, error -400

I have the same on 6sapphire

I have it working just fine on 6 Sapphire. Tried uninstalling and installing the widget again? I do also have two factor authentication enabled if that could have any affect on the login.

Edit: Phone running Android

Uninstalled and reinstalled five times.

For all users having the -400 error code after filling the auth screen:

I found the reason.
In short: The Garrmin API is not compatible with the Homey WebAPI.

The full story and technical details:
In the auth process, some API calls are done. After getting the auth/refreshtoken, the widget needs to login to Homey. Therefore two API calls are done causing this error.
The API result ist returning a body with a JSON value like:
grafik

But the Garmin API requires a JSON object instead like {id: value}. That’s causing the -400 error from the Garmin API.

It seems only newer devices are affected (new firmware?) like Fenix 6/7 or Epix.
Older devices seem to return the JSON string at least as plain text, so I can read it in the widget. But on affected devices, even trying to get the body as plain text doesn’t work.

So I have no chance to fix it. It would need an adaption from Garmin (allowing getting plain text body independent on the content-type) or from Athom (a new or changed API endpoint for returning plain text or JSON object). But that’s something I can’t prioritize.

At the moment I can’t fix this issue. Sorry for the behavior :worried:

PS: I’ll try to get a solution with a proxy to change the header fields.

A question to all users with the -400 error: Are you all using iOS on the connected phone? Or are there Android user affected?

For me it’s IOS

Hi,
I tested again with the devices I can use. It seems to be a bug in the GarminConnect iOS app.
The fenix7s with iOS is not passing back the http body as plain text (instead the -400 error is passed back). The same watch with Android does all right.
So it seems, iOS user are affected by this issue. I try to get some infos in the Garmin forum. Let’s hope Garmin will take this issue to the development team.

But independent of reading the API response as plain text, it’s still a problem of the incompatibility between GarminAPI and HomeyAPI in case of JSON values instead of plain text or JSON object. So reading the response as plain text ist only a workaround - working on Android only.

I don’t know if a watch with Wifi enabled and not connected to the iPhone (BT disabled) will work. That’s something you could try.

Version 1.3.0:
The app category is added based on new API scopes.
If you get an http error, please log off from Homey (widget menu) and log in again to get the new scopes/rights.

Yes iOS

I’ve tried today with the latest update. Unfortunately no luck. See the attached picture.

Kind regards

Zsolt

Yes. it’s the expected message for the iOS issue. Only readable text instead of error code.

I get some funky behavior when entering the flow section of the app. The picture below is what I see first: 1/5 flows, and “Flow not found”, I actually have 7 favorite flows. If I scroll down I get 2/8 flows and “Kaffitrakter” (second image). They all work just fine, so nothing problematic really, just wanted to let you know :slight_smile: