mirror of
https://github.com/MichMich/MagicMirror.git
synced 2026-04-23 22:37:01 +00:00
While looking at the WeatherFlow provider (to evaluate #4107), I noticed a few things that weren't quite right. 1. **UV index was broken for most providers in forecast/hourly views.** The templates read `uv_index`, but only the WeatherAPI provider actually wrote that key. All other providers (OpenWeatherMap, WeatherFlow, PirateWeather, etc.) use `uvIndex` - so UV was silently never displayed for them. This went unnoticed because `showUVIndex` defaults to `false` and there were no test assertions for it. Standardized everything on `uvIndex` and added test coverage. 2. **WeatherFlow didn't map precipitation for current weather.** The API provides `precip_accum_local_day` and `precip_probability`, but they weren't passed through. While adding them I also noticed the template used truthiness checks, which hid valid zero values. Fixed both. 3. **`||` vs `??` in WeatherFlow provider.** Several numeric fields used `|| null`, replacing valid `0` with `null`. Switched to `??` for correctness.
47 lines
2.2 KiB
Plaintext
47 lines
2.2 KiB
Plaintext
{% if forecast %}
|
|
{% set numSteps = forecast | calcNumSteps %}
|
|
{% set currentStep = 0 %}
|
|
<table class="{{ config.tableClass }}">
|
|
{% if config.ignoreToday %}
|
|
{% set forecast = forecast.splice(1) %}
|
|
{% endif %}
|
|
{% set forecast = forecast.slice(0, numSteps) %}
|
|
{% for f in forecast %}
|
|
<tr
|
|
{% if config.colored %}class="colored"{% endif %}
|
|
{% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}
|
|
>
|
|
{% if (currentStep == 0) and config.ignoreToday == false and config.absoluteDates == false %}
|
|
<td class="day">{{ "TODAY" | translate }}</td>
|
|
{% elif (currentStep == 1) and config.ignoreToday == false and config.absoluteDates == false %}
|
|
<td class="day">{{ "TOMORROW" | translate }}</td>
|
|
{% else %}
|
|
<td class="day">{{ f.date.format(config.forecastDateFormat) }}</td>
|
|
{% endif %}
|
|
<td class="bright weather-icon">
|
|
<span class="wi weathericon wi-{{ f.weatherType }}"></span>
|
|
</td>
|
|
<td class="align-right bright max-temp">{{ f.maxTemperature | roundValue | unit("temperature") | decimalSymbol }}</td>
|
|
<td class="align-right min-temp">{{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }}</td>
|
|
{% if config.showPrecipitationAmount %}
|
|
<td class="align-right bright precipitation-amount">{{ f.precipitationAmount | unit("precip", f.precipitationUnits) }}</td>
|
|
{% endif %}
|
|
{% if config.showPrecipitationProbability %}
|
|
<td class="align-right bright precipitation-prob">{{ f.precipitationProbability | unit('precip', '%') }}</td>
|
|
{% endif %}
|
|
{% if config.showUVIndex %}
|
|
<td class="align-right dimmed uv-index">
|
|
{{ f.uvIndex }}
|
|
<span class="wi dimmed weathericon wi-hot"></span>
|
|
</td>
|
|
{% endif %}
|
|
</tr>
|
|
{% set currentStep = currentStep + 1 %}
|
|
{% endfor %}
|
|
</table>
|
|
{% else %}
|
|
<div class="dimmed light small">{{ "LOADING" | translate }}</div>
|
|
{% endif %}
|
|
<!-- Uncomment the line below to see the contents of the `forecast` object. -->
|
|
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{ forecast | dump }}</div> -->
|