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

Use metric units internally in all weatherproviders #2849

Merged
merged 21 commits into from
Oct 24, 2022

Conversation

rejas
Copy link
Collaborator

@rejas rejas commented May 10, 2022

So finally I think this refactorin is ready to be reviewed :-)

DONE:

  • Removed all conversion functions for wind and temperature from specific weatherproviders
  • Use internally only metric units: celsius for temperature, meters per seconds for wind
  • Convert temp and wind into the configured units when displaying data on the UI
  • look how beaufort calculation uses metrics, added knots as new windunit
  • add more e2e tests

Checked providers:

  • Darksky
  • EnvCanada
  • OpenWeatherMap
  • SMHI provider
  • UK Met Office
  • UK Met Office DataHub
  • WeatherBit
  • WeatherFlow
  • WeatherGov

TODO in different tickets:

@codecov-commenter
Copy link

codecov-commenter commented May 10, 2022

Codecov Report

Merging #2849 (6cd8557) into develop (7bd9443) will decrease coverage by 0.07%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #2849      +/-   ##
===========================================
- Coverage    65.28%   65.21%   -0.08%     
===========================================
  Files           14       14              
  Lines          726      733       +7     
===========================================
+ Hits           474      478       +4     
- Misses         252      255       +3     
Impacted Files Coverage Δ
js/app.js 69.53% <0.00%> (-0.72%) ⬇️
js/server.js 67.56% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@MichMich
Copy link
Collaborator

I love this PR. This is so much cleaner. Thanks! Let me know when it's ready to be merged.

@rejas
Copy link
Collaborator Author

rejas commented Jun 20, 2022

I think this will not be ready for the next release, mainly due to not being sure if there arent any bugs in it. Would be nice to have people test this PR with their repsective providers...
Of course more tests would also be nice, which I might be ablke to do but probably not before August....

@MichMich
Copy link
Collaborator

No worries. It can easily wait till next release. 👍🏻

@buxxi
Copy link
Contributor

buxxi commented Jul 12, 2022

Verified that the SMHI provider works as expected using the branch from this pull request. Great job.

@berlincount
Copy link
Contributor

This is awesome, and truly so much cleaner! 👍

Might I suggest to change the useBeaufort etc to windUnitsalong the lines of tempUnits?

As a pilot, I'd love support for knots there ...

P.S: found this PR while researching the integration of UV Index, but I'll hold off on that until this is merged. Great work!

@rejas
Copy link
Collaborator Author

rejas commented Aug 17, 2022

Since darksky is bought by apple and will stop in 2023 they dont allow new signups for their webapi anymore. Can anyone of the original developers check out the code (and maybe check out #2899 too if that is a proble there too?)

Also, probably have to deprecate the provider sooner or later :-) Not sure if the Apple WeatherKit is something to follow up since there isnt a real free plan as far as I can see (https://developer.apple.com/weatherkit/get-started/)

So, regarding checking darksky out, I look at @nhubbard @fewieden and @buxxi since they might have api access still :-)

@buxxi
Copy link
Contributor

buxxi commented Aug 28, 2022

I have never tried the darksky provider, so I can't help with that.

@rejas
Copy link
Collaborator Author

rejas commented Aug 29, 2022

so I hopefully fixed all providers with respect to temperature and wind.

only with weatherflow I had to blindly "fix" it since I dont have a station for that api. maybe the original author @10bias can test this?

next I will take a look at the other open points. still, any testing is welcome :-)

@rejas
Copy link
Collaborator Author

rejas commented Aug 29, 2022

Might I suggest to change the useBeaufort etc to windUnitsalong the lines of tempUnits?

I am not an expert in wind stuff, so how would the windunits look like at the end?

@berlincount
Copy link
Contributor

berlincount commented Sep 4, 2022

Might I suggest to change the useBeaufort etc to windUnitsalong the lines of tempUnits?

I am not an expert in wind stuff, so how would the windunits look like at the end?

if you've got m/s, it's comparatively simple.

https://www.convert-measurement-units.com/convert+Meters+per+second+to+Beaufort.php

is a great reference :) I guess we'd love km/h, Beaufort, and knots.

(if I get to it, I can write that code, but not today)

@rejas
Copy link
Collaborator Author

rejas commented Sep 16, 2022

Might I suggest to change the useBeaufort etc to windUnitsalong the lines of tempUnits?

I am not an expert in wind stuff, so how would the windunits look like at the end?

if you've got m/s, it's comparatively simple.

https://www.convert-measurement-units.com/convert+Meters+per+second+to+Beaufort.php

is a great reference :) I guess we'd love km/h, Beaufort, and knots.

(if I get to it, I can write that code, but not today)

So I worked a little tonight at the windunits on my branch:

  • useKmh and useBeafort is deprecated, internally the config windUnits is used instead
  • windUnits allows "metric" (m/s), "imperial" (mph), "kmh", "beaufort" for now, plus also "knots"

Slowly getting to the finish line with this PR ;-)

@rejas rejas force-pushed the issue_2812 branch 2 times, most recently from db97ef8 to a554dcb Compare September 21, 2022 04:44
@rejas rejas force-pushed the issue_2812 branch 9 times, most recently from 68f0e02 to 6de8769 Compare October 4, 2022 13:36
especially move sunset/sunrise to e2e tests
@rejas rejas marked this pull request as ready for review October 19, 2022 10:16
Copy link
Contributor

@buxxi buxxi left a comment

Choose a reason for hiding this comment

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

Looking good!

@rejas
Copy link
Collaborator Author

rejas commented Oct 24, 2022

Not sure if the other two will review here, so feel free to merge @khassel :-)

@khassel khassel merged commit 2d3940a into MagicMirrorOrg:develop Oct 24, 2022
@rejas rejas deleted the issue_2812 branch October 24, 2022 18:13
@MichMich MichMich mentioned this pull request Jan 1, 2023
MichMich added a commit that referenced this pull request Jan 1, 2023
## [2.22.0] - 2023-01-01

Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @tom.

Special thanks to @khassel, @rejas and @sdetweil for taking over most
(if not all) of the work on this release as project collaborators. This
version would not be there without their effort. Thank you!

### Added

- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"

### Removed

- Removed usage of internal fetch function of node until it is more
stable

### Updated

- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
  - Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
  - Reworked how weatherproviders handle units (#2849)
  - Use unix() method for parsing times, fix suntimes on the way (#2950)
  - Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `&hellip;` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)

### Fixed

- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)

Signed-off-by: naveen <[email protected]>
Co-authored-by: Karsten Hassel <[email protected]>
Co-authored-by: Malte Hallström <[email protected]>
Co-authored-by: Veeck <[email protected]>
Co-authored-by: veeck <[email protected]>
Co-authored-by: dWoolridge <[email protected]>
Co-authored-by: Johan <[email protected]>
Co-authored-by: Dario Mratovich <[email protected]>
Co-authored-by: Dario Mratovich <[email protected]>
Co-authored-by: Magnus <[email protected]>
Co-authored-by: Naveen <[email protected]>
Co-authored-by: buxxi <[email protected]>
Co-authored-by: Thomas Hirschberger <[email protected]>
Co-authored-by: Kristjan ESPERANTO <[email protected]>
Co-authored-by: Andrés Vanegas Jiménez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants