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

Commit 64e7a71

Browse files
committed
remove confusing fallback solar calculation
1 parent 4ffd77e commit 64e7a71

2 files changed

Lines changed: 12 additions & 23 deletions

File tree

‎app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_weather_forecast():
221221
else:
222222
capacity_kw = 0
223223
logger.info(f"Solar capacity for forecast: {capacity_kw} kW (panel={panel_kw}, inverter_config={inverter_kw}, inverter_api={api_inverter_kw})")
224-
# Analyse forecast with solar predictions (uses forecast.solar if available, falls back to weather-based)
224+
# Analyse forecast with solar predictions (uses forecast.solar if available)
225225
forecast = weather_analyser.analyse_forecast(
226226
forecast,
227227
panel_capacity_kw=capacity_kw if capacity_kw > 0 else None,

‎weather_client.py‎

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ def analyse_forecast(
631631
632632
Args:
633633
forecast: Forecast data from weather client
634-
panel_capacity_kw: Panel capacity for weather-based solar estimation
635-
weather_client: WeatherClient instance for hourly solar calculations
634+
panel_capacity_kw: Panel capacity (unused, kept for compatibility)
635+
weather_client: WeatherClient instance (unused, kept for compatibility)
636636
solar_client: SolarForecastClient for accurate solar predictions
637637
min_solar_threshold: Minimum solar kWh to consider a "good" day
638638
"""
@@ -642,17 +642,19 @@ def analyse_forecast(
642642
daily = forecast["daily"]
643643
bad_weather_days = []
644644

645-
# Try to get solar forecast from forecast.solar first
645+
# Try to get solar forecast from forecast.solar
646646
solar_forecast = None
647647
if solar_client:
648648
solar_forecast = solar_client.get_forecast()
649649
if solar_forecast.get("success"):
650650
logger.info("Using forecast.solar for solar predictions")
651+
elif solar_forecast.get("is_temporary"):
652+
logger.warning("forecast.solar temporarily unavailable (rate limited or timeout)")
651653

652654
for day in daily:
653655
date_str = day.get("date", "")
654656

655-
# Priority 1: Use forecast.solar if available
657+
# Use forecast.solar if available
656658
if solar_forecast and solar_forecast.get("success"):
657659
for solar_day in solar_forecast.get("daily", []):
658660
if solar_day["date"] == date_str:
@@ -663,27 +665,14 @@ def analyse_forecast(
663665
else:
664666
day["estimated_solar_kwh"] = None
665667
day["has_solar_prediction"] = False
666-
667-
# Priority 2: Fall back to weather-based estimation
668-
if not day.get("has_solar_prediction") and panel_capacity_kw and panel_capacity_kw > 0 and weather_client:
669-
hourly_estimate = weather_client.estimate_solar_output_hourly(
670-
panel_capacity_kw,
671-
date_str
672-
)
673-
674-
if hourly_estimate is not None:
675-
day["estimated_solar_kwh"] = hourly_estimate
676-
day["has_solar_prediction"] = True
677-
day["solar_source"] = "weather_estimate"
678-
else:
679-
day["estimated_solar_kwh"] = None
680-
day["has_solar_prediction"] = False
681-
682-
if not day.get("has_solar_prediction"):
668+
day["solar_source"] = None
669+
else:
670+
# No API prediction available - don't fall back to weather estimate
683671
day["estimated_solar_kwh"] = None
684672
day["has_solar_prediction"] = False
673+
day["solar_source"] = None
685674

686-
# Determine if bad weather based on solar prediction
675+
# Determine if bad weather based on solar prediction or weather conditions
687676
if day.get("has_solar_prediction") and min_solar_threshold:
688677
is_bad = day["estimated_solar_kwh"] < min_solar_threshold
689678
else:

0 commit comments

Comments
 (0)