Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Synology Script link von MJPG in Datenpunkt DSM7

    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

    Synology Script link von MJPG in Datenpunkt DSM7

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

      Hallo,

      hat zufällig jemand das Script von @apollon77 welches den MJPG Link der Kamera aus der Synology Surveillance Station holt für das DSM7 angepasst und könnte es zur Verfügung stellen?

      hier das Script welches bis kleiner DSM7 geht:

      var request = require('request');
       
      // Konfiguration
      var user = "User";  // Synology Benutzer mit Berechtigung die Kamera anzuzeigen
      var pass = "Pass";  // Passwort zu eben eingegebenem Benutzer
      var ip = "192.168.x.x";  // IP-Adresse eures Synology-NAS
      var port = 5000;  // default Port der Surveillance Station
      var cameraID = 2;  // ID der Kamera, welche angezeigt werden soll
       
      createState('javascript.' + instance + '.Anzeigen.Kamera.Terrasse', {'type': 'string', 'read': true, 'write': true, 'role': 'value', 'def': ""});
       
      // Authentifizierung an Synology Surveillance Station WebAPI und auslesen der SID
       
      function updateStreamUrl() {
          request('http://' + ip + ':' + port + '/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=' + user + '&passwd=' + pass + '&session=SurveillanceStation&format=sid', function (error, response, body) {
              //console.log('error:', error); // Print the error if one occurred
              //console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
              //console.log('body:', body); // Print the HTML for the Google homepage.
              try {
                  var bodyObj = JSON.parse(body);
              }
              catch (e) {
                  console.log("Error update SurveillanceStation Stream URL: " + e);
                  return;
              }
              if (bodyObj && bodyObj.data && bodyObj.data.sid) {
                  var sid = bodyObj.data.sid;
                  setState('javascript.' + instance + '.Anzeigen.Kamera.Terrasse', 'http://' + ip + ':' + port + '/webapi/SurveillanceStation/videoStreaming.cgi?api=SYNO.SurveillanceStation.VideoStream&version=1&method=Stream&cameraId=' + cameraID + '&format=mjpeg&_sid=' + sid, true);
              }
              else {
                  console.log("Invalid return on SurveillanceStation Stream URL: " + JSON.stringify(bodyObj));
                  return;
              }
          });
      }
       
      schedule("0 * * * *", function() {
          updateStreamUrl();
      });
       
      updateStreamUrl();
      

      Beste Dank

      P 1 Reply Last reply Reply Quote 0
      • P
        PeterPan @XBiT last edited by

        @xbit
        Hi, bei mir hat das große "L" im "Login" Probleme bereitet, versuche es mal mit einem kleinen "l", also "...uth&method=login&ve...."

        XBiT 1 Reply Last reply Reply Quote 0
        • XBiT
          XBiT @PeterPan last edited by XBiT

          @peterpan

          Super Besten Dank, so geht es wieder.

          PS. geht bei dir der Stream noch unter DSM7 ? ich bekomme jetzt die Meldung

          Failed to load camera.
          
          X-Content-Type-Options: nosniff
          X-XSS-Protection: 1; mode=block
          Content-type: text/plain; charset="UTF-8"
          P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
          Set-Cookie: id=XXXXX=Fri, 24-Sep-2021 13:00:17 GMT;path=/;HttpOnly
          
          {"success":true}
          
          P 1 Reply Last reply Reply Quote 0
          • P
            PeterPan @XBiT last edited by PeterPan

            @xbit
            Das sagt mir leider nichts, wo bekommst du diese Meldung und mit welchem Aufruf?

            Ich kann den genierten Link sowohl im Browser als auch im Skript unten benutzen, wobei ich einmal eine NAS mit DSM 7.0-41890 und eine noch mit DSM 6.2.4-25556 Update 2 benutze mit jeweils 2 Kameras.
            Für die VIS nutze ich den Adapter und den DP "synology.0.SurveillanceStation.cameras.Reolink-Terrasse-Front.linkMjpegHttpPath".

            Was ich mache, ist, dass ich (1) ein Snapshot für das iobroker-Verzeichnis und anschließendem Versand via Pushover mache, dann (2) ein Snapshot für die NAS sowie (3) für 6 Sekunden noch ein Film aufnehme. Allerdings habe ich Fehlerabfragen rausgenommen.

            Das Dokument Synology Surveillance Station Web API ist mit der Version 3.10 vom 22.06.2021 recht aktuell, vielleicht findest du da einen Hinweis?

            // Konfiguration
            const user = "AAA"; // Synology Benutzer mit Berechtigung die Kamera anzuzeigen
            const pass = "BBB";  // Passwort zu eben eingegebenem Benutzer
            const ip_1 = "192.168.xxx.xxx";  // IP-Adresse eures Synology-NAS
            const ip_2 = "192.168.xxx.xxx";  // IP-Adresse eures Synology-NAS
            const port = 5000;  // default Port der Surveillance Station
            var iplong_1 = 'http://' + ip_1 + ':' + port + '/webapi/';
            var iplong_2 = 'http://' + ip_2 + ':' + port + '/webapi/';
            const cameraID_Eingang = 1;
            const cameraID_Wohnzimmer = 2;
            const cameraID_Front = 3;  // ID der Kamera, welche den Garten zeigt
            const cameraID_Seite = 4;  // ID der Kamera, welche die Terrasse zeigt
            
            var request = require('request');
            var fs = require('fs');
            
            var url_login_1 = iplong_1 + 'auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=' + user + '&passwd=' + pass + '&session=SurveillanceStation&format=sid';
            var url_login_2 = iplong_2 + 'auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=' + user + '&passwd=' + pass + '&session=SurveillanceStation&format=sid';
            
            // BEWEGUNG AN DER TERRASSE
            // Einstellung für Verzögerung des BWM in der CCU noch ändern?
            on({id: path_link + 'Garten.Bewegung_Haus.Motion', val:true, change: 'ne'}, function (obj) {
                //licht();
                bewegung(iplong_1, url_login_1, cameraID_Seite);
                });
            // Gleiches für weitere Kameras ...
            /*
            =================================================================================================================
            FUNKTIONEN
            =================================================================================================================
            */
            function bewegung (iplong, url_login, cameraID){
                // EINLOGGEN IN DIE SYNOLOGY SURVEILLANCESTATION
                request(url_login, function(error, response, body){
                    var my_sid = JSON.parse(body).data.sid;
                   // ========================
                    // 2.3.4.5 GetSnapshot method
                    var url_GetSnapshot = iplong + 'entry.cgi?version=9&id='+cameraID+'&api="SYNO.SurveillanceStation.Camera"&method="GetSnapshot"&profileType=1&_sid=' + my_sid;
                    //console.log('url_GetSnapshot: ' + url_GetSnapshot);
                    // ========================
                    //2.3.34.8 TakeSnapshot method
                    var url_Snapshot = iplong + 'entry.cgi?camId='+cameraID+'&version="1"&blSave=true&api="SYNO.SurveillanceStation.SnapShot"&dsId=0&method="TakeSnapshot"&_sid=' + my_sid;
                    // ========================
                    // 2.3.10.1 (External) Record method => OK
                    var url_RecordStart = iplong + 'entry.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=1&cameraId='+cameraID+'&action=start&_sid=' + my_sid;
                    var url_RecordStop = iplong + 'entry.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=1&cameraId='+cameraID+'&action=stop&_sid=' + my_sid;
                    // ========================
                    var filename = '/home/iobroker/Snap_Reolink'+cameraID+'.jpg';
                    request.get({url: url_GetSnapshot, encoding: 'binary'}, function(error, response, body){
                        fs.writeFile(filename, body, 'binary', function(err){
                            function fake(){}
                            setTimeout(fake,1000);
                            g_pushover('Bewegung ',6,filename,'tugboat');
                            //Speichert Snapshot auch auf der Synology
                            request(url_Snapshot,function(error, response, body) {});
                            request(url_RecordStart,function(error, response, body) {});
                            setTimeout(function() {
                                // weitere Befehle
                                request(url_RecordStop,function(error, response, body) {});
                                //AUSLOGGEN
                                var url_logout = iplong + 'auth.cgi?api=SYNO.API.Auth&method=Logout&version=2&session=SurveillanceStation&_sid=' + my_sid;
                                request.get({url: url_logout, encoding: 'binary'},function (error){});
                                }, 6000);
                            });
                        });
                    });
                };
            

            Update: Vielleicht liegt es am Cookie und die SID steht dort drin? Das Ablaufdatum des Cookies scheint (gefährliches Halbwissen) ggf. der 24.09.2021 zu sein. Ich rufe den Link nicht mehr ab, sondern benutze den Adapter und den DP. Dort hat es zunächst auch nicht funktioniert, aber nachdem ich die Abrufintervalle hoch gesetzt habe, bekomme ich regelmäßige Updates in den DP.

            XBiT 1 Reply Last reply Reply Quote 0
            • XBiT
              XBiT @PeterPan last edited by

              @peterpan

              Sorry hatte ganz vergessen mich zu melden.
              Ich hatte mal die Kameras in der Synology gelöscht (woran ich nicht mehr gedacht habe) und neu angelegt, da haben sich natürlich auch die ID´s der Kameras geändert.
              Mit der richtigen ID läuft auch alles wieder wie es soll.

              Danke noch mal für die Hilfe.

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

              Support us

              ioBroker
              Community Adapters
              Donate

              564
              Online

              31.8k
              Users

              80.0k
              Topics

              1.3m
              Posts

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