Feature: Stündliche Niederschlagswahrscheinlichkeit auf Wetter-Seite (SW by-v690)

- Backend: Open-Meteo Forecast-Request um hourly precipitation_probability,
  precipitation und weathercode erweitert; stündliche Daten werden pro Tag
  gruppiert und im API-Response unter "hourly" je Tag ausgeliefert
- Frontend: Neue _renderRainTimeline()-Funktion rendert horizontale
  Balken-Zeitskala für alle 24 Stunden des gewählten Tages; bei "Heute"
  wird automatisch zur aktuellen Stunde gescrollt und "jetzt" hervorgehoben;
  Farb-Gradient von hellgrau (<10%) bis dunkelblau (≥75%)
- SW/APP_VER/CSS auf 690 gebumpt
This commit is contained in:
rene 2026-05-04 20:06:30 +02:00
parent 84e6bfdd82
commit 759979ffce
5 changed files with 169 additions and 9 deletions

View file

@ -222,6 +222,7 @@ async def get_forecast(lat: float, lon: float) -> dict:
"apparent_temperature_min,precipitation_probability_max,precipitation_sum,"
"weathercode,windspeed_10m_max,winddirection_10m_dominant,uv_index_max,"
"sunrise,sunset"
"&hourly=precipitation_probability,precipitation,weathercode"
"&timezone=auto&forecast_days=7"
)
pollen_url = (
@ -245,6 +246,7 @@ async def get_forecast(lat: float, lon: float) -> dict:
raw = forecast_resp.json()
daily = raw.get('daily', {})
hourly_fc = raw.get('hourly', {})
timezone = raw.get('timezone', 'auto')
dates = daily.get('time', [])
@ -261,6 +263,24 @@ async def get_forecast(lat: float, lon: float) -> dict:
sunrises = daily.get('sunrise', [])
sunsets = daily.get('sunset', [])
# --- Hourly precipitation data grouped by day ---
hourly_times = hourly_fc.get('time', [])
hourly_pp = hourly_fc.get('precipitation_probability', [])
hourly_precip = hourly_fc.get('precipitation', [])
hourly_wcode = hourly_fc.get('weathercode', [])
# Build: date_str → list of {hour, precip_prob, precip, weathercode}
_hourly_by_day: dict = {}
for idx, ts_str in enumerate(hourly_times):
day_str = ts_str[:10] # 'YYYY-MM-DD'
hour_str = ts_str[11:16] # 'HH:MM'
entry = {
'hour': hour_str,
'precip_prob': hourly_pp[idx] if idx < len(hourly_pp) else None,
'precip': hourly_precip[idx] if idx < len(hourly_precip) else None,
'weathercode': int(hourly_wcode[idx]) if idx < len(hourly_wcode) and hourly_wcode[idx] is not None else None,
}
_hourly_by_day.setdefault(day_str, []).append(entry)
# --- Pollen (optional) ---
pollen_daily: dict | None = None
if not isinstance(pollen_resp, Exception):
@ -361,6 +381,7 @@ async def get_forecast(lat: float, lon: float) -> dict:
'zecken': zecken,
'thunderstorm': wcode in {95, 96, 99},
'paw_cold': wcode in {71, 73, 75, 77, 85, 86} or (t_min is not None and t_min < 0),
'hourly': _hourly_by_day.get(date_str, []),
})
result = {'timezone': timezone, 'days': days}