Home Assistant App for Garmin

I dont know what happend but after restart watch it start working. Before after start app from watch was just black screen and after while error come out.

I think I can explain what happened to you. It just happened to me. First l had the Communications.BLE_QUEUE_FULL (-2), then a “No Internet connection” the next time. Next time, try moving within Bluetooth range of your mobile phone and trying again.

Now I’ve put in code to try and detect the “out of range of your phone” condition using System.getDeviceSettings().phoneConnected and System.getDeviceSettings().connectionAvailable, but wasn’t expecting it to come up with a Communications.BLE_HOST_TIMEOUT as that indicates there was Internet when the HTTP request was initiated.

It wouldn’t have helped you on this occaision, but I could perhaps make the “No Internet connection” more precise based on phoneConnected and connectionAvailable results.

I think a low-hanging fruit would be to display the status of any entity, with the possibility to override the name/title of the entity on the JSON.

I could imagine the use cases being here showing the outdoor/indoor temperature, charging status of an EV vehicle, perhaps the zone a specific user is in etc. All of these would be made possible with the above.

Also, thank you for implementing this. It’s been rock solid for me since I got the setup working.

Wow nice project! Using hass control improve for now, but will definitely try this project tomorrow!

Another cool feature would be changing brightness of lights, not sure how that would work on a small screen on the watch though.

Two tap buttons for increase and decrease brightness, volume, cover etc. I already do this on an HA dashboard.

1 Like

Thank you for this project. Would be possible to do some manual for dummies? I have a Nabu Casa Cloud, I have created the json file on the HA, but I am getting -400 error on watch. I have put json here
image

And setting in Conect is:

  1. Pernament API from HA
  2. URL API: https://<>.ui.nabu.casa:8123/api
  3. URL menu: https://<>.ui.nabu.casa/local/garmin/garmin_menu.json

I had to do something wrong, but I am not sure :confused:
Thanks

Tom

Hi Tom,

We’re not using Nabu Casa Cloud for our public access, so I am not familiar with your particular setup and constraints. Its these variations that make doing a “manual for dummies” slightly hard, and why we opted for generic URLs. Our dummies guide is the README.md! That way the responsibility for setting up URLs and APIs is not our responsibility! That said, when you find the solution, please post it on this thread for others to find.

There’s another discussion providing some clues at Use Nabu Casa URL to use HA API? Their API URL is similar, but without the default port for HA (8123), which I assume is HTTP not HTTPS and hence you are not connecting to the HTTPS server which would be on port 443 (no need to specify in the URL). So try https://<>.ui.nabu.casa/api?

I’m also a nabu casa user. I’m getting error code = 0. Maybe you could share all the error codes?

And it took me a while, but for anyone else. The app isn’t a glance but as an activity sort of

Error codes can be found here:

https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html#Error-module

API documentation from the links above.

Error code 0 is the most unhelpful description, “unknown”! Good luck with that one…

1 Like

And it took me a while, but for anyone else. The app isn’t a glance but as an activity sort of

Correct, the app has no glance view implemented (yet), hence it does not get added to the carosel. But it is an App, and gets listed with the other apps that include activities too.

Great app, works fantastic. Thank you for your work. One question I have.

In the json file, the word “tap” (behind the “type”) is frequently used… In my Garmin it shows up as “Kraan”, which is the dutch translation of the word “tap”. Any idea how to fix this?

Hope to hear from you.

In the json file, the word “tap” (behind the “type”) is frequently used… In my Garmin it shows up as “Kraan”, which is the dutch translation of the word “tap”. Any idea how to fix this?

We’ve implemented an automatic translation override. Please indicate the preferred word for “tap” as in “press and don’t hold”. Perhaps “Tik”

Tap on the window
Tap in the sink
Tik op het raam
Kraan in de gootsteen

I’ve just published a new version (1.4) which will alleviate the problem by allowing you to choose not to have the second row of text which is instead replaced by an icon thanks to a code contribution from a user.

Thanks for the quick reply. I think I will have a go with the 1.4 version. I have said it before, this is a great app.

1 Like

Unfortunately I cannot get this to work. I simply get a “-400 Response body data is invalid for the request type.” error.
I’ve double checked my API key, json url and api but can’t find anything wrong with it. I am using HA behing a NGIX proxy and 2FA setup but I guess that should not really matter…

As you will see from the link to the error codes above, -400 relates to INVALID_HTTP_BODY_IN_NETWORK_RESPONSE.

That suggests to me that your webserver is returning something other than JSON in its reply. In this situation the reply is often plain text with an error messages, e.g. about authentication failure, or a problem serving the URL. The former suggests the API key might not be right, e.g extra spaces front and end. The latter can be checked by browsing to the intended URL and checking JSON is displayed.

Due to the limits of the Connect IQ API, I cannot get the plain text before the function call parses the expected JSON in order to display it. Perhaps I could make a second call and request plain text for displaying the error…

Thanks. I’ve double checked the API key and also created a new one. The json is being displayed when I copy and paste the URL in the browser which is why I am at a loss as to why this doesn’t work…

Do you make use of the JSON schema validation?

If your file is served from Home Assistant as in our example in the README.md, then you should have schema validation working already.

Yes. The JSON is served from: https://myurl.com/local/garmin/garmin.json
and the json itself simply contains the following:

{
“$schema”: “https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json”,
“title”: “Home”,
“items”: [
{
“entity”: “light.nano_dimmer”,
“name”: “Bathroom”,
“type”: “toggle”,
}
]
}

I think that trailing comma after "type": "toggle", has a bad effect. I tried adding such a comma to my own JSON and got the -400 failure.

Try this:

{
  "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
  "title": "Home",
  "items": [
    {
      "entity": "light.nano_dimmer",
      "name": "Bathroom",
      "type": "toggle"
    }
  ]
}

Seems like I am getting closer. I removed the comma and now I am still getting the error but when I swipe back on the watch (left to right swipe) I briefly see the switch but it goes immediately back to the original -400 error…

Hmm. Thinking out loud. It sounds like you have got the menu config URL with JSON working. The next error is likely to be a failure to update the present toggle’s status. That means an issue accessing the API to query the switch’s present state.

Do you have the means to use curl? If so, you should be able to check that when you substitute API_KEY and URL below, you get JSON back.

curl -s \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_KEY}" \
  "${URL}/states/light.nano_dimmer"

The above was used on a Raspberry Pi (Linux), but Windows has curl these days, just different variable substutitions.

I also note that your HA installation did not manage to verify the JSON schema correctly. You might want to install:
image
to edit the JSON file.