Continuing My Unifi Presence Detection Woes

I have around 60 devices. Most of them show as “un-named device”
Out of curiosity, are the ‘un-named devices’ containing _rx and _tx sensors?

Do you know if there’s a way to change the user and password in the integration without completely removing and re-adding the existing integration?

This isn’t what you want to hear, but no I’m afraid I don’t know of any way of replacing the credentials in an existing integration.
I would be inclined to go scorched earth, and (at the risk of stating the obvious) do the following:

  1. Remove the Unifi Integration
  2. Restart HA (you may need to comment out device_trackers if in automations etc to do so).
  3. Check all unifi entities removed completely (from persons etc.)
  4. Stop HA.
  5. Check Unifi Controller credentials for separate account.
  6. Check client names setup as required (so they can pass through to the device trackers on creation
  7. Restart HA
  8. Setup Unifi integration again using read-only admin credentials.

It is a fair amount of work without any guarantee of success I’m afraid.

I’ve also had a quick read through the current Github Unifi issues list but can’t see anything that would provide these problems.

1 Like

I have noticed some odd home/not_home wonkiness using the Unifi integration. I have almost the exact same setup as you do and ended up removing the HA integration and switching it over to NodeRed (which has a much better Unifi integration, imho). I have a flow that runs every minute and checks for 3 devices (my phone, my wife’s phone and my son’s phone) and calls device_tracker.see on HA. Using it this way, it’s been MUCH more reliable and I’ve not had any other issues.

@TazUk

I may just do that…again.

Also do you know of any settings I could check in the controller software that might be causing the issues I’m having?

I could start from scratch there but I don’t know what I should do differently (if anything) and might end up making the same potential mistake again and ending up in the same place.

@code-in-progress

I’ve never used Node-Red but if all else fails I guess I could end up going that route.

I may ask you for a primer on getting the NodeRed unifi integration setup if the above doesn’t work. If you don’t mind…I’ll let you know how I get along.

1 Like

I think probably one of the main benefits of breaking out authentication is that you would be able to confirm that HA was accessing the controller successfully by viewing the login events in the controller.
Other than that, both my sites are ‘Default’ with the standard 8443 port (there may still be issues with MQTT conflicts on this port depending on what you have configured) and I cannot think of anything else in particular.

Absolutely! Once you get it setup, it’s a rabbit hole; Be warned :smiley: But, the amount of things that you can do with NR is amazing.

Just seen this post concerning Unifi which (if you are comfortable hacking around with config files) could be another route to modify the credentials.
Usual caveats apply.

I just changed the core.config_entries file to a new read-only admin user I just created in the controller. So we’ll see how that goes now.

And as an FYI, once you log in with a different user it re-creates all of the entities again so I still needed to go thru the list and disable everything I didn’t want to track.

But this time I left a few extra things that I know for a fact (as much as is possible) that will always be connected (all of my unifi network devices and a couple of PC servers that are always on) so I can see if the non-phone wired devices show the same behavior.

EDIT:

I also enabled debug logging for the aiounifi component.

Any suggestions as to what I might be looking for in that log to inform me of any wonkiness?

Thanks!

I think… :wink:

For some reason this statement popped back into my head…

Do you also happen to have any other non-unifi network gear in your set up? I mentioned above I have a couple of ASUS routers I’m using as AP’s only. I’m wondering if it’s possible that there could be some undesired interaction between those and the Unifi stuff?

After looking a bit more I have put one more piece if data into this mystery.

Generally (but not always…) if a phone is marked as away in HA, if I then restart HA, the phones will be marked as home for exactly five minutes. Which is the setting I have in the integration for the “time in seconds from last seen until considered away”.

So for some reason HA is somehow misinterpreting the restart and the subsequent reconnection to the unifi controller as the devices “being seen” and then marking them away 300 seconds later.

It seems as tho it only happens when the phone is away. Which makes sense I guess considering that if the phone is actually seen as home then it won’t transition to not seen.

However there are still a couple of anomalies -

  1. My phone never goes to home even tho it is home and connected (but since it is always marked as away and I restart HA it is then seen as home for the aforementioned 5 minutes)

  2. my daughters phone only exhibited the “seen as home” behavior this evening but it was actually away all night last night and this morning and it never was erroneously seen as home even tho I restarted HA five times during that same time frame.

So I’ve narrowed down the major issues to two -

  1. figure out why HA switches devices that are away to home after a restart for the “consider home” time.

  2. Figure out why my phone never shows as home (except after HA restart) even tho it is connected to the router.

I set up a ping sensor for my phone and it shows the accurate state of my phone so I know the router knows it’s connected correctly.

The seen at home on restart issue was a bug in 0.103.4 / 0.103.5 fixed in 0.103.6.

I’ve never had to debug my Unifi setup with the logging so I’m afraid I have no suggestions for that.

1 Like

I’m on 103.0 so it must have started earlier than that.

I’ll update and see if that part goes away.

@TazUk

It looks like updating to the latest version at least solved #1 above. I’ve restarted a few times now and the away devices aren’t showing at home anymore. Thanks for that!

Now to see why my phone won’t ever show as home…

This whole thread is an interesting read. I’d be willing to bet that your issues stem from the non-unifi WAPs because that seems to be the only difference between your setup and mine. Are your old ASUS routers possibly attempting to handle the routing?

Also, I have a co-worker who frequents the ubiquiti forums and he warned me to not update to v5.12 for reasons I cant remember. I’ll shoot him a text, but I seem to remember it having to do with dropping clients or creating fake clients in one of the virtual networks.

I don’t think so. I’ve verified that they are both in AP mode.

I could try disconnecting them later and see if anything changes.

Cool! That would be very appreciated.

This.

The controller will only be able to report devices that connect TO the unifi gear. If you’re roaming between WAPs you are “falling off the network” because unifi controller isn’t looking at what’s connected to your router, but what’s connected to Unifi stuff.

That makes a lot of sense. I’d be interested to see what would happen if he got a ubiquiti lite AP

I could almost say that is correct but the controller knows my phone is connected to it. It is connected to an AP (the ASUS) that is connected to the Unifi switch. And that’s how it’s shown in the client list of the controller.

these two screen shots are at the same time

Inkedex1

So I’m not completely convinced that’s the issue…yet…

there’s still more testing to be done.

EDIT to add:

all of those “home” states were all caused by the bug that I fixed when I updated to v103.6 a few hours ago. They weren’t real. But I’ve been home since 10am (over 3 hours ago)

@finity only just got to catch up on this thread. I completely failed to register that you were using non-Unifi kit with the controller although you stated it quite clearly; my apologies (my wife always tells me I can’t multiask).

What @flamingm0e and @petro say seems to make sense to me (although both my sites are pure Unifi networks).

I wonder whether devices are (still) seen as wired as this old reddit thread suggests.
Unfortunately I have no way of testing this as a theory either at home or work.

The phone shows as wired in the client list (since it’s shown as connected to the unifi switch) but in HA it shows as wireless so I’m not sure where that is getting reported.