OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
weather.open_meteo_weather_controller.OpenMeteoWeatherController Class Reference

Refresh and cache Open-Meteo forecast snapshots. More...

Public Member Functions

WeatherSnapshot|None latest (self)
 Return the latest persisted snapshot without network access.
 
WeatherSnapshot refresh (self)
 Fetch, validate, and persist a fresh forecast.
 
WeatherSnapshot refresh_if_stale (self, float max_age_seconds)
 Return cached data when fresh, otherwise request an update.
 

Detailed Description

Refresh and cache Open-Meteo forecast snapshots.

Member Function Documentation

◆ latest()

WeatherSnapshot | None weather.open_meteo_weather_controller.OpenMeteoWeatherController.latest (   self)

Return the latest persisted snapshot without network access.

Returns
Cached snapshot or None.

◆ refresh()

WeatherSnapshot weather.open_meteo_weather_controller.OpenMeteoWeatherController.refresh (   self)

Fetch, validate, and persist a fresh forecast.

Returns
Newly persisted weather snapshot.
Exceptions
requests.RequestExceptionif Open-Meteo cannot be reached.
ValueErrorif the response does not contain forecast data.

◆ refresh_if_stale()

WeatherSnapshot weather.open_meteo_weather_controller.OpenMeteoWeatherController.refresh_if_stale (   self,
float  max_age_seconds 
)

Return cached data when fresh, otherwise request an update.

If refresh fails and older cached data exists, that stale snapshot is returned so consumers retain useful offline behavior.

Parameters
max_age_secondsMaximum acceptable snapshot age.
Returns
Fresh or fallback cached snapshot.

The documentation for this class was generated from the following file: