From 35254c7a8648b1cf8e107aca997b5b77657d10c6 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Wed, 29 Aug 2018 12:34:29 +0000 Subject: [PATCH] 91_notify.pm: add disabledAfterTrigger (Forum #90663) git-svn-id: https://svn.fhem.de/fhem/trunk@17225 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/91_notify.pm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/91_notify.pm b/fhem/FHEM/91_notify.pm index d4ffd1e3e..3f5ad804b 100644 --- a/fhem/FHEM/91_notify.pm +++ b/fhem/FHEM/91_notify.pm @@ -15,8 +15,20 @@ notify_Initialize($) $hash->{DefFn} = "notify_Define"; $hash->{NotifyFn} = "notify_Exec"; $hash->{AttrFn} = "notify_Attr"; - $hash->{AttrList} ="disable:1,0 disabledForIntervals forwardReturnValue:1,0 ". - "readLog:1,0 showtime:1,0 addStateEvent:1,0 ignoreRegexp"; + no warnings 'qw'; + my @attrList = qw( + addStateEvent:1,0 + disable:1,0 + disabledForIntervals + disabledAfterTrigger + forwardReturnValue:1,0 + ignoreRegexp + readLog:1,0 + showtime:1,0 + ); + use warnings 'qw'; + $hash->{AttrList} = join(" ", @attrList); + $hash->{SetFn} = "notify_Set"; $hash->{StateFn} = "notify_State"; $hash->{FW_detailFn} = "notify_fhemwebFn"; @@ -70,6 +82,10 @@ notify_Exec($$) my $ln = $ntfy->{NAME}; return "" if(IsDisabled($ln)); + my $now = gettimeofday(); + my $dat = AttrVal($ln, "disabledAfterTrigger", 0); + return "" if($ntfy->{TRIGGERTIME} && $now < $ntfy->{TRIGGERTIME}+$dat); + my $n = $dev->{NAME}; my $re = $ntfy->{REGEXP}; my $iRe = AttrVal($ln, "ignoreRegexp", undef); @@ -104,6 +120,7 @@ notify_Exec($$) my $r = AnalyzeCommandChain(undef, $exec); Log3 $ln, 3, "$ln return value: $r" if($r); $ret .= " $r" if($r); + $ntfy->{TRIGGERTIME} = $now; $ntfy->{STATE} = AttrVal($ln,'showtime',1) ? $dev->{NTFY_TRIGGERTIME} : 'active'; } @@ -504,6 +521,11 @@ END