Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. Tuya Doorbell Script

    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

    Tuya Doorbell Script

    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User last edited by A Former User

      Hi, ich verwende folgendes Script, um mir das Bild von der Doorbell per Synology-Chat schicken zu lassen.
      Das hat auch mal gut funktioniert, auf einmal wird aber das Bild in /synology/Doorbell.jpg nicht mehr ueberschrieben, er schickt mir immer das gleiche Bild.. 😞
      Loesche ich es mit der Hand, dann stimmt das naechste wieder, aber dann wieder nicht mehr..

      Hat jemand ne Idee, was das sein koennte? Hab so die Timeouts in Verdacht.. ??

      @Glasfaser war das Script so aehnlich von dir?

      var URL_Chat, URL_ioBroker, URL_Snapshot, Nachricht, timeout, send, timeout2, result;
      
      async function Bild_holen() {
            request({url: URL_Snapshot,encoding: null,},
                (error, response, body) => {if (!error && body) {writeFile("0_userdata.0", "/synology/Doorbell.jpg", body, error);
             }
           }
           );
          }
      
      
      URL_Chat = 'http://192.168.0.63:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=SYNOTOKEN&payload={"text":"';
      URL_ioBroker = 'http://192.168.3.41:81/0_userdata.0/synology/Doorbell.jpg';
      URL_Snapshot = getState('tuya.0.bf72e9be420184d658hjd0.154'/*doorbell pic*/).val;
      Nachricht = 'Camera Doorbell:';
      
      on({id: 'tuya.0.bf72e9be420184d658hjd0.154', change: "any"}, async function (obj) {
        var value = obj.state.val;
        var oldValue = obj.oldState.val;
        await Bild_holen();
      
       (function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
       (function () {if (timeout2) {clearTimeout(timeout2); timeout2 = null;}})();
        
        timeout = setTimeout(async function () {
         send = [URL_Chat,String(Nachricht) + '", "file_url": "',URL_ioBroker,'"}'].join('');
         timeout2 = setTimeout(async function () {
            try {
             require("request")(send, async function (error, response, result) {
               console.log(result);
              }).on("error", function (e) {console.error(e);});
            } catch (e) { console.error(e); }
           console.log(send);
            }, 1000);
        }, 2000);
       });
      
      
      Glasfaser 1 Reply Last reply Reply Quote 0
      • Glasfaser
        Glasfaser @Guest last edited by Glasfaser

        @ilovegym sagte in Tuya Doorbell Script:

        Loesche ich es mit der Hand,

        ich lösche es per :

        unlink('0_userdata.0', 'synology/bild1.jpg',(e)=>{
        
            if(e) log(e)
        
        })
        

        var URL_Chat, URL_ioBroker, URL_Snapshot, Nachricht, timeout, send, timeout2, timeout3, result;
        
        // Beschreibe diese Funktion …
        async function loesche_Bild() {
           unlink('0_userdata.0', 'synology/bild1.jpg',(e)=>{
           
               if(e) log(e)
           
           })
           
        
        }
        
        // Beschreibe diese Funktion …
        async function Bild_holen() {
           
           
           
           request(
           
             {
           
               url: URL_Snapshot ,
           
               encoding: null,
           
             },
           
             (error, response, body) => {
           
               if (!error && body) timeout7 = setTimeout(function (){
           
                 writeFile("0_userdata.0", "/synology/bild1.jpg", body);
           
               }, 3000);
           
             }
           
           );
           
        
        }
        
        
        URL_Chat = 'http://192.168.xxx.xx:5000/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=xxxxxxxxxxxxxxxxxx&payload={"text":"';
        URL_ioBroker = 'http://192.168.xxx.xx:8082/0_userdata.0/synology/bild1.jpg';
        URL_Snapshot = getState("synology.0.SurveillanceStation.cameras.Haustür.linkSnapshot").val;
        Nachricht = 'Es klingelt an der Haustuer';
        on({id: 'default', change: "ne"}, async function (obj) {
         var value = obj.state.val;
         var oldValue = obj.oldState.val;
         await Bild_holen();
         (function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
         (function () {if (timeout2) {clearTimeout(timeout2); timeout2 = null;}})();
         timeout = setTimeout(async function () {
           send = [URL_Chat,String(Nachricht) + '", "file_url": "',URL_ioBroker,'"}'].join('');
           timeout2 = setTimeout(async function () {
             try {
               require("request")(send, async function (error, response, result) {
                 console.log(result);
               }).on("error", function (e) {console.error(e);});
             } catch (e) { console.error(e); }
             timeout3 = setTimeout(async function () {
               await loesche_Bild();
             }, 7000);
             console.log(send);
           }, 4000);
         }, 2000);
        });
        

        ? 1 Reply Last reply Reply Quote 0
        • ?
          A Former User @Glasfaser last edited by

          @glasfaser

          Danke, aber es mag nicht…

          Wenn ich mir das Bild mit wget nach /opt/iobroker/pics/Doorbell.jpg hole, das klappt.
          Von dort kann ich es ja nicht an den Chat senden, es muss ja nach userdata/xxx …
          Hmpf

          Glasfaser 1 Reply Last reply Reply Quote 0
          • Glasfaser
            Glasfaser @Guest last edited by

            @ilovegym

            Hast du mal mein Script genutzt !?

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

            Support us

            ioBroker
            Community Adapters
            Donate

            841
            Online

            31.8k
            Users

            80.0k
            Topics

            1.3m
            Posts

            communication javascript multimedia
            2
            4
            297
            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