Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Praktische Anwendungen (Showcase)
    4. [Linux Shell-Skript] WLAN-Wetterstation

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [Linux Shell-Skript] WLAN-Wetterstation

    This topic has been deleted. Only users with topic management privileges can see it.
    • SBorg
      SBorg Forum Testing Most Active @icebear last edited by

      @icebear sagte in [Linux Shell-Skript] WLAN-Wetterstation:

      jetzt hab ich mir mal die wetterstation.conf angesehen und festgestellt das bei den Zusatzsensoren die WS80, WH40H und WH/WN32 nicht explizit aufgeführt sind.

      Liegt schlichtweg daran, dass noch keiner einen der Sensoren hatte. Da ich keinen Support von Ecowitt habe, weiß ich einfach nicht wie die Bezeichner lauten. Wenn du/jemand den String postet kann ich sie auch implementieren 🙂

      1 Reply Last reply Reply Quote 0
      • SBorg
        SBorg Forum Testing Most Active @Negalein last edited by

        @negalein sagte in [Linux Shell-Skript] WLAN-Wetterstation:

        ich kann seit heute Vormittag nichts mehr an Awekas schicken.

        Hatte ich schon Samstag Morgen bei Awekas gemeldet und geht seit aktuell ca. 4 Stunden wieder.

        1 Reply Last reply Reply Quote 0
        • S
          Shakira1972 @Shakira1972 last edited by

          @shakira1972 sagte in [Linux Shell-Skript] WLAN-Wetterstation:

          @boronsbruder sagte in [Linux Shell-Skript] WLAN-Wetterstation:

          @sborg meinte die Kommandozeile ./wetterstation.sh --data ausführen und die Ausgabe der Sensoren, ohne den ganzen Krismkrams darum, posten:

          Ok, ich hoffe das sind nun die richtigen Werte...

          soilmoisture1=50&soilad1=240&soilmoisture2=47&soilad2=249&soilmoisture3=35&soilad3=196&soilmoisture4=46&soilad4=245&soilmoisture5=50&soilad5=260&soilmoisture6=47&soilad6=247&soilmoisture7=41&soilad7=225&soilmoisture8=38&soilad8=222&soilmoisture9=50&soilad9=250&soilmoisture10=48&soilad10=238&soilmoisture11=58&soilad11=282&soilmoisture12=52&soilad12=248&soilmoisture13=54&soilad13=257&soilmoisture14=50&soilad14=239&soilmoisture15=53&soilad15=255&soilmoisture16=56&soilad16=261
          

          Wenn ich das richtig verstehe, dann zeigt es hier, im Gegensatz zu den Werten in IoBroker, die richtigen Werte an.
          Aktuell in IoBroker:
          0f813add-e6a0-44ac-87c8-12eedcfdb69f-image.png
          Danke für Eure Hilfe!

          Niemand eine Idee, woran es liegen könnte?
          Danke
          Shaki

          1 Reply Last reply Reply Quote 0
          • Boronsbruder
            Boronsbruder @SBorg last edited by

            @Shakira1972

            @sborg sagte in [Linux Shell-Skript] WLAN-Wetterstation:

            Da ich einen gedanklichen Fehler bei der V3.5.0 bei der Erhöhung der Sensoranzahl auf 16 Stück beim DP100 hatte:

            Neues Bugfix-Release des Wetterstation WLAN-Skriptes auf GitHub V3.5.1

            • ~ Fix falsche Messwerte bei DP100 Sensor Nr.1 wenn mehr als 10 Sensoren vorhanden sind

            Wie immer zu finden im GitHub


            Update-Routine von Vorgängerversion:

            • aktuellen WS-Updater nutzen

              wget -O ws_updater.sh https://raw.githubusercontent.com/SBorg2014/WLAN-Wetterstation/master/ws_updater.sh
            • ./ws_updater.sh im Installationsverzeichnis ausführen
            • Menüpunkt "4" wählen und die Fragen beantworten

            Update enthält lediglich einen Fix für mehr als 9 Stück DP100 Sensoren, ist also optional.

            S 1 Reply Last reply Reply Quote 0
            • S
              Shakira1972 @Boronsbruder last edited by

              @boronsbruder Super, hat funktioniert!
              Danke!

              R 1 Reply Last reply Reply Quote 0
              • R
                Rand @Shakira1972 last edited by

                Leicht OT, aber vieleicht hilft es ja jemanden 🙂

                Hatte ja nach einem Weg gesucht den WFC01 auszulesen und nun ein einfaches JS basteln lassen:

                const gwIp = '192.168.x.y'; // Replace with your actual GW2000 IP
                const deviceId = 13443;      // Your WFC01 device ID
                const model = 1;             // Always 1 for WFC01
                const request = require('request');
                
                const enableLogging = true;
                const statePrefix = 'javascript.0.WFC01';
                
                function logDebug(msg) {
                    if (enableLogging) log(msg);
                }
                
                function createAndSetState(id, value, unit = '', type = 'number') {
                    const fullId = `${statePrefix}.${id}`;
                    if (!existsState(fullId)) {
                        createState(fullId, value, {
                            type: type,
                            read: true,
                            write: false,
                            unit: unit
                        });
                        logDebug(`Created state: ${fullId}`);
                    }
                    setState(fullId, value, true);
                    logDebug(`Updated ${fullId} → ${value}${unit}`);
                }
                
                const options = {
                    url: `http://${gwIp}/parse_quick_cmd_iot`,
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({
                        command: [{
                            cmd: "read_device",
                            id: deviceId,
                            model: model
                        }]
                    }),
                    timeout: 5000
                };
                
                logDebug('Sending POST request to WFC01...');
                request(options, (error, response, body) => {
                    if (error) {
                        logDebug(`Request error: ${error}`);
                        return;
                    }
                
                    if (response.statusCode !== 200) {
                        logDebug(`Unexpected status code: ${response.statusCode}`);
                        logDebug(`Response body: ${body}`);
                        return;
                    }
                
                    if (!body) {
                        logDebug('Empty response body');
                        return;
                    }
                
                    try {
                        const data = JSON.parse(body);
                        logDebug(`Parsed JSON data: ${JSON.stringify(data)}`);
                
                        const d = data.command[0];
                
                        createAndSetState('flow_velocity', parseFloat(d.flow_velocity), 'L/min');
                        createAndSetState('water_total', parseFloat(d.water_total), 'L');
                        createAndSetState('water_status', parseInt(d.water_status));
                        createAndSetState('water_temp', parseFloat(d.water_temp), '°C');
                        createAndSetState('battery', parseInt(d.wfc01batt));
                        createAndSetState('signal', parseInt(d.rssi));
                        createAndSetState('warning', parseInt(d.warning));
                        createAndSetState('run_time', parseInt(d.run_time), 's');
                
                    } catch (e) {
                        logDebug(`JSON parse error: ${e.message}`);
                    }
                });
                
                

                Habs ohne >request< nicht hinbekommen, da hat er den call nicht sauber gemacht.
                Die Infos dazu stammen aus dem Ecowitt API document welches sie auf Anfrage verschicken (Local IOT API 20240828.docx in meinem Fall).

                S 2 Replies Last reply Reply Quote 0
                • S
                  Solardach @Rand last edited by

                  @rand Hallo !
                  Vielen Dank für das Skript, 👍 👏
                  Danach hatte ich schon länger gesucht.
                  Ich habe es installiert und läuft bei mir mit der WS3900A Wetterstation als Gateway.
                  Den Punkt "happen_water" habe ich noch dazu gesetzt.

                  water volume when water program starts. (L = water_total - happen_water)

                  1 Reply Last reply Reply Quote 0
                  • S
                    Solardach @Rand last edited by

                    @rand
                    Das Problem mit dem Skript ist, das es keinen Trigger gibt.
                    Es werden nur einmalig beim Skript Start die Werte eingelesen und das wars.
                    Vieleicht kann man noch einen Trigger mit einbauen ?

                    R 1 Reply Last reply Reply Quote 0
                    • R
                      Rand @Solardach last edited by Rand

                      @solardach

                      Klar, danke, hätte vieleicht vorher prüfen sollen ob alles tut, aber es war spät;)
                      Es wird auch ohne saubere Werte angelegt (nur als State, das habe ich auch noch gemacht (machen lassen ;))

                      Edit: So Water_happen sollte mit drin sein, hat es beim ersten durchlauf gestern scheinbar ignoriert, aber ist auch bei mir vorhanden.

                      Edit 2 - Es gab noch eine Diskrepanz zwischen State und Ihrem Datentyp (numerisch) -> ping @Solardach
                      Edit 3 - Nochmal korrigiert

                      const gwIp = '192.168.x.y';    // IP of your Sensaphone Web600
                      const deviceId = 13443;           // Device ID of your WFC01
                      const model = 1;                  // Model = 1 for WFC01
                      const version = '1.0.0';          // Script version
                      const request = require('request');
                      
                      const enableLogging = true;
                      const statePrefix = 'javascript.0.WFC01'; // ioBroker state prefix
                      
                      function logDebug(msg) {
                          if (enableLogging) log(msg);
                      }
                      
                      // Log script version on start
                      logDebug(`Starting WFC01 script, version ${version}`);
                      
                      // Recreate or update ioBroker state - Async version to avoid type errors
                      async function recreateState(id, value, meta) {
                          const fullId = `${statePrefix}.${id}`;
                      
                          if (!(await existsStateAsync(fullId))) {
                              await createStateAsync(fullId, value, {
                                  type: meta.type,
                                  role: meta.role,
                                  read: true,
                                  write: false,
                                  unit: meta.unit || ''
                              });
                              logDebug(`Created state: ${fullId}`);
                          }
                      
                          await setStateAsync(fullId, { val: value, ack: true });
                          logDebug(`Updated ${fullId} → ${value}${meta.unit || ''}`);
                      }
                      
                      // Metadata definitions for each field
                      const fieldDefinitions = {
                          flow_velocity:  { unit: 'L/min', type: 'number', role: 'value.flow' },
                          water_total:    { unit: 'L',     type: 'number', role: 'value.total' },
                          happen_water:   { unit: 'L',     type: 'number', role: 'value' },
                          water_volume:   { unit: 'L',     type: 'number', role: 'value' },
                          water_status:   {                type: 'number', role: 'value.status' },
                          water_temp:     { unit: '°C',    type: 'number', role: 'value.temperature' },
                          battery:        {                type: 'number', role: 'value.battery' },
                          signal:         {                type: 'number', role: 'value.signal' },
                          warning:        {                type: 'number', role: 'value.warning' },
                          run_time:       { unit: 's',     type: 'number', role: 'value.interval' },
                          publish_time:   { unit: 's',     type: 'number', role: 'value.time' },
                          timeutc:        { unit: 's',     type: 'number', role: 'value.time' },
                          water_action:   {                type: 'number', role: 'value' },
                          water_running:  {                type: 'number', role: 'indicator.running' }
                      };
                      
                      // Poll the WFC01 device (async version)
                      async function pollDeviceData() {
                          const options = {
                              url: `http://${gwIp}/parse_quick_cmd_iot`,
                              method: 'POST',
                              headers: { 'Content-Type': 'application/json' },
                              body: JSON.stringify({
                                  command: [{
                                      cmd: "read_device",
                                      id: deviceId,
                                      model: model
                                  }]
                              }),
                              timeout: 5000
                          };
                      
                          logDebug('Sending POST request to WFC01...');
                      
                          request(options, async (error, response, body) => {
                              if (error) {
                                  logDebug(`Request error: ${error}`);
                                  return;
                              }
                      
                              if (response.statusCode !== 200) {
                                  logDebug(`Unexpected status code: ${response.statusCode}`);
                                  logDebug(`Response body: ${body}`);
                                  return;
                              }
                      
                              if (!body) {
                                  logDebug('Empty response body');
                                  return;
                              }
                      
                              try {
                                  const data = JSON.parse(body);
                                  const d = data.command[0];
                      
                                  if (!d) {
                                      logDebug('No device data in response.');
                                      return;
                                  }
                      
                                  // Parse and update all standard fields asynchronously
                                  await recreateState('flow_velocity', parseFloat(d.flow_velocity), fieldDefinitions.flow_velocity);
                                  await recreateState('water_total', parseFloat(d.water_total), fieldDefinitions.water_total);
                                  await recreateState('happen_water', parseFloat(d.happen_water), fieldDefinitions.happen_water);
                                  await recreateState('water_status', parseInt(d.water_status), fieldDefinitions.water_status);
                                  await recreateState('water_temp', parseFloat(d.water_temp), fieldDefinitions.water_temp);
                                  await recreateState('battery', parseInt(d.wfc01batt), fieldDefinitions.battery);
                                  await recreateState('signal', parseInt(d.rssi), fieldDefinitions.signal);
                                  await recreateState('warning', parseInt(d.warning), fieldDefinitions.warning);
                                  await recreateState('run_time', parseInt(d.run_time), fieldDefinitions.run_time);
                                  await recreateState('publish_time', parseInt(d.publish_time), fieldDefinitions.publish_time);
                                  await recreateState('timeutc', parseInt(d.timeutc), fieldDefinitions.timeutc);
                                  await recreateState('water_action', parseInt(d.water_action), fieldDefinitions.water_action);
                                  await recreateState('water_running', parseInt(d.water_running), fieldDefinitions.water_running);
                      
                                  // Calculated water_volume
                                  const waterTotal = parseFloat(d.water_total);
                                  const happenWater = parseFloat(d.happen_water);
                                  const waterVolume = waterTotal - happenWater;
                                  await recreateState('water_volume', waterVolume, fieldDefinitions.water_volume);
                      
                              } catch (e) {
                                  logDebug(`JSON parse error: ${e.message}`);
                              }
                          });
                      }
                      
                      // Run initially and set interval to 1 minute
                      pollDeviceData();
                      setInterval(pollDeviceData, 60 * 1000);
                      
                      
                      
                      S 1 Reply Last reply Reply Quote 0
                      • S
                        Solardach @Rand last edited by

                        @rand
                        Kann es sein das jetzt ein altes Skript drin steht ?
                        Es verursacht mehr Probleme mit den Datentypen, und es fehlen die Werte water_happen und Volume.

                        R 1 Reply Last reply Reply Quote 0
                        • R
                          Rand @Solardach last edited by Rand

                          @solardach
                          Ja. Der nachteil von ChatGPT, man muss immer alles doppelt und dreifach prüfen 😞
                          Ich repariere es nachher.

                          Edit: Habe es nochmal korrigiert, ich hoffe es tut nun

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          880
                          Online

                          31.9k
                          Users

                          80.1k
                          Topics

                          1.3m
                          Posts

                          linux shell-script wetterstation wlan-wetterstation
                          147
                          5570
                          3346621
                          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