mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
- fixes the rare but relevant case of two subsequent calls within one seconds (previously led to a division by zero error)
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@346 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7f3143591a
commit
5b4691f52b
@ -173,6 +173,7 @@ KS300_Parse($$)
|
|||||||
# The code also handles counter resets after battery replacement
|
# The code also handles counter resets after battery replacement
|
||||||
|
|
||||||
my $rain_raw_delta= $rain_raw- $rain_raw_prev;
|
my $rain_raw_delta= $rain_raw- $rain_raw_prev;
|
||||||
|
if($tsecs!= $tsecs_prev) { # avoids a rare but relevant condition
|
||||||
my $thours_delta= ($tsecs- $tsecs_prev)/3600.0; # in hours
|
my $thours_delta= ($tsecs- $tsecs_prev)/3600.0; # in hours
|
||||||
my $rain_raw_per_hour= $rain_raw_delta/$thours_delta;
|
my $rain_raw_per_hour= $rain_raw_delta/$thours_delta;
|
||||||
if(($rain_raw_delta<0) || ($rain_raw_per_hour> 200.0)) {
|
if(($rain_raw_delta<0) || ($rain_raw_per_hour> 200.0)) {
|
||||||
@ -184,9 +185,8 @@ KS300_Parse($$)
|
|||||||
$r->{rain_raw_ofs}{TIME} = $tm;
|
$r->{rain_raw_ofs}{TIME} = $tm;
|
||||||
$r->{rain_raw_ofs}{VAL} = $rain_raw_ofs;
|
$r->{rain_raw_ofs}{VAL} = $rain_raw_ofs;
|
||||||
$def->{CHANGED}[$n++] = "rain_raw_ofs: $rain_raw_ofs";
|
$def->{CHANGED}[$n++] = "rain_raw_ofs: $rain_raw_ofs";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$rain_raw_adj= $rain_raw+ $rain_raw_ofs;
|
$rain_raw_adj= $rain_raw+ $rain_raw_ofs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user