Compare commits
4 Commits
f0a2d4fa2f
...
fd4b1b4e00
| Author | SHA1 | Date | |
|---|---|---|---|
| fd4b1b4e00 | |||
| 4f7cdafb64 | |||
| 3fc70eb26a | |||
| 8617ead8e1 |
@@ -1,3 +1,4 @@
|
||||
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
@@ -16,6 +17,12 @@ use constant {
|
||||
STATE_SCHLITZ => 3,
|
||||
};
|
||||
|
||||
use constant {
|
||||
TEMP_IDLE => 0,
|
||||
TEMP_HIGH => 1,
|
||||
TEMP_LOW => 2,
|
||||
TEMP_COLD => 3,
|
||||
};
|
||||
|
||||
my @rolls = (
|
||||
{ roll => "wohn.rollTerrR", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"wohn.fenTerr", state=>STATE_IDLE, },
|
||||
@@ -24,11 +31,11 @@ my @rolls = (
|
||||
{ roll => "ess.roll", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "kuch.rollBar", dir=>"S", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "kuch.rollStr", dir=>"O", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "arb.rollTerr", dir=>"W", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"wohn.fenTerr", state=>STATE_IDLE, },
|
||||
{ roll => "arb.rollTerr", dir=>"W", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "bad.roll", dir=>"S", typ=>"n", temp=>"tempBad", tempSoll=>22, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "schlaf.rollWeg", dir=>"S", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, win=>"", state=>STATE_IDLE, },
|
||||
{ roll => "schlaf.rollStr", dir=>"O", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, win=>"wohn.fenTerr", state=>STATE_IDLE, },
|
||||
{ roll => "schlaf.rollStr", dir=>"O", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, win=>"", state=>STATE_IDLE, },
|
||||
);
|
||||
|
||||
|
||||
@@ -83,9 +90,13 @@ my @blocktime=localtime;
|
||||
my $blocktimerRunning=0;
|
||||
my $delaySec=11;
|
||||
|
||||
my $tempIn_offset=0;
|
||||
my $tempOut_offset=+3;
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub myfhem($) {
|
||||
sub myfhem($)
|
||||
{
|
||||
#Log 1, "@_";
|
||||
fhem("@_");
|
||||
}
|
||||
@@ -184,19 +195,28 @@ sub Dbg($) {
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub RollRunterSchlitz($$) {
|
||||
sub getDelayTime($)
|
||||
{
|
||||
my ($delay_sec) = @_;
|
||||
my @tparts = gmtime($delay_sec);
|
||||
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
|
||||
return($t);
|
||||
}
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub RollRunterSchlitz($$)
|
||||
{
|
||||
my ($r, $ndelay) = @_;
|
||||
$ndelay ||= 0;
|
||||
|
||||
if ($r->{state}!=STATE_SCHLITZ) {
|
||||
my @tparts = gmtime($ndelay*$delaySec);
|
||||
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
|
||||
my @tparts2 = gmtime($ndelay*$delaySec+40);
|
||||
my $t2=sprintf ("%02d:%02d:%02d",@tparts2[2,1,0]);
|
||||
my $t1=getDelayTime($ndelay*$delaySec);
|
||||
my $t2=getDelayTime($ndelay*$delaySec+39);
|
||||
my $i=$tc++;
|
||||
|
||||
Dbg("RollChg: $r->{roll} - runter schlitz($ndelay)\n");
|
||||
myfhem("define r".$i." at +".$t." set ".$r->{roll}." closes");
|
||||
myfhem("define rc".$i." at +".$t1." set ".$r->{roll}." closes");
|
||||
myfhem("define ru".$i." at +".$t2." set ".$r->{roll}." up 6");
|
||||
$r->{state}=STATE_SCHLITZ;
|
||||
}
|
||||
@@ -204,43 +224,44 @@ sub RollRunterSchlitz($$) {
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub RollHoch($$) {
|
||||
sub RollHoch($$)
|
||||
{
|
||||
my ($r, $ndelay) = @_;
|
||||
$ndelay ||= 0;
|
||||
|
||||
if ($r->{state}!=STATE_HOCH) {
|
||||
my @tparts = gmtime($ndelay*$delaySec);
|
||||
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
|
||||
my $t1=getDelayTime($ndelay*$delaySec);
|
||||
my $i=$tc++;
|
||||
|
||||
Dbg("RollChg: $r->{roll} - hoch($ndelay)\n");
|
||||
myfhem("define r".$i." at +".$t." set ". $r->{roll} ." opens");
|
||||
myfhem("define ro".$i." at +".$t1." set ". $r->{roll} ." opens");
|
||||
$r->{state}=STATE_HOCH;
|
||||
}
|
||||
}
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub RollRunter($$) {
|
||||
sub RollRunter($$)
|
||||
{
|
||||
my ($r, $ndelay) = @_;
|
||||
$ndelay ||= 0;
|
||||
|
||||
if ($r->{state}!=STATE_RUNTER) {
|
||||
my @tparts = gmtime($ndelay*$delaySec);
|
||||
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
|
||||
my $t1=getDelayTime($ndelay*$delaySec);
|
||||
my $i=$tc++;
|
||||
|
||||
Dbg("RollChg: $r->{roll} - runter($ndelay)\n");
|
||||
myfhem("define r".$i." at +".$t." set ".$r->roll." closes");
|
||||
myfhem("define rc".$i." at +".$t1." set ".$r->{roll}." closes");
|
||||
$r->{state}=STATE_RUNTER;
|
||||
}
|
||||
}
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub IsSunny($) {
|
||||
sub IsSunny($)
|
||||
{
|
||||
my ($wett)=@_;
|
||||
if($wett==30 || $wett==31 || $wett==32 || $wett==33 || $wett==34 || $wett==35 || $wett==36) { # sonnig, heiter, heiss
|
||||
if($wett==30|| $wett==32 || $wett==34 || $wett==36) { # sonnig, heiter, heiss
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
@@ -248,7 +269,8 @@ sub IsSunny($) {
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub IsLater($) {
|
||||
sub IsLater($)
|
||||
{
|
||||
my($t)=@_;
|
||||
#Dbg("Islater:$t");
|
||||
my @time = localtime(time);
|
||||
@@ -315,13 +337,14 @@ sub setTagHell($$)
|
||||
sub checkTemps($$$)
|
||||
{
|
||||
my($temp, $tempOut, $tempSoll)=@_;
|
||||
my $tempH=0; my $tempOH=0; my $tempL=0; my$tempOL=0;
|
||||
my $tempI=TEMP_IDLE; my $tempO=TEMP_IDLE;
|
||||
|
||||
if ($temp > $tempSoll-0) { $tempH =1; }
|
||||
if ($temp < $tempSoll-1) { $tempL =1; }
|
||||
if ($tempOut > $tempSoll-2) { $tempOH=1; }
|
||||
if ($tempOut < $tempSoll-3) { $tempOL=1; }
|
||||
return($tempH, $tempOH, $tempL, $tempOL);
|
||||
if ($temp > $tempSoll+$tempIn_offset+0.5) { $tempI=TEMP_HIGH; }
|
||||
if ($temp < $tempSoll+$tempIn_offset-0.5) { $tempI=TEMP_LOW; }
|
||||
if ($tempOut > $tempSoll+$tempOut_offset+0.5) { $tempO=TEMP_HIGH; }
|
||||
if ($tempOut < $tempSoll+$tempOut_offset-0.5) { $tempO=TEMP_LOW; }
|
||||
if ($tempOut < $tempSoll+$tempOut_offset-1.5) { $tempO=TEMP_COLD; }
|
||||
return($tempI, $tempO);
|
||||
}
|
||||
|
||||
#------------------------------------------
|
||||
@@ -364,7 +387,9 @@ sub checkSkip($$$)
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub RollCheck() {
|
||||
sub RollCheck()
|
||||
{
|
||||
state $tagalt=0;
|
||||
my $r;
|
||||
my $ndelay =0;
|
||||
my $tempOut=ReadingsVal("myWH1080", "Temp-outside", 99);
|
||||
@@ -373,45 +398,55 @@ sub RollCheck() {
|
||||
my $wett =ReadingsVal("wetter", "code", 99);
|
||||
my $sr =Value("sonnenrichtung");
|
||||
my $sunny =IsSunny($wett);
|
||||
my $dawn =0;
|
||||
|
||||
setTagHell($twil, $light);
|
||||
my $tag=Value("tag");
|
||||
# Nach wechsel von sonne auf !sonne blockert ?
|
||||
my $sonneblock=IsWetterSonneWait($wett);
|
||||
if($twil>=7) { # ss-weather
|
||||
$dawn=1;
|
||||
}
|
||||
|
||||
Dbg("RollCheck to:$tempOut twil:$twil light:$light wett:$wett sr:$sr block:$sonneblock\n");
|
||||
|
||||
for $r ( @rolls ) {
|
||||
#Dbg("--------r:g ".$r->{roll}." / ".$r->{temp});
|
||||
|
||||
# Raum zu warm und aussentemp hoch ?
|
||||
my $temp=ReadingsVal($r->{temp},"temperature", 99);
|
||||
my($tempH, $tempOH, $tempL, $tempOL)=checkTemps($temp, $tempOut, $r->{tempSoll});
|
||||
my $tempIn=ReadingsVal($r->{temp},"temperature", 99);
|
||||
my($tempI, $tempO)=checkTemps($tempIn, $tempOut, $r->{tempSoll});
|
||||
# Sonne scheint ins Fenster ?
|
||||
my $sonne=checkWeather($twil, $sr, $r->{dir}, $sonneblock, $sunny);
|
||||
# Offene Fenster nicht mit Rollaeden verschliessen
|
||||
my ($skipRunter, $skipHoch)=checkSkip(Value($r->{win}), $r->{typ}, Value("wach"));
|
||||
|
||||
|
||||
Dbg("RollCheck:$r->{roll}-tempH,OH,L,OL:$tempH,$tempOH,$tempL,$tempOL tempI,O:$temp,$tempOut so:$sonne wett:$wett sr:$sr twil:$twil tag:$tag skipR,H:$skipRunter,$skipHoch st:$r->{state}");
|
||||
|
||||
Dbg("RollCheck:$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut so:$sonne wett:$wett sr:$sr twil:$twil tag:$tag skipR,H:$skipRunter,$skipHoch st:$r->{state}");
|
||||
|
||||
if (!$tag) {
|
||||
Dbg(" runter");
|
||||
if (!$skipRunter) { RollRunter($r, $ndelay++); }
|
||||
}
|
||||
elsif ($tag && $tempH && ($sonne || $tempOH)) {
|
||||
Dbg(" schl");
|
||||
elsif ($tag && !$dawn && $tempI==TEMP_HIGH && (($sonne && $tempO!=TEMP_COLD) || $tempO==TEMP_HIGH)) {
|
||||
if (!$skipHoch && !$skipRunter) { RollRunterSchlitz($r, $ndelay++); }
|
||||
}
|
||||
elsif ($tag && ($tempL || (!$sonne && $tempOL)) ) {
|
||||
Dbg(" hoch");
|
||||
elsif ($tag && $tempI==TEMP_LOW && $tempO==TEMP_LOW) {
|
||||
if (!$skipHoch) { RollHoch($r, $ndelay++); }
|
||||
}
|
||||
elsif ($tag && !$tagalt) { # bei Tagesbeginn und im Temp-hysteresebereich -> hoch
|
||||
if (!$skipHoch) { RollHoch($r, $ndelay++); }
|
||||
}
|
||||
elsif ($tag && $dawn) {
|
||||
if (!$skipHoch) { RollHoch($r, $ndelay++); }
|
||||
}
|
||||
} # for
|
||||
$tagalt=$tag;
|
||||
}
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
sub Untoggle($) {
|
||||
sub Untoggle($)
|
||||
{
|
||||
my ($obj) = @_;
|
||||
if (Value($obj) eq "toggle"){
|
||||
if (OldValue($obj) eq "off") {
|
||||
|
||||
Reference in New Issue
Block a user