Ubiquiti Unifi WAP (R Hass.io 0.70.1 RP3 )

Hi All

I have taking the plunge into HA, after seeing what it can do!
But I am having alot of problems with getting the Ubiquiti Unifi WAP working.

UPDATE: I even did a fresh install and only added the lines for unifi below
I also tried to uncomment every line to see if this made any change but without any success…

The code (tried everything so it grew and grew):

# Unifi
device_tracker:
  - platform: unifi
    host: 192.168.0.5
  # port: 8443
    username: admin
    password: !secret unifi_password
    ssid_filter:
      - 'HomeSSID'
      - 'IoTSSID'
    verify_ssl: False
  # site_id: streetname
    interval_seconds: 12
    consider_home: 180
    detection_time: 30
    new_device_defaults:
      track_new_devices: True
      hide_if_away: False

I always get the same error, none to which have any connection to unifi (SHIELD android TV is creating that)

2018-06-02 18:32:32 WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-06-02 18:33:00 WARNING (SyncWorker_3) [netdisco.ssdp] Found malformed XML at http://192.168.0.30:9080: status=ok

This did not create the mystical file known_devices.yaml and I had no errors?
When this didnt work and I couldnt see any of my mobile devices I was desperate and tried the one where you dont use any controller, but instead connect directly to the AP by SSH!

  - platform: unifi_direct
    host: 192.168.0.15
    username: admin
    password: !secret unifi_password

I found that using the “verify_ssl: False” here would break it? removing this line I finally got it to show devices (To this one single AP, I have 3 so it’s not a solution)
and it created the known_devices.yaml file in the config folder

But now I started to get errors…

Error setting up platform unifi
5:59 PM components/device_tracker/unifi.py (ERROR)

So can anyone tell me what I have to do to get the controller working?
it’s driving me nuts and after a week googling I am capitulating

Best regards
Casperse

You just have the single site and user is admin user for site?

Config looks good. Where devices populating in Known_devices.yaml before you connected direct to AP?

Thanks for taking the time to help me!

No it didnt even create the file (Guess its because it didn’t fint any devices) so I only have the wired ones auto detected.

After using the direct I then got the file and it started populating

This could be the problem, I am running this a new site (The default home one is not used)
That was why I used the option:

site_id: My_Streetname

Or should it be:

site_id: 'My_Streetname`

hmm just tried no difference

I didn’t have any luck getting the Unifi platform to work either. I manged to get the unifi_direct working all ok, but as you mentioned you have a few access points that doesn’t help.

OKay - Let’s start with that :slight_smile:

DOES ANYONE, HAVE THIS WORKING? - Ubiquiti Unifi WAP, Configuration Hass.io 0.70.1 RP3 ?

It might be broken in the last releases…?
If someone have this setup working could you then please share your configuration?

Are you trying to connecting to a Unifi Controller or the AP?

https://www.home-assistant.io/components/device_tracker.unifi/ - connects to controller
https://www.home-assistant.io/components/device_tracker.unifi_direct/ - connects to the access point

I’m using the AP method, with this config:

device_tracker:
  - platform: unifi_direct
    host: 192.168.1.3
    username: !secret unifi_username
    password: !secret unifi_password
    consider_home: 1800
    new_device_defaults:
      track_new_devices: false

No - As I wrote I have multiple AP’s and need the controller to work with HA in the WAP configuration. I also have the configuration in my first post where I did a test with the AP access and that works, but I cannot use it… every time a person moves to another AP they will be listed as Away.

So "DOES ANYONE, HAVE THIS WORKING? - Ubiquiti Unifi WAP, Configuration Hass.io 0.70.1 RP3 ?"

After another reboot I got this (Not really saying allot to what this mean:

Failed to scan clients: Expecting value: line 1 column 1 (char 0)
4:55 PM components/device_tracker/unifi.py (ERROR)

Log Details (ERROR)
Sun Jun 03 2018 16:55:16 GMT+0200 (Romance Daylight Time)
Failed to scan clients: Expecting value: line 1 column 1 (char 0)

below works without issue

platform: unifi
  host: 192.10.27.12
  port: 8443
  username: !secret ubnt_username
  password: !secret ubnt_password
  site_id: 43rjq0nj
  track_new_devices: false
  interval_seconds: 120
  consider_home: 240

site id is found in url not the name you made for it. based on what you have above it look like you using wrong one

track devices needs true until file is populated with device you want track or you may enter it youself if you understand known_devices format

1 Like

THATS IT! - Site ID - I never knew it existed only used and noticed site name…

One thing I got 20-30 lines of error because of the https certificate so only change is that I added that line and
Woaw… it startet populating right away

# Unifi
device_tracker:
  - platform: unifi
    host: 192.168.0.5
    port: 8443
    username: !secret unifi_username
    password: !secret unifi_password
 #  ssid_filter:
 #    - 'HomeSSID'
 #    - 'IoTSSID'
    verify_ssl: False
    site_id: 9ehn4rk4
    interval_seconds: 120
    consider_home: 240
#  detection_time: 30
    new_device_defaults:
      track_new_devices: True
      hide_if_away: False

What about detection time? Does it do any difference?
Also I would like to hear if you use any other detection than this for home & away

@TMJPUGH Again 1000 THANKS, finally I can move to the next integration on my list

I use Google location but it not working like I expect. It don’t show zone.yaml location vs just simple home/away.

I was only testing that so didn’t look into it further.

If you add another device tracker just integrate the trackers in known_devices. It combined by MAC and hostname or other depending on tracker

I would like to combine different things!
The mobile phone is always with everyone so starting there with WLAN
Away from home should be really quick, if it takes it from the controller.

Since you are experimenting do you know how to chain them together?
I just installed the IOS Home Assistant app and enabled ios: in the config file and now I get another icon for the phone?

Was wondering how to mix the WLAN and the IOS together?

Example: Known_devices.yaml I have ISO + Unifi scan and soon NMAP

caspersens_iphone_7:
  hide_if_away: false
  icon:
  mac: 4C:C6:C6:6C:38:3E
  name: caspersens iphone 7
  picture:
  track: true

4c74bf6c383e:
  hide_if_away: false
  icon:
  mac: 4C:C6:C6:6C:38:3E
  name: 4c74bf6c383e
  picture:
  track: true

So wanting to use both ISO and Unifi and nmap do I just delete entries with the same MAC address?

I think below would combine them.

4c74bf6c383e:
  hide_if_away: false
  icon:
  mac: 4C:C6:C6:6C:38:3E
  name: caspersens iphone 7
  picture:
  track: true

Just delete all other references to the device

I am having the same problem with a different error message. I have the Unifi cloud key controller and 3 access points. I can see the mobile devices configured in known_devices.yaml but they are listed as not present although they are. They are shown in the Unifi dashboard.

This is what I have in /config/configuration.yaml

Unifi Presence Detection in Controller

device_tracker:
  - platform: unifi
host: 192.168.178.54
port: 8443
username: !secret unifi_username
password: !secret unifi_password
site_id: default
track_new_devices: false
interval_seconds: 120
consider_home: 300 

(URL is: https://192.168.178.54:8443/manage/site/default/dashboard; username and password is the same that I use to log into the dashboard)

This is the error message in log:

Log Details (ERROR)
Sat Sep 15 2018 18:26:10 GMT+0200 (CEST)

Error setting up platform unifi
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 600, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 343, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 849, in validate_conn
conn.connect()
File “/usr/local/lib/python3.6/site-packages/urllib3/connection.py”, line 356, in connect
ssl_context=context)
File "/usr/local/lib/python3.6/site-packages/urllib3/util/ssl
.py", line 372, in ssl_wrap_socket
return context.wrap_socket(sock)
File “/usr/local/lib/python3.6/ssl.py”, line 407, in wrap_socket
_context=self, _session=session)
File “/usr/local/lib/python3.6/ssl.py”, line 814, in init
self.do_handshake()
File “/usr/local/lib/python3.6/ssl.py”, line 1068, in do_handshake
self._sslobj.do_handshake()
File “/usr/local/lib/python3.6/ssl.py”, line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/requests/adapters.py”, line 445, in send
timeout=timeout
File “/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py”, line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py”, line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘192.168.178.54’, port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)’),))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 176, in async_setup_platform
platform.get_scanner, hass, {DOMAIN: p_config})
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/unifi.py”, line 78, in get_scanner
site_id=site_id, ssl_verify=verify_ssl)
File “/usr/local/lib/python3.6/site-packages/pyunifi/controller.py”, line 89, in init
self._login(version)
File “/usr/local/lib/python3.6/site-packages/pyunifi/controller.py”, line 148, in _login
r = self.session.post(login_url, params)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 559, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 512, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/sessions.py”, line 622, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.6/site-packages/requests/adapters.py”, line 511, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘192.168.178.54’, port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)’),))

Any pointers to what I could be doing wrong? Thanks!

Ok, here is what I did. I used the component for Access Points and defined 3 of them. Works like a charm.

i think it is broken. i´m using a proper certificate on an external vm.

raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘unifi.XXXX.XXX’, port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:84
1)’),))

Hi @sapnho - is this still working for you?

I have tried this and it only works if I comment out 2 of the 3 WAPs:

device_tracker:
  - platform: unifi_direct
    host: 192.168.7.6
    username: !secret unifi_user
    password: !secret unifi_pass
  - platform: unifi_direct
    host: 192.168.7.7
    username: !secret unifi_user
    password: !secret unifi_pass
  - platform: unifi_direct
    host: 192.168.7.8
    username: !secret unifi_user
    password: !secret unifi_pass

But then, of course, I lose the info about the devices that are logged onto the other APs :cry:

Hi @chairstacker - yes it does again now. There was a time (between HA releases) when it wouldn’t recognize one device but at the moment with 0.82 everything seems to work ok.

One strange thing that I found is that the history would never record an “away” although it shows “away” as the state. In this image below, there have been “away” times but they are not recorded.

Updating to the new 0.90.1 and have lost all my device trackers using Unifi?
Do you experience the same issue?

@chairstacker and @sapnho

Nope, everything works fine.