From 2cef73c40369187bc284b08c6b2d540bbb5d72a3 Mon Sep 17 00:00:00 2001 From: igami Date: Sun, 10 Jun 2018 07:09:52 +0000 Subject: [PATCH] 98_monitoring: fix warning add; add allCount reading git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@16843 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/98_monitoring.pm | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/FHEM/98_monitoring.pm b/FHEM/98_monitoring.pm index be1999555..f2f973392 100644 --- a/FHEM/98_monitoring.pm +++ b/FHEM/98_monitoring.pm @@ -315,7 +315,7 @@ sub monitoring_Notify($$) { Log3($SELF, 4 , "$TYPE ($SELF) triggered by \"$name $event\""); - foreach my $list ("warning", "error"){ + foreach my $list ("error", "warning"){ my $listFuncAdd = AttrVal($SELF, $list."FuncAdd", "preset"); my $listFuncRemove = AttrVal($SELF, $list."FuncRemove", "preset"); my $listWait = eval(AttrVal($SELF, $list."Wait", 0)); @@ -429,7 +429,11 @@ sub monitoring_modify($) { ); if($operation eq "add"){ - return if($readings{$value}); + return if( + $readings{$value} || + ReadingsVal($SELF, "error", "") =~ m/(?:^|,)$value(?:,|$)/ + ); + if($at){ return if($hash->{READINGS}{$reading}); @@ -455,10 +459,16 @@ sub monitoring_modify($) { return unless(@change || $operation eq "add"); + my $allCount = + int(keys %readings) + + ReadingsNum($SELF, ($list eq "warning" ? "error" : "warning")."Count", 0) + ; + readingsBeginUpdate($hash); readingsBulkUpdate($hash, "state", "$list $operation: $value"); readingsBulkUpdate($hash, $list, join(",", sort(keys %readings))); readingsBulkUpdate($hash, $list."Count", int(keys %readings)); + readingsBulkUpdate($hash, "allCount", $allCount); readingsEndUpdate($hash, 1); return; @@ -509,7 +519,7 @@ sub monitoring_setActive($) { readingsSingleUpdate($hash, "state", "active", 0); Log3($SELF, 3, "$TYPE ($SELF) set $SELF active"); - foreach my $reading (sort(keys %{$hash->{READINGS}})){ + foreach my $reading (reverse sort(keys %{$hash->{READINGS}})){ if($reading =~ m/(error|warning)Add_(.+)/){ my $wait = time_str2num(ReadingsVal($SELF, $reading, "")); @@ -666,6 +676,10 @@ sub monitoring_setActive($) { Readings

@@ -1146,6 +1160,10 @@ attr BeamerFilter_monitoring warningFuncRemove {return} Readings