Skip to content

Add humidity to NWS forecast#95575

Merged
gjohansson-ST merged 5 commits into
home-assistant:devfrom
lymanepp:nws_humidity
Jul 6, 2023
Merged

Add humidity to NWS forecast#95575
gjohansson-ST merged 5 commits into
home-assistant:devfrom
lymanepp:nws_humidity

Conversation

@lymanepp
Copy link
Copy Markdown
Contributor

@lymanepp lymanepp commented Jun 29, 2023

Proposed change

HA Core recently added support for including humidity in weather forecasts. Add humidity to NWS forecast to address #95572

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
  • I have followed the perfect PR recommendations
  • 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
Copy Markdown
Contributor

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

Code owner commands

Code owners of nws can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign nws Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@MatthewFlamm
Copy link
Copy Markdown
Contributor

Thanks! Have you tested this locally? It looks like "relativeHumidity" is a relatively new return from NWS endpoint with a different structure compared to other values in the forecase, i.e. it is a nested dict similar to the observations. This isn't in the testing of pynws currently.

@MatthewFlamm
Copy link
Copy Markdown
Contributor

Thanks! Have you tested this locally? It looks like "relativeHumidity" is a relatively new return from NWS endpoint with a different structure compared to other values in the forecase, i.e. it is a nested dict similar to the observations. This isn't in the testing of pynws currently.

Should have read your code a little closer before commenting, sorry. It looks like you have handled it the integration code. I wonder if it should instead be built into pynws to return the numerical value in a consistent manner rather than kludging it here?

@MatthewFlamm
Copy link
Copy Markdown
Contributor

There are also a bunch of new attributes that could be added: wind gust, apparent temp (I assume this is heat index or wind chill in NWS terms). I see other PRs adding these all in one PR if you prefer, and I'm also fine if you don't want to take that on.

@lymanepp
Copy link
Copy Markdown
Contributor Author

There are also a bunch of new attributes that could be added: wind gust, apparent temp (I assume this is heat index or wind chill in NWS terms). I see other PRs adding these all in one PR if you prefer, and I'm also fine if you don't want to take that on.

I created PR MatthewFlamm/pynws#117 to use as a starting point. Remaining tasks are:

  • Recapture test data
  • Add new tests
  • Add other fields of interest (e.g., wind gust, and apparent temp)

@gjohansson-ST
Copy link
Copy Markdown
Member

It seems a bit unclear from above comments but is this ready for merging (in case would you approve @MatthewFlamm ) or should we set it as draft waiting for upstream changes?

@lymanepp lymanepp marked this pull request as draft July 3, 2023 19:40
@lymanepp
Copy link
Copy Markdown
Contributor Author

lymanepp commented Jul 3, 2023

The decision was made to move the changes upstream, so I moved it to draft status

@MatthewFlamm
Copy link
Copy Markdown
Contributor

I concur.

@MatthewFlamm
Copy link
Copy Markdown
Contributor

MatthewFlamm commented Jul 4, 2023

pynws has a new release with better support for the new values, so this PR can be updated accordingly. Thanks to @lymanepp for taking on changes there and here.

Comment thread homeassistant/components/nws/weather.py
@lymanepp lymanepp marked this pull request as ready for review July 4, 2023 23:02
Copy link
Copy Markdown
Contributor

@MatthewFlamm MatthewFlamm left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure if the failing patch coverage will be required as your change on that line is fairly straightforward. If it is required, then I can help adding the test needed.

@lymanepp
Copy link
Copy Markdown
Contributor Author

lymanepp commented Jul 6, 2023

@gjohansson-ST thanks for fixing the reviewer mess that I inadvertently created

@gjohansson-ST
Copy link
Copy Markdown
Member

@lymanepp please do a rebase onto the latest dev branch

Copy link
Copy Markdown
Contributor

@MatthewFlamm MatthewFlamm left a comment

Choose a reason for hiding this comment

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

Test failure looks unrelated

@gjohansson-ST
Copy link
Copy Markdown
Member

---------- coverage: platform linux, python 3.10.11-final-0 ----------
Name                                          Stmts   Miss  Cover   Missing
---------------------------------------------------------------------------
homeassistant/components/nws/__init__.py         68      2    97%   79-80
homeassistant/components/nws/config_flow.py      47      0   100%
homeassistant/components/nws/const.py            18      0   100%
homeassistant/components/nws/sensor.py           69      1    99%   245
homeassistant/components/nws/weather.py         153      0   100%
---------------------------------------------------------------------------
TOTAL                                           355      3    99%

Would be great if we could add the missing coverage in a separate PR.
Test failures are unrelated so will approve this one.

Copy link
Copy Markdown
Member

@gjohansson-ST gjohansson-ST left a comment

Choose a reason for hiding this comment

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

Thanks

@gjohansson-ST gjohansson-ST merged commit 6c4b529 into home-assistant:dev Jul 6, 2023
@lymanepp lymanepp deleted the nws_humidity branch July 6, 2023 21:17
ScottG489 pushed a commit to ScottG489/core that referenced this pull request Jul 6, 2023
* Add humidity to NWS forecast to address home-assistant#95572

* Use pynws 1.5.0 enhancements for probabilityOfPrecipitation, dewpoint, and relativeHumidity.

* Update requirements to match pynws version

* test for clear night

* update docstring

---------

Co-authored-by: MatthewFlamm <39341281+MatthewFlamm@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 7, 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.

Add humidity to National Weather Service (NWS) forecasts

3 participants