...slot aus web
This commit is contained in:
@@ -13,9 +13,9 @@ sub MyUtils_Initialize($$)
|
|||||||
|
|
||||||
use constant {
|
use constant {
|
||||||
STATE_IDLE => 0,
|
STATE_IDLE => 0,
|
||||||
STATE_HOCH => 1,
|
STATE_UP => 1,
|
||||||
STATE_RUNTER => 2,
|
STATE_DOWN => 2,
|
||||||
STATE_SCHLITZ => 3,
|
STATE_SLOT => 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
use constant {
|
use constant {
|
||||||
@@ -26,7 +26,7 @@ use constant {
|
|||||||
TEMP_HOT => 4,
|
TEMP_HOT => 4,
|
||||||
};
|
};
|
||||||
my $tempIn_offset = +0;
|
my $tempIn_offset = +0;
|
||||||
my $tempOut_offset = +5;
|
my $tempOut_offset = +2;
|
||||||
my $tempOutForecastLimit = 27;
|
my $tempOutForecastLimit = 27;
|
||||||
|
|
||||||
# CheckSkip
|
# CheckSkip
|
||||||
@@ -102,9 +102,10 @@ sub SetRollSlot($) {
|
|||||||
Dbg("SetRollSlot $name");
|
Dbg("SetRollSlot $name");
|
||||||
my $r = findRoll($name);
|
my $r = findRoll($name);
|
||||||
if (defined $r) {
|
if (defined $r) {
|
||||||
Dbg("found $r->{name}");
|
Dbg("found $r->{roll}");
|
||||||
RollRunterSchlitz($r, SKIP_NO);
|
RollSlot($r, SKIP_NO, 0);
|
||||||
}
|
}
|
||||||
|
return undef
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
@@ -119,21 +120,42 @@ sub getDelayTime($)
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
sub RollRunterSchlitz($$$)
|
sub RollUpSec($$) {
|
||||||
|
my ($name, $sec) = @_;
|
||||||
|
my $st=Value($name);
|
||||||
|
Dbg("RollUpSec $name State:$st");
|
||||||
|
myfhem("set ".$name." up ".$sec);
|
||||||
|
# if ($st eq "closed") { up sec }
|
||||||
|
# else { down, at +30sec: RollUpSec
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------
|
||||||
|
|
||||||
|
sub RollSlot($$) {
|
||||||
|
my ($r, $ndelay) = @_;
|
||||||
|
$ndelay ||= 0;
|
||||||
|
my $t1=getDelayTime($ndelay*$delaySec);
|
||||||
|
my $t2=getDelayTime($ndelay*$delaySec+39);
|
||||||
|
my $i=$tc++;
|
||||||
|
|
||||||
|
Dbg("RollChg: $r->{roll} - schlitz($ndelay)\n");
|
||||||
|
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);;}");
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------
|
||||||
|
|
||||||
|
sub RollSlotState($$$)
|
||||||
{
|
{
|
||||||
my ($r, $skipRunter, $ndelay) = @_;
|
my ($r, $skipDown, $ndelay) = @_;
|
||||||
$ndelay ||= 0;
|
$ndelay ||= 0;
|
||||||
|
|
||||||
if ($skipRunter==SKIP_NO || $skipRunter==SKIP_DOWN ) {
|
if ($skipDown==SKIP_NO || $skipDown==SKIP_DOWN ) {
|
||||||
if ($r->{state}!=STATE_SCHLITZ) {
|
if ($r->{state}!=STATE_SLOT) {
|
||||||
my $t1=getDelayTime($ndelay*$delaySec);
|
RollSlot($r, $ndelay);
|
||||||
my $t2=getDelayTime($ndelay*$delaySec+39);
|
$r->{state}=STATE_SLOT;
|
||||||
my $i=$tc++;
|
SlotBlockStart($r);
|
||||||
|
|
||||||
Dbg("RollChg: $r->{roll} - runter schlitz($ndelay)\n");
|
|
||||||
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;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,19 +164,19 @@ sub RollRunterSchlitz($$$)
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
sub RollHoch($$$)
|
sub RollUpState($$$)
|
||||||
{
|
{
|
||||||
my ($r, $skipHoch, $ndelay) = @_;
|
my ($r, $skipUp, $ndelay) = @_;
|
||||||
$ndelay ||= 0;
|
$ndelay ||= 0;
|
||||||
|
|
||||||
if ($skipHoch==SKIP_NO) {
|
if ($skipUp==SKIP_NO) {
|
||||||
if ($r->{state}!=STATE_HOCH) {
|
if ($r->{state}!=STATE_UP) {
|
||||||
my $t1=getDelayTime($ndelay*$delaySec);
|
my $t1=getDelayTime($ndelay*$delaySec);
|
||||||
my $i=$tc++;
|
my $i=$tc++;
|
||||||
|
|
||||||
Dbg("RollChg: $r->{roll} - hoch($ndelay)\n");
|
Dbg("RollChg: $r->{roll} - hoch($ndelay)\n");
|
||||||
myfhem("define ro".$i." at +".$t1." set ". $r->{roll} ." opens");
|
myfhem("define ro".$i." at +".$t1." set ". $r->{roll} ." opens");
|
||||||
$r->{state}=STATE_HOCH;
|
$r->{state}=STATE_UP;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,19 +185,19 @@ sub RollHoch($$$)
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
sub RollRunter($$$)
|
sub RollDownState($$$)
|
||||||
{
|
{
|
||||||
my ($r, $skipRunter, $ndelay) = @_;
|
my ($r, $skipDown, $ndelay) = @_;
|
||||||
$ndelay ||= 0;
|
$ndelay ||= 0;
|
||||||
|
|
||||||
if ($skipRunter==SKIP_NO) {
|
if ($skipDown==SKIP_NO) {
|
||||||
if ($r->{state}!=STATE_RUNTER) {
|
if ($r->{state}!=STATE_DOWN) {
|
||||||
my $t1=getDelayTime($ndelay*$delaySec);
|
my $t1=getDelayTime($ndelay*$delaySec);
|
||||||
my $i=$tc++;
|
my $i=$tc++;
|
||||||
|
|
||||||
Dbg("RollChg: $r->{roll} - runter($ndelay)\n");
|
Dbg("RollChg: $r->{roll} - runter($ndelay)\n");
|
||||||
myfhem("define rc".$i." at +".$t1." set ".$r->{roll}." closes");
|
myfhem("define rc".$i." at +".$t1." set ".$r->{roll}." closes");
|
||||||
$r->{state}=STATE_RUNTER;
|
$r->{state}=STATE_DOWN;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,7 +260,7 @@ sub IsWetterSonneWait($)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub SchlitzBlockStart($)
|
sub SlotBlockStart($)
|
||||||
{
|
{
|
||||||
my ($r) = @_;
|
my ($r) = @_;
|
||||||
@{$r->{bt}}=localtime;
|
@{$r->{bt}}=localtime;
|
||||||
@@ -248,7 +270,7 @@ sub SchlitzBlockStart($)
|
|||||||
Dbg("Schlitzblockstart $r->{roll}");
|
Dbg("Schlitzblockstart $r->{roll}");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub SchlitzBlockCheck($)
|
sub SlotBlockCheck($)
|
||||||
{
|
{
|
||||||
my ($r) = @_;
|
my ($r) = @_;
|
||||||
if($r->{btr}) {
|
if($r->{btr}) {
|
||||||
@@ -299,18 +321,19 @@ sub getTempMaxForecast()
|
|||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
# Temperaturen klassifizieren
|
# Temperaturen klassifizieren
|
||||||
sub checkTemps($$$)
|
sub checkTemps($$$$)
|
||||||
{
|
{
|
||||||
my ($temp, $tempOut, $tempSoll)=@_;
|
my ($temp, $tempOut, $tempFore, $tempSoll)=@_;
|
||||||
my $tempI=TEMP_OK; my $tempO=TEMP_OK;
|
my $tempI=TEMP_OK; my $tempO=TEMP_OK; my $tempF=TEMP_OK;
|
||||||
|
|
||||||
if ($temp > $tempSoll+$tempIn_offset+3.0) { $tempI=TEMP_HOT; }
|
if ($temp > $tempSoll+$tempIn_offset+2.0) { $tempI=TEMP_HOT; }
|
||||||
if ($temp > $tempSoll+$tempIn_offset+0.5) { $tempI=TEMP_HIGH; }
|
if ($temp > $tempSoll+$tempIn_offset+0.5) { $tempI=TEMP_HIGH; }
|
||||||
if ($temp < $tempSoll+$tempIn_offset-0.5) { $tempI=TEMP_LOW; }
|
if ($temp < $tempSoll+$tempIn_offset-0.5) { $tempI=TEMP_LOW; }
|
||||||
if ($tempOut > $tempSoll+$tempOut_offset+4.0) { $tempO=TEMP_HOT; }
|
if ($tempOut > $tempSoll+$tempOut_offset+2.0) { $tempO=TEMP_HOT; }
|
||||||
if ($tempOut > $tempSoll+$tempOut_offset+1.0) { $tempO=TEMP_HIGH; }
|
if ($tempOut > $tempSoll+$tempOut_offset+1.0) { $tempO=TEMP_HIGH; }
|
||||||
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; }
|
||||||
return($tempI, $tempO);
|
return($tempI, $tempO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,9 +354,14 @@ sub checkSunDir($$$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Sonne scheint ?
|
# Sonne scheint ?
|
||||||
sub checkSun($$$)
|
sub checkSun($$)
|
||||||
{
|
{
|
||||||
my($twil, $sunblock, $sunny)=@_;
|
my($twil, $wett)=@_;
|
||||||
|
|
||||||
|
my $sunny = IsSunny($wett);
|
||||||
|
# Nach wechsel von sonne auf !sonne blockert ?
|
||||||
|
my $sunblock=IsWetterSonneWait($wett);
|
||||||
|
|
||||||
my $sun=0;
|
my $sun=0;
|
||||||
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand ueber 'weather' liegt
|
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand ueber 'weather' liegt
|
||||||
if ($sunblock) { $sun=1; }
|
if ($sunblock) { $sun=1; }
|
||||||
@@ -353,31 +381,31 @@ sub checkSkip($)
|
|||||||
my $wach=Value("wach");
|
my $wach=Value("wach");
|
||||||
my $winstate=Value($r->{win});
|
my $winstate=Value($r->{win});
|
||||||
my $typ=$r->{typ};
|
my $typ=$r->{typ};
|
||||||
my $skipRunter=SKIP_NO; my $skipHoch=SKIP_NO;
|
my $skipDown=SKIP_NO; my $skipUp=SKIP_NO;
|
||||||
|
|
||||||
if (Value($r->{block})) {
|
if (Value($r->{block})) {
|
||||||
$skipRunter=SKIP_ALL;
|
$skipDown=SKIP_ALL;
|
||||||
$skipHoch=SKIP_ALL;
|
$skipUp=SKIP_ALL;
|
||||||
}
|
}
|
||||||
if ($winstate eq "Open") {
|
if ($winstate eq "Open") {
|
||||||
# Offene Fenster nicht mit Rollaeden verschliessen
|
# Offene Fenster nicht mit Rollaeden verschliessen
|
||||||
$skipRunter=SKIP_ALL;
|
$skipDown=SKIP_ALL;
|
||||||
} elsif (index($typ, "o") != -1) {
|
} elsif (index($typ, "o") != -1) {
|
||||||
# bei typ o nur auf schlitz schliessen
|
# bei typ o nur auf schlitz schliessen
|
||||||
#Dbg("Skip0: t:$typ w:$winstate r:$skipRunter h:$skipHoch");
|
#Dbg("Skip0: t:$typ w:$winstate r:$skipRunter h:$skipUp");
|
||||||
$skipRunter=SKIP_DOWN;
|
$skipDown=SKIP_DOWN;
|
||||||
}
|
}
|
||||||
if (index($typ, "s") != -1) {
|
if (index($typ, "s") != -1) {
|
||||||
# Typ s: zur Schlafzeit nicht oeffnen
|
# Typ s: zur Schlafzeit nicht oeffnen
|
||||||
#Dbg("Skip1: t:$typ w:winstate r:$skipRunter h:$skipHoch");
|
#Dbg("Skip1: t:$typ w:winstate r:$skipRunter h:$skipUp");
|
||||||
if($wach eq "0") {
|
if($wach eq "0") {
|
||||||
#Dbg("Skip2: t:$typ w:winstate r:$skipRunter h:$skipHoch");
|
#Dbg("Skip2: t:$typ w:winstate r:$skipDown h:$skipUp");
|
||||||
|
|
||||||
$skipHoch=SKIP_ALL;
|
$skipUp=SKIP_ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#Dbg("Skip: t:$typ w:winstate r:$skipRunter h:$skipHoch");
|
#Dbg("Skip: t:$typ w:winstate r:$skipDown h:$skipUp");
|
||||||
return($skipRunter, $skipHoch);
|
return($skipDown, $skipUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
@@ -396,14 +424,12 @@ sub RollCheck()
|
|||||||
my $wett = ReadingsVal("wetter", "code", 99);
|
my $wett = ReadingsVal("wetter", "code", 99);
|
||||||
|
|
||||||
my $sr = Value("sonnenrichtung");
|
my $sr = Value("sonnenrichtung");
|
||||||
my $sunny = IsSunny($wett);
|
|
||||||
my $dawn = 0;
|
my $dawn = 0;
|
||||||
|
|
||||||
setTagHell($twil, $light);
|
setTagHell($twil, $light);
|
||||||
my $tag=Value("tag");
|
my $tag=Value("tag");
|
||||||
my $wach=Value("wach");
|
my $wach=Value("wach");
|
||||||
# Nach wechsel von sonne auf !sonne blockert ?
|
my $sun = checkSun($twil, $wett); # Sonne scheint (bleibt true für best. Zeit) ?
|
||||||
my $sonneblock=IsWetterSonneWait($wett);
|
|
||||||
if($twil>=7) { # ss-weather
|
if($twil>=7) { # ss-weather
|
||||||
$dawn=1;
|
$dawn=1;
|
||||||
}
|
}
|
||||||
@@ -411,37 +437,36 @@ sub RollCheck()
|
|||||||
#Dbg("--------r:g ".$r->{roll}." / ".$r->{temp});
|
#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) = checkTemps($tempIn, $tempOut, $r->{tempSoll}); # Temperatur klassifizieren
|
my($tempI, $tempO, $tempF) = checkTemps($tempIn, $tempOut, $tempOutForecastLimit, $r->{tempSoll}); # Temperatur klassifizieren
|
||||||
my $sun = checkSun($twil,$sonneblock, $sunny); # Sonne scheint (bleibt true für best. Zeit) ?
|
my $dirIn = checkSunDir($twil, $sr, $r->{dir}); # Sonne scheint ins Fenster ?
|
||||||
my $sunDir =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 ($skipRunter, $skipHoch)=checkSkip($r);
|
my ($skipDown, $skipUp)=checkSkip($r);
|
||||||
# Bedingungen zum Fahren
|
# Bedingungen zum Fahren auf Schlitz
|
||||||
my $Hot = $tempO>=TEMP_HOT;
|
my $Hot = $tempO>=TEMP_HOT;
|
||||||
my $WarmSun = $sun && $sunDir && $tempO>=TEMP_HIGH;
|
my $WarmSun = $sun && $dirIn && $tempO>=TEMP_HIGH;
|
||||||
my $WarmHotIn = $sunDir && $tempO>=TEMP_HIGH && $tempI>=TEMP_HOT;
|
my $WarmHotIn = $dirIn && $tempO>=TEMP_HIGH && $tempI>=TEMP_HOT;
|
||||||
my $ForecastHotSun = $sun && $sunDir && $tempOutMaxForecast>=$tempOutForecastLimit;
|
my $ForecastHotSun = $sun && $dirIn && $tempF>=TEMP_HOT;
|
||||||
my $ForecastHotWarmIn = $sunDir && $tempOutMaxForecast>=$tempOutForecastLimit && $tempI>=TEMP_HIGH;
|
my $ForecastHotWarmIn = $dirIn && $tempF>=TEMP_HOT && $tempI>=TEMP_HIGH;
|
||||||
my $Cold = $tempO<=TEMP_COLD;
|
# Bedingungen zum öffnen (nach Schlitz)
|
||||||
my $NoSunNotHot = !$sunDir && ($tempO<=TEMP_OK || $tempI<=TEMP_OK);
|
my $Cold = $tempO<=TEMP_COLD;
|
||||||
|
my $NoSunNotHot = !$dirIn && ($tempO<=TEMP_OK || $tempI<=TEMP_OK);
|
||||||
|
|
||||||
if (!$tag) {
|
if (!$tag) {
|
||||||
$run=RollRunter($r, $skipRunter, $ndelay++);
|
$run=RollDownState($r, $skipDown, $ndelay++);
|
||||||
} elsif ($dawn) { # Abenddämmerung
|
} elsif ($dawn) { # Abenddämmerung
|
||||||
$run=RollHoch($r, $skipHoch, $ndelay++);
|
$run=RollUpState($r, $skipUp, $ndelay++);
|
||||||
} elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) {
|
} elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) {
|
||||||
$run=RollRunterSchlitz($r, $skipRunter, $ndelay++);
|
$run=RollSlotState($r, $skipDown, $ndelay++);
|
||||||
if ($run) { SchlitzBlockStart($r); }
|
|
||||||
} elsif ( $Cold || $NoSunNotHot ) {
|
} elsif ( $Cold || $NoSunNotHot ) {
|
||||||
if(!SchlitzBlockCheck($r)) { $run=RollHoch($r, $skipHoch, $ndelay++); }
|
if(!SlotBlockCheck($r)) { $run=RollUp($r, $skipUp, $ndelay++); }
|
||||||
} elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch
|
} elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch
|
||||||
$run=RollHoch($r, $skipHoch, $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 sr:$sr block:$sonneblock tomax:$tempOutMaxForecast "
|
. "to:$tempOut twil:$twil light:$light wett:$wett tomax:$tempOutMaxForecast "
|
||||||
. "$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut sun:$sun/$sunDir 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:$skipRunter,$skipHoch st:$r->{state}");
|
. "twil:$twil tag:$tag/$tagalt wach:$wach/$wachalt skipR,H:$skipDown,$skipUp st:$r->{state}");
|
||||||
}
|
}
|
||||||
} # for $r
|
} # for $r
|
||||||
$tagalt=$tag;
|
$tagalt=$tag;
|
||||||
|
|||||||
Reference in New Issue
Block a user