Beiträge von svenbuer

VPN/Proxy erkannt

Es scheint, dass Sie einen VPN- oder Proxy-Dienst verwenden. Bitte beachten Sie, dass die Nutzung eines solchen Dienstes die Funktionalität dieser Webseite einschränken kann.

    Das Script hat Dekat für mich geschrieben und ich hab es dann in Betrieb genommen, funktioniert auch bestens.

    Hab das Script nochmal vom Shelly in der Garage kopiert.

    Jetzt sollte alles drin sein.

    var intervall= 60, //Humidity Checking Intervall, in Seconds

    remoteIP= "192.168.0.34", //Remote Shelly IP, as String

    hum_delta_min= -20, //Hum_min negativ Delta, to turn on, 0 if not needed

    hum_delta_max= 20, //Hum_max postiv Delta, to turn off, 0 if not needed

    debug= true;

    //Wenn die Luftfeuchtigkeit um einen gewissen Wert außen niedriger ist, wie in der Garage, soll das Relay des Shelly Plus 1 in der Garage geschlossen werden.

    function Check_Loop(res){

    try{

    if(res.code !== 200) return; //Exit if wrong Response

    let extern_hum= Number(JSON.parse(res.body).rh); //Getting remote Humidity Value

    let intern_hum= Number(Status('Humidity', 100).rh); //Getting local Humidity Value

    let hum_Delta= extern_hum-intern_hum; //Calc hum Delta

    if(debug) print('Debug: Hum delta-->',hum_Delta,'ext_h-->',extern_hum,'int_h-->',intern_hum); //Debug output

    if(hum_delta_min && hum_Delta < hum_delta_min) Call("Switch.set",{id:0,on:true},null,null,debug); //Switching Relay Channed 0 on

    if(hum_delta_max && hum_Delta > hum_delta_max) Call("Switch.set",{id:0,on:false},null,null,debug); //Switching Relay Channel 0 off

    }catch(e){ErrorMsg(e,'Check_Loop()');} //Error Handler

    }

    let tH1= 0; //Timer Handler

    function Main(){

    if(!tH1) Timer.set(1000*intervall,true,function(){ //Endless Loop

    Call("http.get",{url: "", timeout: 5},Check_Loop,null,debug); //Call Remote Shelly

    });

    }

    // Dekats Toolbox, a universal Toolbox for Shelly scripts

    function ErrorChk(r,e,m,d){ //Shelly.call error check

    try{

    aC--; if(aC<0) aC= 0;

    if(d.CB && d.uD) d.CB(r,d.uD); if(d.CB && !d.uD) d.CB(r);

    if(!d.CB && d.uD) print('Debug: ',d.uD); if(e) throw new Error(Str(m));

    if(Str(r) && Str(r.code) && r.code !== 200) throw new Error(Str(r));

    }catch(e){ErrorMsg(e,'ErrorChk(), call Answer');}}

    function Cqueue(){ //Shelly.call queue

    try{

    if(!cCache[0] && !nCall[0]) return;

    while(cCache[0] && aC < callLimit){if(cCache[0] && !nCall[0]){nCall= cCache[0]; cCache.splice(0,1);}

    if(nCall[0] && aC < callLimit){Call(nCall[0],nCall[1],nCall[2],nCall[3],nCall[4]); nCall= [];}} if(tH9){Timer.clear(tH9); tH9= 0;}

    if(nCall[0] || cCache[0])if(cSp <= 0) cSp= 0.1; tH9= Timer.set(1000*cSp,0,function(){tH9= 0; Cqueue();});}catch(e){ErrorMsg(e,'Cqueue()');}}

    function Call(m,p,CB,uD,deBug){ //Upgrade Shelly.call

    try{

    let d= {};

    if(deBug) print('Debug: calling:',m,p); if(CB) d.CB= CB; if(Str(uD)) d.uD= uD; if(!m && CB){CB(uD); return;}

    if(aC < callLimit){aC++; Shelly.call(m,p,ErrorChk,d);}else if(cCache.length < cacheLimit){

    cCache.push([m,p,CB,uD,deBug]); if(deBug) print('Debug: save call:',m,p,', call queue now:',cCache.length); Cqueue();

    }else{throw new Error('to many Calls in use, droping call: '+Str(m)+', '+Str(p));}}catch(e){ErrorMsg(e,'Call()');}}

    function Str(d){ //Upgrade JSON.stringify

    try{

    if(d === null || d === undefined) return null; if(typeof d === 'string')return d;

    return JSON.stringify(d);}catch(e){ErrorMsg(e,'Str()');}}

    function Cut(f,k,o,i){ //Upgrade slice f=fullData, k=key-> where to cut, o=offset->offset behind key, i=invertCut

    try{

    let s= f.indexOf(k); if(s === -1) return; if(o) s= s+o.length || s+o; if(i) return f.slice(0,s);

    return f.slice(s);}catch(e){ErrorMsg(e,'Cut()');}}

    function Setup(){ //Wating 2sek, to avoid a Shelly FW Bug

    try{

    if(Main && !tH9){tH9= Timer.set(2000,0,function(){print('\nStatus: started Script _[', scriptN,']_');

    if(callLimit > 5){callLimit= 5;} try{Main();}catch(e){ErrorMsg(e,'Main()'); tH9= 0; Setup();}});}}catch(e){ErrorMsg(e,'Setup()');}}

    function ErrorMsg(e,s,deBug){ //Toolbox formatted Error Msg

    try{

    let i= 0; if(Cut(e.message, '-104: Timed out')) i= 'wrong URL or device may be offline';

    if(s === 'Main()' || deBug) i= e.stack; if(Cut(e.message, '"Main" is not')) i= 'define a Main() function before using Setup()';

    print('Error:',s || "",'---> ',e.type,e.message); if(i) print('Info: maybe -->',i);}catch(e){print('Error: ErrorMsg() --->',e);}}

    var tH8= 0, tH9= 0, aC= 0, cCache= [], nCall= [], callLimit= 5, cacheLimit= 40, cSp= 0.1; //Toolbox global variable

    var Status= Shelly.getComponentStatus, Config= Shelly.getComponentConfig; //Renamed native function

    var info= Shelly.getDeviceInfo(), scriptID= Shelly.getCurrentScriptId(), scriptN= Config('script',scriptID).name; //Pseudo const, variabel

    //Toolbox v3.5 -Alpha(cut), Shelly FW >1.0.8

    Setup();

    Hallo Zusammen,

    ich hab mit einem User aus dem Forum zusammen erfolgreich ein Skript in meine Shellywelt eingebaut, dass zwei Luftfeuchtigkeitswerte vergleicht und dann je nach Unterschied das Garagentor auf Lüftungsposition gefahren wird.

    Es funktioniert auch sehr gut.

    Problem ist nur, dass der Sensor im Außenbereich längere Zeit auf 99,9% stehen bleibt, obwohl das die Luftfeuchtigkeit schon deutlich gesunken ist.

    Nun wollt ich mit einem BLU H&T die Luftfeuchtigkeit messen, was auch deutlich besser funktioniert, nur weiß ich nicht wie ich dessen Messwerte in das Skript einbinden kann.


    Kann mir jemand dabei helfen?

    Hallo Zusammen,

    nach einiger zeit, gibvt es leider etwas Probleme mit der Funktion.

    Der Außen Sensor bleibt sehr oft bei 99,9% stehen, obwohl die Werte schon deutlich geringer sein sollten.

    Ich hab mit nun einen Shelly BLU H&T zu gelegt.

    Dieses scheint sie Werte zuverlässig zu erfassen.

    Könnte mir jemand weiterhelfen das Skript anzupassen?

    Hallo Zusammen, hier die Anleitung und finale Scriptversion.

    Vergleichsmessung Luftfeuchtigkeit z.B. Garage zu Aussenbereich


    Idee:

    Die Luftfeuchtigkeit in unserer Garage ist öfters höher als gewünscht. Deshalb entstand der Wunsch durch ein Vergleichmessung der Luftfeuchtigkeit in der Garage im Vergleich zum Aussenbereich das Relay eines Schelly zu schließen, um damit z.B. das Garagentor auf Lüftungsposition zu fahren.


    Benötigt Komponenten:

    2x Shelly PM1

    2x Shelly AddOn

    2x DHT22 - Digitaler Temperatur und Luftfeuchtesensor

    1x TFA Dostmann Schutzhülle für Sender außen, 98.1114.02


    Ablauf:

    Mit der Hilfe von "De kat" wurde ein Script geschrieben, dass die Werte miteinander vergleicht und dann das Relais schaltet.

    Dieses Script läuft auf dem Shelly in der Garage und dessen Relais wird geschaltet.


    Script:

    var intervall= 60, //Humidity Checking Intervall, in Seconds

    remoteIP= "192.168.0.34", //Remote Shelly IP, as String

    hum_delta_min= -20, //Hum_min negativ Delta, to turn on, 0 if not needed

    hum_delta_max= 20, //Hum_max postiv Delta, to turn off, 0 if not needed

    debug= true;

    //Wenn die Luftfeuchtigkeit um einen gewissen Wert außen niedriger ist, wie in der Garage, soll das Relay des Shelly Plus 1 in der Garage geschlossen werden.

    function Check_Loop(res){

    try{

    if(res.code !== 200) return; //Exit if wrong Response

    let extern_hum= Number(JSON.parse(res.body).rh); //Getting remote Humidity Value

    let intern_hum= Number(Status('Humidity', 100).rh); //Getting local Humidity Value

    let hum_Delta= extern_hum-intern_hum; //Calc hum Delta

    if(debug) print('Debug: Hum delta-->',hum_Delta,'ext_h-->',extern_hum,'int_h-->',intern_hum); //Debug output

    if(hum_delta_min && hum_Delta < hum_delta_min) Call("Switch.set",{id:0,on:true},null,null,debug); //Switching Relay Channed 0 on

    if(hum_delta_max && hum_Delta > hum_delta_max) Call("Switch.set",{id:0,on:false},null,null,debug); //Switching Relay Channel 0 off

    }catch(e){ErrorMsg(e,'Check_Loop()');} //Error Handler

    }

    let tH1= 0; //Timer Handler

    function Main(){

    if(!tH1) Timer.set(1000*intervall,true,function(){ //Endless Loop

    Call("http.get",{url: "http://%22+remoteip+%22/rpc/Humidity.GetStatus?id=100", timeout: 5},Check_Loop,null,debug); //Call Remote Shelly

    });

    }

    // Dekats Toolbox, a universal Toolbox for Shelly scripts

    function ErrorChk(r,e,m,d){ //Shelly.call error check

    try{

    aC--; if(aC<0) aC= 0;

    if(d.CB && d.uD) d.CB(r,d.uD); if(d.CB && !d.uD) d.CB(r);

    if(!d.CB && d.uD) print('Debug: ',d.uD); if(e) throw new Error(Str(m));

    if(Str(r) && Str(r.code) && r.code !== 200) throw new Error(Str(r));

    }catch(e){ErrorMsg(e,'ErrorChk(), call Answer');}}

    function Cqueue(){ //Shelly.call queue

    try{

    if(!cCache[0] && !nCall[0]) return;

    while(cCache[0] && aC < callLimit){if(cCache[0] && !nCall[0]){nCall= cCache[0]; cCache.splice(0,1);}

    if(nCall[0] && aC < callLimit){Call(nCall[0],nCall[1],nCall[2],nCall[3],nCall[4]); nCall= [];}} if(tH9){Timer.clear(tH9); tH9= 0;}

    if(nCall[0] || cCache[0])if(cSp <= 0) cSp= 0.1; tH9= Timer.set(1000*cSp,0,function(){tH9= 0; Cqueue();});}catch(e){ErrorMsg(e,'Cqueue()');}}

    function Call(m,p,CB,uD,deBug){ //Upgrade Shelly.call

    try{

    let d= {};

    if(deBug) print('Debug: calling:',m,p); if(CB) d.CB= CB; if(Str(uD)) d.uD= uD; if(!m && CB){CB(uD); return;}

    if(aC < callLimit){aC++; Shelly.call(m,p,ErrorChk,d);}else if(cCache.length < cacheLimit){

    cCache.push([m,p,CB,uD,deBug]); if(deBug) print('Debug: save call:',m,p,', call queue now:',cCache.length); Cqueue();

    }else{throw new Error('to many Calls in use, droping call: '+Str(m)+', '+Str(p));}}catch(e){ErrorMsg(e,'Call()');}}

    function Str(d){ //Upgrade JSON.stringify

    try{

    if(d === null || d === undefined) return null; if(typeof d === 'string')return d;

    return JSON.stringify(d);}catch(e){ErrorMsg(e,'Str()');}}

    function Cut(f,k,o,i){ //Upgrade slice f=fullData, k=key-> where to cut, o=offset->offset behind key, i=invertCut

    try{

    let s= f.indexOf(k); if(s === -1) return; if(o) s= s+o.length || s+o; if(i) return f.slice(0,s);

    return f.slice(s);}catch(e){ErrorMsg(e,'Cut()');}}

    function Setup(){ //Wating 2sek, to avoid a Shelly FW Bug

    try{

    if(Main && !tH9){tH9= Timer.set(2000,0,function(){print('\nStatus: started Script _[', scriptN,']_');

    if(callLimit > 5){callLimit= 5;} try{Main();}catch(e){ErrorMsg(e,'Main()'); tH9= 0; Setup();}});}}catch(e){ErrorMsg(e,'Setup()');}}

    function ErrorMsg(e,s,deBug){ //Toolbox formatted Error Msg

    try{

    let i= 0; if(Cut(e.message, '-104: Timed out')) i= 'wrong URL or device may be offline';

    if(s === 'Main()' || deBug) i= e.stack; if(Cut(e.message, '"Main" is not')) i= 'define a Main() function before using Setup()';

    print('Error:',s || "",'---> ',e.type,e.message); if(i) print('Info: maybe -->',i);}catch(e){print('Error: ErrorMsg() --->',e);}}

    var tH8= 0, tH9= 0, aC= 0, cCache= [], nCall= [], callLimit= 5, cacheLimit= 40, cSp= 0.1; //Toolbox global variable

    var Status= Shelly.getComponentStatus, Config= Shelly.getComponentConfig; //Renamed native function

    var info= Shelly.getDeviceInfo(), scriptID= Shelly.getCurrentScriptId(), scriptN= Config('script',scriptID).name; //Pseudo const, variabel

    //Toolbox v3.5 -Alpha(cut), Shelly FW >1.0.8

    Setup();

    Super, es funktioniert.

    Vielen, vielen Dank.

    Ich werde es die Tage noch etwas beobachten und dann die Installation fertigstellen, dauert aber noch ein paar Tage bis das Wetter besser wird.

    Sobald alles richtig aktiv ist, melde ich mich nochmal, mit einer Anleitung!