Skip to content
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

Huawei LTE sensor improvements #84019

Merged
merged 8 commits into from
Jan 13, 2023
Merged

Huawei LTE sensor improvements #84019

merged 8 commits into from
Jan 13, 2023

Conversation

scop
Copy link
Member

@scop scop commented Dec 14, 2022

Proposed change

Various improvements to Huawei LTE sensors.

  • Fix current month download/upload amount state classes (totals resetting monthly/manually, not total increasing)
  • Exclude current day duration (running number from start of day) sensor, like we already do for the corresponding month one
  • Make ARFCN, BSIC, current day transfer, EARFCN, downlink frequency, and uplink frequency sensors more human readable, distinguish last two from the similar LTE ones
  • Let HA handle unknown states by returning None
  • Make use of huawei_lte_api's NetworkModeEnum
  • Code reuse and function naming consistency improvements

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @fphammerle, mind taking a look at this pull request as it has been labeled with an integration (huawei_lte) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of huawei_lte can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign huawei_lte Removes the current integration label and assignees on the issue, add the integration domain after the command.

@@ -183,7 +215,7 @@ class HuaweiSensorEntityDescription(SensorEntityDescription):
),
"ltedlfreq": HuaweiSensorEntityDescription(
key="ltedlfreq",
name="Downlink frequency",
name="LTE downlink frequency",
formatter=lambda x: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: in #83904 I noticed there were quite a few multi-line lambdas.
Is there a way they could be converted to single line lambdas or moved to stand-alone functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, at least named functions. I'm not sure multiline lambdas are a problem per se. c530a0e converts bodies of ones that are used more than once to named functions; converting ones that are used only does not seem to be a net positive to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epenet made the requested changes, any chance for a review here? :)

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Dec 21, 2022
@scop scop mentioned this pull request Jan 11, 2023
19 tasks
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oopsie, I forgot to submit this earlier during the holidays as I got stuck trying to understand how the last_reset is expected to work, and frustrated when trying to understanding how all these changes are related...

To my understanding there are (at least) the following changes included in this single PR:

  • New sensors: ARFCN, BSIC, Downlink frequency, Uplink frequency, Current day transfer
  • Renamed sensors: downlink frequency -> lte downlink frequency, uplink frequency -> lte uplink frequency
  • Refactoring: some descriptions were converted to avoid multiline lambdas
  • Fixes: current month upload, current month download converted to use last_reset for handling reset cycles

FWIW, this looks good to me on the surface and could be merged as is, thanks @scop! Could you still update the PR description to be a bit more informative than just "various changes/improvements/fixes", even if just listing a cleaned-up version of the commit messages to help any readers to?

homeassistant/components/huawei_lte/sensor.py Show resolved Hide resolved
@scop
Copy link
Member Author

scop commented Jan 11, 2023

Fair enough, description updated. Note that we don't actually add any new sensors here, but rather add metadata about them to help HA render and utilize better a bunch of ones that were previously passed through "raw as-is" from the device API.

@scop scop force-pushed the scop-huawei-lte-sensors branch from ee8192c to 6bea5c1 Compare January 12, 2023 21:16
@rytilahti
Copy link
Member

Let's merge it and fix whatever we missed if someone chimes in, thanks @scop! :-)

@rytilahti rytilahti merged commit a5a079f into dev Jan 13, 2023
@rytilahti rytilahti deleted the scop-huawei-lte-sensors branch January 13, 2023 17:27
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants