diff --git a/archive.js b/archive.js index 76f05a9..75f3171 100644 --- a/archive.js +++ b/archive.js @@ -7,7 +7,7 @@ function formatRecord(r) { const tmp = r.tempOut !== null ? `${r.tempOut}°C` : "n/a"; const hum = r.humOut !== null ? `${r.humOut}%` : "n/a"; const wnd = r.windAvg !== null ? `${r.windAvg} km/h` : "n/a"; - const dir = r.windDir ?? "n/a"; + const dir = r.windDir !== null ? `${r.windDir}°` : "n/a"; const pre = r.pressure !== null ? `${r.pressure} hPa` : "n/a"; const rai = r.rain > 0 ? ` Regen: ${r.rain}mm` : ""; return `${ts} Außen: ${tmp} Feuchte: ${hum} Wind: ${wnd} ${dir} Druck: ${pre}${rai}`; diff --git a/davis.js b/davis.js index 53d4f1f..c4ba2dc 100644 --- a/davis.js +++ b/davis.js @@ -55,18 +55,8 @@ const fTenthToC = (raw) => raw === -32768 ? null : +((raw / 10 - 32) * 5 / 9).to const mphToKmh = (raw) => raw === 255 ? null : +(raw * 1.60934).toFixed(1); const inHgToHPa = (raw) => raw === 0 ? null : +(raw / 1000 * 33.8639).toFixed(1); -// Windrichtung aus Archiv-Byte (0–15 Index) -const WIND_DIR = ["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"]; -const windDirStr = (raw) => raw === 255 ? null : (WIND_DIR[raw] ?? null); - -// Windrichtung aus LOOP1-Gradangabe (1–360, 0 = kein Wind) -const WIND_STEPS = [22.5,45,67.5,90,112.5,135,157.5,180,202.5,225,247.5,270,292.5,315,337.5,360]; -const WIND_ABBR = ["NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW","N"]; -const degToDir = (deg) => { - if (!deg) return null; - for (let i = 0; i < WIND_STEPS.length; i++) if (deg <= WIND_STEPS[i]) return WIND_ABBR[i]; - return "N"; -}; +// Windrichtung aus Archiv-Byte (0–15 Index à 22,5°), 255 = kein Wert +const archiveWindDir = (raw) => raw === 255 ? null : raw * 22.5; // ── Raw-Port-Helfer ──────────────────────────────────────────────────────── @@ -177,8 +167,8 @@ function parseLOOP1(pkt) { humOut: hum(pkt[33]), humIn: hum(pkt[11]), windAvg: mph(pkt[14]), - windGust: null, - windDir: degToDir(pkt.readUInt16LE(16)), + windGust: mph(pkt[15]), + windDir: pkt.readUInt16LE(16) || null, forecast: pkt[89], pressure: press === 0 ? null : r1(press * 33.8639 / 1000), barTrend: barTrend === 80 ? null : barTrend, @@ -220,7 +210,7 @@ function parseRecord(buf) { humIn: buf[22] === 255 ? null : buf[22], windAvg: mphToKmh(buf[24]), windGust: mphToKmh(buf[25]), - windDir: windDirStr(buf[27]), + windDir: archiveWindDir(buf[27]), pressure: inHgToHPa(buf.readUInt16LE(14)), rain: +(buf.readUInt16LE(10) * RAIN_CLICK).toFixed(1), rainRate: +(buf.readUInt16LE(12) * RAIN_CLICK).toFixed(1), diff --git a/db.js b/db.js index d600528..3d827f5 100644 --- a/db.js +++ b/db.js @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS readings ( hum_in INTEGER, -- % wind_avg REAL, -- km/h wind_high REAL, -- km/h (nur Archiv) - wind_dir TEXT, -- Himmelsrichtung + wind_dir REAL, -- Grad (0–360) pressure REAL, -- hPa rain REAL, -- mm (Archiv: Intervall; Loop: Tagessumme) rain_rate REAL, -- mm/h diff --git a/package.json b/package.json index 48de304..ed243f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wetter_1", - "version": "1.0.1", + "version": "1.1.0", "description": "", "license": "ISC", "author": "rxf", diff --git a/wetter.js b/wetter.js index 461f8d3..1e74741 100644 --- a/wetter.js +++ b/wetter.js @@ -79,11 +79,12 @@ async function runLoop(db) { }).catch(e => warn("POST fehlgeschlagen: " + e.message)); } log( -// `Außen: ${data.tempOut?.toFixed(1)}°C ` + + `Außen: ${data.tempOut?.toFixed(1)}°C ` + `InnenT: ${data.tempIn?.toFixed(1)}°C ` + -// `Feuchte: ${data.humOut}% ` + + `Feuchte: ${data.humOut}% ` + `InnenH: ${data.humIn}% ` + -// `Wind: ${data.windAvg} km/h ` + + `Wind: ${data.windAvg} km/h ` + + `WindRichtung: ${data.windDir}° ` + `Druck: ${data.pressure} hPa ` + `Trend: ${data.barTrend ?? "n/a"} ` + `Forecast: ${data.forecast}`