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

Weather module forecast not working with openweathermap #1504

Closed
fwitte opened this issue Jan 3, 2019 · 12 comments
Closed

Weather module forecast not working with openweathermap #1504

fwitte opened this issue Jan 3, 2019 · 12 comments

Comments

@fwitte
Copy link
Contributor

fwitte commented Jan 3, 2019

Hi again,
looking into the weather modules I stumbled across the different configuration keys for essentially the same purpose in the currentweather (degreeLabel) and the weatherforecast (scale) modules. I think, it would be more intuitive using the same key for both modules. Personally, I prefer the weatherforcast version.

weatherforecast
https://github.com/MichMich/MagicMirror/blob/de57daa3cd881ce1a14b88307bf61e8109879c81/modules/default/weatherforecast/weatherforecast.js#L28

currentweather
https://github.com/MichMich/MagicMirror/blob/de57daa3cd881ce1a14b88307bf61e8109879c81/modules/default/currentweather/currentweather.js#L30

Is this change applicable, as this is a change in the API? I will open a PR, if this change is desired, the implementation should then be postponed to the next major release.

Have a nice day!

@MichMich
Copy link
Collaborator

MichMich commented Jan 3, 2019

I agree, but it's important that it's not a breaking change. So the old configuration should still work. Feel free to send a PR to the develop branch.

@MichMich
Copy link
Collaborator

MichMich commented Jan 3, 2019

Also note that we are working on a new weather module which will replace both current weather modules. It's included in the latest release.

@fwitte
Copy link
Contributor Author

fwitte commented Jan 3, 2019

Thanks for your hint!

Just one more question: I can not make the forecast work, can you provide a working example or give me a hint, where my error might be? Thank you and have a nice day!

This is my code, it works with type: "current". Providing the initialLoadDelay parameter, does not change the behavior. In this configuration, the output is "Loading …".

		{
			module: "weather",
			position: "top_right",
			header: "Vorhersage",
			config: {
				type: "forecast",
				degreeLabel: true,
				location: "mylocation",
				locationID: "mylocationid",  //ID from http://www.openweathermap.org/help/city_list.txt
				apiKey: "myweatherid"
			}
		},

@MichMich
Copy link
Collaborator

MichMich commented Jan 3, 2019

@fewieden Any idea?

@fewieden
Copy link
Contributor

fewieden commented Jan 3, 2019

The problem is that you need to specify another weatherendpoint for openweathermap forecast like weatherEndpoint: "/forecast/daily"

More informations here: https://github.com/MichMich/MagicMirror/tree/master/modules/default/weather#openweathermap-options

@fewieden
Copy link
Contributor

fewieden commented Jan 3, 2019

If is set the initial load delay to 30 seconds it is delayed by 30 seconds. Be aware of that you need to specify th timeframe in milliseconds like: initialLoadDelay: 30000

More informations here: https://github.com/MichMich/MagicMirror/tree/master/modules/default/weather#general-options

@fwitte
Copy link
Contributor Author

fwitte commented Jan 4, 2019

Thanks for your help, still does not work. I dug into the code and found the following:

Excerpt of a single set of data in the .json-file from openweather weather forecast (at least for me) looks like this:

"main":{
"temp":5.52,"temp_min":5.32,"temp_max":5.52,"pressure":1043.34,"sea_level":1044.06,"grnd_level":1043.34,"humidity":86,"temp_kf":0.2
},
"rain":{"3h":0.1625}

Thus, this part needs to be changed

https://github.com/MichMich/MagicMirror/blob/6914465e3dc357b3e15af77f829dedc1ec058bbd/modules/default/weather/providers/openweathermap.js#L95-L103

like this:

weather.date = moment(forecast.dt, "X");
weather.minTemperature = forecast.main.temp_min;
weather.maxTemperature = forecast.main.temp_max;
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
if (this.config.units === "imperial" && !isNaN(forecast.rain['3h'])) {
	weather.rain = forecast.rain['3h'] / 25.4;
} else {
	weather.rain = forecast.rain['3h'];
}

Another issue with the data is, they are provided in a set for three hours. I will make a PR with the adjusted code.

@fwitte
Copy link
Contributor Author

fwitte commented Jan 4, 2019

P. S.: The discussion drifted away in someway, I'll edit the title.

@fwitte fwitte changed the title Change configuration parameter for unit label in weather-modules Weather module forecast not working with openweathermap Jan 4, 2019
@vincep5
Copy link
Contributor

vincep5 commented Jan 4, 2019

I have some concerns with strictly using forecast.rain['3h']. I added a comment to your PR

@fwitte
Copy link
Contributor Author

fwitte commented Jan 4, 2019

Hey vincep5,
thanks for your feedback. As I do not have access to forecast/daily, can you post an excerpt of a .json file for the rain part? I will try adjusting my code, to make it work in both versions.
Have a nice day!

@vincep5
Copy link
Contributor

vincep5 commented Jan 4, 2019

thanks so much, I will have to configure my setup to the develop branch one day to assist in testing this new stuff. Here's a snip of 1 day of my forecast. It's contained inside a "list": []
example :
{ "dt": 1547053200, "temp": { "day": 44.01, "min": 34.54, "max": 50.41, "night": 50.41, "eve": 45.45, "morn": 34.54 }, "pressure": 1004.54, "humidity": 0, "weather": [ { "id": 502, "main": "Rain", "description": "heavy intensity rain", "icon": "10d" } ], "speed": 10.85, "deg": 208, "clouds": 97, "rain": 30.06 }

@fwitte
Copy link
Contributor Author

fwitte commented Jan 5, 2019

Resolved in #1506, further discussion in #1513.

@fwitte fwitte closed this as completed Jan 5, 2019
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

No branches or pull requests

4 participants