Home Assistant App for Garmin

GarminHomeAssistant ia a Garmin application to provide a “dashboard” to control your devices via Home Assistant. You can find it on the Connect IQ store. The application will never be as fully fledged as a Home Assistant dashboard, so it is designed to be good enough for the simple and essential things. Those things that can be activated via an on/off toggle or a tap. That should cover lights, switches, and anything requiring a single press such as an automation. For anything more complicated, e.g. thermostat, it would always be quicker and simpler to reach for your phone or tablet… or the device’s own remote control!

Actual_Venu2_Theme

The application is designed around a simple scrollable menu where menu items have been extended to interface with the Home Assistant API, e.g. to get the status of switches or lights for display on the toggle menu item. It is possible to nest menus, so there is a menu item to open a sub-menu. This can be arbitrarily deep and nested in the format of a tree of items, although you need to consider if reaching for your phone becomes quicker to select the device what you want to control.

It is important to note that your homeassistant instance will need to be accessible via HTTPS with public SSL or all requests from the Garmin will not work. This cannot be a self-signed certificate, it must be a public certificate (You can get one for free from Let’s Encrypt or you can pay for homeassistant cloud).

Configuration instructions are provided via the GitHub repository. This is essential reading due to the need to configure a “dashboard” via a JSON definition file served from your Home Assistant instance.

This application is offered FREE to the community in order to give back to it when we have personally taken so much from the contribution of others. Please be kind and helpful with your feedback! Or better still offer code contributions to the project. You will need to want to dabble in “Monkey C” code to do so.

Feel free to use this thread for discussion and support. More fully thought out bug reports and feature requests best go via the GitHub project. I am currently investigating why some Garmin devices are not supported immediately when they have the same API requirements as those that are already included.

23 Likes

Nice work @NP_Complete!

My Fenix 6 Sapphire isnt supported yet but keep up the good work!

More devices on the way.

1 Like

Thanks, looking great! I have been using HassControl, but it is limited to activating scenes only. Speaking of which, this supports scenes as well, right?

Hoping to see the Frontrunner 745 being added as well :).

Forgive me I don’t use scenes, it just requires a tap rather than a toggle right? So I would have to investigate by setting one up and determining the API call for it. Weekend of code coming…

1 Like

Yes indeed, there is no way to turn off a scene or ‘deactivate’ one - you just activate a scene to e.g. turn on the correct lightning for watching tv. This is coincidentally my biggest use case for the HassContol app as I am too lazy to get up from sofa to pick up my mobile :).

I’ve just published v1.1

  • Support for 80 devices, 54 new ones added
  • Scene support
  • Added vibrate acknowledgement for tap-based menu items. Falls back to a custom visual confirmation in the absence of ‘toast’ and vibrate support.
  • Bug fix for large menus needing status updates
  • If you request changes too quickly you will be given an error message “API calls too rapid” as the device cannot keep up with the rate of responses.
2 Likes

Thanks a lot!

Tried installing this, but for the love of it I cannot get the application to start. The watch just displays an ‘IQ(!)’ logo briefly and dies. Not sure if there’s a way to get debug logs - cannot find anything relevant in HA’s own logs.

I have:

  • Created a long-lived access token (tried several to make sure it was not a typo somewhere)
  • A publicly-available domain with SSL
  • The json definition hosted at HA (which opens e.g. from the browser when testing).

My watch is Forerunner 745.

This is my JSON. Any help greatly appreciated.

{
    "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
    "title": "Bondegatan",
    "items": [
        {
            "entity": "scene.tv",
            "name": "TV lights",
            "type": "tap"
        },
        {
            "entity": "scene.work",
            "name": "Work lights",
            "type": "tap"
        },
        {
            "entity": "scene.work_w11",
            "name": "Work VM",
            "type": "tap"
        },
        {
            "entity": "scene.morning",
            "name": "Morning",
            "type": "tap"
        },
        {
            "entity": "scene.night",
            "name": "Night",
            "type": "tap"
        }
    ]
}

Evening @henrikbla

So we had to amend the JSON format for scenes (services) to work. You are missing a JSON field. This is covered by the updated README.md.

    {
      "entity": "scene.tv_light",
      "name": "TV Lights Scene",
      "type": "tap",
      "service": "scene.turn_on"
    }

However, the application crashing is concerning, as I am missing some error checking at runtime. We are heavily relying on the JSON schema checker and the “service” field is optional, which means it does not detect when it is necessary. The application needs to do better than crash in this instance, so I will debug with your format in due course.

Thank you for your submission.

Thanks again. Thought I had searched for a sample for scenes, but looks like I missed it.

However, the problem seems to lie elsewhere :(. Even with the updated JSON I still get the same problem. See below for current version.


{
    "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
    "title": "Bondegatan",
    "items": [
      {
        "entity": "scene.tv",
        "name": "TV lights",
        "type": "tap",
        "service": "scene.turn_on"
      },
      {
        "entity": "scene.work",
        "name": "Work lights",
        "type": "tap",
        "service": "scene.turn_on"
      },
      {
        "entity": "scene.work_w11",
        "name": "Work VM",
        "type": "tap",
        "service": "scene.turn_on"
      },
      {
        "entity": "scene.morning",
        "name": "Morning",
        "type": "tap",
        "service": "scene.turn_on"
      },
      {
        "entity": "scene.night",
        "name": "Night",
        "type": "tap",
        "service": "scene.turn_on"
      }
    ]
  }

I have a thought, may be an assumption made in the code that there exists at least one item needing its state to be updated. So if there are none, as in your example, it could be dereferencing a zero length array.

If so, that’s poor testing on my part. Will take a look later.

Update: Bug found, new version coming.

1.2 released with the following bug fixes:

  • Do not crash on zero items to update
  • Report unreachable URLs
  • Verify API URL does not have a trailing slash ‘/’
  • Increased HTTP response diagnosis
  • Reduced minimum API Level required from 3.3.0 to 3.1.0 to allow more device “part numbers” to be satisfied.
2 Likes

Oh yes, works now! Thanks a lot. And no need to apologize, I work a lot with devs in my daily job and this is very good quality, especially given that you’re doing this for free.

One slight correction: Your sample shows the API URL with a trailing slash - yet, the app expects the API URL to be without the trailing slash.

To think about this a little more, you might even leave the API URL as optional and assume it is the same host + /api as what has been inputted for the menu configuration, if nothing else is stated :).

That’s been addressed in the latest README.md thanks to some user feedback.

My thought on this was to allow separation of the URLs and not assume where the menu might be defined.

I’m delighted the App is now working for you, thanks for your patience and assistance.

Regards,

Philip

Can you please help me to set it up?

I´ve got error -2
My setup in ap
1 field token created in HA
2 field url api in form https://mydomain.duckdns.org:8123/api
3 field url for menu https://mydomain.duckdns.org:8123/local/garmin/garmin.json
garmin.json is stored under www/garmin/garmin.json

my garmin.json is :

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

You’ve just downloaded v1.3 which improves the error reporting.

Error “-2” is defined as Communications.BLE_HOST_TIMEOUT.

We’ve just fixed a problem causing Communications.BLE_HOST_TIMEOUT in v1.3. Thanks to another user we’ve discovered a difference between emulation in testing and real devices. We’re still hunting down the exact cause of this difference as to why an HTTP PUT does work in emulation where we don’t observe the problem and real devices where we are sure the HTTP PUT did used to work but does not now. However, this fix is for the “tap” menu item not the “toggle” one.

As the timeout can be quite long, I’m going to guess that you pressed several menu items in sequence, and this timeout actually relates to an earlier press on a “tap” menu item. Is that possible?

If so, we have a solution. You will notice from README.md that we’ve amended the JSON format so that every “tap” has a ‘service’ field.

In retrospect, it looks like we need to implement a forced rejection of menu items if the service tag is missing as the timeout error is widespread and there is no chance of a transition period.

Can you you also add a service field to any ‘tap’ menu items?

{
  "$schema": "https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json",
  "title": "Home",
  "items": [
    {
      "entity": "script.food_on_table",
      "name": "Food is Ready!",
      "type": "tap",
      "service" : "script.turn_on"
    }
  ]
}

Please can you reply indicating if I’m on the right track?

Hi,
Thank you for your reply. 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. And I dont think that was problem with multiple press because in menu i´ve only one togle for test.
But now it is working so it is perfect.
One more question can you in future add possibility to show data from sensor? for example outdoor temperature ?

One more question can you in future add possibility to show data from sensor? for example outdoor temperature ?

That’s been a subject of discussion. At what point do we stop trying to be the full fledged Home Assistant Dashboard?

The way I see it, we use Home Assistant and a mobile phone for those things we’re too lazy to get on our feet to operate. We use a watch for those things we are too lazy to reach for the mobile phone to operate. Its a triage process, and the watch just fields a small number of “favourites”.

We could implement:

  • Toggle status display, e.g. garage door open/closed
  • Numeric display, e.g. Fixed text + temperature
  • text display, e.g. Fixed text + status text

I wonder what the wider user community would appreciate here? Question open to other replies.

2 Likes

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.

1 Like