Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. per script Rest anfrage senden

    NEWS

    • Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    per script Rest anfrage senden

    This topic has been deleted. Only users with topic management privileges can see it.
    • FernetMenta
      FernetMenta Developer @Delphinis last edited by FernetMenta

      @delphinis wie sieht der Fehler genau aus? Bei mit sieht das so aus und ich habe keinen Fehler:

      const axios = require('axios');
      
      const apiurl_current = "https://api.openweathermap.org/data/2.5/weather?lat=xxx&lon=xxx&appid=xxx";
      const apiurl_forecast = "https://api.openweathermap.org/data/2.5/forecast?lat=xxx&lon=xxx&appid=xxx";
      
      async function getWeatherData() {
        let jsonData;
        try {
          let response = await axios.get(apiurl_current);
          jsonData = await response.data;
          setState("0_userdata.0.weather.current", JSON.stringify(jsonData), true);
      
          response = await axios.get(apiurl_forecast);
          jsonData = await response.data;
          setState("0_userdata.0.weather.forecast", JSON.stringify(jsonData), true);
        } catch(error) {
          console.error(error);
        }
      }
      

      Wie alt ist deine Installation. Scheint ein älteres "Problem" gewesen zu sein: https://forum.iobroker.net/topic/70578/gelöst-axios-hinzufügen-zu-script

      D 1 Reply Last reply Reply Quote 0
      • D
        Delphinis @FernetMenta last edited by Delphinis

        @fernetmenta
        e78a067b-df54-4093-8156-302837f1f178-grafik.png
        Ich hab das im Script-Adapter eingetragen:
        0e566518-1c0a-4879-9227-7ea89c6d8996-grafik.png

        FernetMenta 1 Reply Last reply Reply Quote 0
        • FernetMenta
          FernetMenta Developer @Delphinis last edited by

          @delphinis Das sollte eigentich nicht notwendig sein. Steht bei mir auch nicht drin. Im Forum-Thread (siehe obe) wurde es anscheinend über ein Update von iob gelöst. Ist deine Version so alt? Der Thread ist ja schon von 2023.

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

            @fernetmenta sagte in per script Rest anfrage senden:

            Ist deine Version so alt?

            ich erinnere mich auch dass die Welle damals bei modulen, die bereits im iob js-adapter integriert sind und zusätzlich installiert wurden "grundlos" erschien.

            Der Eintrag von axios in der Instanz muss nicht sein.

            1 Reply Last reply Reply Quote 0
            • D
              Delphinis last edited by

              @homoran said in per script Rest anfrage senden:

              Der Eintrag von axios in der Instanz muss nicht sein.

              ok, dann nehm ich den wieder raus.
              Was heisst eigentlich "den iob updaten"? Ist das der Admin-Adapter? Der ist schon ein bisschen älter, aber ob der so alt ist weiss ich nicht:
              7.6.17
              aktuell 7.7.2

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

                @delphinis zeig mal die Langfassung von iob diag

                D 1 Reply Last reply Reply Quote 0
                • D
                  Delphinis @Homoran last edited by

                  @homoran said in per script Rest anfrage senden:

                  iob diag

                  Sorry, soviel ich weiss geht iob diag auf windows nicht. Gibt es da was ähnliches?

                  Homoran 1 Reply Last reply Reply Quote 0
                  • FernetMenta
                    FernetMenta Developer @Delphinis last edited by FernetMenta

                    @delphinis

                    aktuell 7.7.2

                    Oh ja, dann scheint deine Nodejs-Version auch noch aus der Steinzeit zu sein. Ich habe 8.9.2 (Node v22).

                    Die Leute sagen, dass sich das UI in den Versionen täuschen kann. Aber für einen ersten Anhaltpunkt tut es das. Hier unter Hosts:
                    596924c9-778b-49c7-a16d-cc728707bd52-image.png

                    D 1 Reply Last reply Reply Quote 0
                    • D
                      Delphinis @FernetMenta last edited by

                      @fernetmenta
                      0d1e1051-28cf-4761-9285-fbf328f02a8a-grafik.png

                      D FernetMenta 2 Replies Last reply Reply Quote 0
                      • D
                        Delphinis @Delphinis last edited by

                        ich hab sonst noch:
                        c:\ioBroker>iob info
                        Platform : Windows
                        os : win32
                        Architecture : x64
                        CPUs : 4
                        Speed : 1997 MHz
                        Model : Intel(R) Celeron(R) J4125 CPU @ 2.00GHz
                        RAM : 7.8 GB
                        System uptime : 11d. 11:16:17
                        Node.js : v20.18.1
                        time : 1760261026856
                        timeOffset : -120
                        NPM : 10.8.2
                        adapters count : 580
                        Disk size : 114.2 GiB
                        Disk free : 49.2 GiB

                        c:\ioBroker>iob version
                        7.0.3

                        1 Reply Last reply Reply Quote 0
                        • FernetMenta
                          FernetMenta Developer @Delphinis last edited by FernetMenta

                          @delphinis Ja, dachte mir, dass Node älter ist als 22. Wie hier beschrieben, keine Hektik, aber einplanen: https://forum.iobroker.net/topic/81893/wir-empfehlen-node-js-22-x

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

                            @delphinis sagte in per script Rest anfrage senden:

                            Gibt es da was ähnliches?

                            nicht dass ich wüsste, aber iob list instances und iob list adapters --i sollten was ausspucken

                            D 1 Reply Last reply Reply Quote 0
                            • D
                              Delphinis @Homoran last edited by

                              @homoran said in per script Rest anfrage senden:

                              iob list adapters --i

                              c:\ioBroker>iob list adapters --i
                              ┌─────────┬────────────────────────────────────┬─────────────────────┬──────────┬────────────────┐
                              │ (index) │ id                                 │ name                │ version  │ upgrade policy │
                              ├─────────┼────────────────────────────────────┼─────────────────────┼──────────┼────────────────┤
                              │ 0       │ 'system.adapter.admin'             │ 'admin'             │ '7.6.17' │ 'none'         │
                              │ 1       │ 'system.adapter.alias-manager'     │ 'alias-manager'     │ '2.0.0'  │ 'none'         │
                              │ 2       │ 'system.adapter.backitup'          │ 'backitup'          │ '3.3.5'  │ 'none'         │
                              │ 3       │ 'system.adapter.cloud'             │ 'cloud'             │ '5.0.1'  │ 'none'         │
                              │ 4       │ 'system.adapter.echarts'           │ 'echarts'           │ '1.9.2'  │ 'none'         │
                              │ 5       │ 'system.adapter.email'             │ 'email'             │ '2.0.4'  │ 'none'         │
                              │ 6       │ 'system.adapter.flexcharts'        │ 'flexcharts'        │ '0.4.1'  │ 'none'         │
                              │ 7       │ 'system.adapter.flot'              │ 'flot'              │ '1.12.0' │ 'none'         │
                              │ 8       │ 'system.adapter.history'           │ 'history'           │ '3.0.1'  │ 'none'         │
                              │ 9       │ 'system.adapter.javascript'        │ 'javascript'        │ '8.9.2'  │ 'none'         │
                              │ 10      │ 'system.adapter.modbus'            │ 'modbus'            │ '6.3.2'  │ 'none'         │
                              │ 11      │ 'system.adapter.netatmo-crawler'   │ 'netatmo-crawler'   │ '1.0.0'  │ 'none'         │
                              │ 12      │ 'system.adapter.sayit'             │ 'sayit'             │ '5.0.0'  │ 'none'         │
                              │ 13      │ 'system.adapter.simple-api'        │ 'simple-api'        │ '2.8.0'  │ 'none'         │
                              │ 14      │ 'system.adapter.socketio'          │ 'socketio'          │ '6.7.1'  │ 'none'         │
                              │ 15      │ 'system.adapter.sonoff'            │ 'sonoff'            │ '3.1.2'  │ 'none'         │
                              │ 16      │ 'system.adapter.swiss-weather-api' │ 'swiss-weather-api' │ '2.2.2'  │ 'none'         │
                              │ 17      │ 'system.adapter.vis'               │ 'vis'               │ '1.5.6'  │ 'none'         │
                              │ 18      │ 'system.adapter.vis-history'       │ 'vis-history'       │ '1.0.0'  │ 'none'         │
                              │ 19      │ 'system.adapter.web'               │ 'web'               │ '7.0.8'  │ 'none'         │
                              │ 20      │ 'system.adapter.whatsapp-cmb'      │ 'whatsapp-cmb'      │ '0.3.0'  │ 'none'         │
                              │ 21      │ 'system.adapter.ws'                │ 'ws'                │ '2.6.2'  │ 'none'         │
                              │ 22      │ 'system.adapter.zigbee'            │ 'zigbee'            │ '2.0.5'  │ 'none'         │
                              └─────────┴────────────────────────────────────┴─────────────────────┴──────────┴────────────────┘
                              
                              FernetMenta Homoran 2 Replies Last reply Reply Quote 0
                              • FernetMenta
                                FernetMenta Developer @Delphinis last edited by FernetMenta

                                @delphinis sagte in per script Rest anfrage senden:

                                '8.9.2

                                Das zeigt aber nicht, was du installiert hast. Der Script-Adapter in Version 8.9.x benötigt Node v22. Darum hängst du wahrscheinlich nocht auf 7.x

                                EDIT: unsinn ^^ 🙂

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

                                  @delphinis
                                  @FernetMenta
                                  hab selber suchen müssen!
                                  iob update zeigt alles wichtige an, ohne jetzt die Versionen selbst zusammensuchen zu müssen

                                  D 1 Reply Last reply Reply Quote 0
                                  • D
                                    Delphinis @Homoran last edited by

                                    @homoran

                                    c:\ioBroker>iob update
                                    Used repository: stable
                                    Adapter    "admin"        : 7.7.2    , installed 7.6.17 [Updatable]
                                    Adapter    "alias-manager": 2.0.0    , installed 2.0.0
                                    Adapter    "backitup"     : 3.3.5    , installed 3.3.5
                                    Adapter    "cloud"        : 5.0.1    , installed 5.0.1
                                    Adapter    "discovery"    : 5.0.0    , installed 5.0.0
                                    Adapter    "echarts"      : 1.9.2    , installed 1.9.2
                                    Adapter    "email"        : 2.0.4    , installed 2.0.4
                                    Adapter    "flexcharts"   : 0.5.0    , installed 0.4.1  [Updatable]
                                    Adapter    "flot"         : 1.12.0   , installed 1.12.0
                                    Adapter    "history"      : 3.0.1    , installed 3.0.1
                                    Adapter    "javascript"   : 8.9.2    , installed 8.9.2
                                    Controller "js-controller": 7.0.7    , installed 7.0.3  [Updatable]
                                    Adapter    "modbus"       : 6.3.2    , installed 6.3.2
                                    Adapter    "netatmo-crawler": 1.0.0  , installed 1.0.0
                                    Adapter    "sayit"        : 5.0.0    , installed 5.0.0
                                    Adapter    "simple-api"   : 2.8.0    , installed 2.8.0
                                    Adapter    "socketio"     : 6.7.1    , installed 6.7.1
                                    Adapter    "sonoff"       : 3.2.1    , installed 3.1.2  [Updatable]
                                    Adapter    "swiss-weather-api": 2.2.2, installed 2.2.2
                                    Adapter    "vis"          : 1.5.6    , installed 1.5.6
                                    Adapter    "vis-history"  : 1.0.0    , installed 1.0.0
                                    Adapter    "web"          : 7.0.8    , installed 7.0.8
                                    Adapter    "whatsapp-cmb" : 0.3.0    , installed 0.3.0
                                    Adapter    "ws"           : 2.6.2    , installed 2.6.2
                                    Adapter    "zigbee"       : 3.0.5    , installed 2.0.5  [Updatable]
                                    
                                    
                                    D 1 Reply Last reply Reply Quote 0
                                    • D
                                      Delphinis @Delphinis last edited by

                                      @delphinis
                                      ich werde mal versuchen ein update durchzuführen. Gibt es da eine Schritt für Schritt - Anleitung wie man ein Update aller relevanten Teile von iob unter Windows durchführt?

                                      Great SUN 1 Reply Last reply Reply Quote 0
                                      • Great SUN
                                        Great SUN last edited by

                                        @delphinis Ich bin nicht mehr sicher, warum ich axios nicht verwende, aber ich glaube es hatte etwas mit Zentralisierung/Vereinfachung zu tun, sowie, dass ich den Status code selbst prüfen möchte (Fehler bei != 200, axios wirft den Fehler automatisch, wenn 4xx oder 5xx kommen), und damit, dass ich einige Stellen habe, bei denen ich einen Request triggern möchte und den ich dann entsprechend abarbeiten will...

                                        Evtl. hilft mein code ja jemandem, der irgendwann zufällig hier drüber stolpert (logStr einfach mit log ersetzen):

                                        async function requestUrl(reqUrl, addHeaderDict={}, callback=null, callbackParamDict=null) {
                                            const XMLHttpRequest = require('xhr2');
                                            try {
                                                const Http = new XMLHttpRequest.XMLHttpRequest();
                                                Http.open('GET', reqUrl);
                                                for(const[headerName, headerVal] of Object.entries(addHeaderDict)) {
                                                    if(headerName == 'responseType') {
                                                        Http.responseType = headerVal;
                                                    }
                                                    Http.setRequestHeader(headerName, headerVal);
                                                }
                                                Http.send();
                                                Http.onload = function () {
                                                    if(Http.status==200) {
                                                        logStr('Http request executed successfully: ' + reqUrl, 'debug');
                                                        if(callback != null) {
                                                            logStr('sending data to callback: ' + reqUrl + ' -> ' + Http.response, 'debug');
                                                            if(callbackParamDict != null) {
                                                                callback(reqUrl, Http.response, callbackParamDict);
                                                            } else {
                                                                callback(reqUrl, Http.response);
                                                            }
                                                        }
                                                    } else {
                                                        logStr('Error occured when requesting: ' + reqUrl + ' (' + Http.status + ' -> ' + Http.responseText + ')', 'warn');
                                                    }
                                                }
                                            } catch(exception) {
                                                logStr('ERROR while trying to request ' + reqUrl + ' -> ' + JSON.stringify(exception), 'warn');
                                            }
                                        }
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • Great SUN
                                          Great SUN @Delphinis last edited by

                                          @delphinis Windows ist generell etwas schwieriger, als Linux. Du musst wohl zuerst mal node.js updaten, vorher macht alles andere keinen Sinn (es sei denn, Du hast schon die aktuellste Version). Danach kannst Du iobroker updaten. Ich finde diese Diskussion https://forum.iobroker.net/topic/80988/uralt-system-updaten-oder-umzug ganz gut.

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

                                          Support us

                                          ioBroker
                                          Community Adapters
                                          Donate

                                          463
                                          Online

                                          32.3k
                                          Users

                                          81.0k
                                          Topics

                                          1.3m
                                          Posts

                                          6
                                          31
                                          443
                                          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