Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. JavaScript
  5. Hilfe für Javascript Legastheniker und js v8.3.x

NEWS

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    17
    1
    2.1k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    936

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.2k

Hilfe für Javascript Legastheniker und js v8.3.x

Scheduled Pinned Locked Moved JavaScript
104 Posts 8 Posters 13.3k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • HomoranH Homoran

    @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

    kann aber nachher nochmal nachschauen

    danke schonmal. hab jetzt als erste Hilfe den Timeout hochgesetzt.

    @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

    Wie sieht das Blockly denn in JS aus.

    ist nur ein gaaanz kleiner Teil des Originals

    schedule("*/4 * * * *", async () => {
      httpGet('http://192.168.138.62/?json:', { timeout: 4000, responseType: 'text' }, async (err, response) => {
        if (err) {
          console.error(err);
        }
        setState('javascript.1.WIFFI.Systeminfo.ip_Homematic_CCU' /* ip_Homematic_CCU */, getAttr(response.data, 'vars.0.value'), true);
        setState('javascript.1.WIFFI.wz_co2' /* Luftqualitaet */, getAttr(response.data, 'vars.1.value'), true);
        setState('javascript.1.WIFFI.wz_temp' /* Temperatur */, getAttr(response.data, 'vars.2.value'), true);
        setState('javascript.1.WIFFI.wz_feuchte' /* Luftfeuchte */, getAttr(response.data, 'vars.3.value'), true);
        setState('javascript.1.WIFFI.wz_taupunkt' /* Taupunkt */, getAttr(response.data, 'vars.4.value'), true);
        setState('javascript.1.WIFFI.wz_feuchte_abs' /* Absolutfeuchte */, getAttr(response.data, 'vars.5.value'), true);
        setState('javascript.1.WIFFI.wz_baro' /* Luftdruck */, getAttr(response.data, 'vars.6.value'), true);
        setState('javascript.1.WIFFI.wz_luftdrucktrend' /* Luftdrucktrend */, getAttr(response.data, 'vars.7.value'), true);
        setState('javascript.1.WIFFI.wz_lux' /* Helligkeit */, getAttr(response.data, 'vars.8.value'), true);
        setState('javascript.1.WIFFI.wz_motion_left' /* Bewegung links */, getAttr(response.data, 'vars.9.value'), true);
        setState('javascript.1.WIFFI.wz_motion_right' /* Bewegung rechts */, getAttr(response.data, 'vars.10.value'), true);
        setState('javascript.1.WIFFI.wz_noise' /* Geraeusch */, getAttr(response.data, 'vars.12.value'), true);
        setState('javascript.1.WIFFI.wz_elevation' /* Sonne-Elevation */, getAttr(response.data, 'vars.13.value'), true);
        setState('javascript.1.WIFFI.wz_azimut' /* Sonne-Azimut */, getAttr(response.data, 'vars.14.value'), true);
        setState('javascript.1.WIFFI.wz_buzzer' /* Buzzer */, getAttr(response.data, 'vars.15.value'), true);
      });
    });
    

    ooh.
    sehe gerade das ist ja "hard-coded" if (err) {console.error(err);}
    das kann man dann wohl nicht unterbinden

    T Offline
    T Offline
    TT-Tom
    wrote on last edited by
    #46

    @homoran

    Das ist so richtig, damit du auch eine log-Ausgabe bekommst. Das if-Statement bedeutet soviel wie: Wenn ein Fehler vorliegt, dann schreibe ins Log die Fehlermeldung.

    Mann könnte jetzt das ganze so um stellen, dass bei einem Fehler keine Auswertung gemacht wird.

    Gruß Tom
    https://github.com/tt-tom17
    Wenn meine Hilfe erfolgreich war, benutze bitte das Voting unten rechts im Beitrag

    NSPanel Script Wiki
    https://github.com/joBr99/nspanel-lovelace-ui/wiki

    NSPanel Adapter Wiki
    https://github.com/ticaki/ioBroker.nspanel-lovelace-ui/wiki

    HomoranH 1 Reply Last reply
    1
    • T TT-Tom

      @homoran

      Das ist so richtig, damit du auch eine log-Ausgabe bekommst. Das if-Statement bedeutet soviel wie: Wenn ein Fehler vorliegt, dann schreibe ins Log die Fehlermeldung.

      Mann könnte jetzt das ganze so um stellen, dass bei einem Fehler keine Auswertung gemacht wird.

      HomoranH Do not disturb
      HomoranH Do not disturb
      Homoran
      Global Moderator Administrators
      wrote on last edited by
      #47

      @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

      dass bei einem Fehler keine Auswertung gemacht wird.

      aber das log wird trotzdem zugemüllt.
      Allerdings dann (hoffentlich) nur noch mit timeout of x msec exceeded und nicht mehr die ganzen null Meldungen

      kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

      Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

      der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

      T paul53P 2 Replies Last reply
      0
      • T TT-Tom

        @ofbeqnpolkkl6mby5e13

        Hast du auch beide Zeilen angepasst? Der Fehler kam zweimal vor. Zeile 47 glaube ich

        O Offline
        O Offline
        oFbEQnpoLKKl6mbY5e13
        wrote on last edited by
        #48

        @tt-tom

        Inzwischen ja. Leider wird weiterhin keine Objektstruktur angelegt. Hier der aktuelle Stand:

        const city_id = XXXXX;
        const area_id = XXX;
        const logging = false;
        const name = 'Müllabfuhr';
        const numberOfEntries = 69;
        
        const instanz = '0_userdata.' + instance + '.muell-test';
        
        if (logging) log('starting muell.' + instanz);
        
        extendObject(instanz, {
               type: "device",
               common: {
                   name: name
               }
           }, function (err) {
               if (err) {
                   log('could not create device: ', 'warn');
                   return;
               }
           
           }
        );
        let baseData = {};
        
        // query names first
        httpGet('https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, { timeout: 2000 }, (error, response) => {
           if (!error && response.statusCode == 200) {
               console.log(response.statusCode);
               console.log(response.data);
           } else {
               console.error(error);
           var data = JSON.parse(response.data);  // info ist ein Objekt
                   data.forEach((v, i) => {
                       baseData[v._name] = v;
                   })
           updateMuell();	
           }
        });
        
        schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}', updateMuell);
        
        function updateMuell() {
           var options = 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3'
        
           httpGet(options), (error, response)
               if (!error && response.statusCode == 200) 
                   var info = JSON.parse(response.data);  // info ist ein Objekt
                   if (info[0].Ack === 'Success') {
                       var data = info[0]._data;  // xy ist eine Eigenschaft des Objektes info
                       let counter = 0;
                       const date = (new Date())
                       const todayStr = date.getFullYear() + "-" + ('00' + (date.getMonth() + 1 )).slice(-2) + "-" + ('00' + date.getDate()).slice(-2)
                       log(todayStr);
                       data.forEach((v, i) => {
                           if (todayStr < v.cal_date && counter <= numberOfEntries) {
                               
                               const basePath = instanz + '.' + ('000' + counter).slice(-3);
                               log(v.cal_date + ' -> ' + basePath, 'debug');
                               // States erstellen
                               extendObject(basePath, {
                                       type: "channel",
                                       common: {
                                           name: v.cal_date_normal
                                       }
                                   }, function (err) {
                                       if (err) {
                                           log('could not create device: ', 'warn');
                                           return;
                                       }
                                   
                                   }
                               );
                               createState(basePath + '.date', v.cal_date_normal, {
                                   name: 'Datum',
                                   desc: 'Datum der Abholung',
                                   type: 'string',
                                   read: true,
                                   write: false
                               }, () => {
                                   setState(basePath + '.date', v.cal_date_normal, true);
                               });
                               
                               createState(basePath + '.desc', baseData[v.cal_garbage_type].title, {
                                   name: 'Beschreibung',
                                   desc: 'Beschreibung der Abholung',
                                   type: 'string',
                                   read: true,
                                   write: false
                               }, () => {
                                   setState(basePath + '.desc', baseData[v.cal_garbage_type].title, true);
                               });
                               createState(basePath + '.color', {
                                   name: 'Farbe',
                                   desc: 'Farbe',
                                   type: 'string',
                                   role: 'level.color',
                                   read: true,
                                   write: false
                               }, () => {
                                   setState(basePath + '.color', baseData[v.cal_garbage_type].color, true);
                               });
        
                               counter++;
                           }
                       });
                   }
               };
           
        

        T HomoranH 2 Replies Last reply
        0
        • HomoranH Homoran

          @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

          dass bei einem Fehler keine Auswertung gemacht wird.

          aber das log wird trotzdem zugemüllt.
          Allerdings dann (hoffentlich) nur noch mit timeout of x msec exceeded und nicht mehr die ganzen null Meldungen

          T Offline
          T Offline
          TT-Tom
          wrote on last edited by
          #49

          @homoran
          Ja davon gehe aus. Muss mir das aber zu Hause erst anschauen.
          Wobei der Timeout eventuell auch höher muss, wenn die Daten nicht so schnell da sind.

          Gruß Tom
          https://github.com/tt-tom17
          Wenn meine Hilfe erfolgreich war, benutze bitte das Voting unten rechts im Beitrag

          NSPanel Script Wiki
          https://github.com/joBr99/nspanel-lovelace-ui/wiki

          NSPanel Adapter Wiki
          https://github.com/ticaki/ioBroker.nspanel-lovelace-ui/wiki

          1 Reply Last reply
          1
          • O oFbEQnpoLKKl6mbY5e13

            @tt-tom

            Inzwischen ja. Leider wird weiterhin keine Objektstruktur angelegt. Hier der aktuelle Stand:

            const city_id = XXXXX;
            const area_id = XXX;
            const logging = false;
            const name = 'Müllabfuhr';
            const numberOfEntries = 69;
            
            const instanz = '0_userdata.' + instance + '.muell-test';
            
            if (logging) log('starting muell.' + instanz);
            
            extendObject(instanz, {
                   type: "device",
                   common: {
                       name: name
                   }
               }, function (err) {
                   if (err) {
                       log('could not create device: ', 'warn');
                       return;
                   }
               
               }
            );
            let baseData = {};
            
            // query names first
            httpGet('https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, { timeout: 2000 }, (error, response) => {
               if (!error && response.statusCode == 200) {
                   console.log(response.statusCode);
                   console.log(response.data);
               } else {
                   console.error(error);
               var data = JSON.parse(response.data);  // info ist ein Objekt
                       data.forEach((v, i) => {
                           baseData[v._name] = v;
                       })
               updateMuell();	
               }
            });
            
            schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}', updateMuell);
            
            function updateMuell() {
               var options = 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3'
            
               httpGet(options), (error, response)
                   if (!error && response.statusCode == 200) 
                       var info = JSON.parse(response.data);  // info ist ein Objekt
                       if (info[0].Ack === 'Success') {
                           var data = info[0]._data;  // xy ist eine Eigenschaft des Objektes info
                           let counter = 0;
                           const date = (new Date())
                           const todayStr = date.getFullYear() + "-" + ('00' + (date.getMonth() + 1 )).slice(-2) + "-" + ('00' + date.getDate()).slice(-2)
                           log(todayStr);
                           data.forEach((v, i) => {
                               if (todayStr < v.cal_date && counter <= numberOfEntries) {
                                   
                                   const basePath = instanz + '.' + ('000' + counter).slice(-3);
                                   log(v.cal_date + ' -> ' + basePath, 'debug');
                                   // States erstellen
                                   extendObject(basePath, {
                                           type: "channel",
                                           common: {
                                               name: v.cal_date_normal
                                           }
                                       }, function (err) {
                                           if (err) {
                                               log('could not create device: ', 'warn');
                                               return;
                                           }
                                       
                                       }
                                   );
                                   createState(basePath + '.date', v.cal_date_normal, {
                                       name: 'Datum',
                                       desc: 'Datum der Abholung',
                                       type: 'string',
                                       read: true,
                                       write: false
                                   }, () => {
                                       setState(basePath + '.date', v.cal_date_normal, true);
                                   });
                                   
                                   createState(basePath + '.desc', baseData[v.cal_garbage_type].title, {
                                       name: 'Beschreibung',
                                       desc: 'Beschreibung der Abholung',
                                       type: 'string',
                                       read: true,
                                       write: false
                                   }, () => {
                                       setState(basePath + '.desc', baseData[v.cal_garbage_type].title, true);
                                   });
                                   createState(basePath + '.color', {
                                       name: 'Farbe',
                                       desc: 'Farbe',
                                       type: 'string',
                                       role: 'level.color',
                                       read: true,
                                       write: false
                                   }, () => {
                                       setState(basePath + '.color', baseData[v.cal_garbage_type].color, true);
                                   });
            
                                   counter++;
                               }
                           });
                       }
                   };
               
            

            T Offline
            T Offline
            TT-Tom
            wrote on last edited by
            #50

            @ofbeqnpolkkl6mby5e13
            Wie gesagt bin noch am Handy und schaue nachher mir das dann an. Das JSON kommt aber jetzt richtig rein?

            Setze das mal in Zeile 48 mit rein, damit du sehen kannst was da kommt.

            console.log(response.data);
            

            Gruß Tom
            https://github.com/tt-tom17
            Wenn meine Hilfe erfolgreich war, benutze bitte das Voting unten rechts im Beitrag

            NSPanel Script Wiki
            https://github.com/joBr99/nspanel-lovelace-ui/wiki

            NSPanel Adapter Wiki
            https://github.com/ticaki/ioBroker.nspanel-lovelace-ui/wiki

            HomoranH O 2 Replies Last reply
            0
            • T TT-Tom

              @ofbeqnpolkkl6mby5e13
              Wie gesagt bin noch am Handy und schaue nachher mir das dann an. Das JSON kommt aber jetzt richtig rein?

              Setze das mal in Zeile 48 mit rein, damit du sehen kannst was da kommt.

              console.log(response.data);
              
              HomoranH Do not disturb
              HomoranH Do not disturb
              Homoran
              Global Moderator Administrators
              wrote on last edited by
              #51

              @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

              Setze das mal in Zeile 48 mit rein,

              steht schon in Zeile 30

              kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

              Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

              der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

              O 1 Reply Last reply
              0
              • T TT-Tom

                @ofbeqnpolkkl6mby5e13
                Wie gesagt bin noch am Handy und schaue nachher mir das dann an. Das JSON kommt aber jetzt richtig rein?

                Setze das mal in Zeile 48 mit rein, damit du sehen kannst was da kommt.

                console.log(response.data);
                
                O Offline
                O Offline
                oFbEQnpoLKKl6mbY5e13
                wrote on last edited by
                #52

                @tt-tom

                Ja, die werden bei jedem Skriptstart im Log ausgegeben, was aber vorher nie so war. Die Objektstruktur wird aber nicht angelegt (nur der Ordner 0_userdata.0.muell-test).

                1 Reply Last reply
                0
                • HomoranH Homoran

                  @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                  Setze das mal in Zeile 48 mit rein,

                  steht schon in Zeile 30

                  O Offline
                  O Offline
                  oFbEQnpoLKKl6mbY5e13
                  wrote on last edited by oFbEQnpoLKKl6mbY5e13
                  #53

                  @homoran

                  Richtig, aber eigentllich sollte das doch nur bei der Bedingung "if (!error && response.statusCode == 200)" ausgegeben werden.

                  Edit:
                  Ach, ich sehe gerade response.statusCode ist auch 200.

                  1 Reply Last reply
                  0
                  • O oFbEQnpoLKKl6mbY5e13

                    @haus-automatisierung

                    Könntest du bitte trotz Trashschedule-Adapter helfen, das Skript auf httpGet umzustellen?

                    Mein aktueller Stand:

                    const city_id = XXXXX;
                    const area_id = XXX;
                    const logging = false;
                    const name = 'Müllabfuhr';
                    const numberOfEntries = 69;
                    
                    const instanz = '0_userdata.' + instance + '.muell-test';
                    
                    if (logging) log('starting muell.' + instanz);
                    
                    extendObject(instanz, {
                           type: "device",
                           common: {
                               name: name
                           }
                       }, function (err) {
                           if (err) {
                               log('could not create device: ', 'warn');
                               return;
                           }
                       
                       }
                    );
                    let baseData = {};
                    
                    // query names first
                    httpGet('https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, { timeout: 2000 }, (error, response) => {
                       if (!error && response.data == 200) {
                           console.log(response.statusCode);
                           console.log(response.data);
                       } else {
                           console.error(error);
                       var data = JSON.parse(response.data);  // info ist ein Objekt
                               data.forEach((v, i) => {
                                   baseData[v._name] = v;
                               })
                       updateMuell();	
                       }
                    });
                    
                    schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}', updateMuell);
                    
                    function updateMuell() {
                       var options = 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3'
                    
                       httpGet(options), (error, response)
                           if (!error && response.data == 200) 
                               var info = JSON.parse(response.data);  // info ist ein Objekt
                               if (info[0].Ack === 'Success') {
                                   var data = info[0]._data;  // xy ist eine Eigenschaft des Objektes info
                                   let counter = 0;
                                   const date = (new Date())
                                   const todayStr = date.getFullYear() + "-" + ('00' + (date.getMonth() + 1 )).slice(-2) + "-" + ('00' + date.getDate()).slice(-2)
                                   log(todayStr);
                                   data.forEach((v, i) => {
                                       if (todayStr < v.cal_date && counter <= numberOfEntries) {
                                           
                                           const basePath = instanz + '.' + ('000' + counter).slice(-3);
                                           log(v.cal_date + ' -> ' + basePath, 'debug');
                                           // States erstellen
                                           extendObject(basePath, {
                                                   type: "channel",
                                                   common: {
                                                       name: v.cal_date_normal
                                                   }
                                               }, function (err) {
                                                   if (err) {
                                                       log('could not create device: ', 'warn');
                                                       return;
                                                   }
                                               
                                               }
                                           );
                                           createState(basePath + '.date', v.cal_date_normal, {
                                               name: 'Datum',
                                               desc: 'Datum der Abholung',
                                               type: 'string',
                                               read: true,
                                               write: false
                                           }, () => {
                                               setState(basePath + '.date', v.cal_date_normal, true);
                                           });
                                           
                                           createState(basePath + '.desc', baseData[v.cal_garbage_type].title, {
                                               name: 'Beschreibung',
                                               desc: 'Beschreibung der Abholung',
                                               type: 'string',
                                               read: true,
                                               write: false
                                           }, () => {
                                               setState(basePath + '.desc', baseData[v.cal_garbage_type].title, true);
                                           });
                                           createState(basePath + '.color', {
                                               name: 'Farbe',
                                               desc: 'Farbe',
                                               type: 'string',
                                               role: 'level.color',
                                               read: true,
                                               write: false
                                           }, () => {
                                               setState(basePath + '.color', baseData[v.cal_garbage_type].color, true);
                                           });
                    
                                           counter++;
                                       }
                                   });
                               }
                           };
                       
                    

                    2024-05-26 18:33:57.582  - info: javascript.0 (3416) Start JavaScript script.js.common._Tests.Test_17 (JavaScript/js)
                    2024-05-26 18:33:57.614  - info: javascript.0 (3416) script.js.common._Tests.Test_17: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
                    2024-05-26 18:33:57.705  - error: javascript.0 (3416) script.js.common._Tests.Test_17: null
                    2024-05-26 18:33:57.707  - error: javascript.0 (3416) Error in callback: TypeError: Cannot read properties of undefined (reading 'headers')
                    2024-05-26 18:33:57.708  - error: javascript.0 (3416)     at getHttpRequestConfig (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:139:18)
                    2024-05-26 18:33:57.708  - error: javascript.0 (3416)     at httpGet (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1179:20)
                    2024-05-26 18:33:57.708  - error: javascript.0 (3416)     at updateMuell (script.js.common._Tests.Test_17:47:5)
                    2024-05-26 18:33:57.709  - error: javascript.0 (3416)     at Object.<anonymous> (script.js.common._Tests.Test_17:38:5)
                    2024-05-26 18:33:57.709  - error: javascript.0 (3416)     at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1189:38
                    2024-05-26 18:33:57.709  - error: javascript.0 (3416)     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                    2024-05-26 18:33:59.284  - info: javascript.0 (3416) Stopping script script.js.common._Tests.Test_17
                    
                    HomoranH Do not disturb
                    HomoranH Do not disturb
                    Homoran
                    Global Moderator Administrators
                    wrote on last edited by
                    #54

                    @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                    if (info[0].Ack === 'Success') {

                    ich könnte mit meinem begrenzten Wissen höchstens vorstellen dass dies nicht true ist und den Rest unterbindet

                    kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                    Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                    der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                    O 1 Reply Last reply
                    0
                    • HomoranH Homoran

                      @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                      if (info[0].Ack === 'Success') {

                      ich könnte mit meinem begrenzten Wissen höchstens vorstellen dass dies nicht true ist und den Rest unterbindet

                      O Offline
                      O Offline
                      oFbEQnpoLKKl6mbY5e13
                      wrote on last edited by oFbEQnpoLKKl6mbY5e13
                      #55

                      @homoran

                      Schätze ich auch. Allerdings, wenn ich auf "if (!error && response.statusCode == 400)" ändere, dann kommt wieder:

                      2024-05-26 21:18:41.065  - info: javascript.0 (3416) Start JavaScript script.js.common._Tests.Test_17 (JavaScript/js)
                      2024-05-26 21:18:41.115  - info: javascript.0 (3416) script.js.common._Tests.Test_17: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
                      2024-05-26 21:18:41.294  - error: javascript.0 (3416) script.js.common._Tests.Test_17: null
                      2024-05-26 21:18:41.296  - error: javascript.0 (3416) Error in callback: TypeError: Cannot read properties of undefined (reading 'headers')
                      2024-05-26 21:18:41.297  - error: javascript.0 (3416)     at getHttpRequestConfig (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:139:18)
                      2024-05-26 21:18:41.297  - error: javascript.0 (3416)     at httpGet (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1179:20)
                      2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at updateMuell (script.js.common._Tests.Test_17:47:5)
                      2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at Object.<anonymous> (script.js.common._Tests.Test_17:38:5)
                      2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1189:38
                      2024-05-26 21:18:41.299  - error: javascript.0 (3416)     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                      2024-05-26 21:18:48.201  - info: javascript.0 (3416) Stopping script script.js.common._Tests.Test_17
                      

                      Edit:
                      Ich kann mir inzwischen nicht mehr vorstellen, dass man eine Anleitung erstellen kann, die einem User bei der Umstellung auf httpGet hilft.

                      HomoranH 1 Reply Last reply
                      0
                      • O oFbEQnpoLKKl6mbY5e13

                        @homoran

                        Schätze ich auch. Allerdings, wenn ich auf "if (!error && response.statusCode == 400)" ändere, dann kommt wieder:

                        2024-05-26 21:18:41.065  - info: javascript.0 (3416) Start JavaScript script.js.common._Tests.Test_17 (JavaScript/js)
                        2024-05-26 21:18:41.115  - info: javascript.0 (3416) script.js.common._Tests.Test_17: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
                        2024-05-26 21:18:41.294  - error: javascript.0 (3416) script.js.common._Tests.Test_17: null
                        2024-05-26 21:18:41.296  - error: javascript.0 (3416) Error in callback: TypeError: Cannot read properties of undefined (reading 'headers')
                        2024-05-26 21:18:41.297  - error: javascript.0 (3416)     at getHttpRequestConfig (/opt/iobroker/node_modules/iobroker.javascript/lib/tools.js:139:18)
                        2024-05-26 21:18:41.297  - error: javascript.0 (3416)     at httpGet (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1179:20)
                        2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at updateMuell (script.js.common._Tests.Test_17:47:5)
                        2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at Object.<anonymous> (script.js.common._Tests.Test_17:38:5)
                        2024-05-26 21:18:41.298  - error: javascript.0 (3416)     at /opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1189:38
                        2024-05-26 21:18:41.299  - error: javascript.0 (3416)     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
                        2024-05-26 21:18:48.201  - info: javascript.0 (3416) Stopping script script.js.common._Tests.Test_17
                        

                        Edit:
                        Ich kann mir inzwischen nicht mehr vorstellen, dass man eine Anleitung erstellen kann, die einem User bei der Umstellung auf httpGet hilft.

                        HomoranH Do not disturb
                        HomoranH Do not disturb
                        Homoran
                        Global Moderator Administrators
                        wrote on last edited by
                        #56

                        @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                        Ich kann mir inzwischen nicht mehr vorstellen, dass man eine Anleitung erstellen kann, die einem User bei der Umstellung auf httpGet hilft.

                        Ich habe es noch nicht ganz aufgegeben, sammle noch Daten.
                        Das fehlende Wissen hat den Vorteil, dass ich die Sache sus der nicht-Programmierer Perspektive sehe.

                        Den Rest muss ich mit trial & error und "Deduktion lieber Watson" versuchen hinzubekommen

                        kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                        O 1 Reply Last reply
                        0
                        • HomoranH Homoran

                          @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                          Ich kann mir inzwischen nicht mehr vorstellen, dass man eine Anleitung erstellen kann, die einem User bei der Umstellung auf httpGet hilft.

                          Ich habe es noch nicht ganz aufgegeben, sammle noch Daten.
                          Das fehlende Wissen hat den Vorteil, dass ich die Sache sus der nicht-Programmierer Perspektive sehe.

                          Den Rest muss ich mit trial & error und "Deduktion lieber Watson" versuchen hinzubekommen

                          O Offline
                          O Offline
                          oFbEQnpoLKKl6mbY5e13
                          wrote on last edited by oFbEQnpoLKKl6mbY5e13
                          #57

                          @homoran

                          Was mich einfach nachdenklich macht und zweifeln lässt, ist, dass ich durchaus die Umstellung gemacht habe. Dazu habe ich auch https://www.iobroker.net/#en/adapters/adapterref/iobroker.javascript/README.md
                          genutzt. Ich habe ja nicht einfach danach gefragt, ob mir das jemand bitte umstellen kann, damit ich mich nicht damit beschäftigen muss. Trotzdem tappe ich total im Dunkeln...

                          HomoranH 1 Reply Last reply
                          1
                          • O oFbEQnpoLKKl6mbY5e13

                            @homoran

                            Was mich einfach nachdenklich macht und zweifeln lässt, ist, dass ich durchaus die Umstellung gemacht habe. Dazu habe ich auch https://www.iobroker.net/#en/adapters/adapterref/iobroker.javascript/README.md
                            genutzt. Ich habe ja nicht einfach danach gefragt, ob mir das jemand bitte umstellen kann, damit ich mich nicht damit beschäftigen muss. Trotzdem tappe ich total im Dunkeln...

                            HomoranH Do not disturb
                            HomoranH Do not disturb
                            Homoran
                            Global Moderator Administrators
                            wrote on last edited by
                            #58

                            @ofbeqnpolkkl6mby5e13 ja, ich will es auch versuchen zu können, wenigstens nachvollziehen.

                            mir scheint, bei denen wo es nicht klappt ist jedesmal die Funktion readJson (url, function(err, response)) mit beteiligt, wobei der url identisch zu dem httpGet url ist.

                            das finde ich bei dir jedoch nicht

                            kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                            Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                            der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                            O 1 Reply Last reply
                            0
                            • HomoranH Homoran

                              @ofbeqnpolkkl6mby5e13 ja, ich will es auch versuchen zu können, wenigstens nachvollziehen.

                              mir scheint, bei denen wo es nicht klappt ist jedesmal die Funktion readJson (url, function(err, response)) mit beteiligt, wobei der url identisch zu dem httpGet url ist.

                              das finde ich bei dir jedoch nicht

                              O Offline
                              O Offline
                              oFbEQnpoLKKl6mbY5e13
                              wrote on last edited by
                              #59

                              @homoran

                              In dem Skript mit request gab es den Parameter url. Den habe ich entfernt, weil er für httpGet nicht benötigt wird. Die Abfrage der Daten funktioniert ja auch. Keine Ahnung...

                              1 Reply Last reply
                              0
                              • O oFbEQnpoLKKl6mbY5e13

                                @tt-tom

                                Inzwischen ja. Leider wird weiterhin keine Objektstruktur angelegt. Hier der aktuelle Stand:

                                const city_id = XXXXX;
                                const area_id = XXX;
                                const logging = false;
                                const name = 'Müllabfuhr';
                                const numberOfEntries = 69;
                                
                                const instanz = '0_userdata.' + instance + '.muell-test';
                                
                                if (logging) log('starting muell.' + instanz);
                                
                                extendObject(instanz, {
                                       type: "device",
                                       common: {
                                           name: name
                                       }
                                   }, function (err) {
                                       if (err) {
                                           log('could not create device: ', 'warn');
                                           return;
                                       }
                                   
                                   }
                                );
                                let baseData = {};
                                
                                // query names first
                                httpGet('https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, { timeout: 2000 }, (error, response) => {
                                   if (!error && response.statusCode == 200) {
                                       console.log(response.statusCode);
                                       console.log(response.data);
                                   } else {
                                       console.error(error);
                                   var data = JSON.parse(response.data);  // info ist ein Objekt
                                           data.forEach((v, i) => {
                                               baseData[v._name] = v;
                                           })
                                   updateMuell();	
                                   }
                                });
                                
                                schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}', updateMuell);
                                
                                function updateMuell() {
                                   var options = 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3'
                                
                                   httpGet(options), (error, response)
                                       if (!error && response.statusCode == 200) 
                                           var info = JSON.parse(response.data);  // info ist ein Objekt
                                           if (info[0].Ack === 'Success') {
                                               var data = info[0]._data;  // xy ist eine Eigenschaft des Objektes info
                                               let counter = 0;
                                               const date = (new Date())
                                               const todayStr = date.getFullYear() + "-" + ('00' + (date.getMonth() + 1 )).slice(-2) + "-" + ('00' + date.getDate()).slice(-2)
                                               log(todayStr);
                                               data.forEach((v, i) => {
                                                   if (todayStr < v.cal_date && counter <= numberOfEntries) {
                                                       
                                                       const basePath = instanz + '.' + ('000' + counter).slice(-3);
                                                       log(v.cal_date + ' -> ' + basePath, 'debug');
                                                       // States erstellen
                                                       extendObject(basePath, {
                                                               type: "channel",
                                                               common: {
                                                                   name: v.cal_date_normal
                                                               }
                                                           }, function (err) {
                                                               if (err) {
                                                                   log('could not create device: ', 'warn');
                                                                   return;
                                                               }
                                                           
                                                           }
                                                       );
                                                       createState(basePath + '.date', v.cal_date_normal, {
                                                           name: 'Datum',
                                                           desc: 'Datum der Abholung',
                                                           type: 'string',
                                                           read: true,
                                                           write: false
                                                       }, () => {
                                                           setState(basePath + '.date', v.cal_date_normal, true);
                                                       });
                                                       
                                                       createState(basePath + '.desc', baseData[v.cal_garbage_type].title, {
                                                           name: 'Beschreibung',
                                                           desc: 'Beschreibung der Abholung',
                                                           type: 'string',
                                                           read: true,
                                                           write: false
                                                       }, () => {
                                                           setState(basePath + '.desc', baseData[v.cal_garbage_type].title, true);
                                                       });
                                                       createState(basePath + '.color', {
                                                           name: 'Farbe',
                                                           desc: 'Farbe',
                                                           type: 'string',
                                                           role: 'level.color',
                                                           read: true,
                                                           write: false
                                                       }, () => {
                                                           setState(basePath + '.color', baseData[v.cal_garbage_type].color, true);
                                                       });
                                
                                                       counter++;
                                                   }
                                               });
                                           }
                                       };
                                   
                                

                                HomoranH Do not disturb
                                HomoranH Do not disturb
                                Homoran
                                Global Moderator Administrators
                                wrote on last edited by Homoran
                                #60

                                @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                httpGet(options), (error, response)

                                oooh, da hatte ich mein Beispiel zu stark vereinfacht.
                                Ich glaube nicht, dass da wörtlich options stehen darf. Da muss je nach Anwendung eine Option, z.B. der url mit timeout usw. rein

                                EDIT: DU hast options als variable deklariert!
                                alles gut

                                kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                                Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                                der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                O 1 Reply Last reply
                                0
                                • HomoranH Homoran

                                  @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                  httpGet(options), (error, response)

                                  oooh, da hatte ich mein Beispiel zu stark vereinfacht.
                                  Ich glaube nicht, dass da wörtlich options stehen darf. Da muss je nach Anwendung eine Option, z.B. der url mit timeout usw. rein

                                  EDIT: DU hast options als variable deklariert!
                                  alles gut

                                  O Offline
                                  O Offline
                                  oFbEQnpoLKKl6mbY5e13
                                  wrote on last edited by oFbEQnpoLKKl6mbY5e13
                                  #61

                                  @homoran

                                  Richtig, options hat der Entwickler als Variable deklariert.

                                  HomoranH 1 Reply Last reply
                                  0
                                  • O oFbEQnpoLKKl6mbY5e13

                                    @homoran

                                    Richtig, options hat der Entwickler als Variable deklariert.

                                    HomoranH Do not disturb
                                    HomoranH Do not disturb
                                    Homoran
                                    Global Moderator Administrators
                                    wrote on last edited by
                                    #62

                                    @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                    @homoran

                                    Richtig, options hat der Entwickler als Variable deklariert.

                                    damit hast du 2x httpGet
                                    einmal mit direkter Eingabe des url in Zeile 27, mit Ausgabe des response in Zeile 30, und einmal in Zeile 46 mit dem url in der Variable options
                                    Da wäre es doch interessant

                                    @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                    Setze das mal in Zeile 48 mit rein, damit du sehen kannst was da kommt.

                                    ob es da auch ankommt

                                    kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                                    Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                                    der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                    O 1 Reply Last reply
                                    0
                                    • HomoranH Homoran

                                      @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                      @homoran

                                      Richtig, options hat der Entwickler als Variable deklariert.

                                      damit hast du 2x httpGet
                                      einmal mit direkter Eingabe des url in Zeile 27, mit Ausgabe des response in Zeile 30, und einmal in Zeile 46 mit dem url in der Variable options
                                      Da wäre es doch interessant

                                      @tt-tom sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                      Setze das mal in Zeile 48 mit rein, damit du sehen kannst was da kommt.

                                      ob es da auch ankommt

                                      O Offline
                                      O Offline
                                      oFbEQnpoLKKl6mbY5e13
                                      wrote on last edited by oFbEQnpoLKKl6mbY5e13
                                      #63

                                      @homoran

                                      Die Funktion updateMuell (Zeile 43) wird nur ausgeführt wenn "schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}'".

                                      Beim ersten Start muss trotzdem aktualisiert bzw. die Objektstruktur erstellt werden.

                                      Edit:
                                      Nee, stimmt nicht. Die wird auch beim Starten ausgeführt.

                                      HomoranH 1 Reply Last reply
                                      0
                                      • O oFbEQnpoLKKl6mbY5e13

                                        @homoran

                                        Die Funktion updateMuell (Zeile 43) wird nur ausgeführt wenn "schedule('{"time":{"exactTime":true,"start":"12:17"},"period":{"days":1}}'".

                                        Beim ersten Start muss trotzdem aktualisiert bzw. die Objektstruktur erstellt werden.

                                        Edit:
                                        Nee, stimmt nicht. Die wird auch beim Starten ausgeführt.

                                        HomoranH Do not disturb
                                        HomoranH Do not disturb
                                        Homoran
                                        Global Moderator Administrators
                                        wrote on last edited by Homoran
                                        #64

                                        @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                        Edit

                                        danke! ich wollte gerade für heute Schluss machen weil ich keine andere Stelle mehr fand ;-)

                                        also mal per log prüfen ob options klappt

                                        kein Support per PN! - Fragen im Forum stellen - es gibt fast nichts, was nicht auch für andere interessant ist.

                                        Benutzt das Voting rechts unten im Beitrag wenn er euch geholfen hat.

                                        der Installationsfixer: curl -fsL https://iobroker.net/fix.sh | bash -

                                        O 1 Reply Last reply
                                        0
                                        • HomoranH Homoran

                                          @ofbeqnpolkkl6mby5e13 sagte in Hilfe für Javascript Legastheniker und js v8.3.x:

                                          Edit

                                          danke! ich wollte gerade für heute Schluss machen weil ich keine andere Stelle mehr fand ;-)

                                          also mal per log prüfen ob options klappt

                                          O Offline
                                          O Offline
                                          oFbEQnpoLKKl6mbY5e13
                                          wrote on last edited by
                                          #65

                                          @homoran

                                          httpGet(options), (error, response)
                                              console.log(response.statusCode);
                                              console.log(response.data);
                                          

                                          Wird nichts ausgegeben.

                                          HomoranH paul53P 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          349

                                          Online

                                          32.6k

                                          Users

                                          82.2k

                                          Topics

                                          1.3m

                                          Posts
                                          Community
                                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                                          ioBroker Community 2014-2025
                                          logo
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Home
                                          • Recent
                                          • Tags
                                          • Unread 0
                                          • Categories
                                          • Unreplied
                                          • Popular
                                          • GitHub
                                          • Docu
                                          • Hilfe