mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
statistics: handles now double calls
git-svn-id: https://svn.fhem.de/fhem/trunk@7142 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
4794df2a7c
commit
5de8d2a9d2
@ -341,8 +341,8 @@ statistics_PeriodChange($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
sub
|
# Take each notified reading and perform the calculation
|
||||||
statistics_DoStatisticsAll($$)
|
sub statistics_DoStatisticsAll($$)
|
||||||
{
|
{
|
||||||
my ($hash,$periodSwitch) = @_;
|
my ($hash,$periodSwitch) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@ -360,8 +360,7 @@ statistics_DoStatisticsAll($$)
|
|||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
sub
|
sub statistics_DoStatistics($$$)
|
||||||
statistics_DoStatistics($$$)
|
|
||||||
{
|
{
|
||||||
my ($hash, $dev, $periodSwitch) = @_;
|
my ($hash, $dev, $periodSwitch) = @_;
|
||||||
my $hashName = $hash->{NAME};
|
my $hashName = $hash->{NAME};
|
||||||
@ -394,74 +393,86 @@ statistics_DoStatistics($$$)
|
|||||||
|
|
||||||
readingsBeginUpdate($dev);
|
readingsBeginUpdate($dev);
|
||||||
|
|
||||||
# Loop through all known readings
|
while (1)
|
||||||
foreach my $f (@knownReadings)
|
|
||||||
{
|
{
|
||||||
# notifing device has known reading, no statistic for excluded readings
|
# Loop through all known readings
|
||||||
$readingName = $$f[0];
|
foreach my $f (@knownReadings)
|
||||||
my $completeReadingName = $devName.":".$readingName;
|
{
|
||||||
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
# notifing device has known reading, no statistic for excluded readings
|
||||||
next if not exists ($dev->{READINGS}{$readingName});
|
$readingName = $$f[0];
|
||||||
$statisticDone = 1;
|
my $completeReadingName = $devName.":".$readingName;
|
||||||
if ($$f[1] == 1) { statistics_doStatisticMinMax ($hash, $dev, $readingName, $$f[2], $periodSwitch, 0);}
|
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
||||||
if ($$f[1] == 2) { statistics_doStatisticDelta ($hash, $dev, $readingName, $periodSwitch );}
|
next if not exists ($dev->{READINGS}{$readingName});
|
||||||
if ($$f[1] == 3) { statistics_doStatisticDuration ($hash, $dev, $readingName, $periodSwitch ); }
|
if ($$f[1] == 1) { statistics_doStatisticMinMax ($hash, $dev, $readingName, $$f[2], $periodSwitch, 0);}
|
||||||
if ($$f[1] == 4 && $periodSwitch>=1) { statistics_doStatisticTendency ($hash, $dev, $readingName, $$f[2]);}
|
if ($$f[1] == 2) { statistics_doStatisticDelta ($hash, $dev, $readingName, $periodSwitch );}
|
||||||
if ($$f[1] == 5) { statistics_doStatisticMinMax ($hash, $dev, $readingName, $$f[2], $periodSwitch, 1);}
|
if ($$f[1] == 3) { statistics_doStatisticDuration ($hash, $dev, $readingName, $periodSwitch ); }
|
||||||
}
|
if ($$f[1] == 4 && $periodSwitch>=1) { statistics_doStatisticTendency ($hash, $dev, $readingName, $$f[2]);}
|
||||||
|
if ($$f[1] == 5) { statistics_doStatisticMinMax ($hash, $dev, $readingName, $$f[2], $periodSwitch, 1);}
|
||||||
my @specialReadings = split /,/, AttrVal($hashName, "deltaReadings", "");
|
$statisticDone = 1;
|
||||||
foreach $readingName (@specialReadings)
|
last;
|
||||||
{
|
}
|
||||||
my $completeReadingName = $devName.":".$readingName;
|
last if $statisticDone == 1;
|
||||||
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
|
||||||
next if not exists ($dev->{READINGS}{$readingName});
|
my @specialReadings = split /,/, AttrVal($hashName, "deltaReadings", "");
|
||||||
$statisticDone = 1;
|
|
||||||
statistics_doStatisticDelta ($hash, $dev, $readingName, $periodSwitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@specialReadings = split /,/, AttrVal($hashName, "durationReadings", "");
|
|
||||||
foreach $readingName (@specialReadings)
|
|
||||||
{
|
|
||||||
my $completeReadingName = $devName.":".$readingName;
|
|
||||||
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
|
||||||
next if not exists ($dev->{READINGS}{$readingName});
|
|
||||||
$statisticDone = 1;
|
|
||||||
statistics_doStatisticDuration ($hash, $dev, $readingName, $periodSwitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@specialReadings = split /,/, AttrVal($hashName, "minAvgMaxReadings", "");
|
|
||||||
foreach $readingName (@specialReadings)
|
|
||||||
{
|
|
||||||
my $completeReadingName = $devName.":".$readingName;
|
|
||||||
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
|
||||||
next if not exists ($dev->{READINGS}{$readingName});
|
|
||||||
$statisticDone = 1;
|
|
||||||
statistics_doStatisticMinMax ($hash, $dev, $readingName, 1, $periodSwitch, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($periodSwitch>=1) {
|
|
||||||
@specialReadings = split /,/, AttrVal($hashName, "tendencyReadings", "");
|
|
||||||
foreach $readingName (@specialReadings)
|
foreach $readingName (@specialReadings)
|
||||||
{
|
{
|
||||||
my $completeReadingName = $devName.":".$readingName;
|
my $completeReadingName = $devName.":".$readingName;
|
||||||
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
||||||
next if not exists ($dev->{READINGS}{$readingName});
|
next if not exists ($dev->{READINGS}{$readingName});
|
||||||
|
statistics_doStatisticDelta ($hash, $dev, $readingName, $periodSwitch);
|
||||||
$statisticDone = 1;
|
$statisticDone = 1;
|
||||||
statistics_doStatisticTendency ($hash, $dev, $readingName, 1);
|
last;
|
||||||
}
|
}
|
||||||
}
|
last if $statisticDone == 1;
|
||||||
|
|
||||||
if ($statisticDone != 1) {
|
@specialReadings = split /,/, AttrVal($hashName, "durationReadings", "");
|
||||||
|
foreach $readingName (@specialReadings)
|
||||||
|
{
|
||||||
|
my $completeReadingName = $devName.":".$readingName;
|
||||||
|
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
||||||
|
next if not exists ($dev->{READINGS}{$readingName});
|
||||||
|
statistics_doStatisticDuration ($hash, $dev, $readingName, $periodSwitch);
|
||||||
|
$statisticDone = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
last if $statisticDone == 1;
|
||||||
|
|
||||||
|
@specialReadings = split /,/, AttrVal($hashName, "minAvgMaxReadings", "");
|
||||||
|
foreach $readingName (@specialReadings)
|
||||||
|
{
|
||||||
|
my $completeReadingName = $devName.":".$readingName;
|
||||||
|
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
||||||
|
next if not exists ($dev->{READINGS}{$readingName});
|
||||||
|
statistics_doStatisticMinMax ($hash, $dev, $readingName, 1, $periodSwitch, 1);
|
||||||
|
$statisticDone = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
last if $statisticDone == 1;
|
||||||
|
|
||||||
|
if ($periodSwitch>=1) {
|
||||||
|
@specialReadings = split /,/, AttrVal($hashName, "tendencyReadings", "");
|
||||||
|
foreach $readingName (@specialReadings)
|
||||||
|
{
|
||||||
|
my $completeReadingName = $devName.":".$readingName;
|
||||||
|
next if ($completeReadingName =~ m/^($exclReadings)$/ );
|
||||||
|
next if not exists ($dev->{READINGS}{$readingName});
|
||||||
|
statistics_doStatisticTendency ($hash, $dev, $readingName, 1);
|
||||||
|
$statisticDone = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
last if $statisticDone == 1;
|
||||||
|
}
|
||||||
|
|
||||||
if ( exists ($dev->{READINGS}{state}) && $dev->{READINGS}{state}{VAL} ne "defined" ) {
|
if ( exists ($dev->{READINGS}{state}) && $dev->{READINGS}{state}{VAL} ne "defined" ) {
|
||||||
statistics_doStatisticDuration $hash, $dev, "state", $periodSwitch;
|
statistics_doStatisticDuration $hash, $dev, "state", $periodSwitch;
|
||||||
$statisticDone = 1;
|
$statisticDone = 1;
|
||||||
|
last;
|
||||||
}
|
}
|
||||||
|
last;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($periodSwitch >0) {readingsEndUpdate($dev,1);}
|
if ($periodSwitch >0) {readingsEndUpdate($dev,1);}
|
||||||
else {readingsEndUpdate($dev,0);}
|
else {readingsEndUpdate($dev,0);}
|
||||||
|
|
||||||
|
|
||||||
# Record device as monitored
|
# Record device as monitored
|
||||||
my $monReadingName;
|
my $monReadingName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user