From fc456ae2ac5a815e4cb20400d4639839c304ab7c Mon Sep 17 00:00:00 2001 From: SimolZimol <70102430+SimolZimol@users.noreply.github.com> Date: Tue, 21 Apr 2026 09:32:33 +0200 Subject: [PATCH] modified: __pycache__/app.cpython-310.pyc modified: app.py modified: templates/weather.html --- __pycache__/app.cpython-310.pyc | Bin 7521 -> 7800 bytes app.py | 13 ++++++++++++- templates/weather.html | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/__pycache__/app.cpython-310.pyc b/__pycache__/app.cpython-310.pyc index 3ac5196ce3b6c0a8ed2b939b69853eb0c41e86cc..bf6f1a2b9f6d6f6c71618d6dc246e40e34717ad9 100644 GIT binary patch delta 1626 zcmZ8hO>7%Q6rQ(s9M`ee>-FER*Un!Ca)^t#AaMZSkl=t2J)m-_04X;lBn}*a6A=Q+oAovnGMYEveEZFt z_vSt4hhtk~>U=7dVDxA0{;7UrbWJTod~NjEW^^`XtH`itHa(}=8ZZZ(Obcv%iec1Gt8n_!XsIP!+Vit46lrWD4S}jN4C}Xh= zXrQ^m$aBTfXUbSYYYMQu_o{*w><>Ql2hstO4&qS23^*AaKBu^s>BwNG1ivd#>FCi@ z0DHulo(>!kTI@?W+W9v2R|IOEdx<*{c&hWBx(sl&lhtMcZi-8pRrpB6^uwx2+3Pf) zrn&T;IHiBq^b#|D8%eUM8MO^FX?lpvRq*?G6m^sNNgh4PUK;dMJcU`>tDeSH%(WDE zm8&xuWalA3;kgEI)lc&@?>pDyzROd75?BKk=j+VZ0#8@|=c$<|SMPImLvOQ2ub1U& z3n+xbszR4#c!p~i!2OgeQJiAkfyR1_YdkZ?C?wNlK?q+3SHcS23@nwpYVzg z^In{G76q%d6hd?{ojo0B2ydUI1c`UNxMz^6pYm^kXG$oM^{jzJudUS28%-v3UxMmChF(>ykGE()J+U`$)Zx4V-NK}Q?}FYmO@v3 zKwVJAJ#EhTBBah>OQo)>u0tKg&S>386HR^2ad=kFD&uo?3%)*EN%U7(+j z`?xfVf)`FyT?t>1=9n~N(kw}HL>f<;C#5+rek>e@B~dCK(f&v-JLBH8HSD$k(&Nm!8a^9QV>~)=m+3`uoJt^;A6uXRLC7(5NO_;V7^z1l#6iNMp<2H#E-x!8=iGcg2G?%4miQkN&*e3*+ zJ`{#o-DgDNAjb&JC=KQBXph_v(=0%eW`AHM(!|TAbv(J1OKQPa6_oo4MWrt#P!xrB zfdxY0NNgj?#D8_y#K-1ccuh1*pTmGSZXKlm))dw=(yR(@4ZwA=ZdD;GzOo*JTVl&P z3Pa*R`NiIDNw0{v$|vA$ai@GRwk8kVx?UOWJ4DE!Fq04$hbkjGUP(Yan}g{6e*ngD BixB_- delta 1370 zcmZ8fO>7%Q6rMNhIF7wu@A`lJ+qi|)1R;egC4`^~(Mv%>6e>U#5E(s_xWrDgUPvjk zHDE^|(uhO@w@BD1orXQ#! zFpQBtt0hs#D9tG}Fh+A4=g`7J;fFehGIaCVqtjz{0KIuaMCb|>Zo?6661LXYx z*ZlwmKLF|D08uRZj+?%t#v1cXp%089 zqnD|_$i0|n36m;_2}{+o502*gya#Q%)lWH|- z=RREe5H01|hpoCBz^Y(E6Ck(>17tdk)zC#c}3rD)ZO)l^T4{>+Nc`xuZ*y2 z(d}j%SF!1=w(G4%H6sVvMedxHn!S8_TZMRqpqh3z6n|R5c?EAOxIj=dTAQ6#^YUuP zt-H<5wsS>x?Bl7o)V@&Q5&Q`2HIA;lVP_*(mDpAAw*1|m4Sq$m^O20^s?UUYKnp<# zDm2od(Do3*R<%b9}}CekaTg$N}e^eDW}t3j}XDyYhPO zCR~;u= jetzt (UTC), sonst erste verfügbare + now_utc = _dt.datetime.now(_dt.timezone.utc).replace(tzinfo=None) current = forecast[0] + for h in forecast: + dt = h["datetime"] + dt_naive = dt.replace(tzinfo=None) if hasattr(dt, "tzinfo") and dt.tzinfo is not None else dt + if dt_naive >= now_utc: + current = h + break # Tageszusammenfassung daily = {} @@ -233,7 +242,7 @@ def wetter(): }) # Chart-Daten (erste 48 h) - chart_labels, chart_temps, chart_precip = [], [], [] + chart_labels, chart_temps, chart_precip, chart_rain_prob = [], [], [], [] for h in forecast[:48]: dt = h["datetime"] label = (dt.strftime("%d.%m %H:%M") if hasattr(dt, "strftime") @@ -241,6 +250,7 @@ def wetter(): chart_labels.append(label) chart_temps.append(h["temp_c"]) chart_precip.append(h.get("precip_mm") or 0) + chart_rain_prob.append(h.get("rain_prob") or 0) return render_template( "weather.html", @@ -257,6 +267,7 @@ def wetter(): chart_labels=chart_labels, chart_temps=chart_temps, chart_precip=chart_precip, + chart_rain_prob=chart_rain_prob, wind_dir_name=wind_direction_name, ) diff --git a/templates/weather.html b/templates/weather.html index e85f54c..e460f57 100644 --- a/templates/weather.html +++ b/templates/weather.html @@ -45,8 +45,8 @@ {% set items = [ ("Gefühlt wie", (current.temp_c|string + " °C") if current.temp_c is not none else "–"), ("Böen", (current.gust_kmh|string + " km/h") if current.gust_kmh is not none else "–"), - ("Niederschlag", (current.precip_mm|string + " mm") if current.precip_mm is not none else "0 mm"), - ("Sonne", (current.sun_min|string + " min/h") if current.sun_min is not none else "–"), + ("Niederschlag", (current.precip_mm|string + " mm") if (current.precip_mm is not none and current.precip_mm > 0) else ((current.rain_prob|string + " %") if (current.rain_prob is not none and current.rain_prob > 0) else "0 mm")), + ("Sonne", (current.sun_min|string + " min/h") if (current.sun_min is not none and current.sun_min > 0) else "–"), ] %} {% for label, val in items %}
@@ -174,6 +174,13 @@ const labels = {{ chart_labels | tojson }}; const temps = {{ chart_temps | tojson }}; const precip = {{ chart_precip | tojson }}; + const rainProb = {{ chart_rain_prob | tojson }}; + + // Prüfen ob echte Niederschlagsmengen vorhanden sind + const hasRealPrecip = precip.some(v => v > 0); + const barData = hasRealPrecip ? precip : rainProb; + const barLabel = hasRealPrecip ? "Niederschlag (mm)" : "Regenwahrsch. (%)"; + const barMax = hasRealPrecip ? undefined : 100; // Nur jeden 3. Label anzeigen, Rest leer lassen const sparseLabels = labels.map((l, i) => i % 3 === 0 ? l : ""); @@ -205,8 +212,8 @@ }, { type: "bar", - label: "Niederschlag (mm)", - data: precip, + label: barLabel, + data: barData, backgroundColor: "rgba(80,180,255,0.55)", borderColor: "rgba(80,180,255,0.9)", borderWidth: 1, @@ -254,7 +261,8 @@ yR: { position: "right", min: 0, - ticks: { color: "#50b4ff", font: { family: "Inter", size: 11 }, callback: v => v + "mm" }, + ...(barMax !== undefined ? { max: barMax } : {}), + ticks: { color: "#50b4ff", font: { family: "Inter", size: 11 }, callback: v => hasRealPrecip ? v + "mm" : v + "%" }, grid: { display: false } } }