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.
    • D
      Delphinis @FernetMenta last edited by

      @fernetmenta
      ok, ich hab mal das erste einfache Beispiel genommen:

      const axios = require('axios');
      
      // Make a request for a user with a given ID
      axios.get('https://data.geo.admin.ch/ch.meteoschweiz.ogd-smn/abo/ogd-smn_abo_t_now.csv')
        .then(function (response) {
          // handle success
          console.log(response);
        })
        .catch(function (error) {
          // handle error
          console.log(error);
        })
        .finally(function () {
          // always executed
        });
      

      er meldet zwar einen Fehler bei

      const axios = require('axios');
      

      Cannot find module 'axios' or its corresponding type declarations.

      Aber das programm läuft und es liefert mir ein json, mit den Daten als csv. parsen kann ich dann selbst.
      Aber ich weiss jetzt nicht, wo ich z.B. in den Header das "If-None-Match" eingeben kann, und wo ich collections und items definieren kann. Wird das in "paramters" gemacht (wie im zweiten Beispiel)?

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

        @delphinis

        Headers kann man zu z.B. so setzen:

        axios.get(URL, { headers: { Authorization: AuthStr } })
        

        Das findet man aber rellativ leicht raus, weil axios quasi der Standard ist für REST API in Node. httpGet hat, glaube ich, auch axois unter der Haube. Also ein zusätzlicher Wrapper. Kann in manchen Fällen gut sein. In diesem Fall aber m.E. nich tausreichen Dokumentiert.

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

          @fernetmenta said in per script Rest anfrage senden:

          headers:

          Danke erst mal. Ich muss mich da noch ein bisschen schlau machen. Jedenfalls kann ich jetzt schon ausprobieren.
          Weisst du wieso es einen Fehler bei 'axios' anzeigt?

          FernetMenta 1 Reply Last reply Reply Quote 0
          • 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
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            474
                                            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