I’ve added support for deleted messages from the controller. It does not affect anything of you removed stuff prior to the support was added
I run a script based on @shbatm 's script (in this thread) every hour with cron/systemd. It deletes bogus MACs from the unifi controller.
Ever since, I have not had the problem again
Can you share the script. I could provide a service doing that
My original one is here Unifi integration - large number of unnamed devices
Curious to see @inkylatte’s improvements too.
Here’s my script (python). It’s a bit unique to my situation because all the bogus MACs that I want to remove all end with the same MAC suffix. But one can tweak/customize the script.
cc: @shbatm
Hey all! Time really does fly, I apologise I didn’t resolve what I stated earlier (though I’ve kept the last reply in mail form as unread as I always intended to get back to it).
I’m back on this issue now (https://github.com/Kane610/aiounifi/pull/73), and have started looking into old references to this issue to grasp what solution would be the appropriate one from a usability stand point.
The goal here is to offer a service for UniFi in Home Assistant, the big question is how smart the service should be; should it just remove everything fitting a certain number of empty attributes or should the user select entities to remove or both.
Or maybe the service input should select what attributes and limits to look at for all clients.
I’d like your feedback on how you’d like this to work.
/Robban
First off thank you Robban for all the work you’ve done. I just purged my controller last night. I would like to see a drop down for each option, like you have for the network access switch, for device trackers and rx/tx stats.
Right now it’s all or nothing. To track 3 devices I have 50 entities. Same with rx/tx stats.
This is really a discussion by itself, and shouldn’t be part of this specific issue. Can you create a new post. Maybe feature request in the forum and tag me for future discussions? I do have thoughts on the subject that has evolved from the original implementation.
I started a feature request and it can be found here:
Hello!
I’m thinking of limiting an initial implementation with the following logic:
async def async_remove_clients(controllers, data):
"""Remove select clients from controller.
Validates based on:
- Total time between first seen and last seen is less than 15 minutes.
- Neither IP, hostname nor name is configured
"""
for controller in controllers:
if not controller.available:
continue
clients_to_remove = []
for client in controller.api.clients_all.values():
if client.last_seen - client.first_seen > 900:
continue
if any({client.fixed_ip, client.hostname, client.name}):
continue
clients_to_remove.append(client.mac)
await controller.api.clients.remove_clients(macs=clients_to_remove)
Pull request has been posted, feel free to comment https://github.com/home-assistant/core/pull/56717
I know this is a very late reply, and I didn’t check if someone has pointed it out already, but this has been my experience: when I forget a device in the UniFi controller, I have to make sure the related entity in HA is enabled. If it is, then forgetting the device in the UniFi controller will remove it from HA as well. If the entity is disabled in HA, then forgetting the device in the UniFi controller will only remove it there, not in HA.
Well, that is quite useful information.
thanks!
Has there been any movement on this (the original point about unnamed devices?
I sometimes get cryptic entities added which is annoying although I have been able to remove them from HA after forgetting them in the controller but I have four devices I can’t get rid of.
Any help would be greatly appreciated.
Yes the behaviour of device trackers will change for next release in that devices will not be created for device trackers, they will only attach to already existing devices.
So if I just wait for the next release, my unnamed devices will automagically disappear?
If so, great, and thanks!
Sorry, i’m not following that.
Could you more fully explain, please?
Devices in home assistant will not be generated by device trackers but only by other entity platforms. Meaning if you have device trackers they might not seem to belong to a device until another entity reports it belongs to the same device.
With device I mean device in device registry in home assistant and with device Tra ker i mean the entity that tracks network devices to show if they’re at home or not
So they still create entities but just not necessarily devices?
Yes that’s correct