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: Bild von Motioneye nach VIS kopieren mit JavaScript

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Gelöst: Bild von Motioneye nach VIS kopieren mit JavaScript

    This topic has been deleted. Only users with topic management privileges can see it.
    • Chaot
      Chaot @Digi-Bit last edited by

      @digi-bit Ich bin mir nicht ganz sicher, aber ich glaube mich erinnern zu können das man in den Ordner VIS.0 nicht mehr direkt schreiben kann.
      Meine Bilder landen in:

      const img_path = '/opt/iobroker/iobroker-data/files/0_userdata.0';
      
      D 1 Reply Last reply Reply Quote 0
      • D
        Digi-Bit @Chaot last edited by

        @chaot

        Hi,

        Naja, also ich habe vorher ein Bild mit den VIS Dateimanga ein Bild handlich eingefügt und mit dem Script überschreibe ich das ja immer und das funktioniert so auch wunderbar so das ich immer im VIS auch "ein" Bild von der Kamera habe wo Motioneye eine Bewegung war genommen hat, aber ebent nicht DAS Bild sondern eins von der Kamera was leider dann auch noch sec. später erst gemacht wurde.

        Irgend wo habe ich das mal gesehen das man eine Datei aus einem datenpunkt verschieben kann ich weis aber nicht mehr wo und wie das war leider 😞

        mfg

        Digi-Bit

        Chaot 1 Reply Last reply Reply Quote 0
        • Chaot
          Chaot @Digi-Bit last edited by

          @digi-bit Manuell einfügen klappt ja auch. Ich hatte das früher auch an der Stelle. Aber irgendwann hat das nicht mehr funktioniert und ich habe den Ordner gewechselt. Zumal der 0_userdata.0 genau für solche Zwecke vorgesehen ist.

          D 1 Reply Last reply Reply Quote 0
          • D
            Digi-Bit @Chaot last edited by

            @chaot

            Ich habe das Gefühl das wir aneinander vorbei reden.
            Soweit funktioniert das ja alles !!!!!!!!!


            exec('ffmpeg -loglevel fatal -i rtsp://xxxxx:yxyxyxyx@xxx.xxx.xxx.xxx:554/h264Preview_01_main -vframes 1 -y -r 1 /tmp/Vorne.jpg');

            Ich denke nur das dieser teil ausgetauscht werden muss nach:

            nehme bild aus datenpunkt " 0_userdata.0.10_VIS-TAB8.motioneye.getLastPic " mit dem Path "/var/snap/motioneye/common/media/Camera2/2022-11-20/18-05-30_04.jpg" der momentan in diesem datenpunkt steht.


            Leider habe ich nicht die Ahnung von Java das ich das selber schreiben kann.... und hoffe das hier einer ist der das für mich übersetzen kann 👼

            mfg

            Digi-Bit

            bahnuhr 1 Reply Last reply Reply Quote 0
            • bahnuhr
              bahnuhr Forum Testing Most Active @Digi-Bit last edited by

              @digi-bit

              du holst das bild von deiner cam und speicherst dies in /tmp/Vorne.jpg

              10 Sek. später holst du /tmp/Vorne.jpg und speicherst es in ...Sonstige/snapshot.png

              Warum soll das Bild 1 von dem Bild 2 abweichen.

              kann doch eigentlich gar nicht sein, oder ?

              crunchip 1 Reply Last reply Reply Quote 0
              • crunchip
                crunchip Forum Testing Most Active @Digi-Bit last edited by

                @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                Javascript aber mit einem Bild direkt von der Kamera.

                dann hol es doch von motioneye
                ich mach das z.b. so, allerdings ausserhalb des iobroker Ordners, wegen dem nicht mehr diekt hineinschreiben dürfen, dazu gibt es aber mehrere Threads dazu

                var request = require('request');
                var fs      = require('fs');
                 
                function sendImage() {
                    request.get({url: 'http://deinebildquelle', encoding: 'binary'}, function (err, response, body) {
                        fs.writeFile("/opt/iobroker/ipcam/pi.jpg", body, 'binary', function(err) {
                 
                        if (err) {
                            console.error(err);
                        } else {
                            //console.log('Snapshot sent');
                            sendTo('telegram.1', '/opt/iobroker/ipcam/pi.jpg');
                            //sendTo('telegram.0', {text: '/tmp/snap.jpg', caption: 'Snapshot'});
                         }
                       });
                     });
                 }
                
                D 1 Reply Last reply Reply Quote 0
                • crunchip
                  crunchip Forum Testing Most Active @bahnuhr last edited by

                  @bahnuhr stimmt schon, du kannst dir ein Bild von der Cam holen, oder wenn motioneye etwas erkennt und ein Bild macht, vergleichst du dann beide, stellst man einen Versatz fest.

                  bahnuhr 1 Reply Last reply Reply Quote 0
                  • bahnuhr
                    bahnuhr Forum Testing Most Active @crunchip last edited by bahnuhr

                    @crunchip sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                    @bahnuhr stimmt schon, du kannst dir ein Bild von der Cam holen, oder wenn motioneye etwas erkennt und ein Bild macht, vergleichst du dann beide, stellst man einen Versatz fest.

                    ja, genau.

                    Aber sein Script war ja, direkt von der cam und dann speichern.
                    Dürfte kein Unterschied sein.

                    Die Frage ist halt, was er will ?!?!

                    crunchip 1 Reply Last reply Reply Quote 0
                    • crunchip
                      crunchip Forum Testing Most Active @bahnuhr last edited by

                      @bahnuhr sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                      was er will

                      das Bild was motioneye selbst gemacht hat, soweit ich verstanden habe

                      @Digi-Bit oder schau mal HIER

                      D 1 Reply Last reply Reply Quote 0
                      • D
                        Digi-Bit @crunchip last edited by

                        @crunchip sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                        @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                        Javascript aber mit einem Bild direkt von der Kamera.

                        dann hol es doch von motioneye
                        ich mach das z.b. so, allerdings ausserhalb des iobroker Ordners, wegen dem nicht mehr diekt hineinschreiben dürfen, dazu gibt es aber mehrere Threads dazu

                        var request = require('request');
                        var fs      = require('fs');
                         
                        function sendImage() {
                            request.get({url: 'http://deinebildquelle', encoding: 'binary'}, function (err, response, body) {
                                fs.writeFile("/opt/iobroker/ipcam/pi.jpg", body, 'binary', function(err) {
                         
                                if (err) {
                                    console.error(err);
                                } else {
                                    //console.log('Snapshot sent');
                                    sendTo('telegram.1', '/opt/iobroker/ipcam/pi.jpg');
                                    //sendTo('telegram.0', {text: '/tmp/snap.jpg', caption: 'Snapshot'});
                                 }
                               });
                             });
                         }
                        

                        Hi,

                        Ja denke das kommt schon fast so hin in die richtung.

                        ich will ja keine URL sonder einen datenpunkt haben "0_userdata.0.10_VIS-TAB8.motioneye.takeSnapshot"
                        in diesen datenpunkt steht ja der Path zu dem letzten snapshot von M*Eye im meinem fall grade der " /var/snap/motioneye/common/media/Camera2/2022-11-20/18-05-30_04.jpg "

                        /opt/iobroker/ipcam/pi.jpg

                        das müste nach meinem script ja dann " 'vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png' " sein.....

                        nur wen ich das so in deinem script einsetze sieht das sehr komisch aus

                        var request = require('request');
                        var fs      = require('fs');
                         
                        function sendImage() {
                            request.get({'0_userdata.0.10_VIS-TAB8.motioneye.takeSnapshot', encoding: 'binary'}, function (err, response, body) {
                                fs.writeFile("vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png", body, 'binary', function(err) {
                         
                                if (err) {
                                    console.error(err);
                                } else {
                                    //console.log('Snapshot sent');
                                    sendTo('telegram.1', '/opt/iobroker/ipcam/pi.jpg');
                                    //sendTo('telegram.0', {text: '/tmp/snap.jpg', caption: 'Snapshot'});
                                 }
                               });
                             });
                         }
                        
                        

                        kann das noch einer richtig stellen in dem script das es geht ? 😇

                        mfg

                        Digi-Bit

                        1 Reply Last reply Reply Quote 0
                        • D
                          Digi-Bit @crunchip last edited by

                          @crunchip sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                          @bahnuhr sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                          was er will

                          das Bild was motioneye selbst gemacht hat, soweit ich verstanden habe

                          @Digi-Bit oder schau mal HIER

                          Naja.... eigentlich nicht weil das das bild ja auch von HTTP kommt.

                          ich habe ein Bild..... nur ebent mit verschiedenen Endungen und Datums Merkmale was in verschiedenen dir's liegt von M*Eye

                          das einzige was ich konstant habe ist der "Lagerort" des Path's zum Bild nämlich "0_userdata.0.10_VIS-TAB8.motioneye.getLastPic"

                          mfg

                          D 1 Reply Last reply Reply Quote 0
                          • D
                            Digi-Bit @Digi-Bit last edited by

                            Wie muss man den das Script ändern das es dann geht ?

                            var request = require('request');
                            var fs      = require('fs');
                             
                            function sendImage() {
                                request.get({'0_userdata.0.10_VIS-TAB8.motioneye.takeSnapshot', encoding: 'binary'}, function (err, response, body) {
                                              [^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^]
                                    fs.writeFile("vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png", body, 'binary', function(err) {
                             
                                    if (err) {
                                        console.error(err);
                                    } else {
                                        //console.log('Snapshot sent');
                                        sendTo('telegram.1', '/opt/iobroker/ipcam/pi.jpg');
                                        //sendTo('telegram.0', {text: '/tmp/snap.jpg', caption: 'Snapshot'});
                                     }
                                   });
                                 });
                             }
                             
                            
                            

                            kann mir da noch jemand Helfen ?

                            mfg

                            Digi-Bit

                            D 1 Reply Last reply Reply Quote 0
                            • D
                              Digi-Bit @Digi-Bit last edited by

                              also eigentlich reicht ja das

                              var fs = require('fs');
                               
                              var timeout1
                               
                               
                                  timeout1 = setTimeout(function () {
                               
                                     
                               
                                       const picture= fs.readFileSync('/var/snap/motioneye/common/media/Camera2/2022-11-20/20-25-50_02.jpg');
                               
                                      writeFile('vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png', picture, function (error) { });
                               
                               
                               
                                  }, 10000);
                              

                              Also so funktioniert das ja.

                              nur ändert sich der Path ja immer da ich ja 3 Kammeras habe

                              der Aktuelle Path steht in 0_userdata.0.10_VIS-TAB8.motioneye.getLastPic drin.

                              wie bekomme ich das jetzt als variable ind die zele da rein.

                              irgend wie muss das ja so in der art sein

                              var fs = require('fs');
                               
                              var timeout1
                               
                               
                                  timeout1 = setTimeout(function () {
                               
                                      phat+dateiname = ist wert aus datenpunkt =  0_userdata.0.10_VIS-TAB8.motioneye.getLastPic
                               
                                      const picture= fs.readFileSync('/path+dateiname.jpg');
                               
                                      writeFile('vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png', picture, function (error) { });
                               
                               
                               
                                  }, 10000);
                              
                              

                              kann mir das einer in Java Script übersetzen ?

                              mfg

                              Digi-Bit

                              1 Reply Last reply Reply Quote 0
                              • crunchip
                                crunchip Forum Testing Most Active last edited by

                                @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                sonder einen datenpunkt haben

                                eigentlich willst du doch das direkt abgespeicherte Bild was durch motioneye abgelegt wurde?

                                @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                was in verschiedenen dir's liegt

                                ja und?

                                @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                nur ändert sich der Path ja immer da ich ja 3 Kammeras habe

                                ich blicks grad nicht, wo willst du ein Bild holen und woher kommt das bzw wie?

                                Chaot D 2 Replies Last reply Reply Quote 0
                                • Chaot
                                  Chaot @crunchip last edited by Chaot

                                  @crunchip
                                  Ich glaube ich habe das jetzt kapiert.

                                  Unter dem Datenpunkt
                                  0_userdata.0.10_VIS-TAB8.motioneye.getLastPic
                                  steht der aktuelle Pfad zum Bild.

                                  Das soll dann von dem Pfad (der sich wegen der 3 Kameras ständig ändert) geholt werden und in dem Pfad
                                  'vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png'
                                  umbenannt und gespeichert werden.

                                  D 1 Reply Last reply Reply Quote 0
                                  • D
                                    Digi-Bit @crunchip last edited by

                                    @crunchip sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                    @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                    sonder einen datenpunkt haben

                                    eigentlich willst du doch das direkt abgespeicherte Bild was durch motioneye abgelegt wurde?

                                    Genau

                                    @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                    was in verschiedenen dir's liegt

                                    ja und?

                                    ahha

                                    @digi-bit sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                    nur ändert sich der Path ja immer da ich ja 3 Kammeras habe

                                    ich blicks grad nicht, wo willst du ein Bild holen und woher kommt das bzw wie?

                                    ich weiss nicht, drück ich mich so doof aus ?

                                    das bild kommt von Motioneye wird in /var/snap/motioneye/common/media/Camerax/datum/ gespeichtert.

                                    der speicherpunkt liegt in den userdaten "0_userdata.0.10_VIS-TAB8.motioneye.getLastPic"

                                    steht aber eigentlich alles schon Paar mal da !

                                    mfg

                                    1 Reply Last reply Reply Quote 0
                                    • D
                                      Digi-Bit @Chaot last edited by

                                      @chaot sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                      @crunchip
                                      Ich glaube ich habe das jetzt kapiert.

                                      Unter dem Datenpunkt
                                      0_userdata.0.10_VIS-TAB8.motioneye.getLastPic
                                      steht der aktuelle Pfad zum Bild.

                                      Das soll dann von dem Pfad (der sich wegen der 3 Kameras ständig ändert) geholt werden und in dem Pfad
                                      'vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png'
                                      umbenannt und gespeichert werden.

                                      Treffer

                                      mfg

                                      D 1 Reply Last reply Reply Quote 0
                                      • D
                                        Digi-Bit @Digi-Bit last edited by

                                        Ich hab es es selber rausgefunden obwohl ich keine Ahnung von Java eigentlich habe

                                        var fs = require('fs');
                                        
                                            dest_path = getState("0_userdata.0.10_VIS-TAB8.motioneye.getLastPic").val;
                                        
                                        var timeout1
                                         
                                         
                                            timeout1 = setTimeout(function () {
                                         
                                               
                                         
                                                 const picture= fs.readFileSync(dest_path);
                                         
                                                writeFile('vis.0','/Samsung-Tab8/Meine_Icons/Sonstige/snapshot.png', picture, function (error) { });
                                         
                                         
                                         
                                            }, 20000);
                                        
                                            
                                        

                                        trotzdem danke ^^

                                        mfg

                                        Digi-Bit

                                        Chaot 1 Reply Last reply Reply Quote 1
                                        • Chaot
                                          Chaot @Digi-Bit last edited by

                                          @digi-bit Da war ich wohl zu langsam beim Schreiben.
                                          Ich denke das das mit dem variablen Pfad keiner (auch ich) richtig verstanden hat am Anfang.

                                          D 1 Reply Last reply Reply Quote 0
                                          • D
                                            Digi-Bit @Chaot last edited by

                                            @chaot sagte in Bild von Motioneye nach VIS kopieren mit JavaScript:

                                            @digi-bit Da war ich wohl zu langsam beim Schreiben.
                                            Ich denke das das mit dem variablen Pfad keiner (auch ich) richtig verstanden hat am Anfang.

                                            ja, so kommt mir das auch vor obwohl ich das oben geschrieben habe und mehrmals erwähnt habe.....

                                            schade eigentlich aber nun geht es ja.....

                                            ich weis nur nicht ob das so "sauber" geschrieben ist , vielleicht hat der eine oder andere ja noch Verbesserungen einzubringen ............

                                            mfg

                                            Digi-Bit

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

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            1.1k
                                            Online

                                            31.7k
                                            Users

                                            79.7k
                                            Topics

                                            1.3m
                                            Posts

                                            javascript
                                            6
                                            24
                                            1060
                                            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