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($$$$)
  • disable
  • disabledForIntervals
  • - -
  • forwardReturnValue
    - Forward the return value of the executed command to the caller, - default is disabled (0). If enabled (1), then e.g. a set command which - triggers this notify will also return this value. This can cause e.g - FHEMWEB to display this value, when clicking "on" or "off", which is - often not intended.
  • -
  • addStateEvent
    The event associated with the state Reading is special, as the "state: " @@ -406,6 +415,26 @@ notify_fhemwebFn($$$$) Note 2: this attribute will only work for events generated by devices supporting the readingFnAttributes.
  • + + +
  • forwardReturnValue
    + Forward the return value of the executed command to the caller, + default is disabled (0). If enabled (1), then e.g. a set command which + triggers this notify will also return this value. This can cause e.g + FHEMWEB to display this value, when clicking "on" or "off", which is + often not intended.
  • + + +
  • readLog
    + Execute the notify for messages appearing in the FHEM Log. The device + in this case is set to the notify itself, e.g. checking for the startup + message looks like: + +
  • +
    @@ -576,12 +605,7 @@ notify_fhemwebFn($$$$) Attribute - + + +
  • forwardReturnValue
    + Rückgabe der Werte eines ausgeführten Kommandos an den + Aufrufer. Die Voreinstellung ist 0 (ausgeschaltet), um weniger + Meldungen im Log zu haben. +
  • + + +
  • readLog
    + Das notify wird für Meldungen, die im FHEM-Log erscheinen, + ausgegeführt. Das "Event-Generierende-Gerät" wird auf dem + notify selbst gesetzt. Z.Bsp. kann man mit folgendem notify auf die + Startup Meldung reagieren: + +