zachcheatham / ha-omada

Home Assistant TP-Link Omada Integration
189 stars 26 forks source link

feature request: service to clean up old device ids #49

Open wuppiwuppi opened 1 year ago

wuppiwuppi commented 1 year ago

Hi,

I like this integration really much - however I have a lot of "tracked devices". The AVM FritzTools Integration offers a service to clean up old entities. https://www.home-assistant.io/integrations/fritz/#platform-services

It would be nice to have a similar thing for this integration.

br Andre

jcbolive commented 1 year ago

I would also like a function to filter the devices for integration

wuppiwuppi commented 1 year ago

You can always disable the not needed device tracker entities in home assistant.

How would you define the Filter?

jcbolive commented 1 year ago

I would like to filter like it is done below, inside the config

Omada: filter: include_entities:

ankushg commented 1 year ago

+1 to this - would be great if we could opt-in to only track certain devices

TommySharpNZ commented 1 year ago

Agreed, rather than blindly loading all devices.... I would prefer to select which devices the integration tracks.

J1mooo commented 1 year ago

That would be a cool feature +1

martinj27 commented 1 year ago

+1

nafur commented 9 months ago

I'd love some version of this. My HA interface is virtually unusable once it has loaded all omada devices... Some other variants that would solve this for me:

nafur commented 9 months ago

So I looked into this a bit further, and realized that there is a lot of stuff already in place to deal with this issue: there is an ssid filter (I'm not sure about the relation of ssid and vlan names here), and there are mechanisms to remove "outdated" entities. ~There is one weird thing so: The core logic of which devices are considered is here:~ https://github.com/zachcheatham/ha-omada/blob/257cccca035b1315b0ef2f0e7160b926c1b96a8b/custom_components/omada/controller.py#L184 ~It says to add a device if there is no ssid filter set or the client was not already added or the ssid of the client is in the ssid filter. This seems a bit off, and I would expect this to be if there is no ssid filter set or (the client was not already added and the ssid of the client is in the ssid filter). I've done this change locally, and it seems to reduce the number of (stale) devices and entities in my system every time HA is restarted (it will always timeout because there are so many, but it manages to remove a bunch before). @zachcheatham is this a bug?~

[Update] After some more debugging, it seems that this second part of the condition takes care of devices (in the omada sense) that are not clients, i.e., switches, APs etc. So I guess as long as you can get away with the ssid filter, everything should be fine.