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. [gelöst] Skript auf AXIOS/httpGet umbauen

NEWS

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

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

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.2k

[gelöst] Skript auf AXIOS/httpGet umbauen

Scheduled Pinned Locked Moved JavaScript
59 Posts 18 Posters 12.3k Views 19 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.
  • DJMarc75D Offline
    DJMarc75D Offline
    DJMarc75
    wrote on last edited by DJMarc75
    #1

    Tag,
    heutiges Projekt soll sein mich mal ein wenig mit Javaskript zu beschäftigen.
    Ich muss gestehen dass ich damit wenig bis eigentlich nix gemacht habe und mir die wenigen Skripte welche bei mir laufen auch nur "geklaut" habe.

    Ziel ist es folgende JS-Funktion in Blockly auf Axios umzubauen:

    var request =require('request');
    let result;
    const options = {
        url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
        method: 'GET',
        headers: {
            'Accept': 'application/json',
            'Accept-Charset': 'utf-8',
            'User-Agent': 'iobroker script'
        }
    }
    
    request(options, function(err,response,body){
        result = JSON.parse(body);
    })
    await wait(1000);
    return result;
    

    Die Worte "request" muss ich ja durch "axios" ersetzen - richtig?

    Aber dann verliessen sie ihn auch schon.

    Für Hilfe wäre ich dankbar.
    Merci

    Lehrling seit 1975 !!!
    Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
    https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge

    M L 2 Replies Last reply
    0
    • DJMarc75D DJMarc75

      Tag,
      heutiges Projekt soll sein mich mal ein wenig mit Javaskript zu beschäftigen.
      Ich muss gestehen dass ich damit wenig bis eigentlich nix gemacht habe und mir die wenigen Skripte welche bei mir laufen auch nur "geklaut" habe.

      Ziel ist es folgende JS-Funktion in Blockly auf Axios umzubauen:

      var request =require('request');
      let result;
      const options = {
          url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
          method: 'GET',
          headers: {
              'Accept': 'application/json',
              'Accept-Charset': 'utf-8',
              'User-Agent': 'iobroker script'
          }
      }
      
      request(options, function(err,response,body){
          result = JSON.parse(body);
      })
      await wait(1000);
      return result;
      

      Die Worte "request" muss ich ja durch "axios" ersetzen - richtig?

      Aber dann verliessen sie ihn auch schon.

      Für Hilfe wäre ich dankbar.
      Merci

      M Online
      M Online
      MCU
      wrote on last edited by
      #2

      @djmarc75

      const axios = require('axios');
      
      const getReverseGeoCoding = async (lat, lon) => {
          try {
              const response = await axios.get(`https://nominatim.openstreetmap.org/reverse.php`, {
                  params: {
                      format: 'json',
                      lat: lat,
                      lon: lon,
                      zoom: 18
                  },
                  headers: {
                      'Accept': 'application/json',
                      'Accept-Charset': 'utf-8',
                      'User-Agent': 'iobroker script'
                  }
              });
              return response.data;
          } catch (error) {
              console.error('Error fetching reverse geocoding data:', error);
              return null;
          }
      };
      
      
      const lat = 52.52; 
      const lon = 13.405; 
      const result = await getReverseGeoCoding(lat, lon);
      console.log(result);
      

      NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
      Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

      DJMarc75D 1 Reply Last reply
      0
      • DJMarc75D DJMarc75

        Tag,
        heutiges Projekt soll sein mich mal ein wenig mit Javaskript zu beschäftigen.
        Ich muss gestehen dass ich damit wenig bis eigentlich nix gemacht habe und mir die wenigen Skripte welche bei mir laufen auch nur "geklaut" habe.

        Ziel ist es folgende JS-Funktion in Blockly auf Axios umzubauen:

        var request =require('request');
        let result;
        const options = {
            url: 'https://nominatim.openstreetmap.org/reverse.php?format=json&lat=' + lat + '&lon=' + lon + '&zoom=18',
            method: 'GET',
            headers: {
                'Accept': 'application/json',
                'Accept-Charset': 'utf-8',
                'User-Agent': 'iobroker script'
            }
        }
        
        request(options, function(err,response,body){
            result = JSON.parse(body);
        })
        await wait(1000);
        return result;
        

        Die Worte "request" muss ich ja durch "axios" ersetzen - richtig?

        Aber dann verliessen sie ihn auch schon.

        Für Hilfe wäre ich dankbar.
        Merci

        L Offline
        L Offline
        Lucky_ESA
        Developer Most Active
        wrote on last edited by
        #3

        @djmarc75

        Mit Javascript >= 7.8.0

        httpGet('http://', { timeout: 2000, responseType: 'arraybuffer oder text' }, async (err, response) => {
                if(err) {
                    console.log('Error: ' + err);
                    return;
                }
                if (response.data) {
                    // etwas tun
                } else {
                    // keine Daten
                }
            });
        
        1 Reply Last reply
        1
        • M MCU

          @djmarc75

          const axios = require('axios');
          
          const getReverseGeoCoding = async (lat, lon) => {
              try {
                  const response = await axios.get(`https://nominatim.openstreetmap.org/reverse.php`, {
                      params: {
                          format: 'json',
                          lat: lat,
                          lon: lon,
                          zoom: 18
                      },
                      headers: {
                          'Accept': 'application/json',
                          'Accept-Charset': 'utf-8',
                          'User-Agent': 'iobroker script'
                      }
                  });
                  return response.data;
              } catch (error) {
                  console.error('Error fetching reverse geocoding data:', error);
                  return null;
              }
          };
          
          
          const lat = 52.52; 
          const lon = 13.405; 
          const result = await getReverseGeoCoding(lat, lon);
          console.log(result);
          
          DJMarc75D Offline
          DJMarc75D Offline
          DJMarc75
          wrote on last edited by
          #4

          @mcu Danke.
          Das wäre dann ein reines Javaskript mit fixen Koordinaten.

          Diese fixen Koordinaten lat und lon müssen aber in meinem Fall durch Datenpunkte ersetzt werden und zusätzlich sollte das Skript als Funktion in Blockly implementiert werden, was so leider einen Fehler auswirft:

          script.js.common.GPS.Adresse_Iris compile failed: at script.js.common.GPS.Adresse_Iris:28
          

          Lehrling seit 1975 !!!
          Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
          https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge

          CodierknechtC M 2 Replies Last reply
          0
          • DJMarc75D DJMarc75

            @mcu Danke.
            Das wäre dann ein reines Javaskript mit fixen Koordinaten.

            Diese fixen Koordinaten lat und lon müssen aber in meinem Fall durch Datenpunkte ersetzt werden und zusätzlich sollte das Skript als Funktion in Blockly implementiert werden, was so leider einen Fehler auswirft:

            script.js.common.GPS.Adresse_Iris compile failed: at script.js.common.GPS.Adresse_Iris:28
            
            CodierknechtC Online
            CodierknechtC Online
            Codierknecht
            Developer Most Active
            wrote on last edited by
            #5

            @djmarc75

            quick & dirty:

            async function updateLocation(latitude, longitude) {
                const url = `https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=json`;
                const response = await axios.get(url);
                if (response && response.data.display_name) {
                  return(response.data.display_name);
                }
            }
            

            "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (Martin Fowler, "Refactoring")

            Proxmox 9.1.1 LXC|8 GB|Core i7-6700
            HmIP|ZigBee|Tasmota|Unifi
            Zabbix Certified Specialist
            Konnte ich Dir helfen? Dann benutze bitte das Voting unten rechts im Beitrag

            1 Reply Last reply
            0
            • DJMarc75D DJMarc75

              @mcu Danke.
              Das wäre dann ein reines Javaskript mit fixen Koordinaten.

              Diese fixen Koordinaten lat und lon müssen aber in meinem Fall durch Datenpunkte ersetzt werden und zusätzlich sollte das Skript als Funktion in Blockly implementiert werden, was so leider einen Fehler auswirft:

              script.js.common.GPS.Adresse_Iris compile failed: at script.js.common.GPS.Adresse_Iris:28
              
              M Online
              M Online
              MCU
              wrote on last edited by MCU
              #6

              @djmarc75 Wenn du Blockly nutzt kannst du auch direkt den Block verwenden?
              2ae1f768-c9ce-4adf-b57d-acd251e9e75b-image.png

              09f8663b-e449-4ebd-8352-3ca5b6745fef-image.png

              <xml xmlns="https://developers.google.com/blockly/xml">
                <variables>
                  <variable id="`eps4Xu;/O9P-h|FWJ-E">lat</variable>
                  <variable id="qICBRrCi%-}_(mq;vWM^">lon</variable>
                  <variable id=")AQ%}HdiHDw^ZDxO0d[?">response</variable>
                </variables>
                <block type="variables_set" id="2DF6oAFi1G}uOwa_3?)w" x="88" y="113">
                  <field name="VAR" id="`eps4Xu;/O9P-h|FWJ-E">lat</field>
                  <value name="VALUE">
                    <block type="math_number" id="FduAcw*36HRQdJJcnT(M">
                      <field name="NUM">52.52</field>
                    </block>
                  </value>
                  <next>
                    <block type="variables_set" id="flw^g!3aB+q_~hAO83[g">
                      <field name="VAR" id="qICBRrCi%-}_(mq;vWM^">lon</field>
                      <value name="VALUE">
                        <block type="math_number" id=":CT|HqW-VISJ=XBdNMzY">
                          <field name="NUM">13.405</field>
                        </block>
                      </value>
                      <next>
                        <block type="http_get" id="er#Datp2ZE*VyGUa%*Kv">
                          <field name="TIMEOUT">2000</field>
                          <field name="UNIT">ms</field>
                          <field name="TYPE">text</field>
                          <value name="URL">
                            <shadow type="text" id="Q_WE@|3:]0*%[l-.!;qf">
                              <field name="TEXT"></field>
                            </shadow>
                            <block type="text_join" id="-ys2STS:FUWU@%[8~o[=">
                              <mutation items="5"></mutation>
                              <value name="ADD0">
                                <block type="text" id="B25~4=^wMHf(vUb3ay~3">
                                  <field name="TEXT">https://nominatim.openstreetmap.org/reverse.php?format=json&amp;lat=</field>
                                </block>
                              </value>
                              <value name="ADD1">
                                <block type="variables_get" id="3Y8[4Y4CR#bn(@$tYkc+">
                                  <field name="VAR" id="`eps4Xu;/O9P-h|FWJ-E">lat</field>
                                </block>
                              </value>
                              <value name="ADD2">
                                <block type="text" id="==#V5Ah1PyKx_!-*~JfY">
                                  <field name="TEXT">&amp;lon=</field>
                                </block>
                              </value>
                              <value name="ADD3">
                                <block type="variables_get" id="ya.!JwNXi/PO.!GZE@tX">
                                  <field name="VAR" id="qICBRrCi%-}_(mq;vWM^">lon</field>
                                </block>
                              </value>
                              <value name="ADD4">
                                <block type="text" id="[JnnacT#;5U-rwb.89lc">
                                  <field name="TEXT">&amp;zoom=18</field>
                                </block>
                              </value>
                            </block>
                          </value>
                          <statement name="STATEMENT">
                            <block type="debug" id="Z/p^=2Hb40.14a$HJF{b">
                              <field name="Severity">log</field>
                              <value name="TEXT">
                                <shadow type="text" id="X7.E)1NBlIOrpnS^9XwS">
                                  <field name="TEXT">test</field>
                                </shadow>
                                <block type="variables_get" id="Jgr?*Epm}01s%F=YGUa+">
                                  <field name="VAR" id=")AQ%}HdiHDw^ZDxO0d[?">response</field>
                                </block>
                              </value>
                            </block>
                          </statement>
                        </block>
                      </next>
                    </block>
                  </next>
                </block>
              </xml>
              

              NUC i7 64GB mit Proxmox ---- Jarvis Infos Aktualisierungen der Doku auf Instagram verfolgen -> mcuiobroker Instagram
              Wenn Euch mein Vorschlag geholfen hat, bitte rechts "^" klicken.

              DJMarc75D 1 Reply Last reply
              3
              • M MCU

                @djmarc75 Wenn du Blockly nutzt kannst du auch direkt den Block verwenden?
                2ae1f768-c9ce-4adf-b57d-acd251e9e75b-image.png

                09f8663b-e449-4ebd-8352-3ca5b6745fef-image.png

                <xml xmlns="https://developers.google.com/blockly/xml">
                  <variables>
                    <variable id="`eps4Xu;/O9P-h|FWJ-E">lat</variable>
                    <variable id="qICBRrCi%-}_(mq;vWM^">lon</variable>
                    <variable id=")AQ%}HdiHDw^ZDxO0d[?">response</variable>
                  </variables>
                  <block type="variables_set" id="2DF6oAFi1G}uOwa_3?)w" x="88" y="113">
                    <field name="VAR" id="`eps4Xu;/O9P-h|FWJ-E">lat</field>
                    <value name="VALUE">
                      <block type="math_number" id="FduAcw*36HRQdJJcnT(M">
                        <field name="NUM">52.52</field>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" id="flw^g!3aB+q_~hAO83[g">
                        <field name="VAR" id="qICBRrCi%-}_(mq;vWM^">lon</field>
                        <value name="VALUE">
                          <block type="math_number" id=":CT|HqW-VISJ=XBdNMzY">
                            <field name="NUM">13.405</field>
                          </block>
                        </value>
                        <next>
                          <block type="http_get" id="er#Datp2ZE*VyGUa%*Kv">
                            <field name="TIMEOUT">2000</field>
                            <field name="UNIT">ms</field>
                            <field name="TYPE">text</field>
                            <value name="URL">
                              <shadow type="text" id="Q_WE@|3:]0*%[l-.!;qf">
                                <field name="TEXT"></field>
                              </shadow>
                              <block type="text_join" id="-ys2STS:FUWU@%[8~o[=">
                                <mutation items="5"></mutation>
                                <value name="ADD0">
                                  <block type="text" id="B25~4=^wMHf(vUb3ay~3">
                                    <field name="TEXT">https://nominatim.openstreetmap.org/reverse.php?format=json&amp;lat=</field>
                                  </block>
                                </value>
                                <value name="ADD1">
                                  <block type="variables_get" id="3Y8[4Y4CR#bn(@$tYkc+">
                                    <field name="VAR" id="`eps4Xu;/O9P-h|FWJ-E">lat</field>
                                  </block>
                                </value>
                                <value name="ADD2">
                                  <block type="text" id="==#V5Ah1PyKx_!-*~JfY">
                                    <field name="TEXT">&amp;lon=</field>
                                  </block>
                                </value>
                                <value name="ADD3">
                                  <block type="variables_get" id="ya.!JwNXi/PO.!GZE@tX">
                                    <field name="VAR" id="qICBRrCi%-}_(mq;vWM^">lon</field>
                                  </block>
                                </value>
                                <value name="ADD4">
                                  <block type="text" id="[JnnacT#;5U-rwb.89lc">
                                    <field name="TEXT">&amp;zoom=18</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="STATEMENT">
                              <block type="debug" id="Z/p^=2Hb40.14a$HJF{b">
                                <field name="Severity">log</field>
                                <value name="TEXT">
                                  <shadow type="text" id="X7.E)1NBlIOrpnS^9XwS">
                                    <field name="TEXT">test</field>
                                  </shadow>
                                  <block type="variables_get" id="Jgr?*Epm}01s%F=YGUa+">
                                    <field name="VAR" id=")AQ%}HdiHDw^ZDxO0d[?">response</field>
                                  </block>
                                </value>
                              </block>
                            </statement>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </xml>
                

                DJMarc75D Offline
                DJMarc75D Offline
                DJMarc75
                wrote on last edited by
                #7

                @mcu Jou, so (ähnlich) habe ich es mir eben auch zusammen gebastelt ;)

                Funktioniert !

                Merci auch an @Codierknecht & @Lucky_ESA

                Muss noch viel was JS angeht lernen.

                Lehrling seit 1975 !!!
                Beitrag geholfen ? dann gerne ein upvote rechts unten im Beitrag klicken ;)
                https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge

                haus-automatisierungH 1 Reply Last reply
                0
                • DJMarc75D DJMarc75

                  @mcu Jou, so (ähnlich) habe ich es mir eben auch zusammen gebastelt ;)

                  Funktioniert !

                  Merci auch an @Codierknecht & @Lucky_ESA

                  Muss noch viel was JS angeht lernen.

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

                  @djmarc75 Die Idee mit den neuen Versionen war ja eigentlich, nicht wieder in das gleiche Problem zu laufen wie aktuell mit request. Also am besten kommt axios gar nicht in deinem Code vor, sondern Du nutzt httpGet (oder die Blockly-Bausteine dafür).

                  Dann können wir in Zukunft die Library darunter austauschen und alle Scripts laufen weiter.

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

                  D 1 Reply Last reply
                  7
                  • haus-automatisierungH haus-automatisierung

                    @djmarc75 Die Idee mit den neuen Versionen war ja eigentlich, nicht wieder in das gleiche Problem zu laufen wie aktuell mit request. Also am besten kommt axios gar nicht in deinem Code vor, sondern Du nutzt httpGet (oder die Blockly-Bausteine dafür).

                    Dann können wir in Zukunft die Library darunter austauschen und alle Scripts laufen weiter.

                    D Online
                    D Online
                    darkiop
                    Most Active
                    wrote on last edited by
                    #9

                    @haus-automatisierung

                    Der httpGet Block hat aktuell keine Option um Zertifikatsfehler zu ignorieren oder?

                    Proxmox-ioBroker-Redis-HA Doku: https://forum.iobroker.net/topic/47478/dokumentation-einer-proxmox-iobroker-redis-ha-umgebung

                    haus-automatisierungH 1 Reply Last reply
                    0
                    • D darkiop

                      @haus-automatisierung

                      Der httpGet Block hat aktuell keine Option um Zertifikatsfehler zu ignorieren oder?

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

                      @darkiop sagte in [gelöst] Skript auf AXIOS umbauen:

                      Der httpGet Block hat aktuell keine Option um Zertifikatsfehler zu ignorieren

                      Ja, richtig. Weiß auch noch nicht ob ich das anbieten soll. Immerhin ist die Validierung ein Sicherheitsfeature.

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

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

                        @darkiop sagte in [gelöst] Skript auf AXIOS umbauen:

                        Der httpGet Block hat aktuell keine Option um Zertifikatsfehler zu ignorieren

                        Ja, richtig. Weiß auch noch nicht ob ich das anbieten soll. Immerhin ist die Validierung ein Sicherheitsfeature.

                        D Online
                        D Online
                        darkiop
                        Most Active
                        wrote on last edited by
                        #11

                        @haus-automatisierung

                        Stimmt - allerdings gerade im häuslichen Umfeld oft "normal".

                        Am Ende ist ist es ein abwägen von Risiko und Nutzen ;)

                        Proxmox-ioBroker-Redis-HA Doku: https://forum.iobroker.net/topic/47478/dokumentation-einer-proxmox-iobroker-redis-ha-umgebung

                        haus-automatisierungH 1 Reply Last reply
                        0
                        • D darkiop

                          @haus-automatisierung

                          Stimmt - allerdings gerade im häuslichen Umfeld oft "normal".

                          Am Ende ist ist es ein abwägen von Risiko und Nutzen ;)

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

                          @darkiop Ja, und was ist der Nutzen von einer https Verbindung im LAN?

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

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

                            @darkiop Ja, und was ist der Nutzen von einer https Verbindung im LAN?

                            D Online
                            D Online
                            darkiop
                            Most Active
                            wrote on last edited by
                            #13

                            @haus-automatisierung

                            Lässt sich manchmal ja nicht ohne zusätzlichen Aufwand (z.B. per ReverseProxy) vermeiden.

                            Unser SMA WR liefert das WebUi per https aus, eine Möglichkeit ein eigenes Zertifikat zu hinterlegen gibt es imho nicht.

                            Hier läuft alles über einen internen ReverseProxy, mir ist nur aufgefallen das die Option SSL Prüfungen abzuschalten, noch nicht implementiert ist.

                            Proxmox-ioBroker-Redis-HA Doku: https://forum.iobroker.net/topic/47478/dokumentation-einer-proxmox-iobroker-redis-ha-umgebung

                            1 Reply Last reply
                            0
                            • bahnuhrB Online
                              bahnuhrB Online
                              bahnuhr
                              Forum Testing Most Active
                              wrote on last edited by
                              #14

                              Guten Morgen,

                              bin auch gerade an dem Thema dran:

                              mit request lasse ich mir Bilder der cam an telegram senden, wie folgt:

                              var ip = 159; var vUser = "Dieter"; var cam = "Test";
                              
                              var request = require('request');
                              var fs      = require('fs');
                                  request.get({url: 'http://192.168.243.' + ip + ':88//cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx', encoding: 'binary'}, function (err, response, body) {
                                      fs.writeFile('/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', body, 'binary', function(err) {
                                      if (err) {
                                          console.error(err);
                                      } else {
                                          log('Snapshot sent '+ ip);
                                          sendTo('telegram.0', {user: vUser, text: '/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', caption: cam});
                                      }
                                    }); 
                                  });
                              

                              Wenn ich dies nun mit axios versuche, klappt dies nicht:

                              var ip = 159; var vUser = "Dieter"; var cam = "Test";
                              
                              const axios = require('axios');
                              var fs      = require('fs');
                                  axios.get({url: 'http://192.168.243.' + ip + ':88//cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx', encoding: 'binary'}, function (err, response, body) {
                                      fs.writeFile('/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', body, 'binary', function(err) {
                                      if (err) {
                                          console.error(err);
                                      } else {
                                          log('Snapshot sent '+ ip);
                                          sendTo('telegram.0', {user: vUser, text: '/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', caption: cam});
                                      }
                                    }); 
                                  });
                              

                              Kann der axios diesen "binary" nicht ?
                              Oder liegt es an etwas anderes ?

                              Vielleicht auch ne Info wie der Befehl mit httpget aussehen müsste.
                              Danke.


                              Wenn ich helfen konnte, dann Daumen hoch (Pfeil nach oben)!
                              Danke.
                              gute Forenbeiträge: https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge
                              ScreenToGif :https://www.screentogif.com/downloads.html

                              haus-automatisierungH 1 Reply Last reply
                              0
                              • bahnuhrB bahnuhr

                                Guten Morgen,

                                bin auch gerade an dem Thema dran:

                                mit request lasse ich mir Bilder der cam an telegram senden, wie folgt:

                                var ip = 159; var vUser = "Dieter"; var cam = "Test";
                                
                                var request = require('request');
                                var fs      = require('fs');
                                    request.get({url: 'http://192.168.243.' + ip + ':88//cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx', encoding: 'binary'}, function (err, response, body) {
                                        fs.writeFile('/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', body, 'binary', function(err) {
                                        if (err) {
                                            console.error(err);
                                        } else {
                                            log('Snapshot sent '+ ip);
                                            sendTo('telegram.0', {user: vUser, text: '/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', caption: cam});
                                        }
                                      }); 
                                    });
                                

                                Wenn ich dies nun mit axios versuche, klappt dies nicht:

                                var ip = 159; var vUser = "Dieter"; var cam = "Test";
                                
                                const axios = require('axios');
                                var fs      = require('fs');
                                    axios.get({url: 'http://192.168.243.' + ip + ':88//cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx', encoding: 'binary'}, function (err, response, body) {
                                        fs.writeFile('/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', body, 'binary', function(err) {
                                        if (err) {
                                            console.error(err);
                                        } else {
                                            log('Snapshot sent '+ ip);
                                            sendTo('telegram.0', {user: vUser, text: '/opt/iobroker/iobroker-data/tmp/snap' + ip + '.jpg', caption: cam});
                                        }
                                      }); 
                                    });
                                

                                Kann der axios diesen "binary" nicht ?
                                Oder liegt es an etwas anderes ?

                                Vielleicht auch ne Info wie der Befehl mit httpget aussehen müsste.
                                Danke.

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

                                @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                Kann der axios diesen "binary" nicht ?

                                Du kannst nicht einfach nur 1:1 die Funktion austauschen. Dokumentation gibts hier: https://github.com/axios/axios

                                Das Ganze heißt responseEncoding: 'binary', im Config-Objekt. Aber warum nutzt Du nicht httpGet ?

                                https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httpget

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

                                haus-automatisierungH bahnuhrB 2 Replies Last reply
                                1
                                • haus-automatisierungH haus-automatisierung

                                  @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                  Kann der axios diesen "binary" nicht ?

                                  Du kannst nicht einfach nur 1:1 die Funktion austauschen. Dokumentation gibts hier: https://github.com/axios/axios

                                  Das Ganze heißt responseEncoding: 'binary', im Config-Objekt. Aber warum nutzt Du nicht httpGet ?

                                  https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httpget

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

                                  nicht getestet, nur im Forum programmiert

                                  const fs = require('node:fs');
                                  
                                  const ip = 159;
                                  const vUser = 'Dieter';
                                  const cam = 'Test';
                                  
                                  httpGet(`http://192.168.243.${ip}:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx`, { responseType: 'arraybuffer' }, (err, response) => {
                                      if (err) {
                                          console.error(err);
                                      } else {
                                          const filePath = `/opt/iobroker/iobroker-data/tmp/snap${ip}.jpg`;
                                  
                                          fs.writeFile(filePath, response.data, (err) => {
                                              if (err) {
                                                  console.error(err);
                                              } else {
                                                  log(`Snapshot sent: ${ip}`);
                                  
                                                  sendTo('telegram.0', {
                                                      user: vUser,
                                                      text: filePath,
                                                      caption: cam
                                                  });
                                              }
                                          });
                                      }
                                  });
                                  

                                  🧑‍🎓 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
                                  • haus-automatisierungH haus-automatisierung

                                    @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                    Kann der axios diesen "binary" nicht ?

                                    Du kannst nicht einfach nur 1:1 die Funktion austauschen. Dokumentation gibts hier: https://github.com/axios/axios

                                    Das Ganze heißt responseEncoding: 'binary', im Config-Objekt. Aber warum nutzt Du nicht httpGet ?

                                    https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#httpget

                                    bahnuhrB Online
                                    bahnuhrB Online
                                    bahnuhr
                                    Forum Testing Most Active
                                    wrote on last edited by
                                    #17

                                    @haus-automatisierung sagte in [gelöst] Skript auf AXIOS umbauen:

                                    Aber warum nutzt Du nicht httpGet ?

                                    weil es mit der 7.8.0 noch nicht funktioniert.
                                    und die 7.9.0 ist noch nicht stable.

                                    Muss ich wohl mal die beta installieren.


                                    Wenn ich helfen konnte, dann Daumen hoch (Pfeil nach oben)!
                                    Danke.
                                    gute Forenbeiträge: https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge
                                    ScreenToGif :https://www.screentogif.com/downloads.html

                                    haus-automatisierungH 1 Reply Last reply
                                    0
                                    • bahnuhrB bahnuhr

                                      @haus-automatisierung sagte in [gelöst] Skript auf AXIOS umbauen:

                                      Aber warum nutzt Du nicht httpGet ?

                                      weil es mit der 7.8.0 noch nicht funktioniert.
                                      und die 7.9.0 ist noch nicht stable.

                                      Muss ich wohl mal die beta installieren.

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

                                      @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                      Muss ich wohl mal die beta installieren.

                                      In 8.3.0 habe ich heute noch eine weitere Funktion eingefügt. Damit wird das noch kürzer:

                                      const ip = 159;
                                      const user = 'Dieter';
                                      const caption = 'Test';
                                       
                                      httpGet(`http://192.168.243.${ip}:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx`, { responseType: 'arraybuffer' }, (err, response) => {
                                          if (err) {
                                              console.error(err);
                                          } else {
                                              sendTo('telegram.0', {
                                                  user,
                                                  caption,
                                                  text: createTempFile(`snap${ip}.jpg`, response.data),
                                              });
                                          }
                                      });
                                      
                                      

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

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

                                        @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                        Muss ich wohl mal die beta installieren.

                                        In 8.3.0 habe ich heute noch eine weitere Funktion eingefügt. Damit wird das noch kürzer:

                                        const ip = 159;
                                        const user = 'Dieter';
                                        const caption = 'Test';
                                         
                                        httpGet(`http://192.168.243.${ip}:88/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xx&pwd=xx`, { responseType: 'arraybuffer' }, (err, response) => {
                                            if (err) {
                                                console.error(err);
                                            } else {
                                                sendTo('telegram.0', {
                                                    user,
                                                    caption,
                                                    text: createTempFile(`snap${ip}.jpg`, response.data),
                                                });
                                            }
                                        });
                                        
                                        
                                        bahnuhrB Online
                                        bahnuhrB Online
                                        bahnuhr
                                        Forum Testing Most Active
                                        wrote on last edited by
                                        #19

                                        @haus-automatisierung
                                        so, habs ausprobiert (bin jetzt auf 8.3.0).

                                        Wenn ich folgenden kleinen code ausführe:

                                        httpGet(`http://192.168.243.203/YamahaExtendedControl/v1/main/setPower?power=standby`, { responseType: 'text' }, (err, response) => {
                                            if (err) { console.error(err); } else { log (""); }
                                        });
                                        

                                        kommt trotzdem im log:

                                        	script.js.Scripte.test6: request package is deprecated - please use httpGet (or a stable lib like axios) instead!
                                        

                                        Warum kommt dies im log ?
                                        (httpGet ist in JS auch rot unterstrichen)

                                        Benutze doch httpGet.


                                        Wenn ich helfen konnte, dann Daumen hoch (Pfeil nach oben)!
                                        Danke.
                                        gute Forenbeiträge: https://forum.iobroker.net/topic/51555/hinweise-f%C3%BCr-gute-forenbeitr%C3%A4ge
                                        ScreenToGif :https://www.screentogif.com/downloads.html

                                        haus-automatisierungH liv-in-skyL 2 Replies Last reply
                                        0
                                        • bahnuhrB bahnuhr

                                          @haus-automatisierung
                                          so, habs ausprobiert (bin jetzt auf 8.3.0).

                                          Wenn ich folgenden kleinen code ausführe:

                                          httpGet(`http://192.168.243.203/YamahaExtendedControl/v1/main/setPower?power=standby`, { responseType: 'text' }, (err, response) => {
                                              if (err) { console.error(err); } else { log (""); }
                                          });
                                          

                                          kommt trotzdem im log:

                                          	script.js.Scripte.test6: request package is deprecated - please use httpGet (or a stable lib like axios) instead!
                                          

                                          Warum kommt dies im log ?
                                          (httpGet ist in JS auch rot unterstrichen)

                                          Benutze doch httpGet.

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

                                          @bahnuhr sagte in [gelöst] Skript auf AXIOS umbauen:

                                          Warum kommt dies im log ?
                                          (httpGet ist in JS auch rot unterstrichen)

                                          Kann ich nicht reproduzieren, die Meldung kommt auch nur, wenn require aufgerufen wird. Und das passiert bei Dir im Script ja nicht.

                                          Du hast aber schon über npm installiert (und nicht über GitHub), oder?

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

                                          bahnuhrB 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

                                          656

                                          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