From 503a906aaffa57b05d9514614087c57ef2183a2d Mon Sep 17 00:00:00 2001 From: tobiasfaust <> Date: Thu, 22 May 2014 13:57:52 +0000 Subject: [PATCH] Sprinkle.pm: add fix for schedule in past git-svn-id: https://svn.fhem.de/fhem/trunk@5931 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/97_SprinkleControl.pm | 2 +- fhem/contrib/98_Sprinkle.pm | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fhem/contrib/97_SprinkleControl.pm b/fhem/contrib/97_SprinkleControl.pm index 528819f73..fcf8be3a9 100644 --- a/fhem/contrib/97_SprinkleControl.pm +++ b/fhem/contrib/97_SprinkleControl.pm @@ -271,7 +271,7 @@ sub UpdateSprinkleControlList($$) { foreach my $d (sort keys %defs) { if($defs{$d}{TYPE} eq "SprinkleControl") { - push(@newlist, $d) unless(defined($hash) && ($d eq $hash->{NAME}) && ($cmd eq "del")) + push(@newlist, $d) unless(defined($hash) && ($d eq $hash->{NAME}) && ($cmd eq "del")); } } diff --git a/fhem/contrib/98_Sprinkle.pm b/fhem/contrib/98_Sprinkle.pm index 1a00e7824..5e4800a77 100644 --- a/fhem/contrib/98_Sprinkle.pm +++ b/fhem/contrib/98_Sprinkle.pm @@ -285,10 +285,14 @@ sub Sprinkle_InternalTimerDoIt(@) { my ($rel, $hr, $min, $sec) = ($1, $2, $3, $4); my @lt = localtime(time); my $nt = time; - $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 - + + if($rel ne "+") { + $nt -= (($lt[2]*3600)+($lt[1]*60)+$lt[0]); # Midnight for absolute time + $nt += 86400 if((($lt[2]*3600)+($lt[1]*60)+$lt[0]) >= (($hr*3600)+($min*60)+$sec)); # tomorrow is next time + } + + $nt += (($hr*3600)+($min*60)+$sec); # Plus relative time + @lt = localtime($nt); my $ntm = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]); $hash->{NextTime} = $ntm; @@ -394,7 +398,7 @@ sub Sprinkle_DoIt($$) { if($oldState ne "on" && (($SprinkleControl && SprinkleControl_AllocateNewThread($SprinkleControl, $me, $cmd)) || !$SprinkleControl)) { fhem "set $device $OnCmdAdd $OnCmd"; $doit = 1; - } elsif ($oldState ne $newState) { + } elsif($oldState ne $newState) { $newState = "Wait"; $doit = 2; } @@ -408,7 +412,6 @@ sub Sprinkle_DoIt($$) { } readingsSingleUpdate($hash, "state", $newState, 1) if($doit >= 1); - return $newState; }