mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
weather module adjustments for rain and snow
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* MIT Licensed
|
||||
*
|
||||
* This class is a provider for Dark Sky.
|
||||
* Note that the Dark Sky API does not provide rainfall. Instead it provides snowfall and precipitation probability
|
||||
*/
|
||||
WeatherProvider.register("darksky", {
|
||||
// Set the name of the provider.
|
||||
@@ -81,12 +82,20 @@ WeatherProvider.register("darksky", {
|
||||
weather.minTemperature = forecast.temperatureMin;
|
||||
weather.maxTemperature = forecast.temperatureMax;
|
||||
weather.weatherType = this.convertWeatherType(forecast.icon);
|
||||
if (this.config.units === "metric" && !isNaN(forecast.precipAccumulation)) {
|
||||
weather.rain = forecast.precipAccumulation * 10;
|
||||
} else {
|
||||
weather.rain = forecast.precipAccumulation;
|
||||
weather.snow = 0;
|
||||
|
||||
// The API will return centimeters if units is 'si' and will return inches for 'us'
|
||||
// Note that the Dark Sky API does not provide rainfall. Instead it provides snowfall and precipitation probability
|
||||
if (forecast.hasOwnProperty("precipAccumulation")) {
|
||||
if (this.config.units === "imperial" && !isNaN(forecast.precipAccumulation)) {
|
||||
weather.snow = forecast.precipAccumulation;
|
||||
} else if (!isNaN(forecast.precipAccumulation)) {
|
||||
weather.snow = forecast.precipAccumulation * 10;
|
||||
}
|
||||
}
|
||||
|
||||
weather.precipitation = weather.snow;
|
||||
|
||||
days.push(weather);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user