NEWS
ioMeter einbinden
-
Moin allerseits,
Mit der Suche hab ich nix gefunden:
Gibt es eine Möglichkeit/Anleitung, wie man ioMeter in ioBroker einbinden kann?
Für HA geht es, damit sollte es doch auch eine Möglichkeit für ioB geben.
Eckhard
Hat wie es aussieht eine sehr einfache Api.
Sollte man per Script hinbekommen.https://github.com/iometer-gmbh/iometer.py/blob/main/docs/api.md
Ungetestet
// ============================================================ // IOmeter Bridge – Datenpunkte & Polling // Ablageort: 0_userdata.0.iometer.* // Intervall: alle 10 Minuten + Sofortstart // ============================================================ const BRIDGE_IP = "192.168.x.x"; // <─── IP der IOmeter Bridge anpassen! const BASE = "0_userdata.0.iometer"; // ── Ordner-Struktur ────────────────────────────────────────── const CHANNELS = [ { id: BASE, name: "IOmeter" }, { id: `${BASE}.reading`, name: "Zählerstand" }, { id: `${BASE}.status`, name: "Status" }, { id: `${BASE}.status.bridge`, name: "Bridge" }, { id: `${BASE}.status.core`, name: "Core" }, ]; // ── Datenpunkte ────────────────────────────────────────────── const DPS = [ // Zählerstand ------------------------------------------------ { id: "reading.meterNumber", common: { name: "Zählernummer", type: "string", role: "text", read: true, write: false }, }, { id: "reading.time", common: { name: "Zeitstempel (ISO)", type: "string", role: "text", read: true, write: false }, }, { id: "reading.consumption_wh", common: { name: "Gesamtverbrauch", type: "number", role: "value.energy.consumed", read: true, write: false, unit: "Wh" }, }, { id: "reading.production_wh", common: { name: "Gesamteinspeisung", type: "number", role: "value.energy", read: true, write: false, unit: "Wh" }, }, { id: "reading.power_w", common: { name: "Aktuelle Leistung", type: "number", role: "value.power", read: true, write: false, unit: "W" }, }, // Status – Bridge -------------------------------------------- { id: "status.bridge.rssi", common: { name: "Bridge WLAN-Signal", type: "number", role: "value", read: true, write: false, unit: "dBm" }, }, { id: "status.bridge.version", common: { name: "Bridge Firmware", type: "string", role: "text", read: true, write: false }, }, // Status – Core ---------------------------------------------- { id: "status.core.connectionStatus", common: { name: "Verbindungsstatus", type: "string", role: "text", read: true, write: false }, }, { id: "status.core.rssi", common: { name: "Core WLAN-Signal", type: "number", role: "value", read: true, write: false, unit: "dBm" }, }, { id: "status.core.version", common: { name: "Core Firmware", type: "string", role: "text", read: true, write: false }, }, { id: "status.core.powerStatus", common: { name: "Stromversorgung", type: "string", role: "text", read: true, write: false }, }, { id: "status.core.batteryLevel", common: { name: "Akkustand", type: "number", role: "value.battery", read: true, write: false, unit: "%" }, }, { id: "status.core.attachmentStatus", common: { name: "Montagestatus", type: "string", role: "text", read: true, write: false }, }, { id: "status.core.pinStatus", common: { name: "PIN-Status", type: "string", role: "text", read: true, write: false }, }, // Status – Gerät --------------------------------------------- { id: "status.deviceId", common: { name: "Geräte-ID", type: "string", role: "text", read: true, write: false }, }, // Meta ------------------------------------------------------- { id: "_lastUpdate", common: { name: "Letztes Update", type: "number", role: "value.time", read: true, write: false }, }, { id: "_error", common: { name: "Fehlermeldung", type: "string", role: "text", read: true, write: false }, }, ]; // ── Hilfsfunktion: sequenziell über Array iterieren ───────── function seqMap(arr, fn, cb) { let i = 0; function next() { if (i >= arr.length) { cb && cb(); return; } fn(arr[i++], next); } next(); } // ── Channels anlegen ───────────────────────────────────────── function ensureChannels(cb) { seqMap(CHANNELS, (ch, next) => { setObject(ch.id, { type: "channel", common: { name: ch.name }, native: {} }, next); }, cb); } // ── Datenpunkte anlegen ────────────────────────────────────── function ensureDatapoints(cb) { seqMap(DPS, (dp, next) => { setObject(`${BASE}.${dp.id}`, { type: "state", common: dp.common, native: {} }, next); }, cb); } // ── API-Abfrage ────────────────────────────────────────────── async function fetchIOmeter() { try { // /v1/reading const resR = await fetch(`http://${BRIDGE_IP}/v1/reading`); if (!resR.ok) throw new Error(`Reading HTTP ${resR.status}`); const r = await resR.json(); const regs = r.meter.reading.registers; const byObis = (code) => regs.find(x => x.obis === code)?.value ?? null; setState(`${BASE}.reading.meterNumber`, r.meter.number, true); setState(`${BASE}.reading.time`, r.meter.reading.time, true); setState(`${BASE}.reading.consumption_wh`, byObis("01-00:01.08.00*ff"), true); setState(`${BASE}.reading.production_wh`, byObis("01-00:02.08.00*ff"), true); setState(`${BASE}.reading.power_w`, byObis("01-00:10.07.00*ff"), true); // /v1/status const resS = await fetch(`http://${BRIDGE_IP}/v1/status`); if (!resS.ok) throw new Error(`Status HTTP ${resS.status}`); const s = await resS.json(); const bridge = s.device?.bridge ?? {}; const core = s.device?.core ?? {}; setState(`${BASE}.status.deviceId`, s.device?.id ?? "", true); setState(`${BASE}.status.bridge.rssi`, bridge.rssi ?? null, true); setState(`${BASE}.status.bridge.version`, bridge.version ?? "", true); setState(`${BASE}.status.core.connectionStatus`, core.connectionStatus ?? "", true); setState(`${BASE}.status.core.rssi`, core.rssi ?? null, true); setState(`${BASE}.status.core.version`, core.version ?? "", true); setState(`${BASE}.status.core.powerStatus`, core.powerStatus ?? "", true); setState(`${BASE}.status.core.batteryLevel`, core.batteryLevel ?? null, true); setState(`${BASE}.status.core.attachmentStatus`, core.attachmentStatus ?? "", true); setState(`${BASE}.status.core.pinStatus`, core.pinStatus ?? "", true); setState(`${BASE}._lastUpdate`, Date.now(), true); setState(`${BASE}._error`, "", true); const kWh = ((byObis("01-00:01.08.00*ff") ?? 0) / 1000).toFixed(2); log(`IOmeter ✓ Leistung: ${byObis("01-00:10.07.00*ff")} W | Gesamt: ${kWh} kWh`, "info"); } catch (err) { setState(`${BASE}._error`, err.message, true); log("IOmeter Fehler: " + err.message, "error"); } } // ── Bootstrap ──────────────────────────────────────────────── ensureChannels(() => ensureDatapoints(() => { log("IOmeter: Datenpunkte bereit – starte erste Abfrage", "info"); fetchIOmeter(); // Sofort beim Skriptstart schedule("*/10 * * * *", fetchIOmeter); // Dann alle 10 Minuten }) );
Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.
Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.
Mit deinem Input könnte dieser Beitrag noch besser werden 💗
Registrieren Anmelden