Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. (gelöst) request auf httpGet umstellen für Snapshot

    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

    (gelöst) request auf httpGet umstellen für Snapshot

    This topic has been deleted. Only users with topic management privileges can see it.
    • O
      oranggila last edited by oranggila

      Re: Hilfe bei Skripte von request auf httpGet umbauen
      Ich habe mehrere JavaScripte, die per Telegram einen fullybrowser Snapshot schicken. Könnt Ihr mir bitte beim Umbauen auf httpGet helfen?

      var request = require('request');
              var fs      = require('fs');
             request.get({url: 'http://192.x.x.x:2323/?cmd=getCamshot&password=xxx', encoding: 'binary'}, function (err, response, body) {
                  fs.writeFile("/home/Pictures/snap.jpg", body, 'binary', function(err) {
                      if (err) {
                          console.error(err);
                      } else {
                          var info_text = 'Snapshot';
                          console.log('Snapshot sent');
                          sendTo('telegram.0', {text: '/home/Pictures/snap.jpg', caption: info_text });
                      }
                  });
              });		
      
      bahnuhr 1 Reply Last reply Reply Quote 0
      • bahnuhr
        bahnuhr Forum Testing Most Active @oranggila last edited by

        @oranggila

        Suche benutzen !
        Diesen Fall gab es schon mehrmals.

        O 1 Reply Last reply Reply Quote 0
        • O
          oranggila @bahnuhr last edited by

          @bahnuhr Ich habe es auch anhand der Beispiele versucht. Es sind keine Syntaxfehler drin, aber es klappt noch nicht. Das File erhält zwar einen aktualisierten Timestamp und console.log wird auch ausgegeben, aber es wird nichts über Telegram gesendet. Was mache ich z.B. aus dem

          encoding: 'binary'
          

          ? Das fehlt aktuell.

          Hier mein umgestelltes Script:

          var fs = require('fs');
          httpGet('http://192.x.x.x:2323/?cmd=getCamshot&password=xxx', (err, response) => {
              fs.writeFile("/home/Pictures/snap.jpg", response.data, 'binary', function (err) {
                  if (err) {
                      console.error(err);
                  } else {
                      var info_text = 'Snapshot';
                      console.log('Snapshot sent');
                      sendTo('telegram.0', { text: '/home/Pictures/snap.jpg', caption: info_text });
                   }
              });
          }); 
          
          bahnuhr 1 Reply Last reply Reply Quote 0
          • bahnuhr
            bahnuhr Forum Testing Most Active @oranggila last edited by

            @oranggila

            so auf die Schnelle durch die Suche:

            const ip = 159;
             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: vUser,
                        text: createTempFile(`snap${ip}.jpg`, response.data),
                        caption: cam
                    });
                }
            });
            

            oder

            var fs      = require('fs');
            httpGet('http://192.168.243.xxx:88//cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=xxx&pwd=xxx', { responseType: 'arraybuffer' }, (err, response) => {
                log (response.data)
                if (err) {
                    console.error(err);       
                } else {
                    fs.writeFile("/opt/iobroker/iobroker-data/tmp/snap.jpg", response.data, 'binary', function(err2) {
                        if (err2) {
                            console.error(err2);
                            sendTo('telegram.0', "Garage wird geöffnet."); 
                        } else {
                            log('Snapshot sent');
                            sendTo('telegram.0', {text: '/opt/iobroker/iobroker-data/tmp/snap.jpg', caption: 'Garage wird geöffnet.'});
                        }
                    }); 
                }
            });
            
            O 1 Reply Last reply Reply Quote 0
            • O
              oranggila @bahnuhr last edited by

              @bahnuhr Vielen Dank! 👍

              { responseType: 'arraybuffer' }
              

              war die Lösung.

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

              Support us

              ioBroker
              Community Adapters
              Donate

              963
              Online

              31.8k
              Users

              80.0k
              Topics

              1.3m
              Posts

              2
              5
              323
              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