From b9e29ef99215600a3e4f0640d12f236184949b0d Mon Sep 17 00:00:00 2001 From: tpoitzsch Date: Fri, 9 May 2014 16:24:40 +0000 Subject: [PATCH] # $Id:$ git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5798 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/23_LUXTRONIK2.pm | 1 + fhem/FHEM/70_JSONMETER.pm | 13 ++++++------- fhem/FHEM/98_statistics.pm | 21 ++++++++++++++------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/fhem/FHEM/23_LUXTRONIK2.pm b/fhem/FHEM/23_LUXTRONIK2.pm index 32f5475ea..d22ea0f8b 100644 --- a/fhem/FHEM/23_LUXTRONIK2.pm +++ b/fhem/FHEM/23_LUXTRONIK2.pm @@ -1,4 +1,5 @@ ############################################################### +# $Id$ # # 23_LUXTRONIK2.pm # diff --git a/fhem/FHEM/70_JSONMETER.pm b/fhem/FHEM/70_JSONMETER.pm index 1171d1841..48cee8e5e 100644 --- a/fhem/FHEM/70_JSONMETER.pm +++ b/fhem/FHEM/70_JSONMETER.pm @@ -1,4 +1,5 @@ ############################################################### +# $Id$ # # 70_JSONMETER.pm # @@ -814,13 +815,11 @@ JSONMETER_doStatisticDeltaSingle ($$$$$$) # get statistic values of previous period my @last; - if ($periodSwitch >= 1) { - if (exists ($hash->{READINGS}{$readingName."Last"})) { - @last = split / /, $hash->{READINGS}{$readingName."Last"}{VAL}; - if ($last[0] eq "Day:") { $last[9]=$last[7]; $last[7]=$last[5]; $last[5]=$last[3]; $last[3]=$last[1]; $last[1]="-"; } - } else { - @last = split / /, "Hour: - Day: - Month: - Year: -"; - } + if (exists ($hash->{READINGS}{$readingName."Last"})) { + @last = split / /, $hash->{READINGS}{$readingName."Last"}{VAL}; + if ($last[0] eq "Day:") { $last[9]=$last[7]; $last[7]=$last[5]; $last[5]=$last[3]; $last[3]=$last[1]; $last[1]="-"; } + } else { + @last = split / /, "Hour: - Day: - Month: - Year: -"; } # Do statistic diff --git a/fhem/FHEM/98_statistics.pm b/fhem/FHEM/98_statistics.pm index 2c3d477e8..55768d7b9 100644 --- a/fhem/FHEM/98_statistics.pm +++ b/fhem/FHEM/98_statistics.pm @@ -1,4 +1,5 @@ ############################################## +# $Id$ # # 98_statistic.pm # @@ -227,11 +228,13 @@ statistics_PeriodChange($) foreach my $r (keys $hash->{READINGS}) { if ($r =~ /^monitoredDevices.*/) { - Log3 $name,4,"$name: Starting period change statistics (Type: $periodSwitch) for all devices of reading '$r'"; - my @devNameArray = split /,/, $hash->{READINGS}{$r}{VAL}; - foreach my $devName (@devNameArray) { - Log3 $name,4,"$name: Doing period change statistics for device '$devName'"; - statistics_DoStatistics($hash, $defs{$devName}, $periodSwitch); + if ($r !~/UnknownTypes|Unsupported/) { + Log3 $name,4,"$name: Starting period change statistics (Type: $periodSwitch) for all devices of reading '$r'"; + my @devNameArray = split /,/, $hash->{READINGS}{$r}{VAL}; + foreach my $devName (@devNameArray) { + Log3 $name,4,"$name: Doing period change statistics for device '$devName'"; + statistics_DoStatistics($hash, $defs{$devName}, $periodSwitch); + } } } } @@ -247,6 +250,7 @@ statistics_DoStatistics($$$) my $hashName = $hash->{NAME}; my $devName = $dev->{NAME}; my $devType = $dev->{TYPE}; + my $statisticDone = 0; return "" if(AttrVal($hashName, "disable", undef)); @@ -264,7 +268,8 @@ statistics_DoStatistics($$$) # notifing device type is known and the device has also the known reading # No statistic for excluded Readings my $completeReadingName = $devName.":".$readingName; - if ($$f[0] eq $devType && $completeReadingName !~ m/^($exclReadings)$/ ) { + if ($$f[0] eq $devType && $completeReadingName !~ m/^($exclReadings)$/ ) { + $statisticDone = 1; if ($$f[2] == 1) { statistics_doStatisticMinMax ($hash, $dev, $readingName, $$f[3], $periodSwitch);} if ($$f[2] == 2) { statistics_doStatisticDelta ($hash, $dev, $readingName, $$f[3], $periodSwitch);} } @@ -273,7 +278,9 @@ statistics_DoStatistics($$$) else {readingsEndUpdate($dev,0);} # Record device as monitored - my $monReadingName = "monitoredDevices".$devType; + my $monReadingName; + if ($statisticDone ==1) { $monReadingName = "monitoredDevices".$devType; } + else {$monReadingName = "monitoredDevicesUnsupported"; $devName .= "($devType)"} my $monReadingValue = ReadingsVal($hashName,$monReadingName,""); my $temp = '^'.$devName.'$|^'.$devName.',|,'.$devName.'$|,'.$devName.','; if ($monReadingValue !~ /$temp/) {