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.
This commit is contained in:
Kevin G 2021-05-13 10:56:30 -04:00 committed by GitHub
parent e31450f731
commit 96db21f9bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -14,15 +14,21 @@
{% endif %} {% endif %}
<td class="bright weather-icon"><span class="wi weathericon wi-{{ f.weatherType }}"></span></td> <td class="bright weather-icon"><span class="wi weathericon wi-{{ f.weatherType }}"></span></td>
<td class="align-right bright max-temp"> <td class="align-right bright max-temp">
{{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }} {{ f.maxTemperature | roundValue | unit("temperature") }}
</td> </td>
<td class="align-right min-temp"> <td class="align-right min-temp">
{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }} {{ f.minTemperature | roundValue | unit("temperature") }}
</td> </td>
{% if config.showPrecipitationAmount %} {% if config.showPrecipitationAmount %}
<td class="align-right bright precipitation"> {% if f.precipitationUnits %}
{{ f.precipitation | unit("precip") }} <td class="align-right bright precipitation">
</td> {{ f.precipitation }}{{ f.precipitationUnits }}
</td>
{% else %}
<td class="align-right bright precipitation">
{{ f.precipitation | unit("precip") }}
</td>
{% endif %}
{% endif %} {% endif %}
</tr> </tr>
{% set currentStep = currentStep + 1 %} {% set currentStep = currentStep + 1 %}

View File

@ -11,6 +11,10 @@
{{ hour.temperature | roundValue | unit("temperature") }} {{ hour.temperature | roundValue | unit("temperature") }}
</td> </td>
{% if config.showPrecipitationAmount %} {% if config.showPrecipitationAmount %}
<td class="align-right bright precipitation">
{{ hour.precipitation }}{{ hour.precipitationUnits }}
</td>
{% else %}
<td class="align-right bright precipitation"> <td class="align-right bright precipitation">
{{ hour.precipitation | unit("precip") }} {{ hour.precipitation | unit("precip") }}
</td> </td>

View File

@ -28,6 +28,7 @@ class WeatherObject {
this.rain = null; this.rain = null;
this.snow = null; this.snow = null;
this.precipitation = null; this.precipitation = null;
this.precipitationUnits = null;
this.feelsLikeTemp = null; this.feelsLikeTemp = null;
} }