Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. wilhelminen

    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

    W
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 5
    • Best 1
    • Groups 1

    wilhelminen

    @wilhelminen

    Starter

    1
    Reputation
    5
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    wilhelminen Follow
    Starter

    Best posts made by wilhelminen

    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @ticaki Super!!!

      Es geht wieder! Ich habe 2x das ignore eingefügt und nun geht es.

      Danke

      posted in Skripten / Logik
      W
      wilhelminen

    Latest posts made by wilhelminen

    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @ticaki Super!!!

      Es geht wieder! Ich habe 2x das ignore eingefügt und nun geht es.

      Danke

      posted in Skripten / Logik
      W
      wilhelminen
    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @sonny

      Hallo,

      ich hatte den HPM länger rumliegen und habe mich dieses Jahr daran gemacht ihn anzuschließen - leider musste ich zusätzlich dieses überteuerte Kabel kaufen...
      Er funktioniert, hat aber ab und zu Macken (Sollwerte aufeinmal zu hoch...). Ich habe die aktuellste? SW (Version H1.1.27).

      Den HPM nutze ich hauptsächlich um per Shelly die Eingänge zu steuern (Heizen / Kühlen / Solarüberschuß usw..).

      Über das Script logge ich nur die Werte mit.

      Ich habe das Script unverändert von hier übernommen - wie gesagt aufeinmal ging es nicht mehr.

      Ich habe zu diesem Fehler auch nichts gefunden was ich nachvollziehen könnte...

      Gruß
      Timo

      posted in Skripten / Logik
      W
      wilhelminen
    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @ticaki @ticaki

      Hallo,

      hier das Script:

      
       
      const ip = '192.168.178.11';
      const prefix = '0_userdata.0.test'; // wird erstellt oder erweitert bei jedem durchlauf
      const channelName = 'HPM';
      const interval = '*/5 * * * *';
      const DEBUG = true
      const axios = require('axios');
      const { HTMLToJSON } = require('html-to-json-parser');
       
      let values: any = {};
      async function main() {
          const result = await axios(`http://${ip}`);
          if ( result && result.data) {
              logDebug(`Get data from http://${ip}`);0
              logDebug(``);
              for (const r of db) {
                  const match = result.data.match(r);
                  if (match && Array.isArray(match) && match.length >= 1) {
                      //log(`http://${ip}/${match[0]}`)
                      const response = await axios(`http://${ip}/${match[0]}`);
                      if (response && response.data) {
                          logDebug(`Get data from http://${ip}/${match[0]}`);
                          let body = response.data.replace(/\n/gm, '').match(/<body>.*?<\/body>/gms)
                          if (body || Array.isArray(body) ) {
                              body = body[0];
                          }
                          if (!body) {
                              log('Regex: Body not found', 'error');
                              continue;
                          }
                          let data
                          try {
                              data = await HTMLToJSON(body, false);
                          } catch (e) {
                              log(e)
                          }
                          if (data && data.type == 'body') {
                              logDebug(`Parse data ok, found body`);
                              let d = data.content;
                              for (const c in d) {
                                  const v = d[c];
                                  if (v.type === 'div') {
                                      logDebug(`div found`);
                                      for (const i of v.content) {
                                          if (i.attributes && i.attributes.class == 'dp') {
                                              logDebug(`class db found`);
                                              for (const b of i.content) {
                                                  if (b.type) {
                                                      logDebug(`type ${b.type} found`);
                                                      let val = b.content.join(' ').match(/ [0-9\.,-]+/);
                                                      let end = '';
                                                      logDebug(val);
                                                      if (!val || isNaN(val.join(''))) val = b.content.join(' ');
                                                      else {
                                                          end = '_' + b.content.join(' ').replace(val, '');
                                                          val = parseFloat(val.join(''));
                                                      }
                                                      values[(b.attributes.href + end).replace(/^.*?sessionid\=[0-9A-Z]+\&id\=/, '').replace(/[^_\-/:!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu, '_')] = val;
                                                  }
                                              }
                                          }
                                      }
       
                                  }
                              }
                          } else logDebug(`${data ? 'Parse data ok' : 'Parse data failed!'}, ${data.type == 'body' ? 'body found' : 'body not found'}`);
                      } else logDebug(`Don't get data from http://${ip}/${match[0]}`);
                  }
              }
          } else logDebug(`Don't get data from http://${ip}`);
          for (const id in values) {
              const val = values[id];
              await extendObjectAsync(`${prefix}`,{type: 'channel', common:{name: channelName}});
              if (!existsState(`${prefix}.${id}`)) await createStateAsync(`${prefix}.${id}`, val, {name: 'no description', role: typeof val === 'string' ? 'text' : 'value', type: typeof val, read: true, write: false})
              await setStateAsync(`${prefix}.${id}`, val, true);
          }
      }
       
      function logDebug(l: string): void {
          if (DEBUG) log(l);
      }
       
      const db: RegExp[] = [
          /v107000\.rsp\?sessionid=[0-9A-Z]+/,
          /v20\.rsp\?sessionid=[0-9A-Z]+/,
          /v21\.rsp\?sessionid=[0-9A-Z]+/,
          /v50\.rsp\?sessionid=[0-9A-Z]+/,  
       //   /menue\.rsp\?sessionid=[0-9A-Z]+\&branchnr=1&level=4/,
        //  /menue\.rsp\?sessionid=[0-9A-Z]+/&branchnr=1&level=4/
      
      //    http://192.168.178.11/menue.rsp?sessionid=904F6140&branchnr=1&level=4
      //    http://192.168.178.11/v21.rsp?sessionid=904F6140
      
      ]
       
      schedule(interval, main);
      
      

      Gruß Timo

      posted in Skripten / Logik
      W
      wilhelminen
    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @ticaki
      @haus-automatisierung

      Hallo, danke für die schnelle Reaktion.

      Meine Versionen sind alle aktuell -JS v8.8.3.
      Es hatte ja auch funktioniert -allerdings seit August nicht mehr!?
      Gerade nochmal gestartet:
      javascript.0 09:11:35.835 info Stopping script script.js.hpm
      javascript.0 09:11:35.980 info Compiling TypeScript source script.js.hpm
      javascript.0 09:11:36.204 error script.js.hpm: TypeScript compilation failed: let body = response.data.replace(/\n/gm, '').match(/<body>.?</body>/gms); ^ ERROR: This regular expression flag is only available when targeting 'es2018' or later. values[(b.attributes.href + end).replace(/^.?sessionid=[0-9A-Z]+&id=/, '').replace(/[^-/:!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu, '')] = val; ^ ERROR: This regular expression flag is only available when targeting 'es6' or later.

      Es geht um das Script von ticaki vom 13 Jan 2024, 15:46

      Ich habe gelesen dass man die version in einer Datei vorgeben kann - allerdings macht es ja keinen Sinn das eine neuere Version gefordert ist wenn es schonmal funktioniert hat. Nur wenn ich eine "ältere Version" installiert hätte...

      Gruß
      Timo

      posted in Skripten / Logik
      W
      wilhelminen
    • RE: Panasonic Wärmepumpenmanager, Script / Ideen gesucht

      @ticaki

      Hallo,

      der Code funktioniert wunderbar doch leider bekomme ich seit einiger Zeit die Fehlermeldung:

      script.js.hpm: TypeScript compilation failed: let body = response.data.replace(/\n/gm, '').match(/<body>.*?</body>/gms); ^ ERROR: This regular expression flag is only available when targeting 'es2018' or later.

      values[(b.attributes.href + end).replace(/^.*?sessionid=[0-9A-Z]+&id=/, '').replace(/[^-/:!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu, '')] = val; ^ ERROR: This regular expression flag is only available when targeting 'es6' or later.

      Hast Du eine Idee wie ich das lösen kann?

      Danke und Gruß
      Timo

      posted in Skripten / Logik
      W
      wilhelminen
    Community
    Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
    The ioBroker Community 2014-2023
    logo