From 341ee705ce1ca5fd3ce4003244b70bc2a3abf5be Mon Sep 17 00:00:00 2001 From: igami Date: Mon, 27 Mar 2017 06:52:13 +0000 Subject: [PATCH] 98_monitoring: changed blacklist attribute git-svn-id: https://svn.fhem.de/fhem/trunk@13814 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/98_monitoring.pm | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 7ac656a5c..0166968d3 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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: 98_monitoring: blacklist attribute is now a space seperated list + of devspecs instead a comma seperated list of devices - bugfix: 32_withings: web token fix - bugfix: 93_DbRep: switch wintertime to summertime, minor fixes - update: 32_withings: account data encryption diff --git a/fhem/FHEM/98_monitoring.pm b/fhem/FHEM/98_monitoring.pm index 999a9db33..a992b74ec 100644 --- a/fhem/FHEM/98_monitoring.pm +++ b/fhem/FHEM/98_monitoring.pm @@ -193,7 +193,19 @@ sub monitoring_Attr(@) { my ($cmd, $SELF, $attribute, $value) = @_; my ($hash) = $defs{$SELF}; - if($attribute eq "disable"){ + if($attribute eq "blacklist" && $value){ + my @blacklist; + + push(@blacklist, devspec2array($_)) foreach (split(" ", $value)); + + my %blacklist = map{$_, 1} @blacklist; + + foreach my $name (sort(keys %blacklist)){ + monitoring_modify("$SELF|warning|remove|$name"); + monitoring_modify("$SELF|error|remove|$name"); + } + } + elsif($attribute eq "disable"){ if($cmd eq "set" and $value == 1){ monitoring_setActive($hash); } @@ -234,7 +246,13 @@ sub monitoring_Notify($$) { || $removeRegex && $removeRegex =~ m/^$name:/ || $events ); - return if(AttrVal($SELF, "blacklist", "") =~ m/(^|,)$name(,|$)/); + + my @blacklist; + + push(@blacklist, devspec2array($_)) + foreach (split(" ", AttrVal($SELF, "blacklist", ""))); + + return if(@blacklist && grep(/$name/, @blacklist)); foreach my $event (@{$events}){ my $addMatch = "$name:$event" =~ $addRegex; @@ -603,7 +621,9 @@ sub monitoring_setActive($) {
  • blacklist
    - Comma-separated list of devices which will be ignored. + Space-separated list of devspecs which will be ignored.
    + If the attribute is set all devices which are specified by the devspecs + are removed from both lists.
  • disable (1|0)
    @@ -1066,7 +1086,9 @@ attr BeamerFilter_monitoring warningFuncRemove {return}
  • blacklist
    - Durch Komma getrennte Liste von Geräten die ignoriert werden. + Durch Leerzeichen getrennte Liste von devspecs die ignoriert werden.
    + Wenn das Attribut gesetzt wird werden alle Geräte die durch die + devspecs definiert sind von beiden Listen gelöscht.
  • disable (1|0)