qJake / HADotNet.CommandCenter

📱 A web-based, wall-mountable command center for Home Assistant.
https://hacc.dev
Apache License 2.0
158 stars 11 forks source link

HACC unable to reach Homeassistant Instance #109

Closed wretanhewe closed 3 years ago

wretanhewe commented 3 years ago

Description

When setting up a new docker container of HACC, and inputting my Base URL and Long-Lived Token, I get the error: "The settings entered are not valid. HACC is unable to reach your Home Assistant instance. Try your entries again, consult the setup guide for help, or check the logs (console) for more information."

And in the logs of the Docker container I see on repeat:

HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
     Can't initialize HACC API, missing the base URL.

Which seems sensible. I've not told it where to connect yet, because that value IS missing. So, going to the wbepage and after I enter my settings, I see in the logs:

HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
 Initializing HACC API with URL http://192.168.###.###:8123 and access token [••••••••••I]
Unexpected response code 0 from Home Assistant API endpoint /api/discovery_info.
 Invalid system settings entered, or unable to reach Home Assistant with the specified information.
 at HADotNet.CommandCenter.Controllers.AdminController.Settings() in /src/HADotNet.CommandCe nter/Controllers/AdminController.cs:line 67
  at HADotNet.Core.Clients.DiscoveryClient.GetDiscoveryInfo()
  at HADotNet.Core.BaseClient.Get[T](String path)

I found that the API /api/discovery_info exists to provide URL and port info (among other things) as per the HTTP component, but I dont know what would cause it to return response code 0?

A long time back (a year maybe?) this configuration, with whatever versions were available at the time, was functional.

Environment

I'm running HACC 1.0.22 in a docker container, on a Synology NAS, DS418-Play Homeassistant Core is also running, Version 0.118.4 on another docker container on the Synology NAS. Both are using the "host" network settings, so the NAS IP followed by Port number (8095 and 8123 respectively) are the routes to access. I can get to both webpages from any computers in the network.

I've confirmed via telnet inside the terminal of the HACC container that it can connect with HomeAssistant at the IP and Port 8123. I've added firewall rules in case that was an issue, and even tested after removing the firewall. I've tested making HACC in a container with the "bridge" type connection, if somehow both containers using the host network settings were causing a problem (however, that was not an issue when it had worked a long time ago). I've tried tiny different syntax changes to the IP address, just in case, with no change. (The spaces after "http://" are intentional here, so the text doesn't hyperlink. I'm not immediately seeing an option for disabling automatic hyperlinking on text)

I found only Issue #89 here which seemed perhaps to be a similar problem? But by the end of that issue, it was functional in HACC version 1.0.18 (currently I'm running 1.0.22). Checking my Configuration.yaml, I did not have the HTTP component enabled (as brought up in issue 89, but I never had before either, and it had worked way back when.) I proceeded to enable HTTP with no extra fields. No luck. I added Server_port and base_url to the HTTP component. No luck. (Homeassistant complains that Base_URL in this context as deprecated, so since that didn't fix the issue, I just took it back out. This URL is set in the settings webpage, as well as any external URL's, so I guess that's where this info has "moved" to in newer version of HomeAssistant)

Summary, I'm on up to date Homeassistant and HACC. I can access each instance. I've tried new Tokens to confirm I'm using good and active ones, I've confirmed the HTTP component is configured, and that the containers can see each other, and no firewall/routing problem is preventing their access to each other, and adjusted Syntax on the Base Url in HACC settings.

Steps to Reproduce (at least for me, this is abnormal behaviour)

  1. Running instance of Homeassistant-Core on Synology Docker Container
  2. Create Docker instance of HACC on same Synology host
  3. Create new Long Lived Access Token for HACC
  4. Enter my base URL in HACC settings (http://192.168.###.###:8123) and Token.
  5. Error is shown, no connection is made.

Screenshots

Screenshot_Linux_20201203_160907

github-actions[bot] commented 3 years ago

Hey there, looks like this is your first time submitting a bug or enhancement to HACC! Thanks for helping make HACC a better app! 🎉

qJake commented 3 years ago

Thanks for reporting this, I think there may be some issues with 0.118.x and the API that I need to investigate, I will let you know what I find soon!

bctrainers commented 3 years ago

Just wanted to pop in and say I'm having the same issues here. Fresh install of Home Assistant on Debian 10 Virtual Machine, the HACC container is on the same install as HA.

Returned error on the terminal...

warn: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      Can't initialize HACC API, missing the base URL.
info: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      Initializing HACC API with URL http://192.168.20.209:8123 and access token [eyJ0eX•••••••••••Q9GWDo].
fail: HADotNet.CommandCenter.Controllers.AdminController[0]
      Invalid system settings entered, or unable to reach Home Assistant with the specified information.
System.Exception: Unexpected response code 0 from Home Assistant API endpoint /api/discovery_info.
   at HADotNet.Core.BaseClient.Get[T](String path)
   at HADotNet.Core.Clients.DiscoveryClient.GetDiscoveryInfo()
   at HADotNet.CommandCenter.Controllers.AdminController.Settings() in /src/HADotNet.CommandCenter/Controllers/AdminController.cs:line 67
warn: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      Can't initialize HACC API, missing the base URL.
warn: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      Can't initialize HACC API, missing the base URL.
info: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      HA connection is not initialized, redirecting user to settings area...
warn: HADotNet.CommandCenter.Middleware.HAClientInitialization[0]
      Can't initialize HACC API, missing the base URL.

The running instance of HA and the given URL...

{"uuid": "275c6125bd204f64a25e5159446e6c31", "base_url": "http://192.168.20.209:8123", "external_url": null, "internal_url": "http://192.168.20.209:8123", "location_name": "Home", "installation_type": "Home Assistant Supervised", "requires_api_password": true, "version": "2020.12.1"}

Forcing an External URL and Internal URL under HA's /config/core makes no difference.

{"uuid": "275c6125bd204f64a25e5159446e6c31", "base_url": "http://192.168.20.209:8123", "external_url": "http://192.168.20.209:8123", "internal_url": "http://192.168.20.209:8123", "location_name": "Home", "installation_type": "Home Assistant Supervised", "requires_api_password": true, "version": "2020.12.1"}

edit: HA details...

System Health

version 2020.12.1
installation_type Home Assistant Supervised
dev false
hassio true
docker true
virtualenv false
python_version 3.8.6
os_name Linux
os_version 4.19.0-13-amd64
arch x86_64
timezone America/Chicago
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Hass.io host_os | Debian GNU/Linux 10 (buster) -- | -- update_channel | stable supervisor_version | 2020.12.7 docker_version | 20.10.1 disk_total | 17.6 GB disk_used | 3.9 GB healthy | true supported | true supervisor_api | ok version_api | ok installed_addons | Spotify Connect (0.8.2)
Lovelace dashboards | 1 -- | -- mode | auto-gen resources | 0
slm4996 commented 3 years ago

V1.0.24 (HA Supervised install via beta channel) now throws this error and then stops: Screenshot_20210124-205033_Chrome

qJake commented 3 years ago

@slm4996 Thanks for reporting that. That's actually a separate bug related to a dependency versioning issue.

I'm in the process of releasing v1.0.25 that I'm hoping will fix this. Please try this version as soon as it reaches you!

slm4996 commented 3 years ago

Happy to report that version 1.0.26 resolves both issues. Thank you!

qJake commented 3 years ago

Sweet, thanks for reporting back!