RollCheck

This commit is contained in:
2017-07-17 23:25:21 +02:00
parent 8617ead8e1
commit 3fc70eb26a

View File

@@ -24,11 +24,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, },
);
@@ -84,11 +84,12 @@ my $blocktimerRunning=0;
my $delaySec=11;
my $tempIn_offset=0;
my $tempOut_offset=+1;
my $tempOut_offset=+2;
#------------------------------------------
sub myfhem($) {
sub myfhem($)
{
#Log 1, "@_";
fhem("@_");
}
@@ -187,61 +188,71 @@ 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 ru".$i." at +".$t2." set ".$r->{roll}." up 6");
myfhem("define rc".$i." at +".$t1." set ".$r->{roll}." closes");
myfhem("define ru".$i." at +".$t2." set ".$r->{roll}." up 5");
$r->{state}=STATE_SCHLITZ;
}
}
#------------------------------------------
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
return(1);
@@ -251,7 +262,8 @@ sub IsSunny($) {
#------------------------------------------
sub IsLater($) {
sub IsLater($)
{
my($t)=@_;
#Dbg("Islater:$t");
my @time = localtime(time);
@@ -367,9 +379,11 @@ sub checkSkip($$$)
#------------------------------------------
sub RollCheck() {
sub RollCheck()
{
state $tagalt=0;
my $r;
my $ndelay =1;
my $ndelay =0;
my $tempOut=ReadingsVal("myWH1080", "Temp-outside", 99);
my $twil =Value("twil");
my $light =ReadingsVal("twil", "light", 0);
@@ -396,25 +410,26 @@ sub RollCheck() {
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}");
if (!$tag) {
Dbg(" runter");
if (!$skipRunter) { RollRunter($r, $ndelay++); }
}
elsif ($tag && $tempH && ($sonne || $tempOH)) {
Dbg(" schl");
elsif ($tag && $tempH && (($sonne && !$tempOL) || $tempOH)) {
if (!$skipHoch && !$skipRunter) { RollRunterSchlitz($r, $ndelay++); }
}
elsif ($tag && ($tempL || (!$sonne && $tempOL)) ) {
Dbg(" hoch");
elsif ($tag && $tempL && $tempOL) {
if (!$skipHoch) { RollHoch($r, $ndelay++); }
}
elsif ($tag && !$tagalt) { # bei Tagesbeginn und im Temp-hysteresebereich -> hoch
if (!$skipHoch) { RollHoch($r, $ndelay++); }
}
} # for
$tagalt=$tag;
}
#------------------------------------------
sub Untoggle($) {
sub Untoggle($)
{
my ($obj) = @_;
if (Value($obj) eq "toggle"){
if (OldValue($obj) eq "off") {