Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Einsteigerfragen
    4. Ecowitt GW2000 MQTT Problem

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Ecowitt GW2000 MQTT Problem

    This topic has been deleted. Only users with topic management privileges can see it.
    • Endurance
      Endurance last edited by

      Hallo zusammen,

      Habe ein GW2000 mit WS90, und versuche Daten an meinen MQTT Broker zu senden (ikobroker Adapter)
      Es kommt aber nur die ID an, keine Daten
      b5b5465a-a125-4bc2-9a5a-d2ddba4eab6a-image.png

      Hier das Webinterface des GW2000:

      972955f7-f192-4d48-8118-e1be66e881f2-image.png

      Hat jemand eine Idee, woran das liegen kann?

      Endurance 1 Reply Last reply Reply Quote 0
      • Endurance
        Endurance @Endurance last edited by

        @endurance
        Habs herausgefunden, daten stecken alle in einem Objekt....
        Habs mit dem folgenden Skript auseinandergenommen:

        // === Einstellungen ===
        const MQTT_STATE = 'mqtt.0.ecowitt.3C8A1F2A63C7'; // <- DEINE State-ID hier eintragen
        const BASE = '0_userdata.0.ecowitt.';             // Zielordner
        
        // === Hilfsfunktionen ===
        function toNumber(x) { const n = Number(x); return isFinite(n) ? n : null; }
        function f2c(f){ const n = toNumber(f); return n==null ? null : (n-32)*5/9; }
        function inHg2hPa(h){ const n = toNumber(h); return n==null ? null : n*33.8638866667; }
        function mph2ms(m){ const n = toNumber(m); return n==null ? null : m*0.44704; }
        function inch2mm(i){ const n = toNumber(i); return n==null ? null : i*25.4; }
        
        // Einfacher Querystring‑Parser (ohne URLSearchParams)
        function parseQuery(q) {
          const out = {};
          if (typeof q !== 'string' || !q) return out;
          // WU-Style: '+' = Leerzeichen
          q = q.replace(/\+/g, ' ');
          // Teile erst an & und dekodiere dann key/value
          q.split('&').forEach(pair => {
            const idx = pair.indexOf('=');
            let k, v;
            if (idx >= 0) {
              k = decodeURIComponent(pair.slice(0, idx));
              v = decodeURIComponent(pair.slice(idx + 1));
            } else {
              k = decodeURIComponent(pair);
              v = '';
            }
            if (k) out[k] = v;
          });
          return out;
        }
        
        // State-Schreiber (legt State an, falls nicht vorhanden)
        async function put(id, val, unit='', type='number') {
          const full = BASE + id;
          if (!await existsStateAsync(full)) {
            await setObjectAsync(full, {type: 'state', common: {name: id, read: true, write: false, type, role: 'value', unit}, native: {}});
          }
          setState(full, val, true);
        }
        
        // === Subscriber: jedes Update parsen ===
        on({ id: MQTT_STATE, change: 'any' }, async obj => {
          try {
            if (!obj || !obj.state || typeof obj.state.val !== 'string') return;
        
            const params = parseQuery(obj.state.val);
        
            // Meta
            await put('meta.stationtype', params.stationtype || '', '', 'string');
            await put('meta.model',       params.model || '', '', 'string');
            await put('meta.dateutc',     params.dateutc || '', '', 'string');
            await put('meta.interval',    toNumber(params.interval));
        
            // Innen
            await put('inside.temp_C',        f2c(params.tempinf), '°C');
            await put('inside.humidity_pct',  toNumber(params.humidityin), '%');
            await put('pressure.rel_hPa',     inHg2hPa(params.baromrelin), 'hPa');
            await put('pressure.abs_hPa',     inHg2hPa(params.baromabsin), 'hPa');
        
            // Außen
            await put('outside.temp_C',       f2c(params.tempf), '°C');
            await put('outside.humidity_pct', toNumber(params.humidity), '%');
            await put('outside.vpd_kPa',      toNumber(params.vpd), 'kPa');
        
            // Wind
            await put('wind.dir_deg',         toNumber(params.winddir), '°');
            await put('wind.dir_avg10m_deg',  toNumber(params.winddir_avg10m), '°');
            await put('wind.speed_ms',        mph2ms(params.windspeedmph), 'm/s');
            await put('wind.gust_ms',         mph2ms(params.windgustmph), 'm/s');
            await put('wind.maxdailygust_ms', mph2ms(params.maxdailygust), 'm/s');
        
            // Solar/UV
            await put('solar.radiation_Wm2',  toNumber(params.solarradiation), 'W/m²');
            await put('uv.index',             toNumber(params.uv));
        
            // Regen (Zoll -> mm)
            await put('rain.rate_mmph',       inch2mm(params.rrain_piezo), 'mm/h');
            await put('rain.event_mm',        inch2mm(params.erain_piezo), 'mm');
            await put('rain.hour_mm',         inch2mm(params.hrain_piezo), 'mm');
            await put('rain.day_mm',          inch2mm(params.drain_piezo), 'mm');
            await put('rain.week_mm',         inch2mm(params.wrain_piezo), 'mm');
            await put('rain.month_mm',        inch2mm(params.mrain_piezo), 'mm');
            await put('rain.year_mm',         inch2mm(params.yrain_piezo), 'mm');
        
            // Batteries / Misc (Wittboy)
            await put('wittboy.cap_volt',     toNumber(params.ws90cap_volt), 'V');
            await put('wittboy.version',      toNumber(params.ws90_ver));
            await put('wittboy.batt_V',       toNumber(params.wh90batt), 'V');
        
            // Rohdaten ablegen (optional, hilfreich zum Debuggen)
            await put('raw.query', obj.state.val, '', 'string');
          } catch (e) {
            log(`Ecowitt parse error: ${e}`, 'error');
          }
        });
        
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate

        879
        Online

        32.0k
        Users

        80.5k
        Topics

        1.3m
        Posts

        1
        2
        19
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo