mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #2600 from njwilliams/njw/openweathermap-onecall-fix
This commit is contained in:
commit
7fdf7de11c
@ -48,6 +48,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel,
|
|||||||
- Fix calendar start function logging inconsistency.
|
- Fix calendar start function logging inconsistency.
|
||||||
- Fix updatenotification start function logging inconsistency.
|
- Fix updatenotification start function logging inconsistency.
|
||||||
- Checks and applies the showDescription setting for the newsfeed module again
|
- Checks and applies the showDescription setting for the newsfeed module again
|
||||||
|
- Fix issue with openweathermap not showing current or forecast info when using onecall API
|
||||||
- Fix tests in weather module and add one for decimalPoint in forecast
|
- Fix tests in weather module and add one for decimalPoint in forecast
|
||||||
- Fix decimalSymbol in the forecast part of the new weather module #2530
|
- Fix decimalSymbol in the forecast part of the new weather module #2530
|
||||||
- Fix wrong treatment of `appendLocationNameToHeader` when using `ukmetofficedatahub`
|
- Fix wrong treatment of `appendLocationNameToHeader` when using `ukmetofficedatahub`
|
||||||
|
@ -30,16 +30,14 @@ WeatherProvider.register("openweathermap", {
|
|||||||
fetchCurrentWeather() {
|
fetchCurrentWeather() {
|
||||||
this.fetchData(this.getUrl())
|
this.fetchData(this.getUrl())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data || !data.main || typeof data.main.temp === "undefined") {
|
if (this.config.weatherEndpoint === "/onecall") {
|
||||||
// Did not receive usable new data.
|
const weatherData = this.generateWeatherObjectsFromOnecall(data);
|
||||||
// Maybe this needs a better check?
|
this.setCurrentWeather(weatherData.current);
|
||||||
return;
|
this.setFetchedLocation(`${data.timezone}`);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
this.setFetchedLocation(`${data.name}, ${data.sys.country}`);
|
|
||||||
|
|
||||||
const currentWeather = this.generateWeatherObjectFromCurrentWeather(data);
|
const currentWeather = this.generateWeatherObjectFromCurrentWeather(data);
|
||||||
this.setCurrentWeather(currentWeather);
|
this.setCurrentWeather(currentWeather);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function (request) {
|
.catch(function (request) {
|
||||||
Log.error("Could not load data ... ", request);
|
Log.error("Could not load data ... ", request);
|
||||||
@ -51,16 +49,15 @@ WeatherProvider.register("openweathermap", {
|
|||||||
fetchWeatherForecast() {
|
fetchWeatherForecast() {
|
||||||
this.fetchData(this.getUrl())
|
this.fetchData(this.getUrl())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (!data || !data.list || !data.list.length) {
|
if (this.config.weatherEndpoint === "/onecall") {
|
||||||
// Did not receive usable new data.
|
const weatherData = this.generateWeatherObjectsFromOnecall(data);
|
||||||
// Maybe this needs a better check?
|
this.setWeatherForecast(weatherData.days);
|
||||||
return;
|
this.setFetchedLocation(`${data.timezone}`);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
this.setFetchedLocation(`${data.city.name}, ${data.city.country}`);
|
|
||||||
|
|
||||||
const forecast = this.generateWeatherObjectsFromForecast(data.list);
|
const forecast = this.generateWeatherObjectsFromForecast(data.list);
|
||||||
this.setWeatherForecast(forecast);
|
this.setWeatherForecast(forecast);
|
||||||
|
this.setFetchedLocation(`${data.city.name}, ${data.city.country}`);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function (request) {
|
.catch(function (request) {
|
||||||
Log.error("Could not load data ... ", request);
|
Log.error("Could not load data ... ", request);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user