From 8961b9237c5922b26b51f4e5396a47ae564bc58d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reinhard=20X=2E=20F=C3=BCrst?= Date: Fri, 24 Apr 2026 15:49:03 +0200 Subject: [PATCH] =?UTF-8?q?Barometer-Trend=20mit=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/main.py | 5 +++-- frontend/src/components/WeatherDashboard.css | 5 +++++ frontend/src/components/WeatherDashboard.jsx | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/api/main.py b/api/main.py index c526ae7..1ad9ee3 100644 --- a/api/main.py +++ b/api/main.py @@ -59,6 +59,7 @@ class WeatherData(BaseModel): wind_dir: Optional[float] = None rain: Optional[float] = None rain_rate: Optional[float] = None + bar_trend: Optional[int] = None received_at: datetime @@ -138,7 +139,7 @@ async def get_latest_weather(): SELECT id, datetime, temperature, humidity, pressure, wind_speed * 1.60934 as wind_speed, wind_gust * 1.60934 as wind_gust, - wind_dir, rain, rain_rate, received_at + wind_dir, rain, rain_rate, bar_trend, received_at FROM weather_data ORDER BY datetime DESC LIMIT 1 @@ -172,7 +173,7 @@ async def get_weather_history( SELECT id, datetime, temperature, humidity, pressure, wind_speed * 1.60934 as wind_speed, wind_gust * 1.60934 as wind_gust, - wind_dir, rain, rain_rate, received_at + wind_dir, rain, rain_rate, bar_trend, received_at FROM weather_data WHERE datetime >= NOW() - make_interval(hours => %s) ORDER BY datetime DESC diff --git a/frontend/src/components/WeatherDashboard.css b/frontend/src/components/WeatherDashboard.css index 4a96b53..ee55f52 100644 --- a/frontend/src/components/WeatherDashboard.css +++ b/frontend/src/components/WeatherDashboard.css @@ -139,6 +139,11 @@ margin: 0.2rem -0.5rem -0.5rem -0.5rem; } +.bar-trend { + font-size: 0.9em; + cursor: help; +} + .dashboard-footer { /* margin-top: 2rem; */ padding-top: 1rem; diff --git a/frontend/src/components/WeatherDashboard.jsx b/frontend/src/components/WeatherDashboard.jsx index ea3f8a3..a705c0d 100644 --- a/frontend/src/components/WeatherDashboard.jsx +++ b/frontend/src/components/WeatherDashboard.jsx @@ -218,6 +218,21 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = ' return { yMin: min, yMax: max } } + // Hilfsfunktion: BarTrend-Wert (Davis VantagePro) → Pfeil + Label + // Werte laut Davis Serial Communication Reference Rev 2.6.1: + // -60 = Falling Rapidly, -20 = Falling Slowly, 0 = Steady, + // 20 = Rising Slowly, 60 = Rising Rapidly, 80/'P' = kein Trend + const barTrendArrow = (trend) => { + switch (trend) { + case -60: return { arrow: '⬇⬇', label: 'Fällt schnell' } + case -20: return { arrow: '⬇', label: 'Fällt langsam' } + case 0: return { arrow: '→', label: 'Stabil' } + case 20: return { arrow: '⬆', label: 'Steigt langsam' } + case 60: return { arrow: '⬆⬆', label: 'Steigt schnell' } + default: return null + } + } + // Gemeinsame Chart-Optionen (angepasst an Zeitraum) const getCommonOptions = () => { // Prüfe, ob es ein custom range ist @@ -999,7 +1014,7 @@ const WeatherDashboard = ({ data, currentData = [], rainData = [], timeRange = '
Aktuell: {current.pressure?.toFixed(0) || '-'} hPa
-

🌐 Luftdruck{aggregationSuffix}[hPa]

+

🌐 Luftdruck{aggregationSuffix}{(() => { const t = barTrendArrow(current.bar_trend); return t ? {t.arrow} : null })()}[hPa]