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
Update Unifi bandwidth sensors #101598
Update Unifi bandwidth sensors #101598
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.
Hi @wittypluck
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
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
|
Thanks for the PR. Please start by fixing the failing checks which seems to be related to unsorted imports. If you use the pre-commit tools this would be fixed automatically |
Thank you for the comment and the tip, I'm still having issues with the pre commit tools but will make sure the formatting is correct. |
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.
Thanks
Hi @Kane610, thanks for approving the change. It seems I still have a few tests to fix, I'm working on it. |
Apologies for loosing track of the review. Let's get this in before next beta branches off |
No problem! |
Thank you @wittypluck |
Thank you @Kane610 as this was my first commit in home assistant ! |
Welcome to the club @wittypluck |
Proposed change
This Pull request aim is to improve Unifi network bandwidth sensor. Currently, bandwidth sensors (RX, TX) have the unit set as MEGABYTE, and are not flagged as Measurement. They need to be wrapped in template sensors to be used as bandwidth sensors.
Updating the unit of measurement to MEGABYTES_PER_SECOND and the device class to DATA_RATE ensure that the sensors can be used "as is" in Home assistant without adding additional template sensors to convert to the correct units.
Additionally the sensors are now automatically picked up by the History feature of Home assistant to provide long term statistics.
The PR also adds
a suggested unit of measurement (MEGABITS_PER_SECOND) andan icon to each of the TX, RX sensors.I have tested locally that the PR does not provoke regressions for existing users of the integration, and that changes to the sensors are picked up correctly for existing and new users of the integration.
I have also tested locally through bandwidth tests that although the Unifi documentation of the underlying sensors (rx_bytes-r / tx_bytes-r / wired-rx_bytes-r / wired-tx_bytes-r) is not very explicit, they do indeed correspond to a measure in bytes over the last second.
I have also tested locally that somewhat un-intuitively the "TX" sensor corresponds to download bandwidth (as seen from the device) and the "RX" sensor corresponds to upload bandwidth (as seen from the device).
Type of change
Additional information
Checklist
black --fast 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: