From 96db21f9bf3609b7ca5aeeb7f603aa159d1cb39d Mon Sep 17 00:00:00 2001 From: Kevin G Date: Thu, 13 May 2021 10:56:30 -0400 Subject: [PATCH] Updates to support Environment Canada provider Code updates to support a new weatherobject element called precipitationUnits. For the 'forecast' and 'hourly' UI, the weather module will use this new element if it is not null (i.e. a provider has pushed some value into this object element). If the element is null, then default 'units' processing will still occur. This allows a provider to have a customn unit of measure for precipitation - e.g. Env Canada will use mm for rain and cm for snow. --- modules/default/weather/forecast.njk | 16 +++++++++++----- modules/default/weather/hourly.njk | 4 ++++ modules/default/weather/weatherobject.js | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index c78e89ed..18c2b44f 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -14,15 +14,21 @@ {% endif %} - {{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }} + {{ f.maxTemperature | roundValue | unit("temperature") }} - {{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }} + {{ f.minTemperature | roundValue | unit("temperature") }} {% if config.showPrecipitationAmount %} - - {{ f.precipitation | unit("precip") }} - + {% if f.precipitationUnits %} + + {{ f.precipitation }}{{ f.precipitationUnits }} + + {% else %} + + {{ f.precipitation | unit("precip") }} + + {% endif %} {% endif %} {% set currentStep = currentStep + 1 %} diff --git a/modules/default/weather/hourly.njk b/modules/default/weather/hourly.njk index 3950ece2..76ab94a6 100644 --- a/modules/default/weather/hourly.njk +++ b/modules/default/weather/hourly.njk @@ -11,6 +11,10 @@ {{ hour.temperature | roundValue | unit("temperature") }} {% if config.showPrecipitationAmount %} + + {{ hour.precipitation }}{{ hour.precipitationUnits }} + + {% else %} {{ hour.precipitation | unit("precip") }} diff --git a/modules/default/weather/weatherobject.js b/modules/default/weather/weatherobject.js index 3fbbb42a..5bd5be9a 100755 --- a/modules/default/weather/weatherobject.js +++ b/modules/default/weather/weatherobject.js @@ -28,6 +28,7 @@ class WeatherObject { this.rain = null; this.snow = null; this.precipitation = null; + this.precipitationUnits = null; this.feelsLikeTemp = null; }