mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
fixed typos, fetching forecast parameters by day
This commit is contained in:
parent
b52da7c9fc
commit
2156aac046
@ -88,24 +88,48 @@ WeatherProvider.register("openweathermap", {
|
|||||||
*/
|
*/
|
||||||
generateWeatherObjectsFromForecast(forecasts) {
|
generateWeatherObjectsFromForecast(forecasts) {
|
||||||
const days = [];
|
const days = [];
|
||||||
|
var minTemp = [];
|
||||||
|
var maxTemp = [];
|
||||||
|
var rain = 0;
|
||||||
|
let date = "";
|
||||||
|
var weather = new WeatherObject(this.config.units);
|
||||||
|
|
||||||
for (const forecast of forecasts) {
|
for (const forecast of forecasts) {
|
||||||
const weather = new WeatherObject(this.config.units);
|
|
||||||
|
if (date === moment(forecast.dt, "X").format("YYYY-MM-DD")) {
|
||||||
weather.date = moment(forecast.dt, "X");
|
minTemp.push(forecast.main.temp_min);
|
||||||
weather.minTemperature = forecast.temp.min;
|
maxTemp.push(forecast.main.temp_max);
|
||||||
weather.maxTemperature = forecast.temp.max;
|
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
||||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
rain += forecast.rain["3h"] / 25.4;
|
||||||
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
|
} else {
|
||||||
weather.rain = forecast.rain / 25.4
|
rain += forecast.rain["3h"];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
weather.rain = forecast.rain;
|
weather.minTemperature = Math.min.apply(null, minTemp);
|
||||||
|
weather.maxTemperature = Math.max.apply(null, maxTemp);
|
||||||
|
weather.rain = rain;
|
||||||
|
days.push(weather);
|
||||||
|
weather = new WeatherObject(this.config.units);
|
||||||
|
|
||||||
|
minTemp = [];
|
||||||
|
maxTemp = [];
|
||||||
|
rain *= 0;
|
||||||
|
date = moment(forecast.dt, "X").format("YYYY-MM-DD");
|
||||||
|
|
||||||
|
weather.date = moment(forecast.dt, "X");
|
||||||
|
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||||
|
|
||||||
|
minTemp.push(forecast.main.temp_min);
|
||||||
|
maxTemp.push(forecast.main.temp_max);
|
||||||
|
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
||||||
|
rain += forecast.rain["3h"] / 25.4;
|
||||||
|
} else {
|
||||||
|
rain += forecast.rain["3h"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
days.push(weather);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return days;
|
return days.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user