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
70 stars 12 forks source link

Venu 3 - application doesn't start #121

Closed silcrox closed 4 months ago

silcrox commented 5 months ago

Hello,

The application doesn't start in my Venu 3.

I have hime assistant running in docker in my NAS on my lan.

I have set up an https access using let's encrypt.

In my home router I associated the domain used for the certificate to the local ip of the home assistant.

I configured home assistant to expos the rest api.

I created a never expiring access token.

I can access the api url correctly from one pc of the same lan.

--> Bug: in the application on my watch I see : API: not available Menu: not available

If I click on it I see the error message : "No answer, check your internet connection"

Thanks in advance for any advice

bjobo commented 5 months ago

For my Venu 3s it works flawless

silcrox commented 5 months ago

Maybe it is because I am on my private lan No idea...

I would like to see the logs of the app but I dont know how

bjobo commented 5 months ago

I'm only using Home Assistant and the app on my local network.

I'm sure you already checked, that your Garmin is connected to your phone and the phone is in the same network as your Home Assistant server (I suppose you're using the HA companion app on this phone and it works).

I forgot on my first try to add '/api' to the config url. Perhaps you could again check your URLs and the API token?

silcrox commented 5 months ago

Yes they are all in the same network. I didn't use the the HA companion app but I will try. Normally I control l every thing in HA via browser on a PC on the same network.

I put the right url ("/api") in the config. I also tested via pc the api is reacheable with long life access token and it is.

I will try to test HA companion app on my phone.

So the watch access HA via paired phone? I thought directly via wifi network...

Anyway thansk a lot for your hints and time to write the message.

bjobo commented 5 months ago

Yes, it seems to work via phone only. When I disable Bluetooth or WiFi on my phone, it stops working. However, for my use case, this is sufficient.

silcrox commented 5 months ago

In fact I installed HA app already, I forgot .. And it works well, with phone connected on the same wifi network.

No idea of what's wrong. I will review the json schema and configuration file. It is a pity not being able to see logs

silcrox commented 5 months ago

I tested wit the troubleshooting page and everything seems to work there, but still not on my watch :-(

I tested it directly from my android smartphone, that run the Garmin Connect app.

I went to this page: https://house-of-abbey.github.io/GarminHomeAssistant/web/

And cut and paste the api url, the menu url, the token, directly from the settings of the home assistant garmin app. No possibility of mistake.

No idea of what's wrong with the app running in the watch...

Capture

philipabbey commented 5 months ago

Thank you for using the troubleshooting page, that filters out much of the silliness. So if the page at https://house-of-abbey.github.io/GarminHomeAssistant/web/ works, then essentially it works. So you just need to figure out what's up with your watch.

So the watch access HA via paired phone? I thought directly via wifi network...

The watch connects via BlueTooth to your phone, then by Wi-Fi/mobile access to your HA server. We've had people claiming their watch is Wi-Fi capable before (my Venu2 is), but they are mistaken. If the watch was on Wi-Fi all the time, the battery would be dead(er). So you must have your phone in Bluetooth reach, and the watch must be paired and sync'ing via the ConnectIQ app.

Are you using an iPhone by any chance? If so see the known issues and then have a moan at Apple! https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/README.md#known-issues

It is a pity not being able to see logs

You get what HA gives you for logging.

Good luck! And thanks @bjobo for fielding the replies in the meantime.

philipabbey commented 5 months ago

This will be a "bug" when I confirm it is.

silcrox commented 5 months ago

Thanks a lot Philip for your reply. And also to have created that troubleshooting page, I was happy my self to see that my parameters were configured well.

Happy to know also that the wifi connection from the phone is not the guilty one, as it connects via Bluetooth to the paired phone and then the phone "talk" with the ha server.

I am using a samsung s21, and yes my phone is always at reach of the watch and connected to the the wifi network where ha is running (I am using a docker image of ha running on my nas).

I will see logs on ha to see if at least it receives http requests from the phone when I run the app on the watch.

Thansk again for your work and for the hints.

philipabbey commented 5 months ago

If the HA app works on your phone, and your watch sync's via your phone, and that web-based editor worked, then there is little else that can be wrong, other than your app settings. Check for rogue spaces in you settings.

--> Bug: in the application on my watch I see : API: not available Menu: not available

URLs are not correct or no Internet access. I know you said you copied & pasted...

Do you get an error message when you start the main app?

philipabbey commented 5 months ago

Have you made any further progress with resolving this issue?

silcrox commented 5 months ago

No sorry. I didnt have time to investigate and it will be the case also for the next 2 weeks.... :-( I have the feeling that no http request is triggered from my phone where garmin connect is running towards HA...

philipabbey commented 4 months ago

Guessing: DNS resolution?

silcrox commented 4 months ago

In my home network the ha host (associated to the lets erncrypt certificate) is translated correctly to the local ip. In fact if i put the same url I put in your app in chrome running on the same phone where garmin connect is installed, I can reach both the api and the menu.

Now I have the doubt that garmin connect doesnt use my home network dns, but an external one. If that is true than I have to open the ha port (the hostname is translated to my external gateway, but there all traffic is blocked).

I will try this evening. If not I have to see logs, both in my router and in ha server.

Thanks again

silcrox commented 4 months ago

Just did a test, but no luck again. I will have to troubleshoot in the logs.... I opened the port on my router and redirected to the ha instance, I can correctly access my ha server from internet (of course in https). Then I reinstalled and re-configured the app but I have the same behavior, If I open the app on the watch I get the messages:

API: not available Menù: not available 960701f8-4c6c-4687-9c52-fa73fdf08d1a

No answer: check your internet connection 1e321e09-dab0-470d-9f0c-2a8bff95d641

philipabbey commented 4 months ago

In fact if i put the same url I put in your app in chrome running on the same phone where garmin connect is installed, I can reach both the api and the menu.

Okay, this information confirms all is well, and really should be solvable. But the problem does seem to be peculiar to your own setup so I'm afraid I can be of no further assistance.

Good Luck.

silcrox commented 4 months ago

No silly questions in IT stuff, every check or doubt can bring to the solution :-)

I would love to have the logs of the app it self, but I will start from having a look if the request comes to my router. Considering how quick the app on the watch tells me "No internet connection" I have the strong doubt that the request is not even triggered by the phone....

thanks for your time anyway I appreciated it very much.

philipabbey commented 4 months ago

I would love to have the logs of the app

The app makes no logs. For the logs to be useful, they woudl flood the SD RAM. But it does give you the error messages. Not sure the logs would be able to provide any more information even if theoretically they could be made.

philipabbey commented 4 months ago

Just had a thought as I was pondering this issue.

You are running on a private LAN with Let's Encrypt for HTTPS. That means the Garmin Watch can't verify your domain name locally for the certificate, whilst the on-line editor can because it is public.

You need to set up a local LAN DNS resolution for your domain name from your certificate so the watch will trust your HA. E.g. a host file entry.

silcrox commented 4 months ago

Hi Philip,

I already had the host-->privateIp mapping in my router. That's how I could use the hostname for which I created the certificate letencrypt even in my local network.

I also tried to open/redirect the HA port on the public IP. I could indeed access my HA from internet but still the app shew me the same error message: "no answer, check your internet connection"

Il Gio 21 Mar 2024, 19:47 Philip Abbey @.***> ha scritto:

Just had a thought as I was pondering this issue.

You are running on a private LAN with Let's Encrypt for HTTPS. That means the Garmin Watch can't verify your domain name locally for the certificate, whilst the in line editor can because it is public.

You need to set up a local LAN DNS resolution for your domain name in your certificate so the watch will trust your HA. E.g. a host file entry.

— Reply to this email directly, view it on GitHub https://github.com/house-of-abbey/GarminHomeAssistant/issues/121#issuecomment-2013296529, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATOJVH3QK5W75SNYMIAXHC3YZMTKPAVCNFSM6AAAAABEYWM3J2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJTGI4TMNJSHE . You are receiving this because you authored the thread.Message ID: @.***>

silcrox commented 4 months ago

Hi Philip, thanks another time for your idea/advise. I sent you by mail the diagram of my private network.

In fact I already had the host-->privateIp mapping in my router.

That's how I could use the hostname for which I created the certificate letencrypt even in my local network, from my phone browser for example.

I also tried to open/redirect the HA port on the public IP. I could indeed access my HA from internet but still the app shew me the same error message: "no answer, check your internet connection"

:-(

JosephAbbey commented 4 months ago

This may also be caused by the private DNS setting on your phone, this setting forces your phone to use a trusted DNS server, so will prevent it finding your DNS record.

This can be turned off in the more connectivity options page of your phone's settings, or search for "Private DNS".

silcrox commented 4 months ago

That is a very good idea. Let me try.

philipabbey commented 4 months ago

In fact I already had the host-->privateIp mapping in my router.

Yeah, I don't think that covers the function of DNS. Surely that's about serving IP addresses under DHCP?

I'm not yet convinced that is sufficient. I'm looking at this per device. Does your router server DNS to your LAN. Does each device on your LAN have the router as the DNS server? I think your phone needs to be able to resolve the DNS of your Let's Encrypt certificate. I bet you didn't create that certificate on your phone, so you have not convinced me the phone can resolve local DNS. You created that certificate on a host that could resolve the domain name. The key thing here is your phone must be able to complete the lookup. Perhaps you've already verified the certificate in your phone's browser, in which case you should be fine?

We solved a similar problem locally when I cut the Internet coaxial cable with the garden sheers. (I was unpopular for that.) In order to make HA still work, we needed to resolve the external name home.something.something.uk within the LAN. So we added a lookup for that in dnsmasq on the Raspberry Pi so we could resolve the same domain name without leaving the LAN (owing to being an Internet island at the time). That saved us switching various settings between the public domain name (served via a dynamic DNS service) and homeassistant.local.

philipabbey commented 4 months ago

This may also be caused by the private DNS setting on your phone, this setting forces your phone to use a trusted DNS server, so will prevent it finding your DNS record.

This can be turned off in the more connectivity options page of your phone's settings, or search for "Private DNS".

Google's most unhelpful page on the topic: https://support.google.com/fi/answer/2819583?hl=en#zippy=%2Cprivate-dns

silcrox commented 4 months ago

This may also be caused by the private DNS setting on your phone, this setting forces your phone to use a trusted DNS server, so will prevent it finding your DNS record.

This can be turned off in the more connectivity options page of your phone's settings, or search for "Private DNS".

I tried but no change

silcrox commented 4 months ago

In fact I already had the host-->privateIp mapping in my router.

Yeah, I don't think that covers the function of DNS. Surely that's about serving IP addresses under DHCP?

I'm not yet convinced that is sufficient. I'm looking at this per device. Does your router server DNS to your LAN. Does each device on your LAN have the router as the DNS server? I think your phone needs to be able to resolve the DNS of your Let's Encrypt certificate. I bet you didn't create that certificate on your phone, so you have not convinced me the phone can resolve local DNS. You created that certificate on a host that could resolve the domain name. The key thing here is your phone must be able to complete the lookup. Perhaps you've already verified the certificate in your phone's browser, in which case you should be fine?

We solved a similar problem locally when I cut the Internet coaxial cable with the garden sheers. (I was unpopular for that.) In order to make HA still work, we needed to resolve the external name home.something.something.uk within the LAN. So we added a lookup for that in dnsmasq on the Raspberry Pi so we could resolve the same domain name without leaving the LAN (owing to being an Internet island at the time). That saved us switching various settings between the public domain name (served via a dynamic DNS service) and homeassistant.local.

About the DNS used by the devices connected to the lan I need to check but I think they use the router (that at its turn uses my gateway that at its turn uses some public DNS).

PS I found an option in my router (openwrt) to log each DNS request ... I will check if requests for myhostname arrive.

silcrox commented 4 months ago

Logs of my router when I launch the GarminHA on my watch:

Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: 529 ipv6_of_my_phone/43740 query[AAAA] myhostname from ipv6_of_my_phone Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: ipv6_of_my_phone/43740 forwarded myhostname to ipv4_of_my_gateway Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: 529 ipv6_of_my_phone/43740 forwarded myhostname to ipv6_of_my_gateway Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: 530 ipv6_of_my_phone/20570 query[A] myhostname from ipv6_of_my_phone Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: 530 ipv6_of_my_phone/20570 /tmp/hosts/dhcp.cfg01411c myhostname is ha_local_ip Thu Mar 21 22:41:33 2024 daemon.info dnsmasq[1]: 529 ipv6_of_my_phone/43740 reply myhostname is NODATA-IPv6

It looks like 2 dns queries arrive: the first one is forwarded to the gateway DNS, the second one is answered correctly with the HA local ip

philipabbey commented 4 months ago

Silly question coming up...

How do this DNS queries compare with the domain names used in your Let's Encrypt certificate? Including any alternate names you might have used.

ConnectIQ API is strict about the HTTPS. The API calls fail, and provide little reason, just failed. ConnectIQ needs to verify the host declared in the certificate, and resolve to the correct IP address, which is different when checked publically to privately. If the checks fail, no HTTP.

If you are already getting the JSON menu into your phone's browser, then there's nothing else that can go wrong apart from the application settings... so we've been here before.

Try a DNS change app on your phone? Control where request are getting sent.

silcrox commented 4 months ago

I confirm that the troubleshooting page running on the browser of the same phone running garmin connect works well. And I confirm that the exact same configuration is set in the garmin home assistant app.

I got the DNS logs in my router after triggering 3 requests: 1) opening the garmin ha app 2) testing menu in troubleshooting page 3) testing api in troubleshooting page

the logs after 1) miss the http requests that are triggered just after in case of 2) and 3)

it has something to do with the certificate and https validation and the DNS. I will check in coming weeks after coming back home. Because tomorrow I will leave for one week for my work.

once again thank you Philip and everybody else who tried to help me. PS: feel free to close the bug if you want/need.

philipabbey commented 4 months ago

Closed as suggested by @silcrox.