Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Hilfe für Javascript Legastheniker und js v8.3.x

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

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

    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TT-Tom @oFbEQnpoLKKl6mbY5e13 last edited by

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

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

      console.log(response.data);
      
      Homoran O 2 Replies Last reply Reply Quote 0
      • Homoran
        Homoran Global Moderator Administrators @TT-Tom last edited by

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

        Setze das mal in Zeile 48 mit rein,

        steht schon in Zeile 30

        O 1 Reply Last reply Reply Quote 0
        • O
          oFbEQnpoLKKl6mbY5e13 @TT-Tom last edited by

          @tt-tom

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

          1 Reply Last reply Reply Quote 0
          • O
            oFbEQnpoLKKl6mbY5e13 @Homoran last edited by oFbEQnpoLKKl6mbY5e13

            @homoran

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

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

            1 Reply Last reply Reply Quote 0
            • Homoran
              Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

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

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

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

              O 1 Reply Last reply Reply Quote 0
              • O
                oFbEQnpoLKKl6mbY5e13 @Homoran last edited by oFbEQnpoLKKl6mbY5e13

                @homoran

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

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

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

                Homoran 1 Reply Last reply Reply Quote 0
                • Homoran
                  Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

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

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

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

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

                  O 1 Reply Last reply Reply Quote 0
                  • O
                    oFbEQnpoLKKl6mbY5e13 @Homoran last edited by oFbEQnpoLKKl6mbY5e13

                    @homoran

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

                    Homoran 1 Reply Last reply Reply Quote 1
                    • Homoran
                      Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

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

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

                      das finde ich bei dir jedoch nicht

                      O 1 Reply Last reply Reply Quote 0
                      • O
                        oFbEQnpoLKKl6mbY5e13 @Homoran last edited by

                        @homoran

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

                        1 Reply Last reply Reply Quote 0
                        • Homoran
                          Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by Homoran

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

                          httpGet(options), (error, response)

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

                          EDIT: DU hast options als variable deklariert!
                          alles gut

                          O 1 Reply Last reply Reply Quote 0
                          • O
                            oFbEQnpoLKKl6mbY5e13 @Homoran last edited by oFbEQnpoLKKl6mbY5e13

                            @homoran

                            Richtig, options hat der Entwickler als Variable deklariert.

                            Homoran 1 Reply Last reply Reply Quote 0
                            • Homoran
                              Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

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

                              @homoran

                              Richtig, options hat der Entwickler als Variable deklariert.

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

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

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

                              ob es da auch ankommt

                              O 1 Reply Last reply Reply Quote 0
                              • O
                                oFbEQnpoLKKl6mbY5e13 @Homoran last edited by oFbEQnpoLKKl6mbY5e13

                                @homoran

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

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

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

                                Homoran 1 Reply Last reply Reply Quote 0
                                • Homoran
                                  Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by Homoran

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

                                  Edit

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

                                  also mal per log prüfen ob options klappt

                                  O 1 Reply Last reply Reply Quote 0
                                  • O
                                    oFbEQnpoLKKl6mbY5e13 @Homoran last edited by

                                    @homoran

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

                                    Wird nichts ausgegeben.

                                    Homoran paul53 2 Replies Last reply Reply Quote 0
                                    • Homoran
                                      Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

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

                                      @homoran

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

                                      Wird nichts ausgegeben.

                                      dann wird auch nichts angelegt.

                                      Nur warum?
                                      ist options nicht korrekt zusammengebaut?

                                      console.log(options) sagt das gleiche was in Zeile 27 steht?

                                      O 1 Reply Last reply Reply Quote 0
                                      • O
                                        oFbEQnpoLKKl6mbY5e13 @Homoran last edited by

                                        @homoran

                                        Wenn ich das mache:

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

                                        Wird "test" nicht ausgegeben. Das Skript ruft also die Funktion gar nicht auf.

                                        Homoran 1 Reply Last reply Reply Quote 0
                                        • Homoran
                                          Homoran Global Moderator Administrators @oFbEQnpoLKKl6mbY5e13 last edited by

                                          @ofbeqnpolkkl6mby5e13
                                          Sorry, dann mach ich doch Schluss für heute.
                                          mir raucht der Kopf. Das hemmt die Kreativität

                                          Mal sehen was abdere bis morgen rausfinden

                                          1 Reply Last reply Reply Quote 1
                                          • paul53
                                            paul53 @oFbEQnpoLKKl6mbY5e13 last edited by

                                            @ofbeqnpolkkl6mby5e13 sagte: Wird nichts ausgegeben.

                                            Es fehlt auch was.

                                            httpGet(options, (error, response) => {
                                            
                                            O 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            872
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

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