From 9ff9d5263e44b8ba3a8a93e3950cddd9e7acf14c Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Fri, 1 Dec 2017 21:01:39 +0000 Subject: [PATCH] 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 --- fhem/CHANGED | 1 + fhem/FHEM/91_notify.pm | 25 ++++++++++++++++++++++++- fhem/FHEM/92_FileLog.pm | 13 +++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index d4add549f..30d010a2e 100644 --- a/fhem/CHANGED +++ b/fhem/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: 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) diff --git a/fhem/FHEM/91_notify.pm b/fhem/FHEM/91_notify.pm index a64e14ad6..6fb92e9c4 100644 --- a/fhem/FHEM/91_notify.pm +++ b/fhem/FHEM/91_notify.pm @@ -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. + +