Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Kamera Steuerung (PTZ) mit Bewegungsmelder htp

    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

    Kamera Steuerung (PTZ) mit Bewegungsmelder htp

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

      @kasperfunsurfer

      idMotion , Eintrag fehlt !!
      nimm mal das !

      const idMotion = ["mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state","mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state","mihome.0.devices.sensor_motion_aq2_158d0002e30682.state"];
      
      

      Nutze das Skript gerade bei meiner Hikvision ( natürlich abgeändert ), funktioniert super.
      Kamera fährt beim Klingeln in Pos 1. und nach 30 sek. in die Home Position zurück .

      Super Skript Paul !

      1 Reply Last reply Reply Quote 0
      • K
        kasperfunsurfer last edited by kasperfunsurfer

        Servus,

        nee das ist es leider auch nicht. Die Kamera fährt keine Position mehr an sowie die Bewegungsmelder werden nicht zurück gesetzt. 😢

        Die Änderung hat doch was gebracht. Kamera fährt aber immer nur in eine Position nicht in die andere.
        Bewegungsmelder mihome.0.devices.sensor_motion_aq2_158d0002e30682.state Funktioniert mit 15sec. die anderen leider nicht.

        17:51:21.182 info javascript.0 Stop script script.js.Skript_57_enu
        17:51:22.034 info javascript.0 Start javascript script.js.Skript_57_enu
        17:51:22.035 info javascript.0 script.js.Skript_57_enu: registered 3 subscriptions and 0 schedules
        17:51:30.992 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true
        17:51:45.998 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: false
        17:51:59.304 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state: true
        17:51:59.305 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true
        17:53:59.129 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state: false

        paul53 1 Reply Last reply Reply Quote 0
        • paul53
          paul53 @kasperfunsurfer last edited by

          @kasperfunsurfer sagte:

          17:51:59.304 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state: true
          17:51:59.305 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true

          Zwischen beiden BWM ist nur 1 ms Abstand ! Wie kann das sein ?

          K 1 Reply Last reply Reply Quote 0
          • K
            kasperfunsurfer @paul53 last edited by kasperfunsurfer

            @paul53 hier nochmal das Script.

            const idMotion = ["mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state","mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state","mihome.0.devices.sensor_motion_aq2_158d0002e30682.state"];
            const url = 'http://******@192.168.2.110:81'; 
            var timer = null;
            
             
            
            on(idMotion, function(dp) {
            
            log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
               
               if(dp.state.val && !timer) { // Bewegung erkannt
            
               var pos = 0;
            
                  if(dp.id = 'mihome.0.devices.sensor_motion_aq2_158d0002e30682.state') pos = 1;
            
                  request(url + '/param.cgi?cmd=preset&-act=goto&-number=' + pos);
            
                  
                  timer = setTimeout(function() {
            
                     request(url + '/CGI-COMMAND/param.cgi?cmd=pushhostalarm');
            
                     setState(dp.id, false);  
            
                     timer = null;
            
                  }, 15000); // nach 15 s
            
               }
            
            });
            

            Wenn ich den denn mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state auf True setzte oder den den mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state: true kommt der andere Automatisch mit ?? Aber nur in dem Script in echt unter Objekte passiert das nicht da bleibt der mihome.0.devices.sensor_motion_aq2_158d0002e30682.state auf flase

            18:08:55.661 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state: true
            18:08:55.662 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true
            18:10:55.475 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state: false
            18:11:01.966 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state: true
            18:11:01.969 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true
            18:13:01.779 info javascript.0 script.js.Skript_57_enu: mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state: false

            paul53 1 Reply Last reply Reply Quote 0
            • paul53
              paul53 @kasperfunsurfer last edited by

              @kasperfunsurfer
              Dann versuche es mal mit getrennten Triggern

              const idMotion1 = "mihome.0.devices.sensor_motion_aq2_158d000236b7e6.state";
              const idMotion2 = "mihome.0.devices.sensor_motion_aq2_158d0002e922d3.state";
              const idMotion3 = "mihome.0.devices.sensor_motion_aq2_158d0002e30682.state";
              const url = 'http://******@192.168.2.110:81'; 
              
              var timer = null;
              
              function kamera(id, pos) {
                 request(url + '/param.cgi?cmd=preset&-act=goto&-number=' + pos);
                 timer = setTimeout(function() {
                    request(url + '/CGI-COMMAND/param.cgi?cmd=pushhostalarm');
                    setState(id, false);  
                    timer = null;
                    log('Verzögert: ' + id);
                 }, 15000); // nach 15 s
              }
              
              on(idMotion1, function(dp) {
                 log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                 if(dp.state.val && !timer) kamera(dp.id, 0);
              });
              
              on(idMotion2, function(dp) {
                 log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                 if(dp.state.val && !timer) kamera(dp.id, 0);
              });
              
              on(idMotion3, function(dp) {
                 log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                 if(dp.state.val && !timer) kamera(dp.id, 1);
              });
              
              1 Reply Last reply Reply Quote 0
              • K
                kasperfunsurfer last edited by

                @paul53 mal wieder sauber. So klappt es 👍 👍

                Wie war das jetzt mit der Funktion Abwesend ? Ist das so richtig ?

                const idAbwesend = 'hm-rega.950';
                
                on(idMotion1, function(dp) {
                
                   log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                
                   if(dp.state.val && !timer && getState(idAbwesend).val) kamera(dp.id, 0);
                
                });
                
                 
                
                on(idMotion2, function(dp) {
                
                   log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                
                   if(dp.state.val && !timer  && getState(idAbwesend).val) kamera(dp.id, 0);
                
                });
                
                 
                
                on(idMotion3, function(dp) {
                
                   log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                
                   if(dp.state.val && !timer && getState(idAbwesend).val) kamera(dp.id, 1);
                
                });
                
                paul53 1 Reply Last reply Reply Quote 0
                • paul53
                  paul53 @kasperfunsurfer last edited by paul53

                  @kasperfunsurfer sagte:

                  Ist das so richtig ?

                  Ja.
                  Besser nur einmal in der Funktion abfragen.

                  const url = 'http://******@192.168.2.110:81'; 
                  const idMotion  = "mihome.0.devices.sensor_motion_aq2_158d000";
                  const idMotion1 = idMotion + "236b7e6.state";
                  const idMotion2 = idMotion + "2e922d3.state";
                  const idMotion3 = idMotion + "2e30682.state";
                  const idAbwesend = 'hm-rega.950';
                  
                  var timer = null;
                  
                  function kamera(id, pos) {
                     if(getState(idAbwesend).val && !timer) {	
                        request(url + '/param.cgi?cmd=preset&-act=goto&-number=' + pos);
                        timer = setTimeout(function() {
                           request(url + '/CGI-COMMAND/param.cgi?cmd=pushhostalarm');
                           setState(id, false);  
                           timer = null;
                           log('Verzögert: ' + id);
                        }, 15000); // nach 15 s
                     }
                  }
                  
                  on(idMotion1, function(dp) {
                     log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                     if(dp.state.val) kamera(dp.id, 0);
                  });
                  
                  on(idMotion2, function(dp) {
                     log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                     if(dp.state.val) kamera(dp.id, 0);
                  });
                  
                  on(idMotion3, function(dp) {
                     log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                     if(dp.state.val) kamera(dp.id, 1);
                  });
                  
                  1 Reply Last reply Reply Quote 0
                  • K
                    kasperfunsurfer last edited by kasperfunsurfer

                    Hmm das gibt es schon wieder kleine Probleme

                    19:44:14.373 info javascript.0 Stop script script.js.Skript_158_neuer
                    19:44:14.415 info javascript.0 Start javascript script.js.Skript_158_neuer
                    19:44:14.416 info javascript.0 script.js.Skript_158_neuer: registered 3 subscriptions and 0 schedules
                    19:45:00.948 info javascript.0 script.js.Skript_158_neuer: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: true
                    19:45:00.951 warn javascript.0 at kamera (script.js.Skript_158_neuer:11:7)
                    19:45:00.952 warn javascript.0 at Object.<anonymous> (script.js.Skript_158_neuer:34:21)
                    19:47:00.758 info javascript.0 script.js.Skript_158_neuer: mihome.0.devices.sensor_motion_aq2_158d0002e30682.state: false

                    paul53 1 Reply Last reply Reply Quote 0
                    • paul53
                      paul53 @kasperfunsurfer last edited by

                      @kasperfunsurfer
                      Damit ich ich die Zeilennummern in den Warnungen zuordnen kann, muss ich das Skript so sehen, wie es bei Dir läuft.

                      1 Reply Last reply Reply Quote 0
                      • K
                        kasperfunsurfer last edited by kasperfunsurfer

                        const url = 'http://+++++@192.168.2.110:81'; 
                        const idMotion  = "mihome.0.devices.sensor_motion_aq2_158d000";
                        const idMotion1 = idMotion + "236b7e6.state";
                        const idMotion2 = idMotion + "2e922d3.state";
                        const idMotion3 = idMotion + "2e30682.state";
                        const idAbwesend = 'hm-rega.950';
                        
                         var timer = null;
                        
                           function kamera(id, pos) {
                           if(getState(idAbwesend).val && !timer) {	
                              request(url + '/param.cgi?cmd=preset&-act=goto&-number=' + pos);
                              timer = setTimeout(function() {
                              request(url + '/CGI-COMMAND/param.cgi?cmd=pushhostalarm');
                              setState(id, false);  
                              timer = null;
                                log('Verzögert: ' + id);
                              }, 10000); // nach 10 s
                         }
                        }
                        
                         on(idMotion1, function(dp) {
                           log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                           if(dp.state.val) kamera(dp.id, 0);
                        });
                        
                         on(idMotion2, function(dp) {
                           log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                           if(dp.state.val) kamera(dp.id, 0);
                        });
                        
                         on(idMotion3, function(dp) {
                           log(dp.id + ': ' + dp.state.val); // eingefügte Log-Zeile
                           if(dp.state.val) kamera(dp.id, 1);
                        });
                        

                        Der Bewegungsmelder setzt sich auch wieder nicht zurück.....

                        paul53 1 Reply Last reply Reply Quote 0
                        • paul53
                          paul53 @kasperfunsurfer last edited by

                          @kasperfunsurfe:

                          const idAbwesend = 'hm-rega.950';

                          Fehlt da nicht die Instanz-Nummer ?

                          const idAbwesend = 'hm-rega.0.950';
                          
                          K 1 Reply Last reply Reply Quote 0
                          • K
                            kasperfunsurfer @paul53 last edited by

                            @paul53 ja logisch Sorry mein Fehler. Jetzt passt es. Noch mal vielen vielen DANK...….

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

                            Support us

                            ioBroker
                            Community Adapters
                            Donate

                            879
                            Online

                            31.9k
                            Users

                            80.1k
                            Topics

                            1.3m
                            Posts

                            3
                            45
                            1921
                            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