Ubiquiti - Correct Configuration No Devices

Hi Everyone,

Just starting out in the home automation world and have come across a real difficult one to solve. The basics of my problem is that I am trying to setup device_tracker with unifi, not direct access :slight_smile: and have no devices being found.

All that is in the log is the following (Debug mode turned on)

2018-02-08 10:20:21 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.unifi from homeassistant.components.device_tracker.unifi
2018-02-08 10:20:21 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.unifi
2018-02-08 10:20:21 DEBUG (SyncWorker_1) [pyunifi.controller] Controller for https://x.x.x.x:8443/
2018-02-08 10:20:21 DEBUG (SyncWorker_1) [pyunifi.controller] login() as homeassistant

Running on Centos as a VM.
(homeassistant) [homeassistant@hassio .homeassistant]$ hass --version
0.62.1

My config is like so. With username, password and host sanitised to protect the innocent.

device_tracker:
- platform: unifi
username: username
password: password
host: x.x.x.x
verify_ssl: false
site_id: default
track_new_devices: yes

So you may be thinking what have I tried?
Well just about everything. I have confirmed that the login is working by entering account incorrectly then correctly getting an error message. I have run the python script manually to test connectivity and that works.
deps/lib/python3.6/site-packages/pyunifi

Entered incorrect site ID to confirm that was not the problem and this shows in the logs.

Entered one client manually and it is not being detected.

So basically there are no error messages I can run the script as homeassistant user with no problems and get a list of clients. I have a known_devices.yaml file but it is not being updated.

I don’t know what else to try. Any help would be appreciated.

Do you have any devices in known devices yaml

Looks good. I know that is optional to specify a port but have you tried adding one?

How about the last part of the help guide:

CONFLICTS WITH MQTT

The Unifi controller can either be a dedicated hardware device (Unifi’s cloud key), or as software any Linux system. If you run the the Unifi controller on the same operating system as Home Assistant there may be conflicts in ports if you have the MQTT component as well.

It is recommended that you run the Unifi controller in a dedicate virtual machine to avoid that situation.

Thanks for the replies :).

No devices in known devices
Unifi is running on a seperate VM so MQTT should not be involved.
Have logged in manually on 8443 and set the port to 8443 but still no luck.

My next steps are to

  1. upgrade unifi controller. I am currently running 5.4.19
  2. Add extra logging to unifi.py to see where the script is getting up to.

Fixed it!!!

Answer
For those of you that are running home assistant on a VM the first thing you need to do is setup ntp :). I didnt and my time was out 12 hours. This made the following lines in the configuration return 0 results instead of all of my clients. I knew this by adding a logger stanza above the following lines.

self._clients = {
client[‘mac’]: client
for client in clients
if (dt_util.utcnow() - dt_util.utc_from_timestamp(float(
client[‘last_seen’]))) < self._detection_time}