-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sensor for CPU and memory utilization for unifi device #114986
Add sensor for CPU and memory utilization for unifi device #114986
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
a7c06f3
to
f33e062
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
335eeab
to
519598a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great, one thing left
632f54f
to
5766857
Compare
@Kane610 I see that So should we either add the missing data or should we expend |
I think we need to replace the lambda with a method here to be a bit smarter with supported_fn. It should take device and index or something and still validate the existence of system stats but also check for the expected value if it is "" the method should return false |
ebfe095
to
55aa868
Compare
Do you think on something like this @Kane610 ? |
If you add index as well we can combine them to one method and you can use partial to define index to look for when instantiating the entity description. If that makes sense |
Do you think on something like this def device_system_stats_supported_fn(
hub: UnifiHub, obj_id: str, stat_index: int
) -> bool:
"""Determine if a device supports reading item at index in system stats."""
return (
"system-stats" in hub.api.devices[obj_id].raw
and hub.api.devices[obj_id].system_stats[stat_index] != ""
) supported_fn=lambda hub, obj_id: device_system_stats_supported_fn(
hub, obj_id, 0
), |
Exactly, I think you might need to put the stat index first and you can skip the lambda and do partial which is shorter supported_fn=partial(device_system_stats_supported_fn, 0), |
55aa868
to
e72f8f9
Compare
e72f8f9
to
7c39f76
Compare
Didn't know that! Nice. |
Skimmed through and it looked OK. Will review tonight |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks
It's me that say thanks! @Kane610 I've considered to look into if I could add the WAN tx/rx, so it's possible to see the usage of all connected devices. |
You're welcome to do it! Not exactly sure where, you probably need to figure out which device is the main gateway and maybe there it will have a port which represents WAN rx/tx |
Breaking change
This should only be additive.
Proposed change
I saw that this pr was stalled and never merged: #74025
As I was setting up my new home assistant, I tought it would be nice with this information on my dashboard. So why not contributing 🤷♂️
So this PR aims to add
system_stats
sensors. The uptime is already added, but bot trough the system stats tough.I've added a sensor for CPU and memory utilization.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: