Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

weather : weather forecasts

This page gives developer information about the lino.modlib.weather plugin, which adds a function get_forecast_for_date() and a system task get_weather_forecasts.

This plugin requires the python-weather module.

This page contains code snippets (lines starting with >>>), which are being tested during our development workflow. The following snippet initializes the demo project used throughout this page.

>>> import lino
>>> lino.startup('lino_book.projects.min9.settings')
>>> from lino.api.doctest import *
lino_xl.lib.weather.get_forecast_for_date(date)

Returns a python_weather forecast for the given date.

lino_xl.lib.weather.locale

Which language to use for textual descriptions.

lino_xl.lib.weather.place_name

The name of the place for which we want our weather forecasts.

This plugin doesn’t support forecasts for multiple places.

lino_xl.lib.weather.get_weather_forecasts

This system task requests a weather forcast for the place defined by place_name

The following code snippet tries to reproduce a ValueError “hour must be in 0..23” encountered during issue 75.

>>> from lino_book import DEMO_DATA
>>> import python_weather
>>> from python_weather.forecast import Forecast
>>> python_weather.__version__
'2.2.5'
>>> options = dict(unit=python_weather.METRIC, locale=python_weather.Locale('fr'))
>>> # pth = DEMO_DATA / 'weather/20260916_0215.json'
>>> pth = DEMO_DATA / 'weather/20260916_0948.json'
>>> data = json.loads(pth.read_text())
>>> fc = Forecast(data, **options)
>>> print(fc.temperature)
9
>>> print(fc.location)
Monte-Rigi