house-of-abbey / GarminHomeAssistant

Garmin application to provide a dashboard to control your Home Assistant
https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348
MIT License
91 stars 12 forks source link

GHA over Wi-Fi #142

Open philipabbey opened 4 months ago

philipabbey commented 4 months ago

@brunoleon suggested it should be able to make the application work over Wi-Fi, see https://community.home-assistant.io/t/home-assistant-app-for-garmin/637348/270. Previously we have looked into this but not found a way. @brunoleon has provided some sample code at https://github.com/brunoleon/garmin-ha-wifi-test.

  1. Evaluate the sample code, check it works on own Garmin Venu2.
  2. Identify how this solution can be added to the Application (not Widget) version of GarminHomeAssistant.
mortenmathiasen commented 3 months ago

Awesome app, but it requires bluetooth connection. What is the status of supporting WiFi?

philipabbey commented 3 months ago

Not great. There's been a suggestion it can work, but so far we've not had any success. The "Sync" process over Wi-Fi is for sync'ing (e.g. FIT files), and is not immediately available for general HTTPS, not as far as we have found. This issue is dragging on, and too many people seem to believe because they have Wi-Fi on their watch this must be possible. We're still looking to see if we can hijack the sync process for HTTPS, but we'll need to take the whole process apart and see if we can pretend to be sync'ing. Then we may have to re-architect the App as there are multiple GET requests over Bluetooth that the App needs to work, and the Wi-Fi sync process has an overhead we can't afford more than once.

To be honest, the request is a bit of a nightmare presently

Wi-Fi has additional demands over Bluetooth, e.g. its more power hungry (discharging your watch battery), and I'm sceptical it will deliver the benefit people want and take dispproportionate effort to code.

brunoleon commented 3 months ago

I think that it might be wise to be able to explicitely enable wifi when you need it for a feature (I mean an option in the json config you provide to the app)

ex: I need a wifi fallback for opening my garage door, for updating a widget I don't care and prefer to save battery

philipabbey commented 3 months ago

Except you need to enable Wi-Fi to get the JSON config (unless cached). Again possible, but new failure modes to code around. The usually off nature of Wi-Fi makes for a quite different proposition. A re-design even.

philipabbey commented 1 month ago

I've finally got around to looking at this more closely. I've simplified the code, and removed a class. Here's a video of the transfer of a single file. The purpose of the demo is to get the text field "Okay" from the JSON file printed in the watch view.

https://github.com/user-attachments/assets/81624bed-a044-42ff-8ffa-fd5890746343

This does pose a few questions about how to integrate Wi-Fi based HTTP GET & POST requests in the application as originally feared. Naively we could sync for each GET/POST request, but that's actually impractical since we start with the Webhook IDs, then move on to the menu, then the updates (which might be easier now we've moved to a single update request for all menu items), then we have to start a sync for each action, and then the next round of updates too.

Ideally we would start the transfer and keep the sync going for multiple requests, until the app is closed. That means covering the sync view up with the menu view over the top. Perhaps not impossible. And we have made the job easier for ourselves with v2.19 (single update request). Integration remains risky at best and potentially disruptive. Starting up a sync makes HTTP requests significantly laggy, but I expect those asking for the functionality are happy with that.