openmeteo
openmeteo
#
Hourly weather forecasts from Open-Meteo (free, no API key).
A cached, retrying client requests the hourly variables for the coming days;
each returned hour converts to a cg.Weather in canonical units.
CACHE_EXPIRY_SECONDS = 3600
module-attribute
#
How long a fetched forecast stays fresh in the HTTP cache.
HOURLY_VARIABLES = ('temperature_2m', 'apparent_temperature', 'dew_point_2m', 'relative_humidity_2m', 'pressure_msl', 'wind_speed_10m', 'wind_gusts_10m', 'wind_direction_10m', 'cloud_cover', 'precipitation', 'visibility', 'uv_index', 'is_day', 'weather_code')
module-attribute
#
The Open-Meteo hourly variables requested, in response order.
MAX_FORECAST_DAYS = 16
module-attribute
#
The furthest ahead Open-Meteo forecasts.
UNKNOWN_CONDITION = ('Unknown', 'cloud.fill')
module-attribute
#
What a WMO code outside the table reports.
WMO_CONDITIONS = {0: ('Clear', 'sun.max.fill'), 1: ('Mainly Clear', 'sun.max.fill'), 2: ('Partly Cloudy', 'cloud.sun.fill'), 3: ('Overcast', 'cloud.fill'), 45: ('Fog', 'cloud.fog.fill'), 48: ('Depositing Rime Fog', 'cloud.fog.fill'), 51: ('Light Drizzle', 'cloud.drizzle.fill'), 53: ('Moderate Drizzle', 'cloud.drizzle.fill'), 55: ('Dense Drizzle', 'cloud.drizzle.fill'), 61: ('Slight Rain', 'cloud.rain.fill'), 63: ('Moderate Rain', 'cloud.rain.fill'), 65: ('Heavy Rain', 'cloud.heavyrain.fill'), 71: ('Slight Snow', 'cloud.snow.fill'), 73: ('Moderate Snow', 'cloud.snow.fill'), 75: ('Heavy Snow', 'cloud.snow.fill'), 77: ('Snow Grains', 'cloud.snow.fill'), 80: ('Slight Rain Showers', 'cloud.rain.fill'), 81: ('Moderate Rain Showers', 'cloud.rain.fill'), 82: ('Violent Rain Showers', 'cloud.heavyrain.fill'), 85: ('Slight Snow Showers', 'cloud.snow.fill'), 86: ('Heavy Snow Showers', 'cloud.snow.fill'), 95: ('Thunderstorm', 'cloud.bolt.rain.fill'), 96: ('Thunderstorm with Slight Hail', 'cloud.bolt.rain.fill'), 99: ('Thunderstorm with Heavy Hail', 'cloud.bolt.rain.fill')}
module-attribute
#
Each WMO weather code as its condition name and SF Symbol.
default_cache_path()
#
Where Open-Meteo responses are cached when no path is given.
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/forecast/openmeteo.py
hourly_weather(location, days=3, cache_path=None)
#
Fetch an hourly weather forecast from Open-Meteo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location
|
The place to forecast for. |
required |
days
|
int
|
Number of days to forecast (1-16). Defaults to 3. |
3
|
cache_path
|
Path | None
|
Where to cache the HTTP responses. Defaults to [default_cache_path][] under the user's cache directory. |
None
|
Returns:
| Type | Description |
|---|---|
Array[Weather]
|
One |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the response carries no hourly data. |