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
    930

  • 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

    @haus-automatisierung Danke!
    Das "Problem" ist, dass duese Doku sich an Programmierer richtet und daher natürlich so spezifisch wie möglich sein muss.

    Für c&p User, die 'nur mal eben' was anpassen wollen, ist das nicht geeignet, eeil zu theoretisch und nicht praxisbezogen.

    Beides in einer Doku unter einen Hut zu bekommen ist IMHO unmöglich

    haus-automatisierungH Online
    haus-automatisierungH Online
    haus-automatisierung
    Developer Most Active
    wrote on last edited by
    #21

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

    Das "Problem" ist, dass duese Doku sich an Programmierer richtet

    Richtig, so wie sich auch JavaScript-Scripts im Adapter an Programmierer richten. Wer vorher request verstanden hat, sollte damit kein Problem haben

    🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
    🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
    📚 Meine inoffizielle ioBroker Dokumentation

    HomoranH 1 Reply Last reply
    1
    • haus-automatisierungH haus-automatisierung

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

      Das "Problem" ist, dass duese Doku sich an Programmierer richtet

      Richtig, so wie sich auch JavaScript-Scripts im Adapter an Programmierer richten. Wer vorher request verstanden hat, sollte damit kein Problem haben

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

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

      Wer vorher request verstanden hat, sollte damit kein Problem haben

      korrekt!
      Aber genau um diese User geht es mir hier nicht, sondern um Hilfe für

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

      c&p User, die 'nur mal eben' was anpassen wollen

      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 -

      haus-automatisierungH 1 Reply Last reply
      0
      • HomoranH Homoran

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

        Wer vorher request verstanden hat, sollte damit kein Problem haben

        korrekt!
        Aber genau um diese User geht es mir hier nicht, sondern um Hilfe für

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

        c&p User, die 'nur mal eben' was anpassen wollen

        haus-automatisierungH Online
        haus-automatisierungH Online
        haus-automatisierung
        Developer Most Active
        wrote on last edited by
        #23

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

        c&p User, die 'nur mal eben' was anpassen wollen

        Da wäre es eigentlich schöner, wenn man nicht jeden Script direkt auf httpGet umschreibt, sondern erstmal schaut ob das nicht auch per Blockly lösbar wäre.

        Ja, da sind auch nicht alle Parameter enthalten welche es in JS gibt, aber mittlerweile kann man doch recht viel erreichen, was vorher nicht ging (und JavaScript erfordert hat).

        🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
        🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
        📚 Meine inoffizielle ioBroker Dokumentation

        HomoranH 1 Reply Last reply
        1
        • haus-automatisierungH haus-automatisierung

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

          c&p User, die 'nur mal eben' was anpassen wollen

          Da wäre es eigentlich schöner, wenn man nicht jeden Script direkt auf httpGet umschreibt, sondern erstmal schaut ob das nicht auch per Blockly lösbar wäre.

          Ja, da sind auch nicht alle Parameter enthalten welche es in JS gibt, aber mittlerweile kann man doch recht viel erreichen, was vorher nicht ging (und JavaScript erfordert hat).

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

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

          sondern erstmal schaut ob das nicht auch per Blockly lösbar wäre.

          ja, wäre vielleicht eine Möglichkeit.

          Wenn ich meine js-Skripte als Beispiel nehme, so stammen sie aus Zeiten als es noch kein Blockly gab.
          Außerdem sind sie teilweise so umfangreich, dass eine Umstellung auf Blockly 'mal eben' gar nicht möglich ist.

          Weiterhin gibt es unter den 80.000 iobroker Anwendern reichlich User, die von sich sagen, dass sie "kein Java können", aber meist schon am strukturierten, logischen Ansatz scheitern, was durchaus zu akzeptieren sein sollte.
          Wir können nicht davon ausgehen, dass jeder Anwender programmieren kann!
          Das will ich auch nicht als Bedingung für ioBroker voraussetzen!

          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 -

          haus-automatisierungH 1 Reply Last reply
          0
          • HomoranH Homoran

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

            sondern erstmal schaut ob das nicht auch per Blockly lösbar wäre.

            ja, wäre vielleicht eine Möglichkeit.

            Wenn ich meine js-Skripte als Beispiel nehme, so stammen sie aus Zeiten als es noch kein Blockly gab.
            Außerdem sind sie teilweise so umfangreich, dass eine Umstellung auf Blockly 'mal eben' gar nicht möglich ist.

            Weiterhin gibt es unter den 80.000 iobroker Anwendern reichlich User, die von sich sagen, dass sie "kein Java können", aber meist schon am strukturierten, logischen Ansatz scheitern, was durchaus zu akzeptieren sein sollte.
            Wir können nicht davon ausgehen, dass jeder Anwender programmieren kann!
            Das will ich auch nicht als Bedingung für ioBroker voraussetzen!

            haus-automatisierungH Online
            haus-automatisierungH Online
            haus-automatisierung
            Developer Most Active
            wrote on last edited by
            #25

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

            Wir können nicht davon ausgehen, dass jeder Anwender programmieren kann!

            Richtig, deswegen gibt's ja Blockly. Aber das Problem bleiben ja ältere Beiträge hier im Forum, welche man über Google findet und dann 1:1 übernimmt. Die sollte man ggf. entsprechend kennzeichnen.

            🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
            🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
            📚 Meine inoffizielle ioBroker Dokumentation

            HomoranH 1 Reply Last reply
            0
            • haus-automatisierungH haus-automatisierung

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

              Wir können nicht davon ausgehen, dass jeder Anwender programmieren kann!

              Richtig, deswegen gibt's ja Blockly. Aber das Problem bleiben ja ältere Beiträge hier im Forum, welche man über Google findet und dann 1:1 übernimmt. Die sollte man ggf. entsprechend kennzeichnen.

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

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

              deswegen gibt's ja Blockly.

              Das ist keine Programmierung?? :thinking_face:

              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 -

              haus-automatisierungH 1 Reply Last reply
              0
              • HomoranH Homoran

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

                deswegen gibt's ja Blockly.

                Das ist keine Programmierung?? :thinking_face:

                haus-automatisierungH Online
                haus-automatisierungH Online
                haus-automatisierung
                Developer Most Active
                wrote on last edited by
                #27

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

                Das ist keine Programmierung??

                Doch klar, aber ohne die Syntax kennen zu müssen.

                Habe das hier gerade kurz zusammengeschrieben: https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/upgrade-guide.md

                Hätte das gern alles an einer Stelle und nicht verteilt im Forum (gibt ja schon zig Threads).

                🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                📚 Meine inoffizielle ioBroker Dokumentation

                HomoranH 1 Reply Last reply
                1
                • haus-automatisierungH haus-automatisierung

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

                  Das ist keine Programmierung??

                  Doch klar, aber ohne die Syntax kennen zu müssen.

                  Habe das hier gerade kurz zusammengeschrieben: https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/upgrade-guide.md

                  Hätte das gern alles an einer Stelle und nicht verteilt im Forum (gibt ja schon zig Threads).

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

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

                  Doch klar, aber ohne die Syntax kennen zu müssen.

                  das beträfe mich, aber nicht die vorhin genannte andere Gruppe

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

                  Hätte das gern alles an einer Stelle und nicht verteilt im Forum

                  dann bitte hier im Forum.
                  Das Forum ist der zentrale Anlaufpunkt für User.

                  Oder ist das verlinkte nur für Entwickler?

                  ganz davon abgesehen ist /en/ auch nicht allen Usern geläufig

                  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 -

                  haus-automatisierungH 1 Reply Last reply
                  0
                  • HomoranH Homoran

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

                    Doch klar, aber ohne die Syntax kennen zu müssen.

                    das beträfe mich, aber nicht die vorhin genannte andere Gruppe

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

                    Hätte das gern alles an einer Stelle und nicht verteilt im Forum

                    dann bitte hier im Forum.
                    Das Forum ist der zentrale Anlaufpunkt für User.

                    Oder ist das verlinkte nur für Entwickler?

                    ganz davon abgesehen ist /en/ auch nicht allen Usern geläufig

                    haus-automatisierungH Online
                    haus-automatisierungH Online
                    haus-automatisierung
                    Developer Most Active
                    wrote on last edited by
                    #29

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

                    Oder ist das verlinkte nur für Entwickler?

                    Für alle, welche den Adapter nutzen. Dafür gibt es doch die Dokumentation je Adapter, oder? Das landet ja dann auch alles hier:

                    https://www.iobroker.net/#en/adapters/adapterref/iobroker.javascript/README.md

                    Zumindest hatte ich mir noch vorgenommen, die Blockly-Dokumentation auf den aktuellen Stand zu bringen (auf drei Sprachen). Ist natürlich eine menge Arbeit und wäre Quatsch, wenn das eh niemand liest.

                    🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                    🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                    📚 Meine inoffizielle ioBroker Dokumentation

                    1 Reply Last reply
                    1
                    • apollon77A Offline
                      apollon77A Offline
                      apollon77
                      wrote on last edited by apollon77
                      #30

                      Aber nochmal für mich: Warum muss Rainer überhaupt was ändern? Ich dachte das "request" als Paket weiterhin da ist nur halt nicht mehr automatisch drin ist. Also mit einem

                      var request = require("request");
                      

                      sollte doch weiterhin alles gehen, oder? Vllt hätten wir in der Doku die Request Beispiele mit Deprecation info noch lassen sollen?

                      Beitrag hat geholfen? Votet rechts unten im Beitrag :-) https://paypal.me/Apollon77 / https://github.com/sponsors/Apollon77

                      • Debug-Log für Instanz einschalten? Admin -> Instanzen -> Expertenmodus -> Instanz aufklappen - Loglevel ändern
                      • Logfiles auf Platte /opt/iobroker/log/… nutzen, Admin schneidet Zeilen ab
                      haus-automatisierungH 1 Reply Last reply
                      0
                      • apollon77A apollon77

                        Aber nochmal für mich: Warum muss Rainer überhaupt was ändern? Ich dachte das "request" als Paket weiterhin da ist nur halt nicht mehr automatisch drin ist. Also mit einem

                        var request = require("request");
                        

                        sollte doch weiterhin alles gehen, oder? Vllt hätten wir in der Doku die Request Beispiele mit Deprecation info noch lassen sollen?

                        haus-automatisierungH Online
                        haus-automatisierungH Online
                        haus-automatisierung
                        Developer Most Active
                        wrote on last edited by
                        #31

                        @apollon77 Ja, funktioniert alles. Und ist im Standard auch noch als dependency erhalten. Es gibt nur eine Warnung im Log. Mehr nicht.

                        🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                        🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                        📚 Meine inoffizielle ioBroker Dokumentation

                        apollon77A 1 Reply Last reply
                        1
                        • haus-automatisierungH haus-automatisierung

                          @apollon77 Ja, funktioniert alles. Und ist im Standard auch noch als dependency erhalten. Es gibt nur eine Warnung im Log. Mehr nicht.

                          apollon77A Offline
                          apollon77A Offline
                          apollon77
                          wrote on last edited by
                          #32

                          @haus-automatisierung Vllt machen wir wie bei anderen deprecations eine "info" log draus? damit man es im Log unterdrücken kann? oder nur einmal die warnung per skript per vorkommen? Weil wenn ich alle 5s einen "request" call mache dann ist das schon viel log :-)

                          Beitrag hat geholfen? Votet rechts unten im Beitrag :-) https://paypal.me/Apollon77 / https://github.com/sponsors/Apollon77

                          • Debug-Log für Instanz einschalten? Admin -> Instanzen -> Expertenmodus -> Instanz aufklappen - Loglevel ändern
                          • Logfiles auf Platte /opt/iobroker/log/… nutzen, Admin schneidet Zeilen ab
                          haus-automatisierungH 1 Reply Last reply
                          0
                          • apollon77A apollon77

                            @haus-automatisierung Vllt machen wir wie bei anderen deprecations eine "info" log draus? damit man es im Log unterdrücken kann? oder nur einmal die warnung per skript per vorkommen? Weil wenn ich alle 5s einen "request" call mache dann ist das schon viel log :-)

                            haus-automatisierungH Online
                            haus-automatisierungH Online
                            haus-automatisierung
                            Developer Most Active
                            wrote on last edited by
                            #33

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

                            Vllt machen wir wie bei anderen deprecations eine "info" log draus?

                            Dann macht wieder keiner was und die Leute, welche das Loglevel jetzt schon angepasst haben, sind am Ende wieder überrascht warum es "plötzlich" nicht mehr geht. :(

                            🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                            🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                            📚 Meine inoffizielle ioBroker Dokumentation

                            apollon77A 1 Reply Last reply
                            0
                            • haus-automatisierungH haus-automatisierung

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

                              Vllt machen wir wie bei anderen deprecations eine "info" log draus?

                              Dann macht wieder keiner was und die Leute, welche das Loglevel jetzt schon angepasst haben, sind am Ende wieder überrascht warum es "plötzlich" nicht mehr geht. :(

                              apollon77A Offline
                              apollon77A Offline
                              apollon77
                              wrote on last edited by
                              #34

                              @haus-automatisierung Ja ich weiss, aber glabe mir, wir haben da so einige Erfahrungen mit Deprecations und Usern ... und beim JavaScript Adapter ist das - wie man hier auch sieht, wo Kenntnisswelten aufeinanderprallen - nochmal ne andere Baustelle.

                              Viele User haben sich irgendwann man Skripte herkopiert und vllt "zurechtgepfuscht" (Alles gut - weil Sie es nicht besser können) ... die Rennen jetzt dann alle da rein. Sollten wir. auch bedenken.
                              Wir haben verschiedenene User-Typen hier und ganz viele sind halt keine (Skript) Profis. Von daher finde ich Rainers ansinnen super hier im Forum eine deutsche und ausführlichere Variante der Migration-Infos zu haben.

                              Beitrag hat geholfen? Votet rechts unten im Beitrag :-) https://paypal.me/Apollon77 / https://github.com/sponsors/Apollon77

                              • Debug-Log für Instanz einschalten? Admin -> Instanzen -> Expertenmodus -> Instanz aufklappen - Loglevel ändern
                              • Logfiles auf Platte /opt/iobroker/log/… nutzen, Admin schneidet Zeilen ab
                              O 1 Reply Last reply
                              3
                              • apollon77A apollon77

                                @haus-automatisierung Ja ich weiss, aber glabe mir, wir haben da so einige Erfahrungen mit Deprecations und Usern ... und beim JavaScript Adapter ist das - wie man hier auch sieht, wo Kenntnisswelten aufeinanderprallen - nochmal ne andere Baustelle.

                                Viele User haben sich irgendwann man Skripte herkopiert und vllt "zurechtgepfuscht" (Alles gut - weil Sie es nicht besser können) ... die Rennen jetzt dann alle da rein. Sollten wir. auch bedenken.
                                Wir haben verschiedenene User-Typen hier und ganz viele sind halt keine (Skript) Profis. Von daher finde ich Rainers ansinnen super hier im Forum eine deutsche und ausführlichere Variante der Migration-Infos zu haben.

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

                                Ich finde es gut, dass @Homoran versucht, eine für Anwender verständliche Anleitung zum Umbau von request auf httpget zu erstellen. Ich finde es auch richtig, von request wegzukommen.

                                Danke an @haus-automatisierung !

                                Aber auch ich nutze ein Skript, welches ich von hier kopiert habe:

                                https://github.com/volkerrichert/ioBroker.mymuell

                                Ich kann das trotz der Hinweise von @Homoran nicht umbauen.

                                Hier das Original:

                                const city_id = XXXXX;
                                const area_id = XXX;
                                const logging = false;
                                const name = 'Müllabfuhr';
                                const numberOfEntries = 69;
                                
                                const request = require('request');
                                const instanz = '0_userdata.' + instance + '.muell';
                                
                                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
                                request({
                                   url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                   method: 'GET', 
                                   headers: { 'Accept': 'application/json' }
                                   }, function(error, response, body) {
                                       if (!error && response.statusCode == 200) {
                                           var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                
                                   request(options, function(error, response, body) {
                                       if (!error && response.statusCode == 200) {
                                           var info = JSON.parse(body);  // 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++;
                                                   }
                                               });
                                           }
                                       }
                                   });
                                };
                                

                                Hier mein Versuch (Funktion nicht getestet):

                                const city_id = XXXXX;
                                const area_id = XXX;
                                const logging = false;
                                const name = 'Müllabfuhr';
                                const numberOfEntries = 69;
                                
                                const axios = require('axios');
                                const instanz = '0_userdata.' + instance + '.muell';
                                
                                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({
                                   url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                   method: 'GET', 
                                   headers: { 'Accept': 'application/json' }
                                   }, function(error, response) {
                                       if (!error && response.data == 200) {
                                           var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                
                                   httpGet(options, (error, response) {
                                       if (!error && response.data == 200) {
                                           var info = JSON.parse(body);  // 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++;
                                                   }
                                               });
                                           }
                                       }
                                   });
                                };
                                

                                haus-automatisierungH HomoranH 3 Replies Last reply
                                0
                                • O oFbEQnpoLKKl6mbY5e13

                                  Ich finde es gut, dass @Homoran versucht, eine für Anwender verständliche Anleitung zum Umbau von request auf httpget zu erstellen. Ich finde es auch richtig, von request wegzukommen.

                                  Danke an @haus-automatisierung !

                                  Aber auch ich nutze ein Skript, welches ich von hier kopiert habe:

                                  https://github.com/volkerrichert/ioBroker.mymuell

                                  Ich kann das trotz der Hinweise von @Homoran nicht umbauen.

                                  Hier das Original:

                                  const city_id = XXXXX;
                                  const area_id = XXX;
                                  const logging = false;
                                  const name = 'Müllabfuhr';
                                  const numberOfEntries = 69;
                                  
                                  const request = require('request');
                                  const instanz = '0_userdata.' + instance + '.muell';
                                  
                                  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
                                  request({
                                     url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                     method: 'GET', 
                                     headers: { 'Accept': 'application/json' }
                                     }, function(error, response, body) {
                                         if (!error && response.statusCode == 200) {
                                             var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                  
                                     request(options, function(error, response, body) {
                                         if (!error && response.statusCode == 200) {
                                             var info = JSON.parse(body);  // 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++;
                                                     }
                                                 });
                                             }
                                         }
                                     });
                                  };
                                  

                                  Hier mein Versuch (Funktion nicht getestet):

                                  const city_id = XXXXX;
                                  const area_id = XXX;
                                  const logging = false;
                                  const name = 'Müllabfuhr';
                                  const numberOfEntries = 69;
                                  
                                  const axios = require('axios');
                                  const instanz = '0_userdata.' + instance + '.muell';
                                  
                                  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({
                                     url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                     method: 'GET', 
                                     headers: { 'Accept': 'application/json' }
                                     }, function(error, response) {
                                         if (!error && response.data == 200) {
                                             var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                  
                                     httpGet(options, (error, response) {
                                         if (!error && response.data == 200) {
                                             var info = JSON.parse(body);  // 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++;
                                                     }
                                                 });
                                             }
                                         }
                                     });
                                  };
                                  

                                  haus-automatisierungH Online
                                  haus-automatisierungH Online
                                  haus-automatisierung
                                  Developer Most Active
                                  wrote on last edited by
                                  #36

                                  @ofbeqnpolkkl6mby5e13 MyMüll hab ich im Trashschedule Adapter doch schon integriert 🙃

                                  🧑‍🎓 Autor des beliebten ioBroker-Master-Kurses
                                  🎥 Tutorials rund um das Thema DIY-Smart-Home: https://haus-automatisierung.com/
                                  📚 Meine inoffizielle ioBroker Dokumentation

                                  O 1 Reply Last reply
                                  0
                                  • O oFbEQnpoLKKl6mbY5e13

                                    Ich finde es gut, dass @Homoran versucht, eine für Anwender verständliche Anleitung zum Umbau von request auf httpget zu erstellen. Ich finde es auch richtig, von request wegzukommen.

                                    Danke an @haus-automatisierung !

                                    Aber auch ich nutze ein Skript, welches ich von hier kopiert habe:

                                    https://github.com/volkerrichert/ioBroker.mymuell

                                    Ich kann das trotz der Hinweise von @Homoran nicht umbauen.

                                    Hier das Original:

                                    const city_id = XXXXX;
                                    const area_id = XXX;
                                    const logging = false;
                                    const name = 'Müllabfuhr';
                                    const numberOfEntries = 69;
                                    
                                    const request = require('request');
                                    const instanz = '0_userdata.' + instance + '.muell';
                                    
                                    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
                                    request({
                                       url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                       method: 'GET', 
                                       headers: { 'Accept': 'application/json' }
                                       }, function(error, response, body) {
                                           if (!error && response.statusCode == 200) {
                                               var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                    
                                       request(options, function(error, response, body) {
                                           if (!error && response.statusCode == 200) {
                                               var info = JSON.parse(body);  // 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++;
                                                       }
                                                   });
                                               }
                                           }
                                       });
                                    };
                                    

                                    Hier mein Versuch (Funktion nicht getestet):

                                    const city_id = XXXXX;
                                    const area_id = XXX;
                                    const logging = false;
                                    const name = 'Müllabfuhr';
                                    const numberOfEntries = 69;
                                    
                                    const axios = require('axios');
                                    const instanz = '0_userdata.' + instance + '.muell';
                                    
                                    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({
                                       url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                       method: 'GET', 
                                       headers: { 'Accept': 'application/json' }
                                       }, function(error, response) {
                                           if (!error && response.data == 200) {
                                               var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                    
                                       httpGet(options, (error, response) {
                                           if (!error && response.data == 200) {
                                               var info = JSON.parse(body);  // 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
                                    #37

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

                                    Hier mein Versuch

                                    du hast auf axios umgebaut?
                                    die Hinweise sind für httpGet

                                    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 -

                                    1 Reply Last reply
                                    0
                                    • O oFbEQnpoLKKl6mbY5e13

                                      Ich finde es gut, dass @Homoran versucht, eine für Anwender verständliche Anleitung zum Umbau von request auf httpget zu erstellen. Ich finde es auch richtig, von request wegzukommen.

                                      Danke an @haus-automatisierung !

                                      Aber auch ich nutze ein Skript, welches ich von hier kopiert habe:

                                      https://github.com/volkerrichert/ioBroker.mymuell

                                      Ich kann das trotz der Hinweise von @Homoran nicht umbauen.

                                      Hier das Original:

                                      const city_id = XXXXX;
                                      const area_id = XXX;
                                      const logging = false;
                                      const name = 'Müllabfuhr';
                                      const numberOfEntries = 69;
                                      
                                      const request = require('request');
                                      const instanz = '0_userdata.' + instance + '.muell';
                                      
                                      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
                                      request({
                                         url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                         method: 'GET', 
                                         headers: { 'Accept': 'application/json' }
                                         }, function(error, response, body) {
                                             if (!error && response.statusCode == 200) {
                                                 var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                      
                                         request(options, function(error, response, body) {
                                             if (!error && response.statusCode == 200) {
                                                 var info = JSON.parse(body);  // 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++;
                                                         }
                                                     });
                                                 }
                                             }
                                         });
                                      };
                                      

                                      Hier mein Versuch (Funktion nicht getestet):

                                      const city_id = XXXXX;
                                      const area_id = XXX;
                                      const logging = false;
                                      const name = 'Müllabfuhr';
                                      const numberOfEntries = 69;
                                      
                                      const axios = require('axios');
                                      const instanz = '0_userdata.' + instance + '.muell';
                                      
                                      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({
                                         url: 'https://mymuell.jumomind.com/mmapp/api.php?r=trash&city_id=' + city_id + '&area_id=' + area_id, 
                                         method: 'GET', 
                                         headers: { 'Accept': 'application/json' }
                                         }, function(error, response) {
                                             if (!error && response.data == 200) {
                                                 var data = JSON.parse(body);  // 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 = {url: 'https://mymuell.jumomind.com/webservice.php?idx=termins&city_id=' + city_id + '&area_id=' + area_id + '&ws=3', method: 'GET', headers: { 'Accept': 'application/json' }};
                                      
                                         httpGet(options, (error, response) {
                                             if (!error && response.data == 200) {
                                                 var info = JSON.parse(body);  // 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
                                      #38

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

                                      var data = JSON.parse(body); // info ist ein Objekt

                                      und zumindest da ist noch ein body anstelle von response.data

                                      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 -

                                      1 Reply Last reply
                                      0
                                      • haus-automatisierungH haus-automatisierung

                                        @ofbeqnpolkkl6mby5e13 MyMüll hab ich im Trashschedule Adapter doch schon integriert 🙃

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

                                        @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
                                        
                                        T HomoranH 2 Replies 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
                                          
                                          T Offline
                                          T Offline
                                          TT-Tom
                                          wrote on last edited by
                                          #40

                                          @ofbeqnpolkkl6mby5e13

                                          response.data sind deine Daten die zurückkommen, die wirst du nicht auf den Status prüfen wollen.
                                          Da müsste also response.statusCode stehen.

                                          if (!error && response.data == 200)
                                          

                                          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

                                          O HomoranH 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

                                          733

                                          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