From 1a547a5616d1b4ef7f3626c628664a5685eb2ea0 Mon Sep 17 00:00:00 2001 From: dietmar63 Date: Fri, 23 Aug 2013 15:24:19 +0000 Subject: [PATCH] avoiding to raise light events on startup of Twilight git-svn-id: https://svn.fhem.de/fhem/trunk@3773 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/59_Twilight.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/59_Twilight.pm b/fhem/FHEM/59_Twilight.pm index ad8ff6ea2..fe1d41f98 100644 --- a/fhem/FHEM/59_Twilight.pm +++ b/fhem/FHEM/59_Twilight.pm @@ -1,4 +1,4 @@ -# $Id$ +# $Id ############################################################################## # # 59_Twilight.pm @@ -356,6 +356,10 @@ sub Twilight_fireEvent($) $nextEventTime = strftime("%H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})) if ($hash->{TW}{$nextEvent}{TIME} ne "nan"); Log 3, "[".$hash->{NAME}."] " . sprintf ("%-10s state=%-2s light=%-2s nextEvent=%-10s %-14s deg=%+.1f°",$sx_name, $state, $light, $nextEvent, strftime("%d.%m.%Y %H:%M:%S",localtime($hash->{TW}{$nextEvent}{TIME})), $deg); + my $eventTime = $hash->{TW}{$sx_name}{TIME}; + my $now = time(); + my $delta = abs ($now - $eventTime); + $hash->{STATE} = $state; readingsBeginUpdate($hash); readingsBulkUpdate ($hash, "light", $light); @@ -364,7 +368,9 @@ sub Twilight_fireEvent($) readingsBulkUpdate ($hash, "nextEvent", $nextEvent); readingsBulkUpdate ($hash, "nextEventTime", $nextEventTime); - readingsEndUpdate ($hash, defined($hash->{LOCAL} ? 0 : 1)); + my $doNotTrigger = $hash->{LOCAL}; + $doNotTrigger = $doNotTrigger || ($delta > 5); + readingsEndUpdate ($hash, !$doNotTrigger); } #