hassio-addons / addon-unifi

UniFi Network Application - Home Assistant Community Add-ons
https://addons.community
MIT License
267 stars 133 forks source link

hassio loses connection to controller #67

Closed dedepene closed 4 years ago

dedepene commented 4 years ago

Problem/Motivation

Over the past few days I started experiencing a lot of these. All device trackers associated with the UniFi controller switch to "unavailable" inside HA and then to available right back. Please see below the log entries, "debug" level set in the unifi addon setup.

Expected behavior

(What you expected to happen)

Actual behavior

2020-01-15 18:36:09 ERROR (MainThread) [homeassistant.components.unifi] Unable to reach controller xxxx.duckdns.org
2020-01-15 18:36:22 INFO (MainThread) [homeassistant.components.unifi] Reconnected to controller xxxx.duckdns.org

There is absolutely nothing in the addon log. INFO: Starting the UniFi Controller...

Steps to reproduce

(How can someone else make/see it happen)

Proposed changes

(If you have a proposed change, workaround or fix, describe the rationale behind it)

addons-assistant[bot] commented 4 years ago

:wave: Thanks for opening your first issue here! If you're reporting a :bug: bug, please make sure you include steps to reproduce it. Also, logs, error messages and information about your hardware might be useful.

frenck commented 4 years ago

You should not use an external address to connect to add-ons.

Use a0d7b954-unifi, localhost or 127.0.0.1 as the hostname in this case.

dedepene commented 4 years ago

Well, it turned out I never did this in the first place:

Change the Controller Hostname/IP to match the IP or hostname of the device running Hass.io.
Check the box Override inform host with controller hostname/IP.

So I went ahead and did this, , where host is now 127.0.0.1, yet when I hit "open web ui" from the HA addon page it loads up my duckdns URL page, and I still get occasional disconnects....?

Not only this, but these settings messed up my AP - it got stuck in an "adopting" mode...

frenck commented 4 years ago

The log you send, it a Home Assistant log file. So your Home Assistant configuration of the integration is incorrect.

[homeassistant.components.unifi] Reconnected to controller xxxx.duckdns.org

The Home Assistant log clearly shows it is using the duckdns domain, it should not.

dedepene commented 4 years ago

But I have zero configuration entries in my HA config file. It's all the addon that created the integration and the resulting tracker devices....i have not configured anything else...

stocker85 commented 4 years ago

Please read the documentation it is even one of the steps. You now told all your devices to reach controller on 127.0.0.1 which is a loop back interface. If you are unlucky you might need to reset your devices. Hostname/ip inside the controller needs to be the ip of HA. Please fix this error and if that does not solve the issue please look if you maybe pointed your integration to UniFi controller to the dns name.

dedepene commented 4 years ago

@stocker85 , @frenck ,

I'm totally unsure how and why the integration uses a qualified domain name instead of the local ip?! I have never explicitly set this - it's mostly the default behavior of the integration and I keep getting these messages in the HA log :( All of the settings so far:

addon config:

{
  "ssl": true,
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem",
  "log_level": "debug"
}

addon log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 

-----------------------------------------------------------
 Hass.io Add-on: UniFi Controller
 Manage your UniFi network using a web browser
-----------------------------------------------------------
 Add-on version: 0.13.4
 You are running the latest version of this add-on.
 System: Ubuntu 18.04.2 LTS  (amd64 / qemux86-64)
 Home Assistant version: 0.103.5
 Supervisor version: 195
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to DEBUG
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] unifi.sh: executing... 
[21:01:43] DEBUG: Injecting SSL certificate into the controller...
[21:01:44] DEBUG: Preparing certificate in a format UniFi accepts...
[21:01:44] DEBUG: Removing existing certificate from UniFi protected keystore...
[21:01:44] DEBUG: Inserting certificate into UniFi keystore...
Importing keystore /tmp/tmp.zHlSqzALVj to /usr/lib/unifi/data/keystore...

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /usr/lib/unifi/data/keystore -destkeystore /usr/lib/unifi/data/keystore -deststoretype pkcs12".
[cont-init.d] unifi.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[21:01:46] INFO: Starting the UniFi Controller...

Controller settings > Advanced configuration

Enter Controller Hostname/IP : 192.168.1.195 (hassio local ip)
Override inform host... : yes

Yet every time the hassio server is unreachable on the internet:

ERROR (MainThread) [homeassistant.components.unifi] Unable to reach controller xxxxx.duckdns.org

How do I explicitly specify a local ip for the controller????

vandalon commented 4 years ago

You should not use an external address to connect to add-ons.

Use a0d7b954-unifi, localhost or 127.0.0.1 as the hostname in this case.

I'm seeing this issue with either one of the addresses configured. not sure if it's a home assistant issue or addon.

stocker85 commented 4 years ago

it is your integration not the addon. your controller is the addon installed. The integration is the part from homeassistant that integrates with your controller to get the device status so you can device_tracker etc. please go to configuration -> integrations -> unifi controller and delete it and recreate it with one of the options already explained in the post above this.

vandalon commented 4 years ago

That I already did of course. I just bumped in to this issue and just wanted to tell that the issues also exists with the "correct" hosts configured. Also I've created a post about this on the home assistant forum.

addons-assistant[bot] commented 4 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.