Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Visualisierung
    4. Bild unter vis.0 aktualisiert nicht

    NEWS

    • Amazon Alexa - ioBroker Skill läuft aus ?

    • Monatsrückblick – September 2025

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    Bild unter vis.0 aktualisiert nicht

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      saeft_2003 Most Active @coyote last edited by

      @coyote

      Ich bräuchte es so das wenn der Datenpunkt (meine-datenpunkte.0.xyz) aktualisiert wird, wird das skript einmal ausgeführt.

      Kannst du das in das skript noch mit rein machen?

      coyote 1 Reply Last reply Reply Quote 0
      • coyote
        coyote Most Active @saeft_2003 last edited by

        @saeft_2003 Guten morgen,
        da ich jetzt nicht weiß, was für ein Typ dein Datenpunkt ist, versuche es einfach mal so.

        
        var source_url = 'http://192.168.XX.XX:2000/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=XXXX&pwd=XXXX',
        dest_path = '/opt/iobroker/iobroker-data/files/vis.0/';
        
         
        var request = require("request");
        var fs      = require('fs');
        
        
        on({id: 'dein-Datenpunkt.0.XYZ', change: "any"}, function (obj) {
            request.get({url: source_url, encoding: 'binary'}, function (err, response, body) {
        
                fs.writeFile('/tmp/' + 'Postbild.jpg', body, 'binary', function(err) {
        
          if (err) {
        
                    log('Fehler beim Bild speichern: ' + err, 'warn');
        
                } else {
        
                    log('Webcam Bild gespeichert');  
        
                }
        
                })
        
            })
        
            // Bilder werden nach vis gespeichert
        
                const bild1 = fs.readFileSync('/tmp/Postbild.jpg');
        
                writeFile('vis.0','/Postbild.jpg', bild1);
        
        });
        

        Bei diesem Beispiel ist es jetzt aber so, dass egal wie sich dein Datenpunkt ändert, wird das Bild aktualisiert.
        "change: any"

        Hast du einen true/false Datenpunkt, kannst du auch statt "any" z.B. "ne" schreiben, dann wird nur getriggert wenn der Datenpunkt sich von "true" auf "false" oder umgekehrt ändert.

        S 1 Reply Last reply Reply Quote 0
        • S
          saeft_2003 Most Active @coyote last edited by

          @coyote

          Vielen Dank ich werde es testen! Der Datenpunkt ist ein Logikwert mit true false. Das mit dem aktualisiert sollte schon so passen, falls nicht kann ich any ja einfach ändern.

          Ich melde mich dann nochmal spätestens heute Abend...

          coyote 1 Reply Last reply Reply Quote 0
          • coyote
            coyote Most Active @saeft_2003 last edited by

            @saeft_2003 ok, aber wie gesagt, "any" triggert immer egal ob dein Wert von true nach false ider von false nach true wechselt

            S 1 Reply Last reply Reply Quote 0
            • S
              saeft_2003 Most Active @coyote last edited by saeft_2003

              @coyote

              ja das weiß ich, ist auch so gewollt.

              ich habe das skript jetzt angepasst, wenn ich es starte kommt kein Fehler. Sobald ich dann trigger, geht der Playbutton vom skript von grün auf gelb und das steht im log:

              avascript.0	2020-02-12 09:51:06.519	info	(821) script.js.test_test.Skript_2: Webcam Bild gespeichert
              host.iobroker	2020-02-12 09:50:46.056	warn	"system.host.iobroker-slave" is offline
              javascript.0	2020-02-12 09:50:32.916	info	(821) script.js.test_test.Skript_2: Webcam Bild gespeichert
              javascript.0	2020-02-12 09:50:25.136	info	(821) script.js.test_test.Skript_2: Webcam Bild gespeichert
              javascript.0	2020-02-12 09:50:18.803	info	(821) script.js.test_test.Skript_2: Webcam Bild gespeichert
              javascript.0	2020-02-12 09:50:18.530	error	(821) at processImmediate (timers.js:658:5)
              javascript.0	2020-02-12 09:50:18.520	error	(821) at tryOnImmediate (timers.js:676:5)
              javascript.0	2020-02-12 09:50:18.518	error	(821) at runCallback (timers.js:705:18)
              javascript.0	2020-02-12 09:50:18.515	error	(821) at Immediate.setImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:4848:37)
              javascript.0	2020-02-12 09:50:18.514	error	(821) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:439:25)
              javascript.0	2020-02-12 09:50:18.513	error	(821) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1101:38)
              javascript.0	2020-02-12 09:50:18.513	error	(821) at Object.<anonymous> (script.js.test_test.Skript_2:63:26)
              javascript.0	2020-02-12 09:50:18.512	error	(821) at ProtectFs.readFileSync (/opt/iobroker/node_modules/iobroker.javascript/lib/protectFs.js:23:36)
              javascript.0	2020-02-12 09:50:18.512	error	(821) at readFileSync (fs.js:343:35)
              javascript.0	2020-02-12 09:50:18.511	error	(821) at Object.openSync (fs.js:443:3)
              javascript.0	2020-02-12 09:50:18.510	error	(821) Error in callback: Error: ENOENT: no such file or directory, open '/tmp/dafangcurrentpic.jpg'
              

              hier das skript, Bilder speichern von der xiaomi dafang Kamera mit blockly über exec wget output document geht:

              
               
              
              var source_url = 'http://yyyyy:xxxxxxxxx@192.168.178.zzz/cgi-bin/currentpic.cgi',
              
              dest_path = '/opt/iobroker/iobroker-data/files/vis.0/';
              
               
              
               
              
              var request = require("request");
              
              var fs      = require('fs');
              
               
              
               
              
              on({id: 'meine-datenpunkte.0.Stoppe_intervall.Stoppe_intervall_kameras', change: "any"}, function (obj) {
              
                  request.get({url: source_url, encoding: 'binary'}, function (err, response, body) {
              
               
              
                      fs.writeFile('/tmp/' + 'dafangcurrentpic.jpg', body, 'binary', function(err) {
              
               
              
                if (err) {
              
               
              
                          log('Fehler beim Bild speichern: ' + err, 'warn');
              
               
              
                      } else {
              
               
              
                          log('Webcam Bild gespeichert');  
              
               
              
                      }
              
               
              
                      })
              
               
              
                  })
              
               
              
                  // Bilder werden nach vis gespeichert
              
               
              
                      const bild1 = fs.readFileSync('/tmp/dafangcurrentpic.jpg');
              
               
              
                      writeFile('vis.0','/dafangcurrentpic.jpg', bild1);
              
               
              
              });
              
              

              Vielleicht mal hiermit probieren? Weil ich vermute er kann kein Bild speichern... bzw. könnte ich die bilder auch weiter mit blockly halt dann jetzt in tmp speichern. Und das script müsste schauen wenn es ein neues bild in dem ordner tmp gibt wird es dann vis.0 verschoben. Ob das aber dann gehn würde keine Ahnung 🤔

              exec('wget --output-document /opt/iobroker/iobroker-data/files/vis.0/dafang.png http://yyyyy:xxxxxxxxx@192.168.178.zzzz/cgi-bin/currentpic.cgi');
              
              coyote 1 Reply Last reply Reply Quote 0
              • coyote
                coyote Most Active @saeft_2003 last edited by

                @saeft_2003 probier mal mit dem exec befehl, das hat bei meiner Cam nicht funktioniert, deshalb hatte ich es umgeschrieben.
                Ja, er findet wohl kein Bild unter /tmp

                S 1 Reply Last reply Reply Quote 0
                • S
                  saeft_2003 Most Active @coyote last edited by

                  @coyote

                  Ok muss ich dann nur das durch den exec befehl ersetzen?

                  var source_url = 'http://yyyyy:xxxxxxxxx@192.168.178.zzz/cgi-bin/currentpic.cgi',
                  
                  
                  coyote 1 Reply Last reply Reply Quote 0
                  • coyote
                    coyote Most Active @saeft_2003 last edited by

                    @saeft_2003 probier mal das hier, sollte so klappen:

                    var fs      = require('fs');
                    
                        // Speichert das Bild 
                    
                    on({id: 'dein-Datenpunkt.0.XYZ', change: "any"}, function (obj) {
                    
                        exec('wget --output-document /tmp/dafang.jpg \'http://yyyyy:xxxxxxxxx@192.168.178.zzzz/cgi-bin/currentpic.cgi\'');
                           
                    
                        // Bilder werden nach vis gespeichert
                    
                            const bild1 = fs.readFileSync('/tmp/dafang.jpg');
                    
                            writeFile('vis.0','/dafang.jpg', bild1);
                    
                    });
                    
                    S 2 Replies Last reply Reply Quote 1
                    • S
                      saeft_2003 Most Active @coyote last edited by

                      @coyote

                      Ok danke werde ich probieren

                      1 Reply Last reply Reply Quote 0
                      • S
                        saeft_2003 Most Active @coyote last edited by

                        @coyote

                        Vielen Dank für deine Hilfe läuft jetzt auch bei mir 🙂

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

                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        934
                        Online

                        32.3k
                        Users

                        81.0k
                        Topics

                        1.3m
                        Posts

                        vis
                        6
                        39
                        3198
                        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