...setRollSlot, sun und sundir getrennt
This commit is contained in:
@@ -25,9 +25,9 @@ use constant {
|
|||||||
TEMP_HIGH => 3,
|
TEMP_HIGH => 3,
|
||||||
TEMP_HOT => 4,
|
TEMP_HOT => 4,
|
||||||
};
|
};
|
||||||
my $tempIn_offset=0;
|
my $tempIn_offset = +0;
|
||||||
my $tempOut_offset=+5;
|
my $tempOut_offset = +5;
|
||||||
my $tempOutForecastLimit=28;
|
my $tempOutForecastLimit = 27;
|
||||||
|
|
||||||
# CheckSkip
|
# CheckSkip
|
||||||
use constant {
|
use constant {
|
||||||
@@ -63,11 +63,8 @@ my @rolls = (
|
|||||||
my $tc=0;
|
my $tc=0;
|
||||||
my @blocktime=localtime;
|
my @blocktime=localtime;
|
||||||
my $blocktimerRunning=0;
|
my $blocktimerRunning=0;
|
||||||
#my @schlitzblocktime=localtime;
|
|
||||||
#my $schlitzBlocktimerRunning=0;
|
|
||||||
my $delaySec=11;
|
my $delaySec=11;
|
||||||
|
|
||||||
#------------------------------------------
|
|
||||||
|
|
||||||
sub myfhem($)
|
sub myfhem($)
|
||||||
{
|
{
|
||||||
@@ -77,6 +74,14 @@ sub myfhem($)
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
|
sub Dbg($) {
|
||||||
|
if(Value("DebugRoll") eq "1") {
|
||||||
|
Log 1,$_[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------
|
||||||
|
|
||||||
sub findRoll($)
|
sub findRoll($)
|
||||||
{
|
{
|
||||||
my($name) = @_;
|
my($name) = @_;
|
||||||
@@ -89,11 +94,16 @@ sub findRoll($)
|
|||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
sub Dbg($) {
|
sub SetRollSlot($) {
|
||||||
if(Value("DebugRoll") eq "1") {
|
my($name) = @_;
|
||||||
Log 1,$_[0];
|
Dbg("SetRollSlot $name");
|
||||||
|
my $r = findRoll($name);
|
||||||
|
if (defined $r) {
|
||||||
|
Dbg("found $r->{name}");
|
||||||
|
RollRunterSchlitz($r, SKIP_NO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +131,6 @@ sub RollRunterSchlitz($$$)
|
|||||||
my $i=$tc++;
|
my $i=$tc++;
|
||||||
|
|
||||||
Dbg("RollChg: $r->{roll} - runter schlitz($ndelay)\n");
|
Dbg("RollChg: $r->{roll} - runter schlitz($ndelay)\n");
|
||||||
SchlitzBlockStart($r);
|
|
||||||
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." set ".$r->{roll}." up 6");
|
||||||
$r->{state}=STATE_SCHLITZ;
|
$r->{state}=STATE_SCHLITZ;
|
||||||
@@ -256,6 +265,7 @@ sub SchlitzBlockCheck($)
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
|
# fhem-Variablen 'tag' und 'hell' abhängig vom Sonnenstand setzen
|
||||||
sub setTagHell($$)
|
sub setTagHell($$)
|
||||||
{
|
{
|
||||||
my ($twil, $light) = @_;
|
my ($twil, $light) = @_;
|
||||||
@@ -274,7 +284,7 @@ sub setTagHell($$)
|
|||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
# Die maximal für den aktuellen Tag verhergesagte Temperatur bestimmen
|
# Die maximal für den aktuellen Tag verhergesagte Temperatur bestimmen
|
||||||
OBsub getTempMaxForecast()
|
sub getTempMaxForecast()
|
||||||
{
|
{
|
||||||
# aktuellen Wert auch einbeziehen
|
# aktuellen Wert auch einbeziehen
|
||||||
my $max=ReadingsVal("wetter", "tempHigh", 20);
|
my $max=ReadingsVal("wetter", "tempHigh", 20);
|
||||||
@@ -288,10 +298,10 @@ OBsub getTempMaxForecast()
|
|||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
# Raum zu warm und aussentemp hoch ?
|
# Temperaturen klassifizieren
|
||||||
sub checkTemps($$$)
|
sub checkTemps($$$)
|
||||||
{
|
{
|
||||||
my($temp, $tempOut, $tempSoll)=@_;
|
my ($temp, $tempOut, $tempSoll)=@_;
|
||||||
my $tempI=TEMP_OK; my $tempO=TEMP_OK;
|
my $tempI=TEMP_OK; my $tempO=TEMP_OK;
|
||||||
|
|
||||||
if ($temp > $tempSoll+$tempIn_offset+3.0) { $tempI=TEMP_HOT; }
|
if ($temp > $tempSoll+$tempIn_offset+3.0) { $tempI=TEMP_HOT; }
|
||||||
@@ -307,21 +317,30 @@ sub checkTemps($$$)
|
|||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|
||||||
# Sonne scheint ins Fenster ?
|
# Sonne scheint ins Fenster ?
|
||||||
sub checkSunIn($$$$$)
|
sub checkSunDir($$$)
|
||||||
{
|
{
|
||||||
my($twil, $sun_dir, $win_dir, $sunblock, $sunny)=@_;
|
my($twil, $sun_dir, $win_dir)=@_;
|
||||||
# Sonne scheint ins Fenster ?
|
# Sonnenrichtung scheint ins Fenster ?
|
||||||
my $sun_in=0;
|
|
||||||
my $dir_in=0;
|
my $dir_in=0;
|
||||||
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand ueber 'weather' liegt
|
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand über 'weather' liegt
|
||||||
if (index($sun_dir, $win_dir) != -1) { # Sonnenrichtung ins Fenster
|
if (index($sun_dir, $win_dir) != -1) { # Sonnenrichtung ins Fenster
|
||||||
$dir_in=1;
|
$dir_in=1;
|
||||||
if ($sunblock) { $sun_in=1; }
|
|
||||||
if ($sunny) { $sun_in=1; }
|
|
||||||
#Dbg("son3, $sonne");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ($sun_in, $dir_in);
|
return $dir_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Sonne scheint ?
|
||||||
|
sub checkSun($$$)
|
||||||
|
{
|
||||||
|
my($twil, $sunblock, $sunny)=@_;
|
||||||
|
my $sun=0;
|
||||||
|
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand ueber 'weather' liegt
|
||||||
|
if ($sunblock) { $sun=1; }
|
||||||
|
if ($sunny) { $sun=1; }
|
||||||
|
#Dbg("son3, $sonne");
|
||||||
|
}
|
||||||
|
return $sun;
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
@@ -344,13 +363,12 @@ sub checkSkip($)
|
|||||||
# Offene Fenster nicht mit Rollaeden verschliessen
|
# Offene Fenster nicht mit Rollaeden verschliessen
|
||||||
$skipRunter=SKIP_ALL;
|
$skipRunter=SKIP_ALL;
|
||||||
} elsif (index($typ, "o") != -1) {
|
} elsif (index($typ, "o") != -1) {
|
||||||
#Dbg("Skip0: t:$typ w:$winstate r:$skipRunter h:$skipHoch");
|
|
||||||
|
|
||||||
# bei typ o nur auf schlitz schliessen
|
# bei typ o nur auf schlitz schliessen
|
||||||
|
#Dbg("Skip0: t:$typ w:$winstate r:$skipRunter h:$skipHoch");
|
||||||
$skipRunter=SKIP_DOWN;
|
$skipRunter=SKIP_DOWN;
|
||||||
}
|
}
|
||||||
# Zur Schlafzeit nicht oeffnen
|
|
||||||
if (index($typ, "s") != -1) {
|
if (index($typ, "s") != -1) {
|
||||||
|
# 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:$skipHoch");
|
||||||
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:$skipRunter h:$skipHoch");
|
||||||
@@ -392,19 +410,20 @@ sub RollCheck()
|
|||||||
for $r ( @rolls ) {
|
for $r ( @rolls ) {
|
||||||
#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) = checkTemps($tempIn, $tempOut, $r->{tempSoll}); # Temperatur klassifizieren
|
||||||
my($sunIn, $sunDir) =checkSunIn($twil, $sr, $r->{dir}, $sonneblock, $sunny); # Sonne scheint ins Fenster ?
|
my $sun = checkSun($twil,$sonneblock, $sunny); # Sonne scheint (bleibt true für best. Zeit) ?
|
||||||
# Offene Fenster nicht mit Rollaeden verschliessen, zur Schlafenszeit nicht öffnen
|
my $sunDir =checkSunDir($twil, $sr, $r->{dir}); # Sonne scheint ins Fenster ?
|
||||||
|
# Offene Fenster nicht mit Rollaeden verschliessen, zur Schlafenszeit nicht öffnen
|
||||||
my ($skipRunter, $skipHoch)=checkSkip($r);
|
my ($skipRunter, $skipHoch)=checkSkip($r);
|
||||||
# Bedingungen zum Fahren
|
# Bedingungen zum Fahren
|
||||||
my $Hot = $tempO>=TEMP_HOT;
|
my $Hot = $tempO>=TEMP_HOT;
|
||||||
my $WarmSun = $sunIn && $tempO>=TEMP_HIGH;
|
my $WarmSun = $sun && $sunDir && $tempO>=TEMP_HIGH;
|
||||||
my $WarmHotIn = $sunDir && $tempO>=TEMP_HIGH && $tempI>=TEMP_HOT;
|
my $WarmHotIn = $sunDir && $tempO>=TEMP_HIGH && $tempI>=TEMP_HOT;
|
||||||
my $ForecastHotSun = $sunIn && $tempOutMaxForecast>=$tempOutForecastLimit;
|
my $ForecastHotSun = $sun && $sunDir && $tempOutMaxForecast>=$tempOutForecastLimit;
|
||||||
my $ForecastHotWarmIn = $sunDir && $tempOutMaxForecast>=$tempOutForecastLimit && $tempI>=TEMP_HIGH;
|
my $ForecastHotWarmIn = $sunDir && $tempOutMaxForecast>=$tempOutForecastLimit && $tempI>=TEMP_HIGH;
|
||||||
my $Cold = $tempO<=TEMP_COLD;
|
my $Cold = $tempO<=TEMP_COLD;
|
||||||
my $NoSunNotHot = !$sunIn && ($tempO<=TEMP_LOW || $tempI<=TEMP_OK);
|
my $NoSunNotHot = !$sunDir && ($tempO<=TEMP_LOW || $tempI<=TEMP_OK);
|
||||||
|
|
||||||
if (!$tag) {
|
if (!$tag) {
|
||||||
$run=RollRunter($r, $skipRunter, $ndelay++);
|
$run=RollRunter($r, $skipRunter, $ndelay++);
|
||||||
@@ -412,20 +431,22 @@ sub RollCheck()
|
|||||||
$run=RollHoch($r, $skipHoch, $ndelay++);
|
$run=RollHoch($r, $skipHoch, $ndelay++);
|
||||||
} elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) {
|
} elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) {
|
||||||
$run=RollRunterSchlitz($r, $skipRunter, $ndelay++);
|
$run=RollRunterSchlitz($r, $skipRunter, $ndelay++);
|
||||||
|
if ($run) { SchlitzBlockStart($r); }
|
||||||
} elsif ( $Cold || $NoSunNotHot ) {
|
} elsif ( $Cold || $NoSunNotHot ) {
|
||||||
if(!SchlitzBlockCheck($r)) { $run=RollHoch($r, $skipHoch, $ndelay++); }
|
if(!SchlitzBlockCheck($r)) { $run=RollHoch($r, $skipHoch, $ndelay++); }
|
||||||
} elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch
|
} elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch
|
||||||
$run=RollHoch($r, $skipHoch, $ndelay++);
|
$run=RollHoch($r, $skipHoch, $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 sr:$sr block:$sonneblock tomax:$tempOutMaxForecast "
|
||||||
. "$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut sun:$sunIn/$sunDir wett:$wett sr:$sr "
|
. "$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut sun:$sun/$sunDir 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:$skipRunter,$skipHoch st:$r->{state}");
|
||||||
# }
|
}
|
||||||
} # for $r
|
} # for $r
|
||||||
$tagalt=$tag;
|
$tagalt=$tag;
|
||||||
$wachalt=$wach;
|
$wachalt=$wach;
|
||||||
|
#$sunDiralt=$sunDir
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------
|
#------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user