...check slot down

This commit is contained in:
2020-08-21 22:51:17 +02:00
committed by Marc Hoppe
parent 49c3d9dd58
commit 32e029af30

View File

@@ -27,7 +27,6 @@ use constant {
}; };
my $tempIn_offset = +0; my $tempIn_offset = +0;
my $tempOut_offset = +2; my $tempOut_offset = +2;
my $tempOutForecastLimit = 27;
# CheckSkip # CheckSkip
use constant { use constant {
@@ -56,7 +55,7 @@ my @rolls = (
{ roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, }, { roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "bad.roll", dir=>"S", typ=>"n", temp=>"tempBad", tempSoll=>22, win=>"", block=>"", state=>STATE_IDLE, }, { roll => "bad.roll", dir=>"S", typ=>"n", temp=>"tempBad", tempSoll=>22, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollWeg", dir=>"S", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, }, { roll => "schlaf.rollWeg", dir=>"S", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollStr", dir=>"O", typ=>"so", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, }, { roll => "schlaf.rollStr", dir=>"O", typ=>"o", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, },
); );
@@ -103,7 +102,7 @@ sub SetRollSlot($) {
my $r = findRoll($name); my $r = findRoll($name);
if (defined $r) { if (defined $r) {
Dbg("found $r->{roll}"); Dbg("found $r->{roll}");
RollSlot($r, SKIP_NO, 0); RollSlot($r, 0);
} }
return undef return undef
} }
@@ -124,9 +123,14 @@ sub RollUpSec($$) {
my ($name, $sec) = @_; my ($name, $sec) = @_;
my $st=Value($name); my $st=Value($name);
Dbg("RollUpSec $name State:$st"); Dbg("RollUpSec $name State:$st");
myfhem("set ".$name." up ".$sec); #myfhem("set ".$name." up ".$sec);
# if ($st eq "closed") { up sec } if ($st eq "closed") { myfhem("set ".$name." up ".$sec); }
# else { down, at +30sec: RollUpSec else { # noch nicht geschlossen: nochmal versuchen
my $t=getDelayTime(39);
my $i=$tc++;
myfhem("set ".$name." closes");
myfhem("define ru".$i." at +".$t." {RollUpSec(\"".${name}."\",6);;}");
}
} }
#------------------------------------------ #------------------------------------------
@@ -140,7 +144,6 @@ sub RollSlot($$) {
Dbg("RollChg: $r->{roll} - schlitz($ndelay)\n"); Dbg("RollChg: $r->{roll} - schlitz($ndelay)\n");
myfhem("define rc".$i." at +".$t1." 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");
myfhem("define ru".$i." at +".$t2." {RollUpSec(\"".$r->{roll}."\",6);;}"); myfhem("define ru".$i." at +".$t2." {RollUpSec(\"".$r->{roll}."\",6);;}");
} }
@@ -260,6 +263,8 @@ sub IsWetterSonneWait($)
return(0); return(0);
} }
#------------------------------------------
sub SlotBlockStart($) sub SlotBlockStart($)
{ {
my ($r) = @_; my ($r) = @_;
@@ -270,6 +275,8 @@ sub SlotBlockStart($)
Dbg("Schlitzblockstart $r->{roll}"); Dbg("Schlitzblockstart $r->{roll}");
} }
#------------------------------------------
sub SlotBlockCheck($) sub SlotBlockCheck($)
{ {
my ($r) = @_; my ($r) = @_;
@@ -334,7 +341,7 @@ sub checkTemps($$$$)
if ($tempOut < $tempSoll+$tempOut_offset-1.0) { $tempO=TEMP_LOW; } if ($tempOut < $tempSoll+$tempOut_offset-1.0) { $tempO=TEMP_LOW; }
if ($tempOut < $tempSoll+$tempOut_offset-1.5) { $tempO=TEMP_COLD; } if ($tempOut < $tempSoll+$tempOut_offset-1.5) { $tempO=TEMP_COLD; }
if ($tempFore > $tempSoll+$tempOut_offset+2.0) { $tempF=TEMP_HOT; } if ($tempFore > $tempSoll+$tempOut_offset+2.0) { $tempF=TEMP_HOT; }
return($tempI, $tempO); return($tempI, $tempO, $tempF);
} }
#------------------------------------------ #------------------------------------------
@@ -416,12 +423,12 @@ sub RollCheck()
state $wachalt=0; state $wachalt=0;
my $r; my $r;
my $ndelay = 0; my $ndelay = 0;
my $tempOut = ReadingsVal("myWH1080", "Temp-outside", 40); my $tempOut = ReadingsVal("myWH1080", "Temp-outside", 40);
my $tempOutMaxForecast = getTempMaxForecast(); #ReadingsVal("wetter", "tempHigh", 40), my $tempForecast = getTempMaxForecast();
my $twil = Value("twil"); my $twil = Value("twil");
my $light = ReadingsVal("twil", "light", 0); my $light = ReadingsVal("twil", "light", 0);
my $wett = ReadingsVal("wetter", "code", 99); my $wett = ReadingsVal("wetter", "code", 99);
my $sr = Value("sonnenrichtung"); my $sr = Value("sonnenrichtung");
my $dawn = 0; my $dawn = 0;
@@ -434,10 +441,9 @@ sub RollCheck()
$dawn=1; $dawn=1;
} }
for $r ( @rolls ) { for $r ( @rolls ) {
#Dbg("--------r:g ".$r->{roll}." / ".$r->{temp});
my $run=0; my $run=0;
my $tempIn = ReadingsVal($r->{temp},"temperature", 99); my $tempIn = ReadingsVal($r->{temp},"temperature", 99);
my($tempI, $tempO, $tempF) = checkTemps($tempIn, $tempOut, $tempOutForecastLimit, $r->{tempSoll}); # Temperatur klassifizieren my($tempI, $tempO, $tempF) = checkTemps($tempIn, $tempOut, $tempForecast, $r->{tempSoll}); # Temperatur klassifizieren
my $dirIn = checkSunDir($twil, $sr, $r->{dir}); # Sonne scheint ins Fenster ? my $dirIn = checkSunDir($twil, $sr, $r->{dir}); # Sonne scheint ins Fenster ?
# Offene Fenster nicht mit Rollaeden verschliessen, zur Schlafenszeit nicht öffnen # Offene Fenster nicht mit Rollaeden verschliessen, zur Schlafenszeit nicht öffnen
my ($skipDown, $skipUp)=checkSkip($r); my ($skipDown, $skipUp)=checkSkip($r);
@@ -449,24 +455,25 @@ sub RollCheck()
my $ForecastHotWarmIn = $dirIn && $tempF>=TEMP_HOT && $tempI>=TEMP_HIGH; my $ForecastHotWarmIn = $dirIn && $tempF>=TEMP_HOT && $tempI>=TEMP_HIGH;
# Bedingungen zum öffnen (nach Schlitz) # Bedingungen zum öffnen (nach Schlitz)
my $Cold = $tempO<=TEMP_COLD; my $Cold = $tempO<=TEMP_COLD;
my $NoSunNotHot = !$dirIn && ($tempO<=TEMP_OK || $tempI<=TEMP_OK); my $NoSunNotHot = !$dirIn && ($tempO<=TEMP_HIGH || $tempI<=TEMP_OK);
if (!$tag) { if (!$tag) {
$run=RollDownState($r, $skipDown, $ndelay++); if (index($r->{typ}, "o") != -1) { $run=RollUpState ($r, $skipUp, $ndelay++); }
else { $run=RollDownState($r, $skipDown, $ndelay++); }
} elsif ($dawn) { # Abenddämmerung } elsif ($dawn) { # Abenddämmerung
$run=RollUpState($r, $skipUp, $ndelay++); $run=RollUpState($r, $skipUp, $ndelay++);
} elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) { } elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) {
$run=RollSlotState($r, $skipDown, $ndelay++); $run=RollSlotState($r, $skipDown, $ndelay++);
} elsif ( $Cold || $NoSunNotHot ) { } elsif ( $Cold || $NoSunNotHot ) {
if(!SlotBlockCheck($r)) { $run=RollUp($r, $skipUp, $ndelay++); } if(!SlotBlockCheck($r)) { $run=RollUpState($r, $skipUp, $ndelay++); }
} elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch } elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch
$run=RollUpState($r, $skipUp, $ndelay++); $run=RollUpState($r, $skipUp, $ndelay++);
} }
if ($run) { if ($run) {
Dbg("RollCheck: H:$Hot WS:$WarmSun WHI:$WarmHotIn FHS:$ForecastHotSun FHI:$ForecastHotWarmIn C:$Cold NSNH:$NoSunNotHot " Dbg("RollCheck: H:$Hot WS:$WarmSun WHI:$WarmHotIn FHS:$ForecastHotSun FHI:$ForecastHotWarmIn C:$Cold NSNH:$NoSunNotHot "
. "to:$tempOut twil:$twil light:$light wett:$wett tomax:$tempOutMaxForecast " . "to:$tempOut twil:$twil light:$light wett:$wett tomax:$tempForecast "
. "$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut sun:$sun/$dirIn wett:$wett sr:$sr " . "$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut sun:$sun/$dirIn wett:$wett sr:$sr "
. "twil:$twil tag:$tag/$tagalt wach:$wach/$wachalt skipR,H:$skipDown,$skipUp st:$r->{state}"); . "twil:$twil tag:$tag/$tagalt wach:$wach/$wachalt skipR,H:$skipDown,$skipUp st:$r->{state} dawn:$dawn");
} }
} # for $r } # for $r
$tagalt=$tag; $tagalt=$tag;