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

Added a WeatherProvider for Open-Meteo #2964

Merged
merged 7 commits into from
Dec 26, 2022

Conversation

angeldeejay
Copy link
Contributor

Added Weather Provider for Open-Meteo.

I've found a completely free weather REST API (event with option of self-hosting) after having problems with API keys from all MagicMirror weather providers currently implemented (the remote services, not the providers themselves).

This API doesn't return information about reverse geocode from latitude and longitude options like others. I solved that issue using another free API.

APIs used

Considerations

  • This provider is config reliable so, be free to use the same config you can found in the official MagicMirror Weather module documentation.
  • This module config skips the apiKey parameter. It's not used at all. Only latitude and longitude are required.

Config examples:

modules: [
  {
    module: "weather",
    position: "top_right",
    header: "Weather Forecast",
    config: {
      updateInterval: <number here>, 
      weatherProvider: "openmeteo",
      type: "current",
      lat: <number here>,
      lon: <number here>,
      showHumidity: true,
      showWindDirectionAsArrow: true,
      showWindDirection: true,
      degreeLabel: true,
    }
  },
  {
    module: "weather",
    position: "top_right",
    header: "Weather Forecast",
    config: {
      updateInterval: <number here>,
      weatherProvider: "openmeteo",
      type: "daily",
      lat: <number here>,
      lon: <number here>
      colored: true,
      maxNumberOfDays: <number here>,
      showPrecipitationAmount: true,
      appendLocationNameToHeader: true
    }
  },
  {
    module: "weather",
    position: "top_right",
    header: "Weather Forecast",
    config: {
      updateInterval: <number here>,
      weatherProvider: "openmeteo",
      type: "hourly",
      lat: <number here>,
      lon: <number here>,
      maxEntries: <number here>,
      showPrecipitationAmount: true,
      degreeLabel: true,
      appendLocationNameToHeader: true
    }
  },
]

@angeldeejay
Copy link
Contributor Author

@rejas can you please take a look? Thanks!

modules/default/weather/providers/openmeteo.js Outdated Show resolved Hide resolved
modules/default/weather/providers/openmeteo.js Outdated Show resolved Hide resolved
modules/default/weather/providers/openmeteo.js Outdated Show resolved Hide resolved
@angeldeejay
Copy link
Contributor Author

@rejas Changes suggested marked as solved

@rejas
Copy link
Collaborator

rejas commented Nov 4, 2022

Trying out your PR I get an error with this config:

{
	module: "weather",
	//disabled: true,
	position: "top_right",
	config: {
		weatherProvider: 'openmeteo',
		type: "current",
		lat: 52.520008,
		lon: 13.404954,
	}
},

Error is:

Uncaught TypeError: moment.tz is undefined [openmeteo.js:218:5](http://localhost:8080/modules/default/weather/providers/openmeteo.js)

It seems it tries to guess the timezone? Is that really necessary for a current weather call?

@angeldeejay
Copy link
Contributor Author

I'll take a look. Thx

@angeldeejay
Copy link
Contributor Author

angeldeejay commented Dec 12, 2022

@rejas I've removed support for moment-timezone in favor of API Documentation's param timezone with auto value supported now. Timezone is provided automatically by the OpenMeteo API using coordinates given in payload.

Please refer to Open-Meteo Weather Forecast API

modules/default/weather/providers/openmeteo.js Outdated Show resolved Hide resolved
hourly: this.hourlyParams,
// Fixed units as metric
temperature_unit: "celsius",
windspeed_unit: "kmh",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The wind units need to be stored in meters per second in the weatherobject, not kmh. Please convert them if the api doesnt provide that

Copy link
Collaborator

Choose a reason for hiding this comment

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

This isnt fixed yet

- Forecast type bug fixed. Use of type  should be working now.
- Skipping offset of start date (avoiding use of  in provider.
@rejas
Copy link
Collaborator

rejas commented Dec 22, 2022

Since the year is rapidly nearing its end (and therefore a new release is coming up soon) I would propose to merge this even though it still has a bug (or two depending if I caught them all).
The reasoning behind it is:

  • this PR doesnt touch any other code, therefor wont break anything
  • it adds a new feature/provider which works for most use cases
  • releasing it now will get more reach for testing so more bugs can be found

Any comments @angeldeejay @khassel @sdetweil @MichMich ?

@khassel
Copy link
Collaborator

khassel commented Dec 22, 2022

@rejas feel free to merge ...

@rejas
Copy link
Collaborator

rejas commented Dec 26, 2022

Merging this in the holiday spirit :-)

@angeldeejay would be nice if you could add some documentation to the doc repo for this provider (https://github.com/MichMich/MagicMirror-Documentation) and in the new year see if you can fix the remaining bugs. Happy holidays everyone!

@rejas rejas merged commit e9be668 into MagicMirrorOrg:develop Dec 26, 2022
@angeldeejay
Copy link
Contributor Author

Merging this in the holiday spirit :-)

@angeldeejay would be nice if you could add some documentation to the doc repo for this provider (https://github.com/MichMich/MagicMirror-Documentation) and in the new year see if you can fix the remaining bugs. Happy holidays everyone!

I'll be adding more explained docs about this feature. Thanks for your effort

@rejas
Copy link
Collaborator

rejas commented Feb 6, 2023

hi @angeldeejay I wanted to check in if you are still interested in updating the documentation or if you need support for that?

@angeldeejay
Copy link
Contributor Author

hi @angeldeejay I wanted to check in if you are still interested in updating the documentation or if you need support for that?

Off course!, I had some personal issues the last month, but I'll be updating documentation for this provider. Sorry

@angeldeejay
Copy link
Contributor Author

rejas pushed a commit that referenced this pull request Mar 1, 2023
Resolved technical debt for
[2964](#2964):

- Set wind speed unit to m/s
- Rename parameter `past_days` to `pastDays` to be consistent with all
configs
@angeldeejay angeldeejay deleted the openmeteo-provider branch March 1, 2023 08:42
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.

4 participants