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. | |
Refresh and cache Open-Meteo forecast snapshots.
| WeatherSnapshot | None weather.open_meteo_weather_controller.OpenMeteoWeatherController.latest | ( | self | ) |
Return the latest persisted snapshot without network access.
| WeatherSnapshot weather.open_meteo_weather_controller.OpenMeteoWeatherController.refresh | ( | self | ) |
Fetch, validate, and persist a fresh forecast.
| requests.RequestException | if Open-Meteo cannot be reached. |
| ValueError | if the response does not contain forecast data. |
| 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.
| max_age_seconds | Maximum acceptable snapshot age. |