mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
91_notify.pm/92_FileLog.pm: add ignoreRegexp attribute (Forum #79684)
git-svn-id: https://svn.fhem.de/fhem/trunk@15537 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
e85b8f890b
commit
9ff9d5263e
@ -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: notify/FileLog: add ignoreRegexp attribute (Forum #79684)
|
||||
- feature: 46_SmartPi: add decimal Attr, fix Notify bug
|
||||
- bugfix: 74_XiaomiFlowerSens: fix many Notify bugs
|
||||
- change: backup is always started in the background (Forum #80237)
|
||||
|
@ -16,7 +16,7 @@ notify_Initialize($)
|
||||
$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";
|
||||
"readLog:1,0 showtime:1,0 addStateEvent:1,0 ignoreRegexp";
|
||||
$hash->{SetFn} = "notify_Set";
|
||||
$hash->{StateFn} = "notify_State";
|
||||
$hash->{FW_detailFn} = "notify_fhemwebFn";
|
||||
@ -72,6 +72,7 @@ notify_Exec($$)
|
||||
|
||||
my $n = $dev->{NAME};
|
||||
my $re = $ntfy->{REGEXP};
|
||||
my $iRe = AttrVal($ln, "ignoreRegexp", undef);
|
||||
my $events = deviceEvents($dev, AttrVal($ln, "addStateEvent", 0));
|
||||
return if(!$events); # Some previous notify deleted the array.
|
||||
my $max = int(@{$events});
|
||||
@ -89,6 +90,7 @@ notify_Exec($$)
|
||||
$found = ("$n:$s" =~ m/^$re$/);
|
||||
}
|
||||
if($found) {
|
||||
next if($iRe && ($n =~ m/^$iRe$/ || "$n:$s" =~ m/^$iRe$/));
|
||||
Log3 $ln, 5, "Triggering $ln";
|
||||
my %specials= (
|
||||
"%NAME" => $n,
|
||||
@ -133,6 +135,12 @@ notify_Attr(@)
|
||||
return;
|
||||
}
|
||||
|
||||
if($a[0] eq "set" && $a[2] eq "ignoreRegexp") {
|
||||
return "Missing argument for ignoreRegexp" if(!defined($a[3]));
|
||||
eval { "HALLO" =~ m/$a[3]/ };
|
||||
return $@;
|
||||
}
|
||||
|
||||
if($a[0] eq "set" && $a[2] eq "disable") {
|
||||
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
||||
}
|
||||
@ -518,6 +526,13 @@ END
|
||||
FHEMWEB to display this value, when clicking "on" or "off", which is
|
||||
often not intended.</li>
|
||||
|
||||
<a name="ignoreRegexp"></a>
|
||||
<li>ignoreRegexp regexp<br>
|
||||
It is hard to create a regexp which is _not_ matching something, this
|
||||
attribute helps in this case, as the event is ignored if matches the
|
||||
argument. The syntax is the same as for the original regexp.
|
||||
</li>
|
||||
|
||||
<a name="readLog"></a>
|
||||
<li>readLog<br>
|
||||
Execute the notify for messages appearing in the FHEM Log. The device
|
||||
@ -735,6 +750,14 @@ END
|
||||
Meldungen im Log zu haben.
|
||||
</li>
|
||||
|
||||
<a name="ignoreRegexp"></a>
|
||||
<li>ignoreRegexp regexp<br>
|
||||
Es ist nicht immer einfach ein Regexp zu bauen, was etwas _nicht_
|
||||
matcht. Dieses Attribu hilft in diesen Fällen: das Event wird
|
||||
ignoriert, falls den angegebenen Regexp. Syntax ist gleich wie in der
|
||||
Definition.
|
||||
</li>
|
||||
|
||||
<a name="readLog"></a>
|
||||
<li>readLog<br>
|
||||
Das notify wird für Meldungen, die im FHEM-Log erscheinen,
|
||||
|
@ -49,6 +49,7 @@ FileLog_Initialize($)
|
||||
disable:0,1
|
||||
disabledForIntervals
|
||||
eventOnThreshold
|
||||
ignoreRegexp
|
||||
logtype
|
||||
mseclog:1,0
|
||||
nrarchive
|
||||
@ -181,6 +182,7 @@ FileLog_Log($$)
|
||||
|
||||
my $n = $dev->{NAME};
|
||||
my $re = $log->{REGEXP};
|
||||
my $iRe = AttrVal($ln, "ignoreRegexp", undef);
|
||||
my $max = int(@{$events});
|
||||
my $tn = $dev->{NTFY_TRIGGERTIME};
|
||||
if($log->{mseclog}) {
|
||||
@ -197,6 +199,7 @@ FileLog_Log($$)
|
||||
$s = "" if(!defined($s));
|
||||
my $t = (($ct && $ct->[$i]) ? $ct->[$i] : $tn);
|
||||
if($n =~ m/^$re$/ || "$n:$s" =~ m/^$re$/ || "$t:$n:$s" =~ m/^$re$/) {
|
||||
next if($iRe && ($n =~ m/^$iRe$/ || "$n:$s" =~ m/^$iRe$/));
|
||||
$t =~ s/ /_/; # Makes it easier to parse with gnuplot
|
||||
|
||||
if(!$switched) {
|
||||
@ -238,6 +241,12 @@ FileLog_Attr(@)
|
||||
return;
|
||||
}
|
||||
|
||||
if($a[0] eq "set" && $a[2] eq "ignoreRegexp") {
|
||||
return "Missing argument for ignoreRegexp" if(!defined($a[3]));
|
||||
eval { "HALLO" =~ m/$a[3]/ };
|
||||
return $@;
|
||||
}
|
||||
|
||||
if($a[0] eq "set" && $a[2] eq "disable") {
|
||||
$do = (!defined($a[3]) || $a[3]) ? 1 : 2;
|
||||
}
|
||||
@ -1305,6 +1314,8 @@ FileLog_regexpFn($$)
|
||||
feature was implemented. A FHEM crash or kill will falsify the counter.
|
||||
</li><br>
|
||||
|
||||
<li><a href="#ignoreRegexp">ignoreRegexp</a></li>
|
||||
|
||||
<a name="logtype"></a>
|
||||
<li>logtype<br>
|
||||
Used by the pgm2 webfrontend to offer gnuplot/SVG images made from the
|
||||
@ -1626,6 +1637,8 @@ FileLog_regexpFn($$)
|
||||
verfälscht die Zählung.
|
||||
</li><br>
|
||||
|
||||
<li><a href="#ignoreRegexp">ignoreRegexp</a></li>
|
||||
|
||||
<a name="logtype"></a>
|
||||
<li>logtype<br>
|
||||
Wird vom SVG Modul benötigt, um daten grafisch aufzubereiten.
|
||||
|
Loading…
Reference in New Issue
Block a user