From af52b91799e37bc21fe542c07912984cca066e93 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Wed, 2 Jun 2021 11:43:56 -0400 Subject: [PATCH 1/5] Fix to precipitation logic Found a really dumb error I made that broke compatibility with OpenWeatherMap hourly forecast under certain conditions. This is now fixed. --- modules/default/weather/hourly.njk | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/default/weather/hourly.njk b/modules/default/weather/hourly.njk index 38832bdb..90d0d161 100644 --- a/modules/default/weather/hourly.njk +++ b/modules/default/weather/hourly.njk @@ -11,13 +11,15 @@ {{ hour.temperature | roundValue | unit("temperature") }} {% if config.showPrecipitationAmount %} - - {{ hour.precipitation }}{{ hour.precipitationUnits }} - - {% else %} - - {{ hour.precipitation | unit("precip") }} - + {% if hour.precipitationUnits %} + + {{ hour.precipitation }}{{ hour.precipitationUnits }} + + {% else %} + + {{ hour.precipitation | unit("precip") }} + + {% endif %} {% endif %} {% set currentStep = currentStep + 1 %} From 0ecb66c99e1d80f604a1e0571f0a0e49604b262e Mon Sep 17 00:00:00 2001 From: Kevin G Date: Wed, 2 Jun 2021 16:15:44 -0400 Subject: [PATCH 2/5] Fixed precipitation unit conversion logic Found an error that precipitation amount was not being calculated correctly when config.js is asking for Imperial units. This has been fixed. --- .../default/weather/providers/envcanada.js | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/modules/default/weather/providers/envcanada.js b/modules/default/weather/providers/envcanada.js index c48d26dc..db0773ea 100644 --- a/modules/default/weather/providers/envcanada.js +++ b/modules/default/weather/providers/envcanada.js @@ -538,9 +538,20 @@ WeatherProvider.register("envcanada", { setPrecipitation(weather, foreGroup, today) { if (foreGroup[today].querySelector("precipitation accumulation")) { - weather.precipitationUnits = foreGroup[today].querySelector("precipitation accumulation amount").getAttribute("units"); - weather.precipitation = foreGroup[today].querySelector("precipitation accumulation amount").textContent * 1.0; + + weather.precipitationUnits = " " + foreGroup[today].querySelector("precipitation accumulation amount").getAttribute("units"); + + if (this.config.units === "imperial") { + if (weather.precipitationUnits === " cm") { + weather.precipitation = (weather.precipitation * 0.394).toFixed(2); + weather.precipitationUnits = " in"; + } + if (weather.precipitationUnits === " mm") { + weather.precipitation = (weather.precipitation * 0.0394).toFixed(2); + weather.precipitationUnits = " in"; + } + } } // Check Today element for POP @@ -576,32 +587,6 @@ WeatherProvider.register("envcanada", { return kilo; } }, - // - // Convert cm or mm to inches - // - convertPrecipAmt(amt, units) { - if (this.config.units === "imperial") { - if (units === "cm") { - return amt * 0.394; - } - if (units === "mm") { - return amt * 0.0394; - } - } else { - return amt; - } - }, - - // - // Convert ensure precip units accurately reflect configured units - // - convertPrecipUnits(units) { - if (this.config.units === "imperial") { - return null; - } else { - return " " + units; - } - }, // // Convert the icons to a more usable name. From 95d1b8a6d068cd3dcddeccbeff576badfa4c358e Mon Sep 17 00:00:00 2001 From: Kevin G Date: Wed, 2 Jun 2021 16:25:53 -0400 Subject: [PATCH 3/5] Corrected formating --- modules/default/weather/hourly.njk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weather/hourly.njk b/modules/default/weather/hourly.njk index 90d0d161..f58d31a0 100644 --- a/modules/default/weather/hourly.njk +++ b/modules/default/weather/hourly.njk @@ -15,7 +15,7 @@ {{ hour.precipitation }}{{ hour.precipitationUnits }} - {% else %} + {% else %} {{ hour.precipitation | unit("precip") }} From bf5e83861cc026bf0b2a46bb69a413df69926557 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Sat, 5 Jun 2021 11:39:21 -0400 Subject: [PATCH 4/5] Highlight new custom precipitation unit-of-measure for WEATHER With the new Environment Canada provider in WEATHER, it is now possible for provider to set a customized precipitation unit-of-measure --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6e5df9a..7ab8c888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel, - Added custom-properties for gaps around body and between modules - Added test case for recurring calendar events - Added new Environment Canada provider for default WEATHER module (weather data for Canadian locations only) +- Added default WEATHER module such that a provider can optionally set a custom unit-of-measure for precipitation (`weatherObject.precipitationUnits`) ### Updated From b85ac91e6c36ee29355ff6e82d75c2867bbf6ef2 Mon Sep 17 00:00:00 2001 From: Kevin G Date: Mon, 7 Jun 2021 09:28:33 -0400 Subject: [PATCH 5/5] Corrected bullet for Updated list Wording/location corrected for update to WEATHER module --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ab8c888..239e6dcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,6 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel, - Added custom-properties for gaps around body and between modules - Added test case for recurring calendar events - Added new Environment Canada provider for default WEATHER module (weather data for Canadian locations only) -- Added default WEATHER module such that a provider can optionally set a custom unit-of-measure for precipitation (`weatherObject.precipitationUnits`) ### Updated @@ -33,6 +32,7 @@ Special thanks to the following contributors: @B1gG, @codac, @ezeholz, @khassel, - Update dependencies in package.json, require node >= v12, remove `rrule-alt` and `rrule` - Update dependencies in package.json and migrate husky to v6, fix husky setup in prod environment - Cleaned up error handling in newsfeed and calendar modules for real +- Updated default WEATHER module such that a provider can optionally set a custom unit-of-measure for precipitation (`weatherObject.precipitationUnits`) ### Removed