From f5dcadaa024e01698dcd05d70447424271bf4bb4 Mon Sep 17 00:00:00 2001 From: pahenning Date: Mon, 10 Feb 2014 20:14:21 +0000 Subject: [PATCH] git-svn-id: https://svn.fhem.de/fhem/trunk@4877 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/21_OWCOUNT.pm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fhem/FHEM/21_OWCOUNT.pm b/fhem/FHEM/21_OWCOUNT.pm index 7761b81d1..e242aa122 100644 --- a/fhem/FHEM/21_OWCOUNT.pm +++ b/fhem/FHEM/21_OWCOUNT.pm @@ -84,7 +84,7 @@ use strict; use warnings; sub Log($$); -my $owx_version="5.02"; +my $owx_version="5.03"; #-- fixed raw channel name, flexible channel name my @owg_fixed = ("A","B"); my @owg_channel = ("A","B"); @@ -904,7 +904,7 @@ sub OWCOUNT_GetMonth($) { $total2 = int(100*($total+$hash->{READINGS}{$owg_channel[$i]}{VAL}))/100; #-- number of days so far, including the present day my $deltim = int(@month)+($chour+$cmin/60.0 + $csec/3600.0)/24.0; - my $av = int(100*$total2/$deltim)/100; + my $av = $deltim>0 ? int(100*$total2/$deltim)/100 : -1; #-- output format push(@month2,[($total,$total2,$av)]); } @@ -983,6 +983,7 @@ sub OWCOUNT_GetYear($) { #-- sum and average + my @month2 = OWCOUNT_GetMonth($hash); for (my $i=0;$i0); }; #-- add data from current day also for non-summed mode $total = int($total*100)/100; - Log 1," GetYear total = $total"; - $total2 = int(100*($total))/100; - #-- number of months so far, including the present day - my $deltim = int(@year); - my $av = int(100*$total2/$deltim)/100; + $total2 = int(100*($total+$month2[$i]->[1]))/100; + #-- number of days so far, including the present day + my $deltim = $cyday+($chour+$cmin/60.0 + $csec/3600.0)/24.0; + my $av = $deltim>0 ? int(100*$total2/$deltim)/100 : -1; #-- output format push(@year2,[($total,$total2,$av)]); }