From 7a721de180e8236584a823eb73c5d4170f12a2a0 Mon Sep 17 00:00:00 2001 From: orti-otto <> Date: Tue, 7 Feb 2017 23:47:53 +0000 Subject: [PATCH] 98_RandomTimer: improvment when diabling a timer during active runtime git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@13356 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/98_RandomTimer.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FHEM/98_RandomTimer.pm b/FHEM/98_RandomTimer.pm index 65ba70778..e8aabf0c6 100644 --- a/FHEM/98_RandomTimer.pm +++ b/FHEM/98_RandomTimer.pm @@ -168,8 +168,9 @@ sub RandomTimer_Exec($) { Log3 $hash, 3, "[".$hash->{NAME}."]"." ending RandomTimer on $hash->{DEVICE}: " . strftime("%H:%M:%S(%d)",localtime($hash->{helper}{startTime})) . " - " . strftime("%H:%M:%S(%d)",localtime($hash->{helper}{stopTime})); - RandomTimer_setState ($hash); + RandomTimer_down($hash); RandomTimer_setActive($hash,0); + RandomTimer_setState ($hash); } # Wenn aktiv und Abschaltzeit erreicht, dann Gerät ausschalten, Meldung ausgeben und Timer schließen if ($stopTimeReached) { @@ -264,9 +265,9 @@ sub RandomTimer_Attr($$$) { if( $attrName ~~ ["disable","disableCond"] ) { - #RandomTimer_setState($hash); # funktioniert nicht, weil zu diesem Zeitpunkt der Attributwerte noch nicht gesetzt ist. - RemoveInternalTimer($hash); - InternalTimer (time()+1, "RandomTimer_setState", $hash, 0); + # Schaltung vorziehen, damit bei einem disable abgeschaltet wird. + myRemoveInternalTimer("Exec", $hash); + myInternalTimer ("Exec", time()+1, "RandomTimer_Exec", $hash, 0); } return undef; }