From b79ef8504d6fa69f5568ca0edb359732abd863e0 Mon Sep 17 00:00:00 2001 From: Marc Hoppe Date: Fri, 21 Aug 2020 22:51:17 +0200 Subject: [PATCH] ...check slot down --- fhem/FHEM/99_MyUtils.pm | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/fhem/FHEM/99_MyUtils.pm b/fhem/FHEM/99_MyUtils.pm index fc52e6b74..4b5a1e6ee 100644 --- a/fhem/FHEM/99_MyUtils.pm +++ b/fhem/FHEM/99_MyUtils.pm @@ -27,7 +27,6 @@ use constant { }; my $tempIn_offset = +0; my $tempOut_offset = +2; -my $tempOutForecastLimit = 27; # CheckSkip use constant { @@ -56,7 +55,7 @@ my @rolls = ( { 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=>"", block=>"", 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=>"", block=>"", state=>STATE_IDLE, }, + { roll => "schlaf.rollStr", dir=>"O", typ=>"o", temp=>"tempSchlaf", tempSoll=>18, win=>"", block=>"", state=>STATE_IDLE, }, ); @@ -103,7 +102,7 @@ sub SetRollSlot($) { my $r = findRoll($name); if (defined $r) { Dbg("found $r->{roll}"); - RollSlot($r, SKIP_NO, 0); + RollSlot($r, 0); } return undef } @@ -124,9 +123,14 @@ 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 + #myfhem("set ".$name." up ".$sec); + if ($st eq "closed") { myfhem("set ".$name." up ".$sec); } + else { # noch nicht geschlossen: nochmal versuchen + my $t=getDelayTime(39); + my $i=$tc++; + myfhem("set ".$name." closes"); + myfhem("define ru".$i." at +".$t." {RollUpSec(\"".${name}."\",6);;}"); + } } #------------------------------------------ @@ -140,7 +144,6 @@ sub RollSlot($$) { 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);;}"); } @@ -260,6 +263,8 @@ sub IsWetterSonneWait($) return(0); } +#------------------------------------------ + sub SlotBlockStart($) { my ($r) = @_; @@ -270,6 +275,8 @@ sub SlotBlockStart($) Dbg("Schlitzblockstart $r->{roll}"); } +#------------------------------------------ + sub SlotBlockCheck($) { my ($r) = @_; @@ -334,7 +341,7 @@ sub checkTemps($$$$) if ($tempOut < $tempSoll+$tempOut_offset-1.0) { $tempO=TEMP_LOW; } 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, $tempF); } #------------------------------------------ @@ -416,12 +423,12 @@ sub RollCheck() state $wachalt=0; my $r; - my $ndelay = 0; - my $tempOut = ReadingsVal("myWH1080", "Temp-outside", 40); - my $tempOutMaxForecast = getTempMaxForecast(); #ReadingsVal("wetter", "tempHigh", 40), - my $twil = Value("twil"); - my $light = ReadingsVal("twil", "light", 0); - my $wett = ReadingsVal("wetter", "code", 99); + my $ndelay = 0; + my $tempOut = ReadingsVal("myWH1080", "Temp-outside", 40); + my $tempForecast = getTempMaxForecast(); + my $twil = Value("twil"); + my $light = ReadingsVal("twil", "light", 0); + my $wett = ReadingsVal("wetter", "code", 99); my $sr = Value("sonnenrichtung"); my $dawn = 0; @@ -434,10 +441,9 @@ sub RollCheck() $dawn=1; } for $r ( @rolls ) { - #Dbg("--------r:g ".$r->{roll}." / ".$r->{temp}); my $run=0; my $tempIn = ReadingsVal($r->{temp},"temperature", 99); - my($tempI, $tempO, $tempF) = checkTemps($tempIn, $tempOut, $tempOutForecastLimit, $r->{tempSoll}); # Temperatur klassifizieren + my($tempI, $tempO, $tempF) = checkTemps($tempIn, $tempOut, $tempForecast, $r->{tempSoll}); # Temperatur klassifizieren my $dirIn = checkSunDir($twil, $sr, $r->{dir}); # Sonne scheint ins Fenster ? # Offene Fenster nicht mit Rollaeden verschliessen, zur Schlafenszeit nicht öffnen my ($skipDown, $skipUp)=checkSkip($r); @@ -449,24 +455,25 @@ sub RollCheck() my $ForecastHotWarmIn = $dirIn && $tempF>=TEMP_HOT && $tempI>=TEMP_HIGH; # Bedingungen zum öffnen (nach Schlitz) my $Cold = $tempO<=TEMP_COLD; - my $NoSunNotHot = !$dirIn && ($tempO<=TEMP_OK || $tempI<=TEMP_OK); + my $NoSunNotHot = !$dirIn && ($tempO<=TEMP_HIGH || $tempI<=TEMP_OK); if (!$tag) { - $run=RollDownState($r, $skipDown, $ndelay++); + if (index($r->{typ}, "o") != -1) { $run=RollUpState ($r, $skipUp, $ndelay++); } + else { $run=RollDownState($r, $skipDown, $ndelay++); } } elsif ($dawn) { # Abenddämmerung $run=RollUpState($r, $skipUp, $ndelay++); } elsif ($Hot || $WarmSun || $WarmHotIn || $ForecastHotSun || $ForecastHotWarmIn) { $run=RollSlotState($r, $skipDown, $ndelay++); } elsif ( $Cold || $NoSunNotHot ) { - if(!SlotBlockCheck($r)) { $run=RollUp($r, $skipUp, $ndelay++); } + if(!SlotBlockCheck($r)) { $run=RollUpState($r, $skipUp, $ndelay++); } } elsif ( ($tag && !$tagalt) || ($wach && !$wachalt) ) { # bei Tagesbeginn hoch $run=RollUpState($r, $skipUp, $ndelay++); } if ($run) { Dbg("RollCheck: H:$Hot WS:$WarmSun WHI:$WarmHotIn FHS:$ForecastHotSun FHI:$ForecastHotWarmIn C:$Cold NSNH:$NoSunNotHot " - . "to:$tempOut twil:$twil light:$light wett:$wett tomax:$tempOutMaxForecast " + . "to:$tempOut twil:$twil light:$light wett:$wett tomax:$tempForecast " . "$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:$skipDown,$skipUp st:$r->{state}"); + . "twil:$twil tag:$tag/$tagalt wach:$wach/$wachalt skipR,H:$skipDown,$skipUp st:$r->{state} dawn:$dawn"); } } # for $r $tagalt=$tag;