V 1.1.0 Senden von Winddie in Grad, Log mehrere Werte

This commit is contained in:
2026-04-14 15:41:01 +02:00
parent a7d82d31ab
commit fc8c7071f8
5 changed files with 12 additions and 21 deletions

View File

@@ -7,7 +7,7 @@ function formatRecord(r) {
const tmp = r.tempOut !== null ? `${r.tempOut}°C` : "n/a"; const tmp = r.tempOut !== null ? `${r.tempOut}°C` : "n/a";
const hum = r.humOut !== null ? `${r.humOut}%` : "n/a"; const hum = r.humOut !== null ? `${r.humOut}%` : "n/a";
const wnd = r.windAvg !== null ? `${r.windAvg} km/h` : "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 pre = r.pressure !== null ? `${r.pressure} hPa` : "n/a";
const rai = r.rain > 0 ? ` Regen: ${r.rain}mm` : ""; const rai = r.rain > 0 ? ` Regen: ${r.rain}mm` : "";
return `${ts} Außen: ${tmp} Feuchte: ${hum} Wind: ${wnd} ${dir} Druck: ${pre}${rai}`; return `${ts} Außen: ${tmp} Feuchte: ${hum} Wind: ${wnd} ${dir} Druck: ${pre}${rai}`;

View File

@@ -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 mphToKmh = (raw) => raw === 255 ? null : +(raw * 1.60934).toFixed(1);
const inHgToHPa = (raw) => raw === 0 ? null : +(raw / 1000 * 33.8639).toFixed(1); const inHgToHPa = (raw) => raw === 0 ? null : +(raw / 1000 * 33.8639).toFixed(1);
// Windrichtung aus Archiv-Byte (015 Index) // Windrichtung aus Archiv-Byte (015 Index à 22,5°), 255 = kein Wert
const WIND_DIR = ["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"]; const archiveWindDir = (raw) => raw === 255 ? null : raw * 22.5;
const windDirStr = (raw) => raw === 255 ? null : (WIND_DIR[raw] ?? null);
// Windrichtung aus LOOP1-Gradangabe (1360, 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";
};
// ── Raw-Port-Helfer ──────────────────────────────────────────────────────── // ── Raw-Port-Helfer ────────────────────────────────────────────────────────
@@ -177,8 +167,8 @@ function parseLOOP1(pkt) {
humOut: hum(pkt[33]), humOut: hum(pkt[33]),
humIn: hum(pkt[11]), humIn: hum(pkt[11]),
windAvg: mph(pkt[14]), windAvg: mph(pkt[14]),
windGust: null, windGust: mph(pkt[15]),
windDir: degToDir(pkt.readUInt16LE(16)), windDir: pkt.readUInt16LE(16) || null,
forecast: pkt[89], forecast: pkt[89],
pressure: press === 0 ? null : r1(press * 33.8639 / 1000), pressure: press === 0 ? null : r1(press * 33.8639 / 1000),
barTrend: barTrend === 80 ? null : barTrend, barTrend: barTrend === 80 ? null : barTrend,
@@ -220,7 +210,7 @@ function parseRecord(buf) {
humIn: buf[22] === 255 ? null : buf[22], humIn: buf[22] === 255 ? null : buf[22],
windAvg: mphToKmh(buf[24]), windAvg: mphToKmh(buf[24]),
windGust: mphToKmh(buf[25]), windGust: mphToKmh(buf[25]),
windDir: windDirStr(buf[27]), windDir: archiveWindDir(buf[27]),
pressure: inHgToHPa(buf.readUInt16LE(14)), pressure: inHgToHPa(buf.readUInt16LE(14)),
rain: +(buf.readUInt16LE(10) * RAIN_CLICK).toFixed(1), rain: +(buf.readUInt16LE(10) * RAIN_CLICK).toFixed(1),
rainRate: +(buf.readUInt16LE(12) * RAIN_CLICK).toFixed(1), rainRate: +(buf.readUInt16LE(12) * RAIN_CLICK).toFixed(1),

2
db.js
View File

@@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS readings (
hum_in INTEGER, -- % hum_in INTEGER, -- %
wind_avg REAL, -- km/h wind_avg REAL, -- km/h
wind_high REAL, -- km/h (nur Archiv) wind_high REAL, -- km/h (nur Archiv)
wind_dir TEXT, -- Himmelsrichtung wind_dir REAL, -- Grad (0360)
pressure REAL, -- hPa pressure REAL, -- hPa
rain REAL, -- mm (Archiv: Intervall; Loop: Tagessumme) rain REAL, -- mm (Archiv: Intervall; Loop: Tagessumme)
rain_rate REAL, -- mm/h rain_rate REAL, -- mm/h

View File

@@ -1,6 +1,6 @@
{ {
"name": "wetter_1", "name": "wetter_1",
"version": "1.0.1", "version": "1.1.0",
"description": "", "description": "",
"license": "ISC", "license": "ISC",
"author": "rxf", "author": "rxf",

View File

@@ -79,11 +79,12 @@ async function runLoop(db) {
}).catch(e => warn("POST fehlgeschlagen: " + e.message)); }).catch(e => warn("POST fehlgeschlagen: " + e.message));
} }
log( log(
// `Außen: ${data.tempOut?.toFixed(1)}°C ` + `Außen: ${data.tempOut?.toFixed(1)}°C ` +
`InnenT: ${data.tempIn?.toFixed(1)}°C ` + `InnenT: ${data.tempIn?.toFixed(1)}°C ` +
// `Feuchte: ${data.humOut}% ` + `Feuchte: ${data.humOut}% ` +
`InnenH: ${data.humIn}% ` + `InnenH: ${data.humIn}% ` +
// `Wind: ${data.windAvg} km/h ` + `Wind: ${data.windAvg} km/h ` +
`WindRichtung: ${data.windDir}° ` +
`Druck: ${data.pressure} hPa ` + `Druck: ${data.pressure} hPa ` +
`Trend: ${data.barTrend ?? "n/a"} ` + `Trend: ${data.barTrend ?? "n/a"} ` +
`Forecast: ${data.forecast}` `Forecast: ${data.forecast}`