2021-01-23 10:45:55 +01:00
|
|
|
{% if hourly %}
|
2020-08-01 02:59:08 -04:00
|
|
|
{% set numSteps = hourly | calcNumEntries %}
|
2020-06-30 02:40:41 -04:00
|
|
|
{% set currentStep = 0 %}
|
|
|
|
<table class="{{ config.tableClass }}">
|
2020-08-01 02:59:08 -04:00
|
|
|
{% set hours = hourly.slice(0, numSteps) %}
|
2020-06-30 02:40:41 -04:00
|
|
|
{% for hour in hours %}
|
|
|
|
<tr {% if config.colored %}class="colored"{% endif %} {% if config.fade %}style="opacity: {{ currentStep | opacity(numSteps) }};"{% endif %}>
|
2020-07-01 05:08:04 -04:00
|
|
|
<td class="day">{{ hour.date | formatTime }}</td>
|
2020-06-30 02:40:41 -04:00
|
|
|
<td class="bright weather-icon"><span class="wi weathericon wi-{{ hour.weatherType }}"></span></td>
|
2020-07-01 05:08:04 -04:00
|
|
|
<td class="align-right bright">
|
2020-06-30 02:40:41 -04:00
|
|
|
{{ hour.temperature | roundValue | unit("temperature") }}
|
|
|
|
</td>
|
|
|
|
{% if config.showPrecipitationAmount %}
|
Tidy up precipitation (#3023)
Fixes #2953
This is an attempt to fix the issue with precipitation amount and
percentage mixup. I have created a separate
`precipitationPercentage`-variable where the probability of rain can be
stored.
The config options now has the old `showPrecipitationAmount` in addition
to a new setting: `showPrecipitationProbability` (shows the likelihood
of rain).
<details>
<summary>Examples</summary>
### Yr
I tested the Yr weather provider for a Norwegian city Bergen that has a
lot of rain. I have removed properties that are irrelevant for this demo
from the config-samples below.
Config:
```js
{
module: "weather",
config: {
weatherProvider: "yr",
type: "current",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "hourly",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
},
{
module: "weather",
config: {
weatherProvider: "yr",
type: "daily",
showPrecipitationAmount: true,
showPrecipitationProbability: true
}
}
```
Result:<br/>
<img width="444" alt="screenshot"
src="https://user-images.githubusercontent.com/34011212/216775423-4e37345c-f915-47e5-8551-7c544ebd24b1.png">
</details>
---------
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Veeck <github@veeck.de>
2023-02-04 19:02:55 +01:00
|
|
|
<td class="align-right bright precipitationAmount">
|
|
|
|
{{ hour.precipitationAmount | unit("precip", hour.precipitationUnits) }}
|
|
|
|
</td>
|
|
|
|
{% endif %}
|
|
|
|
{% if config.showPrecipitationProbability %}
|
|
|
|
<td class="align-right bright precipitationProbability">
|
|
|
|
{{ hour.precipitationProbability }}%
|
|
|
|
</td>
|
2020-06-30 02:40:41 -04:00
|
|
|
{% endif %}
|
|
|
|
</tr>
|
|
|
|
{% set currentStep = currentStep + 1 %}
|
|
|
|
{% endfor %}
|
|
|
|
</table>
|
|
|
|
{% else %}
|
|
|
|
<div class="dimmed light small">
|
2021-01-20 13:47:32 -05:00
|
|
|
{{ "LOADING" | translate }}
|
2020-06-30 02:40:41 -04:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
2020-08-01 02:59:08 -04:00
|
|
|
<!-- Uncomment the line below to see the contents of the `hourly` object. -->
|
2021-01-23 10:45:55 +01:00
|
|
|
<!-- <div style="word-wrap:break-word" class="xsmall dimmed">{{hourly | dump}}</div> -->
|