1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-07 22:29:19 +00:00

50_HP1000.pm: keep one value minimum in history helper to avoid zero division

git-svn-id: https://svn.fhem.de/fhem/trunk@12267 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2016-10-03 18:08:36 +00:00
parent 8c48f865d3
commit aac8938679

View File

@ -461,11 +461,12 @@ sub HP1000_GetSum($$$$;$) {
return $v if ( $avg && $hash->{INTERVAL} < 1 );
return "0" if ( $hash->{INTERVAL} < 1 );
my $max = int( $s / $hash->{INTERVAL} );
my $max = sprintf( "%.0f", $s / $hash->{INTERVAL} );
$max = "1" if ( $max < 1 );
my $return;
my $v2 = unshift @{ $hash->{helper}{history}{$t} }, "$v";
my $v3 = splice @{ $hash->{helper}{history}{$t} }, "$max";
my $v2 = unshift @{ $hash->{helper}{history}{$t} }, $v;
my $v3 = splice @{ $hash->{helper}{history}{$t} }, $max;
Log3 $name, 5, "HP1000 $name: Updated history for $t:"
. Dumper( $hash->{helper}{history}{$t} );