This commit is contained in:
Marc Hoppe
2019-12-13 16:39:19 +01:00
parent da05479fed
commit 2f68aa9b4f

View File

@@ -40,65 +40,65 @@ use constant {
# dir: Himmelsrichtung des Fensters # dir: Himmelsrichtung des Fensters
# typ: n-normal, s-schlaf bis wecken geschlossen, o-nachts offen # typ: n-normal, s-schlaf bis wecken geschlossen, o-nachts offen
my @rolls = ( my @rolls = (
{ roll => "wohn.rollTerrR", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"wohn.fenTerr", state=>STATE_IDLE, }, { roll => "wohn.rollTerrR", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"wohn.fenTerr", block=>"", state=>STATE_IDLE, },
{ roll => "wohn.rollTerrL", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", state=>STATE_IDLE, }, { roll => "wohn.rollTerrL", dir=>"W", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "wohn.rollSofa", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", state=>STATE_IDLE, }, { roll => "wohn.rollSofa", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "ess.roll", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", state=>STATE_IDLE, }, { roll => "ess.roll", dir=>"S", typ=>"n", temp=>"tempWohn", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollBar", dir=>"S", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", state=>STATE_IDLE, }, { roll => "kuch.rollBar", dir=>"S", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", block=>"", state=>STATE_IDLE, },
{ roll => "kuch.rollStr", dir=>"O", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", state=>STATE_IDLE, }, { roll => "kuch.rollStr", dir=>"O", typ=>"n", temp=>"tempKueche", tempSoll=>20, win=>"", block=>"", 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=>"wohn.fenTerr", block=>"blockRoll", state=>STATE_IDLE, },
{ roll => "arb.rollWeg", dir=>"S", typ=>"n", temp=>"tempStudio", tempSoll=>20, win=>"", 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=>"", 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=>"", 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=>"", state=>STATE_IDLE, }, { roll => "schlaf.rollStr", dir=>"O", typ=>"so", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, },
); );
my @rollHoch = ( #my @rollHoch = (
"bad.roll", # "bad.roll",
"arb.rollWeg", # "arb.rollWeg",
"arb.rollTerr", # "arb.rollTerr",
"kuch.rollStr", # "kuch.rollStr",
"kuch.rollBar", # "kuch.rollBar",
"ess.roll", # "ess.roll",
"wohn.rollSofa", # "wohn.rollSofa",
"wohn.rollTerrL", # "wohn.rollTerrL",
"wohn.rollTerrR" # "wohn.rollTerrR"
); #);
#
#
my @rollRunter = ( #my @rollRunter = (
"wohn.rollTerrR", # "wohn.rollTerrR",
"wohn.rollTerrL", # "wohn.rollTerrL",
"wohn.rollSofa", # "wohn.rollSofa",
"ess.roll", # "ess.roll",
"kuch.rollBar", # "kuch.rollBar",
"kuch.rollStr", # "kuch.rollStr",
"arb.rollTerr", # "arb.rollTerr",
"arb.rollWeg", # "arb.rollWeg",
"bad.roll", # "bad.roll",
"schlaf.rollWeg" # "schlaf.rollWeg"
## "schlaf.rollStr"
#);
#
#my @rollWeck = (
# "schlaf.rollWeg",
# "schlaf.rollStr" # "schlaf.rollStr"
); #);
#
my @rollWeck = ( #my @rollTest = (
"schlaf.rollWeg", # "wohn.rollTerrR"
"schlaf.rollStr" #);
); #
#my @rollSchlaf = (
my @rollTest = ( # "schlaf.rollWeg",
"wohn.rollTerrR" # "schlaf.rollStr"
); #);
#
my @rollSchlaf = ( #my @rollArb = (
"schlaf.rollWeg", # "arb.rollTerr",
"schlaf.rollStr" # "arb.rollWeg",
); #);
my @rollArb = (
"arb.rollTerr",
"arb.rollWeg",
);
my $tc=0; my $tc=0;
my @blocktime=localtime; my @blocktime=localtime;
@@ -106,7 +106,7 @@ my $blocktimerRunning=0;
my $delaySec=11; my $delaySec=11;
my $tempIn_offset=0; my $tempIn_offset=0;
my $tempOut_offset=+5; my $tempOut_offset=+3;
#------------------------------------------ #------------------------------------------
@@ -118,120 +118,135 @@ sub myfhem($)
#------------------------------------------ #------------------------------------------
sub RollCheckSkip($$) sub findRoll($)
{ {
my($cmd, $roll) = @_; my($name) = @_;
my $skip=0;
if ($cmd eq "closes") {
if ($roll eq "wohn.rollTerrR") {
if (Value("wohn.fenTerr") eq "Open") {
$skip=1;
}
}
}
return $skip
}
#------------------------------------------
sub RollCmd($$$)
{
my ($cmd, $roll, $delay) = @_;
if(RollCheckSkip($cmd, $roll)==0) {
myfhem ("define r".int(rand(10000))." at +".$delay." set ".$roll." ".$cmd);
}
}
#------------------------------------------
sub RollGroup(\@$$)
{
my ($rolls, $cmd, $delay) = @_;
#Log 1, "RollGroup ## cmd:$cmd del:$delay";
my $i;
my @myrolls;
@myrolls=@$rolls;
$i=0;
for my $r (@myrolls) {
my @tparts = gmtime($i*$delay+1);
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
my $skip=0;
#$t="00:00:".sprintf("%02d", $i*5);
#Log 1, "time $t";
if ($cmd eq "closes") {
if ($r eq "wohn.rollTerrR") {
if (Value("wohn.fenTerr") eq "Open") {
$skip=1;
}
}
}
if($skip==0) {
myfhem ("define r".$i." at +".$t." set ".$r." ".$cmd);
}
$i=$i+1;
}
}
sub RollGroup2(\@$$)
{
my ($typ, $cmd, $delay) = @_;
#Log 1, "RollGroup ## cmd:$cmd del:$delay";
my $i=0;
my $r=0; my $r=0;
for $r (@rolls) { for $r (@rolls) {
if (index($r->{typ}, $typ) != -1) { if ($r->{roll} eq $name) {
my @tparts = gmtime($i*$delay+1); return $r;
my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
my $skip=0;
#$t="00:00:".sprintf("%02d", $i*5);
#Log 1, "time $t";
if ($cmd eq "closes") {
if ($r eq "wohn.rollTerrR") {
if (Value("wohn.fenTerr") eq "Open") {
$skip=1;
}
}
}
if($skip==0) {
myfhem ("define r".$i." at +".$t." set ".$r." ".$cmd);
}
$i=$i+1;
} }
} }
return undef;
} }
#------------------------------------------ #------------------------------------------
sub RollTest() { #sub RollCheckSkip($$)
&RollGroup(\@rollTest, "closes", 1); #{
} # my($cmd, $roll) = @_;
# my $skip=0;
#------------------------------------------ # if ($cmd eq "closes") {
# if ($roll eq "wohn.rollTerrR") {
sub RollAll($$) { # if (Value("wohn.fenTerr") eq "Open") {
my ($cmd, $delay) = @_; # $skip=1;
# Log 1, "c:$cmd d:$delay"; # }
if($cmd eq "closes") { # }
&RollGroup(\@rollRunter, $cmd,$delay); # }
} # return $skip
else { #}
&RollGroup(\@rollHoch, $cmd,$delay); #
} ##------------------------------------------
} #
#sub RollCmd($$$)
#------------------------------------------ #{
# my ($cmd, $roll, $delay) = @_;
sub RollWeck($) { # if(RollCheckSkip($cmd, $roll)==0) {
my ($delay) = @_; # myfhem ("define r".int(rand(10000))." at +".$delay." set ".$roll." ".$cmd);
#&RollGroup(\@rollWeck, "up 5", $delay); # }
&RollGroup(\@rollWeck, "opens", $delay); #}
myfhem("define weckwachat at +03:00:00 set wach 1"); #
} ##------------------------------------------
#
#------------------------------------------ #sub RollGroup(\@$$)
#{
# my ($rolls, $cmd, $delay) = @_;
# #Log 1, "RollGroup ## cmd:$cmd del:$delay";
# my $i;
# my @myrolls;
# @myrolls=@$rolls;
#
# $i=0;
# for my $r (@myrolls) {
# my @tparts = gmtime($i*$delay+1);
# my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
# my $skip=0;
# #$t="00:00:".sprintf("%02d", $i*5);
# #Log 1, "time $t";
# if ($cmd eq "closes") {
# if ($r eq "wohn.rollTerrR") {
# if (Value("wohn.fenTerr") eq "Open") {
# $skip=1;
# }
# }
# }
# if($skip==0) {
# myfhem ("define r".$i." at +".$t." set ".$r." ".$cmd);
# }
# $i=$i+1;
# }
#}
#
#
#sub RollGroup2(\@$$)
#{
# my ($typ, $cmd, $delay) = @_;
# #Log 1, "RollGroup ## cmd:$cmd del:$delay";
# my $i=0;
# my $r=0;
#
# for $r (@rolls) {
# if (index($r->{typ}, $typ) != -1) {
# my @tparts = gmtime($i*$delay+1);
# my $t=sprintf ("%02d:%02d:%02d",@tparts[2,1,0]);
# my $skip=0;
# #$t="00:00:".sprintf("%02d", $i*5);
# #Log 1, "time $t";
# if ($cmd eq "closes") {
# if ($r eq "wohn.rollTerrR") {
# if (Value("wohn.fenTerr") eq "Open") {
# $skip=1;
# }
# }
# }
# if($skip==0) {
# myfhem ("define r".$i." at +".$t." set ".$r." ".$cmd);
# }
# $i=$i+1;
# }
# }
#}
#
##------------------------------------------
#
#sub RollTest() {
# &RollGroup(\@rollTest, "closes", 1);
#}
#
##------------------------------------------
#
#sub RollAll($$) {
# my ($cmd, $delay) = @_;
## Log 1, "c:$cmd d:$delay";
# if($cmd eq "closes") {
# &RollGroup(\@rollRunter, $cmd,$delay);
# }
# else {
# &RollGroup(\@rollHoch, $cmd,$delay);
# }
#}
#
##------------------------------------------
#
#sub RollWeck($) {
# my ($delay) = @_;
# #&RollGroup(\@rollWeck, "up 5", $delay);
# &RollGroup(\@rollWeck, "opens", $delay);
# myfhem("define weckwachat at +03:00:00 set wach 1");
#}
#
##------------------------------------------
sub Dbg($) { sub Dbg($) {
if(Value("DebugRoll") eq "1") { if(Value("DebugRoll") eq "1") {
@@ -320,6 +335,8 @@ sub getWeather($)
return(WEATHER_BAD); return(WEATHER_BAD);
} }
#------------------------------------------
sub IsSunny($) sub IsSunny($)
{ {
my ($wett)=@_; my ($wett)=@_;
@@ -427,11 +444,17 @@ sub checkSunIn($$$$$)
#------------------------------------------ #------------------------------------------
# Offene Fenster nicht mit Rollaeden verschliessen # Offene Fenster nicht mit Rollaeden verschliessen
sub checkSkip($$$) sub checkSkip($$)
{ {
my ($winstate, $typ, $wach)=@_; my ($r, $wach)=@_;
my $winstate=Value($r->{win});
my $typ=$r->{typ};
my $skipRunter=SKIP_NO; my $skipHoch=SKIP_NO; my $skipRunter=SKIP_NO; my $skipHoch=SKIP_NO;
if (Value($r->{block})) {
$skipRunter=SKIP_ALL;
$skipHoch=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; $skipRunter=SKIP_ALL;
@@ -488,7 +511,7 @@ sub RollCheck()
my($tempI, $tempO)=checkTemps($tempIn, $tempOut, $r->{tempSoll}); # Temperatur klassifizieren my($tempI, $tempO)=checkTemps($tempIn, $tempOut, $r->{tempSoll}); # Temperatur klassifizieren
my $sunIn=checkSunIn($twil, $sr, $r->{dir}, $sonneblock, $sunny); # Sonne scheint ins Fenster ? my $sunIn=checkSunIn($twil, $sr, $r->{dir}, $sonneblock, $sunny); # 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(Value($r->{win}), $r->{typ}, $wach); my ($skipRunter, $skipHoch)=checkSkip($r, $wach);
Dbg("RollCheck:$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut so:$sunIn wett:$wett sr:$sr " Dbg("RollCheck:$r->{roll}-tempLevI,O:$tempI,$tempO tempI,O:$tempIn,$tempOut so:$sunIn wett:$wett sr:$sr "
. "twil:$twil tag:$tag wach:$wach skipR,H:$skipRunter,$skipHoch st:$r->{state}"); . "twil:$twil tag:$tag wach:$wach skipR,H:$skipRunter,$skipHoch st:$r->{state}");
if (!$tag) { if (!$tag) {