weather.yr
Fetches a forecast from the Norwegian Meteorological Institute’s Locationforecast API (yr.no).
sources:
weather:
source: weather.yr
params:
lat: 55.64277
lon: 13.20638
altitude: 17
Params
- pydantic model todays_paper_web.widgets.weather.yr.YrParams[source]
Bases:
DataSourceParams
Returns
A WeatherForecastModel, with one method:
.nextHour(timestamp, hour) -> WeatherForecast | None— the forecast entry closest tohouron the day oftimestamp(or the next day, ifhourhas already passed relative totimestamp), with its own.timestampadjusted intotimestamp’s timezone.
Each WeatherForecast has:
Field |
Type |
Description |
|---|---|---|
|
|
When this forecast entry is for. |
|
|
The condition + time of day; |
|
|
Degrees Celsius. |
|
|
Meters/second. |
|
|
Always |
|
|
Same — present on the model, not populated by |
Used together with <weather.icon> in a template:
{% set forecast = source('weather').nextHour(timestamp, 8) %}
<box>
<text valign="middle">{{ forecast.timestamp.strftime('%H:%M') }}</text>
<weather.icon x="125" valign="middle" icon="{{ forecast.icon.id() }}" theme="erikflower" />
<text x="225" valign="middle">{{ forecast.airTemperature }}°C</text>
<text x="400" valign="middle">{{ forecast.windSpeed|round|int }} m/s</text>
</box>