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

Comments

Projects
None yet
4 participants
@fwitte
Copy link
Contributor

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

currentweather

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Owner

commented Jan 3, 2019

@fewieden Any idea?

@fewieden

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

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

weather.date = moment(forecast.dt, "X");
weather.minTemperature = forecast.temp.min;
weather.maxTemperature = forecast.temp.max;
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
weather.rain = forecast.rain / 25.4
} else {
weather.rain = forecast.rain;
}

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

commented Jan 4, 2019

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

@fwitte

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Jan 5, 2019

Resolved in #1506, further discussion in #1513.

@fwitte fwitte closed this Jan 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.