diff --git a/CHANGED b/CHANGED index 773b4d350..1acc21e07 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 91_notify: add readLog attribute - feature: 98_ping: Add attribute for minimum fails before reporting (minFailCount) - bugfix: PRESENCE: fix log warning "use of uninitialized value ..." when diff --git a/FHEM/91_notify.pm b/FHEM/91_notify.pm index 377ea2213..26a492b25 100755 --- a/FHEM/91_notify.pm +++ b/FHEM/91_notify.pm @@ -15,7 +15,8 @@ notify_Initialize($) $hash->{DefFn} = "notify_Define"; $hash->{NotifyFn} = "notify_Exec"; $hash->{AttrFn} = "notify_Attr"; - $hash->{AttrList} = "disable:0,1 disabledForIntervals forwardReturnValue:0,1 showtime:0,1 addStateEvent:0,1"; + $hash->{AttrList} ="disable:1,0 disabledForIntervals forwardReturnValue:1,0 ". + "readLog:1,0 showtime:1,0 addStateEvent:1,0"; $hash->{SetFn} = "notify_Set"; $hash->{StateFn} = "notify_State"; $hash->{FW_detailFn} = "notify_fhemwebFn"; @@ -107,6 +108,22 @@ notify_Attr(@) { my @a = @_; my $do = 0; + my $hash = $defs{$a[1]}; + + if($a[0] eq "set" && $a[2] eq "readLog") { + if(!defined($a[3]) || $a[3]) { + $logInform{$a[1]} = sub($$){ + my ($me, $msg) = @_; + return if(defined($hash->{CHANGED})); + $hash->{CHANGED}[0] = $msg; + notify_Exec($hash, $hash); + delete($hash->{CHANGED}); + } + } else { + delete $logInform{$a[1]}; + } + return; + } if($a[0] eq "set" && $a[2] eq "disable") { $do = (!defined($a[3]) || $a[3]) ? 1 : 2; @@ -114,7 +131,7 @@ notify_Attr(@) $do = 2 if($a[0] eq "del" && (!$a[2] || $a[2] eq "disable")); return if(!$do); - readingsSingleUpdate($defs{$a[1]}, "state", $do==1 ? "disabled":"active", 1); + readingsSingleUpdate($hash, "state", $do==1 ? "disabled":"active", 1); return undef; } @@ -384,14 +401,6 @@ notify_fhemwebFn($$$$)
+ define n notify n:.*Server.started.* { Log 1, "Really" }
+ attr n readLog
+
+ define n notify n:.*Server.started.* { Log 1, "Wirklich" }
+ attr n readLog
+