Unifi controller, error setting up

Hey all, I’m having trouble setting up Unifi as a device tracker. I’ve tried every solution provided for similar problems on the forums but without luck so far. I’m pretty clueless, maybe someone can help?

I’m running HA on a RasPi 3 using HassIO, and the Unifi Controller on a separate RasPi Zero W. Both are working correctly and are visible on the same subnet. After setting up it didn’t create a known_devices.yaml, but it did when I did a “see” from the services panel. It found my iPhone after providing only the mac address.

The error in the logs that I’m getting is this:

2017-08-18 18:26:35 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform unifi
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 386, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 382, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.6/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 153, in async_setup_platform
    platform.get_scanner, hass, {DOMAIN: p_config})
  File "/usr/lib/python3.6/asyncio/futures.py", line 331, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 244, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/unifi.py", line 52, in get_scanner
    site_id=site_id, ssl_verify=verify_ssl)
  File "/usr/lib/python3.6/site-packages/pyunifi/controller.py", line 89, in __init__
    self._login(version)
  File "/usr/lib/python3.6/site-packages/pyunifi/controller.py", line 148, in _login
    r = self.session.post(login_url, params)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 565, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 488, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

What does your configuration look like?

I should have included this in the post, you’re totally right :slight_smile: I included the default values for “port” and “site_id” to rule out any problems on that side. The IP address is the address of the Pi running Unifi Controller. Login credentials are double checked.

device_tracker:
  - platform: unifi
    username: !secret unifi_username
    password: !secret unifi_password
    host: 192.168.2.18
    port: 8443
    site_id: default
    verify_ssl: false
    track_new_devices: yes

If you login to your controller, the logs will show attempted logins.
Look at this and verify login is succeeding. Maybe controller is disconnecting “RemoteDisconnected: Remote end closed connection without response”

I created seperate Admin user for HA in unifi.
I cannot remember reason but I believe special characters may cause issues. Anyway would be simple to test.

Can’t see any attempts in de logs. However, I do se all these “INFORM-SLOW” messages. Could this have anything to do with my problem?

[2017-08-19 14:19:51,157] <inform-130> INFO  inform - from [f0:9f:c2:7c:07:bf](, U7LT, 3.4.14.3413): state=CONNECTED, ext/stun_ip=192.168.2.4, dev_ip=192.168.2.4, up=236590
[2017-08-19 14:19:52,382] <inform-130> INFO  inform - INFORM-SLOW: mac=f0:9f:c2:7c:07:bf, msec=1246
[2017-08-19 14:20:06,828] <inform-131> INFO  inform - from [f0:9f:c2:7c:07:bf](, U7LT, 3.4.14.3413): state=CONNECTED, ext/stun_ip=192.168.2.4, dev_ip=192.168.2.4, up=236605
[2017-08-19 14:20:08,035] <inform-131> INFO  inform - INFORM-SLOW: mac=f0:9f:c2:7c:07:bf, msec=1227
[2017-08-19 14:20:22,481] <inform-132> INFO  inform - from [f0:9f:c2:7c:07:bf](, U7LT, 3.4.14.3413): state=CONNECTED, ext/stun_ip=192.168.2.4, dev_ip=192.168.2.4, up=236621
[2017-08-19 14:20:23,706] <inform-132> INFO  inform - INFORM-SLOW: mac=f0:9f:c2:7c:07:bf, msec=1246
[2017-08-19 14:20:37,284] <inform-133> INFO  inform - from [f0:9f:c2:7c:07:bf](, U7LT, 3.4.14.3413): state=CONNECTED, ext/stun_ip=192.168.2.4, dev_ip=192.168.2.4, up=236636
[2017-08-19 14:20:38,608] <inform-133> INFO  inform - INFORM-SLOW: mac=f0:9f:c2:7c:07:bf, msec=1345
[2017-08-19 14:20:53,076] <inform-134> INFO  inform - from [f0:9f:c2:7c:07:bf](, U7LT, 3.4.14.3413): state=CONNECTED, ext/stun_ip=192.168.2.4, dev_ip=192.168.2.4, up=236652
[2017-08-19 14:20:54,355] <inform-134> INFO  inform - INFORM-SLOW: mac=f0:9f:c2:7c:07:bf, msec=1300

Inform-slow is unrelated. I looked into it and usually related to performance issue on controller. Are you using RasPi?

Sorry. I meant “Events” in the Unifi Controller UI.
The box with check Mark inside, bottom left in UI.

This shows client roaming and success login.
If no success login shown I would look into why no login.

I expect server log may show same but might be harder to find.

Alright, apparently I’ve accidentally made my HA user in the controller a Super Admin instead of a regular Admin. After changing that I immediately saw all the devices in my network being discovered so that’s a big step forward. However, they are collectively changing from Home to Away every few minutes, but I have to dive in the logs to find out what’s happening there. But thanks so far!

Back and forth home/away likely related to consider_home time too short