99-my temperatur-hysterese

This commit is contained in:
2016-04-10 20:33:38 +02:00
parent 5fa56b6b47
commit 0ca1b464c5

View File

@@ -18,17 +18,17 @@ use constant {
my @rolls = (
{ roll => "wohn.rollTerrR", dir=>"W", typ=>"n", temp=>"tempWohn", tempS=>21, win=>"wohn.fenTerr", state=>STATE_IDLE, },
{ roll => "wohn.rollTerrL", dir=>"W", typ=>"n", temp=>"tempWohn", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "wohn.rollSofa", dir=>"S", typ=>"n", temp=>"tempWohn", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "ess.roll", dir=>"S", typ=>"n", temp=>"tempWohn", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollBar", dir=>"S", typ=>"n", temp=>"tempKueche", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollStr", dir=>"O", typ=>"n", temp=>"tempKueche", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "arb.rollTerr", dir=>"W", typ=>"n", temp=>"tempStudio", tempS=>21, win=>"wohn.fenTerr", state=>STATE_IDLE, },
{ roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempS=>21, win=>"", state=>STATE_IDLE, },
{ roll => "bad.roll", dir=>"S", typ=>"n", temp=>"tempBad", tempS=>23, win=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollWeg", dir=>"S", typ=>"s", temp=>"tempSchlaf", tempS=>18, win=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollStr", dir=>"O", typ=>"s", temp=>"tempSchlaf", tempS=>18, win=>"wohn.fenTerr", state=>STATE_IDLE, },
{ roll => "wohn.rollTerrR", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>21, tempSchalt=>-1, win=>"wohn.fenTerr", state=>STATE_IDLE, },
{ roll => "wohn.rollTerrL", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "wohn.rollSofa", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "ess.roll", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollBar", dir=>"S", typ=>"n", temp=>"tempKueche", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollStr", dir=>"O", typ=>"n", temp=>"tempKueche", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "arb.rollTerr", dir=>"W", typ=>"n", temp=>"tempStudio", tempSoll=>21, tempSchalt=>-1, win=>"wohn.fenTerr", state=>STATE_IDLE, },
{ roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempSoll=>21, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "bad.roll", dir=>"S", typ=>"n", temp=>"tempBad", tempSoll=>23, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollWeg", dir=>"S", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, tempSchalt=>-1, win=>"", state=>STATE_IDLE, },
{ roll => "schlaf.rollStr", dir=>"O", typ=>"s", temp=>"tempSchlaf", tempSoll=>18, tempSchalt=>-1, win=>"wohn.fenTerr", state=>STATE_IDLE, },
);
#my %rollStates = (
@@ -87,12 +87,18 @@ my @rollArb = (
my $tc=0;
my @blocktime=localtime;
my $blocktimerRunning=0;
my $tempHystOffset=-0.9;
my $tempHighOffset=0.3;
#------------------------------------------
sub myfhem($) {
#Log 1, "@_";
fhem("@_");
}
#------------------------------------------
sub RollCheckSkip($$)
{
my($cmd, $roll) = @_;
@@ -107,6 +113,8 @@ sub RollCheckSkip($$)
return $skip
}
#------------------------------------------
sub RollCmd($$$)
{
my ($cmd, $roll, $delay) = @_;
@@ -114,6 +122,8 @@ sub RollCmd($$$)
myfhem ("define r".int(rand(10000))." at +".$delay." set ".$roll." ".$cmd);
}
}
#------------------------------------------
sub RollGroup(\@$$)
{
@@ -147,10 +157,14 @@ sub RollGroup(\@$$)
}
}
#------------------------------------------
sub RollTest() {
&RollGroup(\@rollTest, "closes", 1);
}
#------------------------------------------
sub RollAll($$) {
# Log 1, "################";
my ($cmd, $delay) = @_;
@@ -164,6 +178,7 @@ sub RollAll($$) {
}
}
#------------------------------------------
sub RollWeck($) {
my ($delay) = @_;
@@ -175,9 +190,13 @@ sub RollWeck($) {
#------------------------------------------
sub Dbg($) {
Log 1,$_[0];
if(Value("DebugRoll") eq "1") {
Log 1,$_[0];
}
}
#------------------------------------------
sub RollRunterSchlitz($;$) {
my ($roll, $delay) = @_;
$delay ||= 0;
@@ -193,6 +212,8 @@ sub RollRunterSchlitz($;$) {
myfhem("define ru".$i." at +".$t2." set ".$roll." up 6");
}
#------------------------------------------
sub RollHoch($;$) {
my ($roll, $delay) = @_;
$delay ||= 0;
@@ -205,6 +226,8 @@ sub RollHoch($;$) {
myfhem("define r".$i." at +".$t." set ".$roll." opens");
}
#------------------------------------------
sub RollRunter($;$) {
my ($roll, $delay) = @_;
$delay ||= 0;
@@ -217,6 +240,8 @@ sub RollRunter($;$) {
myfhem("define r".$i." at +".$t." set ".$roll." closes");
}
#------------------------------------------
sub IsSunny($) {
my ($wett)=@_;
if($wett==30 || $wett==31 || $wett==32 || $wett==33 || $wett==34 || $wett==35 || $wett==36) { # sonnig, heiter, heiss
@@ -225,6 +250,8 @@ sub IsSunny($) {
return(0);
}
#------------------------------------------
sub IsLater($) {
my($t)=@_;
#Dbg("Islater:$t");
@@ -236,7 +263,7 @@ sub IsLater($) {
return(0);
}
#------------------------------------------
# Nach dem Wechsel auf !sonne noch 2Std warten
sub IsWetterSonneWait($) {
@@ -268,15 +295,17 @@ sub IsWetterSonneWait($) {
return(0);
}
#------------------------------------------
sub RollCheck() {
# Dbg("RollCheck\n");
my $temp=20;
my $r;
my $i=0;
my $delay=11;
my $tag=0;
my $tempOut=ReadingsVal("wetter", "temp_c", 99);
#my $tempOut=ReadingsVal("wetter", "temp_c", 99);
my $tempOut=ReadingsVal("naAussen", "temperature", 99);
my $twil=Value("twil");
if ($twil>=3 && $twil<10) { # civil
@@ -296,6 +325,7 @@ sub RollCheck() {
# Nach wechsel von sonne auf !sonne blockert ?
my $sonneblock=IsWetterSonneWait($wett);
Dbg("RollCheck to:$tempOut twil:$twil light:$light wett:$wett sr:$sr block:$sonneblock\n");
for $r ( @rolls ) {
@@ -311,18 +341,26 @@ sub RollCheck() {
# Raum zu warm und aussentemp hoch ?
#$temp=ReadingsVal($r->{temp},"measured-temp", 99);
$temp=ReadingsVal($r->{temp},"temperature", 99);
if( ($temp>$r->{tempS} && $tempOut>($r->{tempS}-3)) || $temp>($r->{tempS}+2) ) {
$tempH=1;
}
if( $temp<$r->{tempS}-1 ) {
$tempL=1;
my $tempSoll=$r->{tempSoll};
my $tempSchalt=$tempSoll;
my $tempHyst=99;
if($r->{tempSchalt}>-1) {
$tempSchalt=$r->{tempSchalt};
}
if( ($temp>$tempSoll && $tempOut>($tempSoll-3)) || $temp>($tempSoll+2) ) {
$tempH=1;
}
if( $temp<$tempSoll-1 ) {
$tempL=1;
}
# Sonne scheint ins Fenster ?
if($twil>=5 && $twil<7) { # nur, wenn der Sonnenstand ueber 'weather' liegt
# bei hoher Raum- und Aussentemperatur immer unten lassen
if($temp > ($r->{tempS}+2) && $tempOut > $r->{tempS}) {
if($temp > ($tempSchalt+$tempHighOffset) && $tempOut > $tempSoll+$tempHighOffset) {
$sonne=1;
$tempHyst=$tempHystOffset;
}
elsif (index($sr, $r->{dir}) != -1) { # Sonnenrichtung ins Fenster
if($sonneblock) {
@@ -351,7 +389,7 @@ sub RollCheck() {
}
}
#Dbg("RollCheck:$r->{roll}-tempH:$tempH temp:$temp tempO:$tempOut so:$sonne wett:$wett sr:$sr twil:$twil tag:$tag fen:$fen skipR:$skipRunter skipH:$skipHoch st:$r->{state}");
Dbg("RollCheck:$r->{roll}-tempH:$tempH temp:$temp tempO:$tempOut so:$sonne wett:$wett sr:$sr twil:$twil tag:$tag fen:$fen skipR:$skipRunter skipH:$skipHoch st:$r->{state} h:$tempHyst ts:$tempSchalt");
if( $tag and $sonne and $tempH) {
if($r->{state}!=STATE_SCHLITZ) {
@@ -364,6 +402,7 @@ sub RollCheck() {
if(($tag && !$sonne)||($tag && $tempL)) {
if($r->{state}!=STATE_HOCH) {
$tempHyst=0;
if(!$skipHoch) {
RollHoch($r->{roll}, $ndelay);
$r->{state}=STATE_HOCH;
@@ -379,10 +418,14 @@ sub RollCheck() {
$r->{state}=STATE_RUNTER;
}
}
if($tempHyst<50) {
$r->{tempSchalt}=$tempSoll+$tempHyst;
}
$i=$i+1;
} # for
}
#------------------------------------------
sub Untoggle($) {
my ($obj) = @_;