What version of HA are you running?
I used to see many many login failures for unifi, but in HA 0.41 they upgraded to pyunifi v2 and it resolved the issues for me.
HA 0.41.0 running here ! I made more investigations and discovered that it detects nearly instantly when I’m back, but it takes between 15/20 minutes to detect that I’m away which is definitively too long !
How did you see the login failures in previous version ? Logs of HA ?
I have the same issue. The component doesn’t detect i’m away for roughly 15-20 minutes after I left home. Changing interval_seconds does not do anything.
It’s using ARP to know if device is there or not ? it makes non sense as module requests credentials of controlers so it should be able to check the list of connected devices directly which is a lot more accurate and fast !
ARP time-out is not something you can setup right now on Unifi devices, only by hand modifying Avaya which is not really nice and doesn’t survive firmware update
Are you sure it’s really using ARP ? as I had a quick look at the python file that handles interface with Unifi API, and only method I have seen is Get_Clients which I guess do same thing as client list in Ufini Controler interface.
Not sure where to look to know which method HA uses for Unifi devices
Well, it’s really more of a theory than a concrete answer. I don’t have one of these devices, so i also don’t use the component in HA so I don’t know exactly how its checking for presence. But even though the HA component is connecting and using credentials if the ARP timeout hasn’t occurred HA will still think the device is connected. That’s IF it’s using ARP. Maybe ping the dev of the component?
From the HA perspective, all it does is login to the Unifi controller and query the connected clients. If the Unifi controller reports a client as connected, then HA will see the device as ‘home’. You may need to tweak the config in the Unifi controller to lower the timeout value, although I’m not sure you can. Mine varies, but can be up to 10+ minutes before noticing.
I made further investigation this morning and I noticed also there is a long delay in controler interface before a device disconnected appears as offline (around at least 10 minutes !) so looks like HA can’t do better !
Only way I would see that would be more efficient who be a ping every 30s or whatever to the device to be sure it’s there or not ! Will have to check if a plugin exists to test such thing in HA…
I went finally with Owntracks and updates through my Mosquitto broker and it works great (IP ping is not very efficient due to energy saver algorythm in modern wireless devices !).
I found GPS is lot more efficient
The Unifi controller shows recently connected devices (with 20 minutes or so) on their client list, but also reports a “last_seen” time for each device. I use this last seen time to filter out the devices who haven’t been seen within the “consider_home” timeframe.
Changed line 86 to:
self._clients = {client['mac']: client for client in clients if (dt_util.utcnow() - dt_util.utc_from_timestamp(float(client['last_seen']))) < self.consider_home}
( defined conside_home = config[DOMAIN].get(CONF_CONSIDER_HOME) in get_scanner )
2017-06-13 22:10:03 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.unifi from homeassistant.components.device_tracker.unifi
2017-06-13 22:10:05 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.unifi
2017-06-13 22:10:05 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform unifi
File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker/unifi.py", line 67, in get_scanner
File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker/unifi.py", line 76, in __init__
File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker/unifi.py", line 86, in _update
File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/device_tracker/unifi.py", line 86, in <dictcomp>