zachcheatham / ha-omada

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

Add connected clients sensor #102

Closed h3llrais3r closed 2 months ago

h3llrais3r commented 2 months ago

Add a connected clients sensor that contains the total number of connected clients. It also includes the list of clients (mac, name, ip) in the clients attribute of the sensor. Example: image

h3llrais3r commented 2 months ago

Let me know if this is ok, or any changes are required.

h3llrais3r commented 2 months ago

I'm also not sure why yet, but I cannot get this new sensor to appear in my environment. I see the value fn running, but no entity exists. I'll let you know if I find the problem.

I've just retried by re-adding the integration from scratch, but I directly see the sensor sensor.omada_controller_clients.

image

h3llrais3r commented 2 months ago

Let me know if changes are ok or more changes are required. 😉

zachcheatham commented 2 months ago

Sorry for the delay on this, I haven't had much time to debug and I'm still trying to get it to work. I've tried with a fresh install of home assistant and the entity is still not being added. Every time I restart the instance I can see Registered new sensor.omada entity: sensor.cheatham_clients but it does not appear in the entity list or under the Controller's device. I'm not sure if this is a bug in home assistant or some other issue. I do not see any errors, just no entity appearing.

zachcheatham commented 2 months ago

I ended up finding the issue. The sensor was immediately being removed by restore_cleanup_platform_entities as it did not have a mac associated with it (as it shouldn't.) I'm going to go ahead and accept this and then make the fix to the cleanup function. Thanks again for the contributions!

h3llrais3r commented 2 months ago

I ended up finding the issue. The sensor was immediately being removed by restore_cleanup_platform_entities as it did not have a mac associated with it (as it shouldn't.)

Strange that I didn't had the same behavior. I was running it on a dev environment (clean setup with devcontainer). Anyway, it's a good thing that you found it. Thanks for accepting the PR's. 😉

EDIT: I've just installed version 0.6.0-beta.1 and it works perfectly.