@@ -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