From dbf79f7df08c69ed44986c9a0dfd228a15cb60ab Mon Sep 17 00:00:00 2001 From: tpoitzsch Date: Mon, 12 May 2014 17:05:39 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@5830 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/23_LUXTRONIK2.pm | 1 + fhem/FHEM/98_statistics.pm | 49 ++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/fhem/FHEM/23_LUXTRONIK2.pm b/fhem/FHEM/23_LUXTRONIK2.pm index 3c1d999ca..b0b1526a9 100644 --- a/fhem/FHEM/23_LUXTRONIK2.pm +++ b/fhem/FHEM/23_LUXTRONIK2.pm @@ -1,5 +1,6 @@ ############################################################### # $Id$ +# # 23_LUXTRONIK2.pm # # Copyright notice diff --git a/fhem/FHEM/98_statistics.pm b/fhem/FHEM/98_statistics.pm index 867a57521..b0524fbdb 100644 --- a/fhem/FHEM/98_statistics.pm +++ b/fhem/FHEM/98_statistics.pm @@ -2,6 +2,7 @@ # $Id$ # # 98_statistic.pm +# # Copyright notice # # (c) 2014 Torsten Poitzsch < torsten . poitzsch at gmx . de > @@ -52,16 +53,21 @@ sub statistics_doStatisticDelta ($$$$$); my @knownDeviceReadings = ( ["CUL_WS", "humidity", 1, 0] ,["CUL_WS", "temperature", 1, 1] - ,["KS300", "humidity", 1, 0] - ,["KS300", "temperature", 1, 1] - ,["KS300", "wind", 1, 0] - ,["KS300", "rain", 2, 1] + ,["dummy", "state", 3, 1] ,["FBDECT", "current", 1, 3] ,["FBDECT", "energy", 2, 0] ,["FBDECT", "power", 1, 1] ,["FBDECT", "voltage", 1, 1] + ,["FRM_IN", "counter", 2, 0] + ,["FRM_IN", "power", 1, 2] ,["FS20", "state", 3, 1] - ,["dummy", "state", 3, 1] + ,["KS300", "humidity", 1, 0] + ,["KS300", "temperature", 1, 1] + ,["KS300", "wind", 1, 0] + ,["KS300", "rain", 2, 1] + ,["OREGON", "humidity", 1, 1] + ,["OREGON", "rain", 2, 1] + ,["OREGON", "temperature", 1, 1] ); ############################################################## @@ -274,7 +280,6 @@ statistics_DoStatistics($$$) $dev->{helper}{_98_statistics}=$hashName; } - readingsBeginUpdate($hash); readingsBeginUpdate($dev); # Loop through all known device types and readings @@ -294,11 +299,12 @@ statistics_DoStatistics($$$) if ($periodSwitch >0) {readingsEndUpdate($dev,1);} else {readingsEndUpdate($dev,0);} - # Record device as monitored + + # Record device as monitored my $monReadingName; if ($statisticDone == 1) { $monReadingName = "monitoredDevices".$devType; - readingsBulkUpdate($hash,"state","Updated stats for: $devName",1); + readingsSingleUpdate($hash,"state","Updated stats for: $devName",1); } else { $monReadingName = "monitoredDevicesUnsupported"; $devName .= "#$devType"; @@ -308,23 +314,20 @@ statistics_DoStatistics($$$) if ($monReadingValue !~ /$regExp/) { if($monReadingValue eq "") { $monReadingValue = $devName;} else {$monReadingValue .= ",".$devName;} - readingsBulkUpdate($hash,$monReadingName,$monReadingValue,1); + readingsSingleUpdate($hash,$monReadingName,$monReadingValue,1); my $monReadingValue = ReadingsVal($hashName,"monitoredDevicesUnknownType",""); if ($monReadingValue =~ /$regExp/) { $monReadingValue =~ s/$devName,?//; $monReadingValue =~ s/,$//; if ($monReadingValue ne "") { - readingsBulkUpdate($hash,"monitoredDevicesUnknownType",$monReadingValue,1); + readingsSingleUpdate($hash,"monitoredDevicesUnknownType",$monReadingValue,1); } else { delete $hash->{READINGS}{monitoredDevicesUnknownType}; } } } - readingsEndUpdate($hash,1); - - return undef; } @@ -389,17 +392,17 @@ statistics_doStatisticMinMaxSingle ($$$$$$) # Store current reading as last reading, Reset current reading if ($saveLast) { - readingsBulkUpdate($dev, $statReadingName . "Last", $result); + readingsBulkUpdate($dev, $statReadingName . "Last", $result, 1); $hidden[1] = 0; $hidden[3] = 0; $hidden[9] = 0; # No since value anymore $result = "Min: $value Avg: $value Max: $value"; } # Store current reading - readingsBulkUpdate($dev, $statReadingName, $result, 1); + readingsBulkUpdate($dev, $statReadingName, $result, 0); # Store hidden reading $result = "Sum: $hidden[1] Time: $hidden[3] LastValue: ".$value." LastTime: ".int(gettimeofday())." ShowDate: $hidden[9]"; - readingsBulkUpdate($hash, $hiddenReadingName, $result, 0); + readingsSingleUpdate($hash, $hiddenReadingName, $result, 0); return; } @@ -513,7 +516,7 @@ statistics_doStatisticDelta ($$$$$) # Store hidden reading $result = "LastValue: $value ShowDate: $showDate "; - readingsBulkUpdate($hash, $hiddenReadingName, $result, 0); + readingsSingleUpdate($hash, $hiddenReadingName, $result, 0); Log3 $name,5,"$name: Store '$result' in '$hiddenReadingName'."; return ; @@ -547,8 +550,10 @@ statistics_doStatisticDelta ($$$$$)
Until now the following device types and readings are analysed: @@ -603,8 +608,10 @@ statistics_doStatisticDelta ($$$$$)
Derzeit werden folgende Gerätetypen und Gerätewerte ausgewertet: