Merge branch 'develop' into jest

This commit is contained in:
Karsten Hassel 2021-06-16 20:53:02 +02:00
commit 14a99a3b25
3 changed files with 24 additions and 36 deletions

View File

@ -34,7 +34,8 @@ 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, require node >= v12, remove `rrule-alt` and `rrule`
- Update dependencies in package.json and migrate husky to v6, fix husky setup in prod environment - 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 - Cleaned up error handling in newsfeed and calendar modules for real
- Update documentation - Updated default WEATHER module such that a provider can optionally set a custom unit-of-measure for precipitation (`weatherObject.precipitationUnits`)
- Update documentation.
### Removed ### Removed

View File

@ -11,13 +11,15 @@
{{ hour.temperature | roundValue | unit("temperature") }} {{ hour.temperature | roundValue | unit("temperature") }}
</td> </td>
{% if config.showPrecipitationAmount %} {% if config.showPrecipitationAmount %}
<td class="align-right bright precipitation"> {% if hour.precipitationUnits %}
{{ hour.precipitation }}{{ hour.precipitationUnits }} <td class="align-right bright precipitation">
</td> {{ hour.precipitation }}{{ hour.precipitationUnits }}
{% else %} </td>
<td class="align-right bright precipitation"> {% else %}
{{ hour.precipitation | unit("precip") }} <td class="align-right bright precipitation">
</td> {{ hour.precipitation | unit("precip") }}
</td>
{% endif %}
{% endif %} {% endif %}
</tr> </tr>
{% set currentStep = currentStep + 1 %} {% set currentStep = currentStep + 1 %}

View File

@ -538,9 +538,20 @@ WeatherProvider.register("envcanada", {
setPrecipitation(weather, foreGroup, today) { setPrecipitation(weather, foreGroup, today) {
if (foreGroup[today].querySelector("precipitation accumulation")) { 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.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 // Check Today element for POP
@ -576,32 +587,6 @@ WeatherProvider.register("envcanada", {
return kilo; 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. // Convert the icons to a more usable name.