mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
another typo fix
This commit is contained in:
parent
9cbf331533
commit
bdcc0c5373
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* By Michael Teeuw http://michaelteeuw.nl
|
* By Michael Teeuw http://michaelteeuw.nl
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*
|
*
|
||||||
* This class is the blueprint for a weather provider.
|
* This class is the blueprint for a weather provider.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams();
|
return this.config.apiBase + this.config.apiVersion + this.config.weatherEndpoint + this.getParams();
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate a WeatherObject based on currentWeatherInformation
|
* Generate a WeatherObject based on currentWeatherInformation
|
||||||
*/
|
*/
|
||||||
generateWeatherObjectFromCurrentWeather(currentWeatherData) {
|
generateWeatherObjectFromCurrentWeather(currentWeatherData) {
|
||||||
@ -85,7 +85,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
* Generate WeatherObjects based on forecast information
|
* Generate WeatherObjects based on forecast information
|
||||||
*/
|
*/
|
||||||
generateWeatherObjectsFromForecast(forecasts) {
|
generateWeatherObjectsFromForecast(forecasts) {
|
||||||
|
|
||||||
if (this.config.weatherEndpoint == "/forecast") {
|
if (this.config.weatherEndpoint == "/forecast") {
|
||||||
return this.fetchForecastHourly(forecasts);
|
return this.fetchForecastHourly(forecasts);
|
||||||
} else if (this.config.weatherEndpoint == "/forecast/daily") {
|
} else if (this.config.weatherEndpoint == "/forecast/daily") {
|
||||||
@ -95,7 +95,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
const days = [new WeatherObject(this.config.units)];
|
const days = [new WeatherObject(this.config.units)];
|
||||||
return days;
|
return days;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fetch forecast information for 3-hourly forecast (available for free subscription).
|
* fetch forecast information for 3-hourly forecast (available for free subscription).
|
||||||
*/
|
*/
|
||||||
@ -109,15 +109,15 @@ WeatherProvider.register("openweathermap", {
|
|||||||
// variable for date
|
// variable for date
|
||||||
let date = "";
|
let date = "";
|
||||||
var weather = new WeatherObject(this.config.units);
|
var weather = new WeatherObject(this.config.units);
|
||||||
|
|
||||||
for (const forecast of forecasts) {
|
for (const forecast of forecasts) {
|
||||||
|
|
||||||
if (date === moment(forecast.dt, "X").format("YYYY-MM-DD")) {
|
if (date === moment(forecast.dt, "X").format("YYYY-MM-DD")) {
|
||||||
// the same day as before
|
// the same day as before
|
||||||
// add values from forecast to corresponding variables
|
// add values from forecast to corresponding variables
|
||||||
minTemp.push(forecast.main.temp_min);
|
minTemp.push(forecast.main.temp_min);
|
||||||
maxTemp.push(forecast.main.temp_max);
|
maxTemp.push(forecast.main.temp_max);
|
||||||
|
|
||||||
if (forecast.hasOwnProperty("rain")) {
|
if (forecast.hasOwnProperty("rain")) {
|
||||||
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
||||||
rain += forecast.rain["3h"] / 25.4;
|
rain += forecast.rain["3h"] / 25.4;
|
||||||
@ -139,33 +139,40 @@ WeatherProvider.register("openweathermap", {
|
|||||||
days.push(weather);
|
days.push(weather);
|
||||||
// create new weather-object
|
// create new weather-object
|
||||||
weather = new WeatherObject(this.config.units);
|
weather = new WeatherObject(this.config.units);
|
||||||
|
|
||||||
minTemp = [];
|
minTemp = [];
|
||||||
maxTemp = [];
|
maxTemp = [];
|
||||||
rain = 0;
|
rain = 0;
|
||||||
|
|
||||||
// set new date
|
// set new date
|
||||||
date = moment(forecast.dt, "X").format("YYYY-MM-DD");
|
date = moment(forecast.dt, "X").format("YYYY-MM-DD");
|
||||||
|
|
||||||
// specify date
|
// specify date
|
||||||
weather.date = moment(forecast.dt, "X");
|
weather.date = moment(forecast.dt, "X");
|
||||||
|
|
||||||
// select weather type by first forecast value of a day, is this reasonable?
|
// select weather type by first forecast value of a day, is this reasonable?
|
||||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||||
|
|
||||||
// add values from first forecast of this day to corresponding variables
|
// add values from first forecast of this day to corresponding variables
|
||||||
minTemp.push(forecast.main.temp_min);
|
minTemp.push(forecast.main.temp_min);
|
||||||
maxTemp.push(forecast.main.temp_max);
|
maxTemp.push(forecast.main.temp_max);
|
||||||
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
|
||||||
rain += forecast.rain["3h"] / 25.4;
|
if (forecast.hasOwnProperty("rain")) {
|
||||||
} else if (!isNaN(forecast.rain["3h"])){
|
if (this.config.units === "imperial" && !isNaN(forecast.rain["3h"])) {
|
||||||
rain += forecast.rain["3h"];
|
rain += forecast.rain["3h"] / 25.4;
|
||||||
|
} else if (!isNaN(forecast.rain["3h"])){
|
||||||
|
rain += forecast.rain["3h"];
|
||||||
|
} else {
|
||||||
|
rain += 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rain += 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return days.slice(1);
|
return days.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fetch forecast information for daily forecast (available for paid subscription or old apiKey).
|
* fetch forecast information for daily forecast (available for paid subscription or old apiKey).
|
||||||
*/
|
*/
|
||||||
@ -180,7 +187,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
weather.minTemperature = forecast.temp.min;
|
weather.minTemperature = forecast.temp.min;
|
||||||
weather.maxTemperature = forecast.temp.max;
|
weather.maxTemperature = forecast.temp.max;
|
||||||
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
weather.weatherType = this.convertWeatherType(forecast.weather[0].icon);
|
||||||
|
|
||||||
// forecast.rain not available if amount is zero
|
// forecast.rain not available if amount is zero
|
||||||
if (forecast.hasOwnProperty("rain")) {
|
if (forecast.hasOwnProperty("rain")) {
|
||||||
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
|
if (this.config.units === "imperial" && !isNaN(forecast.rain)) {
|
||||||
@ -199,7 +206,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
|
|
||||||
return days;
|
return days;
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert the OpenWeatherMap icons to a more usable name.
|
* Convert the OpenWeatherMap icons to a more usable name.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user