Error setting up platform unifi

I have tried setting up unifi to use it for tracking. (through configuration- integrations.). It seems to work in the sense that after setting up the password and user, I can choose my site name from the list. (I only have one, I tried bot picking it manually, and using “default”) in the webui it says “This integration has no devices.”. And i get an error in the logs, the error is in the bottom of the post. Any suggestions?

Error setting up platform unifi
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 159, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File “/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py”, line 57, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File “/usr/local/lib/python3.7/socket.py”, line 748, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 839, in _validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 301, in connect
conn = self._new_conn()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 168, in _new_conn
self, “Failed to establish a new connection: %s” % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f28c2a73c18>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘unifi’, port=8443): Max retries exceeded with url: /api/login (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f28c2a73c18>: Failed to establish a new connection: [Errno -2] Name does not resolve’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/init.py”, line 177, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/unifi.py”, line 80, in get_scanner
site_id=site_id, ssl_verify=verify_ssl)
File “/usr/local/lib/python3.7/site-packages/pyunifi/controller.py”, line 89, in init
self._login()
File “/usr/local/lib/python3.7/site-packages/pyunifi/controller.py”, line 137, in _login
r = self.session.post(login_url, json=params)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘unifi’, port=8443): Max retries exceeded with url: /api/login (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f28c2a73c18>: Failed to establish a new connection: [Errno -2] Name does not resolve’)

There is an issue with the name it is trying to hit. Perhaps a problem with the DNS name for the target,

I input the IP directly in the setup. I do get a certificate error when i connect to the unifi-webinterface directly, but that shouldn’t matter, right?

That may matter but I would expect a different error. Are you sure you did not typo the IP address? For example, I have occasionally typed 182 instead of 192.

Thanks. I checked just now, and it seems to be right. I tried putting in a wrong ip just to test and got the following message “No service available”. When i use the right IP, i don’t get the message, and I also see a list where my site , with the site-name from the unifi-controller in the list. So i think the connection settings themselves are right.

Is there any reason you are using the ip address rather than the name on the certificate?
I assuming you are using https? Once you setup a certification in HA http no longer works.

What version of the controller are you running?
Maybe share your redacted config as well.

1 Like

Sorry, I don’t quite understand. “The name on the certificate”? Do you mean the dns adress of the server with the unifi-controller?

I mean the name you would use to NOT get a certificate error.

I use the 5.10.20 versjon of the controller. I have the following config:

device_tracker:
  - platform: unifi
    host: unifi
    username: <user>
    password: <pass>

I think the certificate error in the web interface is because it is a self signed certificate. I don’t think it is because of the name. (this is the ertificate the unifi controller uses not one in homeassistant)

Here are the official instructions. They show a way to turn on debug logging too. t also mentions thast the time clocks on both units need to be synchronized/

I had issues with V5.10 that’s why I have gone back to V5.9.29.
I read that for others V5.10 is working fine, though.

Maybe you also want to try using the IP address.

Yeah, i have tried turning on the logging, but it basically just has the same error in the log (and some data about the base stations, so it seem to connect to it somehow)

Try adding verify_ssl: False?
Is the controller port 8443 ?

And I also had issues with getting disconnected until I set up a distinct account for the HA user.

Yeah, i actually tried that (setting up a dedicated admin HA-user), but I seem to get the same error.

Thanks, tried setting it false, but doesn’t seem to make a difference. The controller is on port 8443.

Those were just some ideas looking through the instructions.
I do not have that hardware so i cannot test. :frowning:

No problem, I have, and I still can’t solve it :slight_smile: