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

Add smhi wind gust speed and thunder probability #50328

Merged
merged 8 commits into from May 10, 2021

Conversation

crallian
Copy link
Contributor

@crallian crallian commented May 9, 2021

Added the extra attributes:
wind_gust_speed and
thunder_probability
that were already implemented in the underlaying library (joysoftware/pypi_smhi).

Also for the existing extra attribute "cloudiness", it is now added if "is not None" instead of just "if self.cloudiness" which would make it False (and therefore not available) if cloudiness = 0, which I think was a bug. Therefore i don't consider it to be a breaking change?
I found this because thunder probability is often 0... and I first wrote the attribute code exactly as the old one.

Proposed change

Adds wind gust speed and thunder probability as extra attributes. These were already implemented in the underlaying library.

I am sorry, but I am not sure how to run the required tests according to the lists below.
I just made the changes in notepad++, uploaded to custom_components folder and it seems to work without any error logs.

Variables/attributes are added, but as I think they are self explaining, and the existing ones are not documented either, I have not proposed any changes to home-assistant.io.

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)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

Added the extra attributes
wind_gust_speed and
thunder_probability
that were already implemented in the underlaying library (joysoftware
/
pypi_smhi).

Also for the existing extra attribute cloudiness, it is added if "is not None" instead of just "if self.cloudiness" which would make it False (and therefore not available) if cloudiness = 0.
@project-bot project-bot bot added this to Needs review in Dev May 9, 2021
Removed white spaces and changed order of list as suggested by the tests.
Removed some more white spaces...
@MartinHjelmare MartinHjelmare changed the title Added some extra attributes Add smhi wind gust speed and thunder probability May 9, 2021
Dev automation moved this from Needs review to Review in progress May 9, 2021
Changed dictionary handling as suggested by MartinHjelmare.
@MartinHjelmare
Copy link
Member

MartinHjelmare commented May 9, 2021

Please add an assertion of the new attributes here:

assert state.attributes[ATTR_SMHI_CLOUDINESS] == 50

Updated test_weather.py to include the new attributes wind_gust_speed and thunder_probability.
Dev automation moved this from Review in progress to Reviewer approved May 10, 2021
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Thanks!

Added the missing imports
ATTR_SMHI_THUNDER_PROBABILITY,
ATTR_SMHI_WIND_GUST_SPEED,
… valuesfor

Renamed the new internal attribute
thunder to thunder_probability, same as the exposed attribute for improved consistency.
Corrected test values according to smhi.json.
@crallian
Copy link
Contributor Author

@MartinHjelmare Thank you for the patience and for showing me where to find the test data. I really learned a lot, and hope it will go much smoother next time!

Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Great!

@MartinHjelmare MartinHjelmare merged commit fca5699 into home-assistant:dev May 10, 2021
Dev automation moved this from Reviewer approved to Done May 10, 2021
@github-actions github-actions bot locked and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants