NEWS
Klingelscript speichert ein Bild nicht
-
Ich habe mir aus mehreren Codescnipseln ein Klingescript zusammengeklebt.
Das funktioniert auch soweit bis auf eine Kleinigkeit die ich nicht finde.Das erste Bild wird scheinbar nicht oder unleserlich gespeichert. Woran kann das liegen?
... und irgendwas habe ich mit den Timeouts verballert
var sperre = false; //verhindert das doppeltes Drücken das Script stoppt var timeout, timeout2, timeout3; on({id: 'sonoff.0.Eingang.POWER2', change: "any"}, function (obj) { if(!sperre) { sperre = true; // Speichert das erste Bild bei Klingeln exec('wget --output-document /opt/iobroker/iobroker-data/files/temp/alarm.jpg \'http://192.168.xxx.95:8765/picture/1/current/?_username=admin&_signature=xxxxx\''); // Es wird 3000ms gewartet um dieses speichern auszuführen timeout = setTimeout(function () { // Und hier wird es versendet sendTo("email", "send", { text: '', to: 'xxxxx@gmail.com', subject: 'Klingel', attachments:[ {path: '/opt/iobroker/iobroker-data/files/temp/alarm.jpg', cid: "file1"}, ] }); }, 3000); // Nach dem ersten Bild wird nach 5000ms das nächste Bild gespeichert timeout2 = setTimeout(function () { exec('wget --output-document /opt/iobroker/iobroker-data/files/temp/alarm1.jpg \'http://192.168.xx.95:8765/picture/1/current/?_username=admin&_signature=xxxxx\''); // Es wird 3000ms gewartet um dieses speichern auszuführen timeout3 = setTimeout(function () { // Und hier wird es versendet sendTo("email", "send", { text: '', to: 'xxxxx@gmail.com', subject: 'Klingel', attachments:[ {path: '/opt/iobroker/iobroker-data/files/temp/alarm1.jpg', cid: "file1"}, ] }); }, 3000); }, 5000); } setState("vis.0.control.command", '{"instance": "FFFFFFFF", "command": "changeView", "data": "Neu/Tuer"}'); // oder //setState("vis.0.control.instance", 'FFFFFFFF'); //setState("vis.0.control.data", 'DemoView'); //setState("vis.0.control.command", 'changeView'); // muss immer letzte sein // Setze View auf Kamerabild setTimeout(function () { setState("vis.0.control.command", '{"instance": "FFFFFFFF", "command": "changeView", "data": "Neu/Info"}'); }, 60000); // Nach 60 Sekunden, zeige wieder Start View setState("tr-064.0.states.ring"/*ring*/, '**611, 15'); //Klingelt 15 Sekunden auf dem Telefon timeout = setTimeout(function () { setState("alexa2.0.Echo-Devices.Gxxxxx.Player.volume"/*volume*/, 70, true); }, 500); // Setzt Alexa auf 90% timeout = setTimeout(function () { setState("alexa2.0.Echo-Devices.Gxxxxx.Commands.speak"/*speak*/, 'Es ist jemand an der Tür'); }, 1000); // Sprachansage timeout = setTimeout(function () { setState("alexa2.0.Echo-Devices.Gxxxxx.Player.volume"/*volume*/, 50, true); }, 5000); // Setzt Alexa auf 50% setTimeout(function() { sperre = false; }, 5000); //Zeit für Klingelsperre 1.Zeile });