Continuing My Unifi Presence Detection Woes

The problem with your suggestion, which I’ve got reported regarding the wired bug issue, is that when a wireless devices goes wired the time stamp changes to something completely wrong making it unreliable for device tracking. So what would be required in that case would be to disable time stamp comparison in order to keep it wireless instead. Would that be a better solution then?

let me do some further testing and see how the timestamps are changing going from wireless to wired and i’ll get back to you. It may take a bit to gather some useful data because of the nature of the bug tho.

well, has something changed with the debug logging in the unifi device tracker component?

I set the log up to debug as I did before and I’m not getting any logs from it at all now.

here is the config that I’m pretty sure worked before unless I’m missing something…

logger:
  default: error
  logs:
    homeassistant.components.device_tracker.unifi: debug

I think that since Unifi is a component on its own, you would drop the device_tracker from it

Yes. That configuration is based on how it was when the platforms where separated

Oh, OK then the docs are way out of date.

they say that to enable logging you can add four different debug lines to the config:

logger:
  default: info
  logs:
    aiounifi: debug
    homeassistant.components.unifi: debug
    homeassistant.components.device_tracker.unifi: debug
    homeassistant.components.switch.unifi: debug

So the only line needed to now get all of the debug info is the “homeassistant.components.unifi: debug” entry?

You can figure this out by taking anything in brackets [] from the log. But yes, that should be correct.

true but if you don’t know what exactly to put in there in the first place (because the docs are wrong) then there are no logs and therefore no brackets to look between.

but yes I agree that worked.

But again it looks like the debug logs needed to have the “.device_tracker” stuck on the end since the reference to the unifi device tracker in the logs with just “homeassistant.components.unifi: debug” contains the following (anonymized):

2020-01-23 15:21:28 DEBUG (MainThread) [homeassistant.components.unifi.device_tracker] New UniFi client tracker Phone - Jxxx (8c:45:xxxxxxx)
2020-01-23 15:21:28 DEBUG (MainThread) [homeassistant.components.unifi.device_tracker] New UniFi client tracker Mxxxxxxx (e4:e4:xxxxxxx)
2020-01-23 15:21:28 DEBUG (MainThread) [homeassistant.components.unifi.device_tracker] New UniFi client tracker Phone - Axxxxxxx (e8:99:xxxxxxxxx)
2020-01-23 15:21:28 DEBUG (MainThread) [homeassistant.components.unifi.device_tracker] New UniFi client tracker Phone - Axxxxx (40:4e:xxxxxxxxx)
2020-01-23 15:21:28 DEBUG (MainThread) [homeassistant.components.unifi.device_tracker] New UniFi client tracker Phone - Jxxxxxx (fc:db:xxxxxxx)

so the docs have the incorrect info in them. It should have been “homeassistant.components.unifi.device_tracker” instead.

Oh, well, at least it’s working for now.

It’s just a filter, homeassistant.components.unifi should work for all logs under it. For example, if you were to use

logger:
  default: info
  logs:
    homeassistant.components: debug

Everything that starts with homeassistant.components will be debug

I personally would love to try this out, but my unifi setup seems to be bugged out like crazy. Nearly every device “disconnects” and “reconnects” multiple times a day, even though they are clearly connected and working without an issue.

Maybe unifi support will someday figure out why my network is always so bi polar. Not holding my breath with the support I have received thus far.

I get that. I really do.

My point was that the docs are wrong and I didn’t realize what I was supposed to put in to get debug information for only the unifi device tracker.

Now I do.

:slightly_smiling_face:

@Robban

I ran two trials today by connecting my phone to the unifi AP then after a few minutes I connected it back to the ASUS AP. I noted those times and searched the logs to make a note of all the assiciated timestamps received by HA from the unifi controller.

Here are the results:

the “@” time is the timestamp from the HA log that the entry was written. The data below each of those contains the lines of info as reported by the controller at the associated times.

@153509 went to wireless

'_last_seen_by_uap': 1579811703, = 	2020-01-23 15:35:03
'_last_seen_by_ugw': 1579811707, = 2020-01-23 15:35:07
'_last_seen_by_usw': 1579811680, = 2020-01-23 15:34:40
'last_seen': 1579811703, = 		2020-01-23 15:35:03
'latest_assoc_time': 1579811702, = 2020-01-23 15:35:02
 
@154028 went to wired

'_last_seen_by_ugw': 1579812017, = 	2020-01-23 15:40:17
'last_seen': 1579812017, = 			2020-01-23 15:40:17
'latest_assoc_time': 1579811997, = 2020-01-23 15:39:57
 
@154500 marked as away

'_last_seen_by_ugw': 1579812278, = 	2020-01-23 15:44:38
'last_seen': 1579812278, = 			2020-01-23 15:44:38
'latest_assoc_time': 1579812259, = 2020-01-23 15:44:19
 
@154516

'_last_seen_by_ugw': 1579812302, = 	2020-01-23 15:45:02
'last_seen': 1579812302, = 			2020-01-23 15:45:02
'latest_assoc_time': 1579812259, = 2020-01-23 15:44:19
 
@154532

'_last_seen_by_ugw': 1579812324, = 	2020-01-23 15:45:24
'last_seen': 1579812324, = 			2020-01-23 15:45:24
'latest_assoc_time': 1579812276, = 2020-01-23 15:44:36
 
@154548

'_last_seen_by_ugw': 1579812342, = 	2020-01-23 15:45:42
'last_seen': 1579812342, = 			2020-01-23 15:45:42
'latest_assoc_time': 1579812324, = 2020-01-23 15:45:24
 
@154604

'_last_seen_by_ugw': 1579812359, = 	2020-01-23 15:45:59
'last_seen': 1579812359, = 			2020-01-23 15:45:59
'latest_assoc_time': 1579812341, = 2020-01-23 15:45:41
 
 --------------------------------------

@160630 went to wireless

'_last_seen_by_uap': 1579813583, = 	2020-01-23 16:06:23
'_last_seen_by_ugw': 1579813584, = 	2020-01-23 16:06:24
'last_seen': 1579813583, = 			2020-01-23 16:06:23
'latest_assoc_time': 1579813577, = 	2020-01-23 16:06:17

@160854 went to wired

'_last_seen_by_ugw': 1579813718, = 	2020-01-23 16:08:38
'last_seen': 1579813718, = 			2020-01-23 16:08:38
'latest_assoc_time': 1579813717, = 	2020-01-23 16:08:37

@161358 marked as away

'_last_seen_by_ugw': 1579814018, = 	2020-01-23 16:13:38
'last_seen': 1579814018, = 			2020-01-23 16:13:38
'latest_assoc_time': 1579814014, = 	2020-01-23 16:13:34

@161414

'_last_seen_by_ugw': 1579814041, = 	2020-01-23 16:14:01
'last_seen': 1579814041, = 			2020-01-23 16:14:01
'latest_assoc_time': 1579814015, = 	2020-01-23 16:13:35

@161430

'_last_seen_by_ugw': 1579814064, = 	2020-01-23 16:14:24
'last_seen': 1579814064, = 			2020-01-23 16:14:24
'latest_assoc_time': 1579814038, = 	2020-01-23 16:13:58

@161446

'_last_seen_by_ugw': 1579814082, = 	2020-01-23 16:14:42
'last_seen': 1579814082, = 			2020-01-23 16:14:42
'latest_assoc_time': 1579814072, = 	2020-01-23 16:14:32

Looking that information it doesn’t look to me like the timestamp differences are any more than would be a reasonable lag in the reporting at 15 second intervals.

Is there anything else you need?

I know it’s not related to the Unifi Presence, but I am getting the same inability to delete an auto discovered MQTT device.

image

WTF?!

Who thought this was a good design?

1 Like

i don’t know if you saw that there is a discussion going on in the v104 release thread about this very thing.

I caught part of it, but based on that conversation, it seemed like it only applied to that one integration…

it did but it was also a general conversation about the ability to remove auto generated entities irrespective of where they come from.

Good day!

Has anyone come across this error in their logs before:

2020-02-17 16:50:11 ERROR (MainThread) [homeassistant.components.unifi] Unknown error connecting with UniFi controller: Invalid content type: text/html

My presence detection was working perfectly until last week, then suddenly this pops up and I have no device tracking from Unifi. The logs show a perfect connection and I can find all my devices, but under the integration screen there is nothing. Just says “The integration has no devices”.

Help please!

What are you running?

Hi Robban.

I’m running Home Assistant v 0.105.4 on Docker in Ubuntu. My Unifi controller is a Cloudkey 1st gen running all the latest software.

Strangely, I can still retrieve information via the unifigateway service as follows:

The set process within HA goes smoothly when I install the Unifi Controller integration. It obviously connects to the Cloudkey as it retrieves a list sites for me to select from during the set process. It then says setup was successful, but shows no devices on the integration page.

I have tried removing the integration, restarting HA, reinstalling but still the same.

I find it odd that everything seems to be working perfectly (and indeed has done until last week) except the step where the integration populates the list of devices on the network.

Any ideas? From the error message, it looks like there may be some corruption to some file or entry somewhere, but I have tried to search for and remove every unifi reference in my installation, then reboot and reinstall the integration. Still no luck.

2020-02-17 16:50:11 ERROR (MainThread) [homeassistant.components.unifi] Unknown error connecting with UniFi controller: Invalid content type: text/html

Can you create an issue on hass github? It’s hard to track problems through the forums?