diff --git a/CHANGED b/CHANGED index 4c0f955c2..0a2c63826 100644 --- a/CHANGED +++ b/CHANGED @@ -583,3 +583,4 @@ - feature: CUL: optional baudrate spec in definition - feature: CUL: sendpool attribute - feature: CUL_HOERMANN module added + - bugfix: DST change: absolute at and relative sunrise fix diff --git a/FHEM/90_at.pm b/FHEM/90_at.pm index 286427db1..62aed421f 100755 --- a/FHEM/90_at.pm +++ b/FHEM/90_at.pm @@ -53,7 +53,7 @@ at_Define($$) $nt -= ($lt[2]*3600+$lt[1]*60+$lt[0]) # Midnight for absolute time if($rel ne "+"); $nt += ($hr*3600+$min*60+$sec); # Plus relative time - $nt += 86400 if($ot >= $nt); # Do it tomorrow... + $nt += SecondsTillTomorrow($ot) if($ot >= $nt); # Do it tomorrow... $nt += $at_tdiff if(defined($at_tdiff)); @lt = localtime($nt); diff --git a/FHEM/99_SUNRISE_EL.pm b/FHEM/99_SUNRISE_EL.pm index be5659832..6d394b2d9 100755 --- a/FHEM/99_SUNRISE_EL.pm +++ b/FHEM/99_SUNRISE_EL.pm @@ -67,11 +67,11 @@ sr($$$$$$) if($data{AT_RECOMPUTE} || # compute it for tommorow int(($nh-$sst)*3600) >= 0) { # if called a subsec earlier $nt += 86400; - $diff = 24; @lt = localtime($nt); - $gmtoff = _calctz($nt,@lt); # in hour + my $ngmtoff = _calctz($nt,@lt); # in hour + $diff = 24+$gmtoff-$ngmtoff; - ($rt,$st) = _sr($needrise,$needset, $lt[5]+1900,$lt[4]+1,$lt[3], $gmtoff); + ($rt,$st) = _sr($needrise,$needset, $lt[5]+1900,$lt[4]+1,$lt[3], $ngmtoff); $sst = ($rise ? $rt : $st) + ($seconds/3600); } diff --git a/fhem.pl b/fhem.pl index eacd7df8d..12ba01f1f 100755 --- a/fhem.pl +++ b/fhem.pl @@ -64,6 +64,7 @@ sub OpenLogfile($); sub PrintHash($$); sub ResolveDateWildcards($@); sub RemoveInternalTimer($); +sub SecondsTillTomorrow($); sub SemicolonEscape($); sub SignalHandling(); sub TimeNow(); @@ -159,13 +160,15 @@ my $nextat; # Time when next timer will be triggered. my $intAtCnt=0; my %duplicate; # Pool of received msg for multi-fhz/cul setups my $duplidx=0; # helper for the above pool -my $cvsid = '$Id: fhem.pl,v 1.103 2010-03-22 14:31:37 rudolfkoenig Exp $'; +my $cvsid = '$Id: fhem.pl,v 1.104 2010-04-02 14:20:53 rudolfkoenig Exp $'; my $namedef = "where is either:\n" . "- a single device name\n" . "- a list seperated by komma (,)\n" . "- a regexp, if contains one of the following characters: *[]^\$\n" . "- a range seperated by dash (-)\n"; +my $stt_sec; # Used by SecondsTillTomorrow() +my $stt_day; # Used by SecondsTillTomorrow() $init_done = 0; @@ -2215,3 +2218,23 @@ AddDuplicate($$) $duplicate{$duplidx}{TIM} = gettimeofday(); $duplidx++; } + +sub +SecondsTillTomorrow($) # 86400, if tomorrow is no DST change +{ + my $t = shift; + my $day = int($t/86400); + + if(!$stt_day || $day != $stt_day) { + my $t = $day*86400+12*3600; + my @l1 = localtime($t); + my @l2 = localtime($t+86400); + $stt_sec = 86400+ + ($l1[2]-$l2[2])*3600+ + ($l1[1]-$l2[1])*60; + $stt_day = $day; + } + + return $stt_sec; +} +