Unifi integration - large number of unnamed devices

The Unifi integration generates a very large number of unnamed devices for me, and on top of that it generates a large number of devices with cryptic names like “unifi e2 22 01 42 c0 30 j9i88aof” (part of that is the MAC address of the device, not sure what the rest is).
it creates device trackers, and TX and RX sensors for all of these, so now I have hundreds of each - which is slowing the overall system down.
I have disabled tracking of new devices, but I’m not sure how to get rid of these existing ones. What are they and how do I get rid of them?
Do I delete the integration and add it again?

3 Likes

there’s no easy way to do it.

You can go to the entities page and delete each one individually but that’s almost the only way.

if you just delete the integration and re-install it the default is to track all entities so it will just add them all back in again before you can set it to not track new entities. Even if you could do it that way then there would be no way that I know of to add the entities that you do want to track manually. So you would still end up setting track new entities to true and then it would add all of those entities again anyway. So you would be back to the same situation.

What I recommend is just (tediously… :roll_eyes:) going thru all of the device trackers you don’t want to track and disable those. then set the “show disabled entities” switch to off.

Unless someone has a better way to do it that’s the only way I know of and that’s how I do it now.

2 Likes

@DDK and @finity - I was having the same problems and found that it was actually the Unifi Controller itself that had the issue.

Wanted to share this here. I was still having issues with “junk” mac addresses cluttering both my known devices in the Unifi controller as well as the Home Assistant integration.

I adapted a script that can be run in cron daily with python3 purge_clients.py to drop junk mac addresses from the known devices (devices that have 0 rx/0 tx packets and do not have a set ip address).

This doesn’t solve the problems of them being picked up in Home Assistant, but at least now when I remove/re-add the integration in Home Assistant they don’t all come back.

1 Like

I don’t really see many (any?..) issues with “junk mac addresses” in my controller. I just have occasionally new unknown mac addresses from one of my many grandkids devices that will connect to the network that then gets transferred to HA as a default MAC address.

Then since I don’t know which kid/device they belong to I don’t really want to block them from the network or HA until I know for sure where the mac is coming from. And maybe they are junk mac addresses. The problem is I just don’t know and I don’t have any good way of temporarily removing them from HA to see if they come back or not. and if they don’t ever come back I don’t have a way to easily remove them permanently from HA without completely removing the integration and re-adding it.

But thanks for the script. I’m sure it will help others.

Just to clarify tho. you run that as a cron job on the Unifi controller itself correct?

EDIT:

Now that I’ve looked closer at the code I’m not sure that last sentence above is actually correct…

I would try forgetting them one by one in the Controller (Insights > Known Clients > Forget – right side of each line when you hover over). I still haven’t figured out how best to remove them from HA at that point, without doing it one by one there too. At least removing them from the Controller keeps them from coming back when you restart HA.

My problem stems from Docker throwing bad MAC addresses out because I have some of my Docker networks on a VLAN that the USG controls. Seems like a different issue than yours, but you could always just adjust the script to clear out any devices that haven’t been seen in X days (which you could also do by adjusting the max history in the controller maintenance settings).

On the same machine. Just has to be on the network that can access the controller via Web.

The biggest issue is even if you remove them from the controller by using “forget”, you still can’t remove them from HA without deleting the entire integration. Even removing them “one by one” as you suggested isn’t an option.

There is literally no way to remove a device tracker created by the unifi integration without removing the entire integration, which then removes everything. I’ve tried. And I’ve had several posts on here about the situation with the same recommendation - “remove the integration”.

1 Like

Added an Issue on GitHub for this: https://github.com/home-assistant/home-assistant/issues/32322

I think it might wipe it out on Home Assistant restart too (assuming you’ve cleared the entries from the controller), but I’ll have to wait to test that until more of these pop up after I reset everything last night.

Thanks for the code. But may I ask what username and password. for the cloud key or USG?
I live in an area where there are many restaurant and retail shops. I am getting close to 200 devices a day showing up in my entities in HA.
I have never been able to get rid of them. Most are on my guest network. No one has logged in but would love to get rid of them.
Also I am running my HA in a VM on unRAID.
How might I run the script.

Thanks for the help.
carltonb

Should be the cloud key (controller) login info.

The script can be run on anything that can run Python and is connected to a network that can reach the controller. It doesn’t have to be on the same VM as HA. Command line would be python3 purge_clients.py.

The one disadvantage at the moment is that it will not remove the entities from HA, just the Controller. You’d still have to periodically remove and re-add the integration in HA to flush everything out. I added an issue for it on GitHub. It might refresh on a restart of HA, but I haven’t tried that yet.

Thank you. Got it now.

Good luck on that issue making a difference.

I’ve had discussions on here in other threads directly with the unifi integration developer (at least I think they are…) and there didn’t seem to be any interest in fixing it.

That decision was based on a philosophical idea that an integration should add all the entities it wants and it’s then up to the user to decide if they want to hide them or not.

And the other rationalization is that even if the user removes the entities then the integration will just add them right back in again. However, they don’t seem to understand that in our cases the integration won’t add them back in because they were removed from the controller.

I just don’t get them being so adamant about not letting me decide what I want to do with my own entities. If I want to keep removing entities from my system every five minutes forever then I should have that ability if that’s what I choose to do…

1 Like

You’re getting 200 entities a day showing up on your network?

Do you have an open guest network (no username or password) that anyone can connect to?

What concerns me the most in that is that you said:

Does that mean there are others who actually connect to your non-guest network?

If I were you I think I would re-think my network security protocol. :grimacing:

Thank you for your concern.
I have for a while made a password based system for guest and it is secure, but still lots of devices show up on my networkunder guest. ie: the starbucks cash register system, ipads, android devices, the local dry cleaners and so on.
The entities change everytime I reboot HA.
What am I missing. I even turned off the guest for awhile b ut still all these entries show up.
carltonb

They are newly showing up on your system even after you added a username and password and even turned off your guest network?

The ones that were already on your network from before you should be able to go into your controller and select to forget them.

As far as I know if they can’t log on to your network with a secure password then they definitely shouldn’t be showing up in the list of connected devices. Just scanning your SSID shouldn’t then show them on your devices list.

As far as HA is concerned that’s an entirely different matter.

Thank you. I will dig into it further this weekend, and remove them from the controller.
Appreciate the help.

1 Like

Hey guys!

Im looking into making the integration automatically removing clients the user chooses to “Forget” in UniFi. This will hopefully smoothen things out a bit for you.

3 Likes

@Robban is there anyway you are able to have the device name populated on the integration? At the moment all the devices show as Unnamed device except for my hue and esphome devices as the corresponding integration has named them. My hope is that in naming the devices by the integration they will link to other existing devices I have slimming down my growing list of devices.

There is a current issue with devices and naming related to third party integrations like unifi. If unifi names all clients they might override a better name and additional information that a first party integrating is doing. Once support is added for second rate information in device description this can be fixed

Thanks for the clarification, perfect explanation.

Robban did you create a integration to automatically remove the clients?