Skip to content
This repository was archived by the owner on Aug 14, 2026. It is now read-only.

Commit 4b5975f

Browse files
committed
owm issue fix
1 parent 4129f25 commit 4b5975f

2 files changed

Lines changed: 6 additions & 38 deletions

File tree

‎app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def get_weather_forecast():
199199
)
200200
weather_forecast_cache["forecast"] = forecast
201201
weather_forecast_cache["last_update"] = datetime.now()
202-
logger.info(f"Weather forecast updated: {forecast.get('consecutive_bad_days', 0)} consecutive bad days")
202+
logger.info(f"Weather forecast updated successfully")
203203
except Exception as e:
204204
logger.error(f"Failed to fetch weather forecast: {e}")
205205
# Return cached data if available

‎weather_client.py‎

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ def _make_request_with_retry(self, url: str, params: dict, max_retries: int = 2)
333333

334334
def get_forecast(self) -> Dict[str, Any]:
335335
"""
336-
Get 8-day weather forecast (today + 7 days)
337-
Uses OpenWeatherMap One Call API 3.0 for daily forecasts
336+
Get 5-day weather forecast with 3-hourly data for solar predictions.
337+
Uses the free tier 5-day/3-hour forecast API which provides
338+
the hourly data needed for accurate solar output estimates.
338339
"""
339340
if self._is_cache_valid() and "forecast" in self._cache:
340341
logger.debug("Using cached forecast data")
@@ -347,41 +348,8 @@ def get_forecast(self) -> Dict[str, Any]:
347348
"error": f"Could not geocode city: {self.city_name}"
348349
}
349350

350-
try:
351-
# Use One Call API 3.0 for daily forecast
352-
url = "https://api.openweathermap.org/data/3.0/onecall"
353-
params = {
354-
"lat": self.latitude,
355-
"lon": self.longitude,
356-
"appid": self.api_key,
357-
"units": "metric",
358-
"exclude": "minutely,hourly,alerts"
359-
}
360-
361-
location_str = self.city_name if self.city_name else f"({self.latitude}, {self.longitude})"
362-
logger.info(f"Fetching weather forecast for {location_str}")
363-
response = self._make_request_with_retry(url, params)
364-
365-
# If One Call 3.0 fails (requires subscription), fallback to 2.5
366-
if response.status_code == 401 or response.status_code == 403:
367-
logger.warning("One Call API 3.0 not available, trying 2.5")
368-
return self._get_forecast_legacy()
369-
370-
response.raise_for_status()
371-
data = response.json()
372-
373-
forecast = self._parse_onecall_forecast(data)
374-
self._cache["forecast"] = forecast
375-
self._cache_time = datetime.now()
376-
377-
return forecast
378-
379-
except WeatherAPIError as e:
380-
logger.warning(f"One Call API failed: {e}, trying legacy API")
381-
return self._get_forecast_legacy()
382-
except requests.exceptions.HTTPError as e:
383-
logger.warning(f"One Call API HTTP error: {e}, trying legacy API")
384-
return self._get_forecast_legacy()
351+
# Use legacy 5-day/3-hour API - free tier and provides hourly data for solar calc
352+
return self._get_forecast_legacy()
385353

386354
def _get_forecast_legacy(self) -> Dict[str, Any]:
387355
"""

0 commit comments

Comments
 (0)