|
|
@@ -17,6 +17,8 @@ log = logging.getLogger(__name__)
|
|
|
|
_CACHE_TTL_S = 3 * 3600 # Prognose alle 3h neu holen, nicht bei jedem Poll
|
|
|
|
_CACHE_TTL_S = 3 * 3600 # Prognose alle 3h neu holen, nicht bei jedem Poll
|
|
|
|
_cache: dict = {} # key: (lat, lon) -> {"ts": float, "hourly": [(epoch_s, ghi_w_m2), ...]}
|
|
|
|
_cache: dict = {} # key: (lat, lon) -> {"ts": float, "hourly": [(epoch_s, ghi_w_m2), ...]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUN_THRESHOLD = 80.0 # W/m² — deutlich mehr als Daemmerung, aber kein voller Sonnentag noetig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _fetch(lat: float, lon: float) -> Optional[List[Tuple[int, float]]]:
|
|
|
|
def _fetch(lat: float, lon: float) -> Optional[List[Tuple[int, float]]]:
|
|
|
|
url = (
|
|
|
|
url = (
|
|
|
@@ -74,8 +76,6 @@ def adjusted_timeout_h(base_timeout_h: float, lat: Optional[float], lon: Optiona
|
|
|
|
# kommende Vormittagssonne ab, falls schon frueh am Morgen geprueft wird)
|
|
|
|
# kommende Vormittagssonne ab, falls schon frueh am Morgen geprueft wird)
|
|
|
|
horizon = [ghi for ts, ghi in hourly if now <= ts < now + 12 * 3600]
|
|
|
|
horizon = [ghi for ts, ghi in hourly if now <= ts < now + 12 * 3600]
|
|
|
|
|
|
|
|
|
|
|
|
SUN_THRESHOLD = 80.0 # W/m² — deutlich mehr als Daemmerung, aber kein voller Sonnentag noetig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if near and max(near) >= SUN_THRESHOLD:
|
|
|
|
if near and max(near) >= SUN_THRESHOLD:
|
|
|
|
# Bald noch nennenswerte Sonne zu erwarten -> mehr Geduld, gedeckelt
|
|
|
|
# Bald noch nennenswerte Sonne zu erwarten -> mehr Geduld, gedeckelt
|
|
|
|
return min(base_timeout_h * 1.75, base_timeout_h + 4.0)
|
|
|
|
return min(base_timeout_h * 1.75, base_timeout_h + 4.0)
|
|
|
|