From f73520559efa8e2b12526a4b331984fec3563f56 Mon Sep 17 00:00:00 2001 From: Bryan Zhu Date: Tue, 30 Jun 2020 12:06:16 -0400 Subject: [PATCH] typo and bug fixes --- .../weather/providers/openweathermap.js | 30 ++++++++++++------- modules/default/weather/wdataHourly.njk | 2 +- modules/default/weather/weatherprovider.js | 1 - 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/modules/default/weather/providers/openweathermap.js b/modules/default/weather/providers/openweathermap.js index 55e2ebfe..5f73dfb0 100755 --- a/modules/default/weather/providers/openweathermap.js +++ b/modules/default/weather/providers/openweathermap.js @@ -146,12 +146,20 @@ WeatherProvider.register("openweathermap", { current.temperature = data.current.temp; current.weatherType = this.convertWeatherType(data.current.weather[0].icon); current.humidity = data.current.humidity; - if (!isNaN(data.current.rain)) { - current.rain = data.current.rain.1h; + if (current.hasOwnProperty("rain") && !isNaN(current.rain["1h"])) { + if (this.config.units === "imperial") { + weather.rain = current.rain["1h"] / 25.4; + } else { + weather.rain = current.rain["1h"]; + } precip = true; } - if (!isNaN(data.current.snow)) { - current.snow = data.current.snow.1h; + if (current.hasOwnProperty("snow") && !isNaN(current.snow["1h"])) { + if (this.config.units === "imperial") { + weather.snow = current.snow["1h"] / 25.4; + } else { + weather.snow = current.snow["1h"]; + } precip = true; } if (precip) { @@ -193,19 +201,19 @@ WeatherProvider.register("openweathermap", { weather.windDirection = hour.wind_deg; weather.weatherType = this.convertWeatherType(hour.weather[0].icon); precip = false; - if (!isNaN(hour.rain)) { + if (hour.hasOwnProperty("rain") && !isNaN(hour.rain["1h"])) { if (this.config.units === "imperial") { - weather.rain = hour.rain.1h / 25.4; + weather.rain = hour.rain["1h"] / 25.4; } else { - weather.rain = hour.rain.1h; + weather.rain = hour.rain["1h"]; } precip = true; } - if (!isNaN(hour.snow)) { + if (hour.hasOwnProperty("snow") && !isNaN(hour.snow["1h"])) { if (this.config.units === "imperial") { - weather.snow = hour.snow.1h / 25.4; + weather.snow = hour.snow["1h"] / 25.4; } else { - weather.snow = hour.snow.1h; + weather.snow = hour.snow["1h"]; } precip = true; } @@ -451,7 +459,7 @@ WeatherProvider.register("openweathermap", { params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; - params += "&APPID=" + this.config.apiKey; + params += "&APPID=" + this.config.appid; return params; } diff --git a/modules/default/weather/wdataHourly.njk b/modules/default/weather/wdataHourly.njk index f69ca8e7..c69e425f 100644 --- a/modules/default/weather/wdataHourly.njk +++ b/modules/default/weather/wdataHourly.njk @@ -5,7 +5,7 @@ {% set hours = wData.hours.slice(0, numSteps) %} {% for hour in hours %} - {{ hour.date | formatTimeMoment }} + {{ hour.date | formatTimeMoment }} {{ hour.temperature | roundValue | unit("temperature") }} diff --git a/modules/default/weather/weatherprovider.js b/modules/default/weather/weatherprovider.js index ac8618eb..dd874be4 100644 --- a/modules/default/weather/weatherprovider.js +++ b/modules/default/weather/weatherprovider.js @@ -97,7 +97,6 @@ var WeatherProvider = Class.extend({ // Set the weatherDataObject and notify the delegate that new information is available. setWeatherData: function (weatherDataObject) { - // We should check here if we are passing a WeatherDay this.weatherDataObject = weatherDataObject; },