From 0cbd24b6ac27ca0f27c931c085c76da4e4d9e24c Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Fri, 29 Mar 2024 20:00:59 +0000 Subject: [PATCH] 70_PylonLowVoltage: avoid possible Illegal division by zero git-svn-id: https://svn.fhem.de/fhem/trunk@28724 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/70_PylonLowVoltage.pm | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 235f89d50..ce55ab243 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 70_PylonLowVoltage: avoid possible Illegal division by zero - feature: 76_SolarForecast: integrate the Open-Meteo API - change: 50_Signalbot: Improved registration procedure for Voice - feature: 93_DbRep: multicmd: add attr seqDoubletsVariance diff --git a/fhem/FHEM/70_PylonLowVoltage.pm b/fhem/FHEM/70_PylonLowVoltage.pm index 36776bae3..5571c26b8 100644 --- a/fhem/FHEM/70_PylonLowVoltage.pm +++ b/fhem/FHEM/70_PylonLowVoltage.pm @@ -122,6 +122,7 @@ BEGIN { # Versions History intern (Versions history by Heiko Maaz) my %vNotesIntern = ( + "0.2.4" => "29.03.2024 avoid possible Illegal division by zero at line 1438 ", "0.2.3" => "19.03.2024 edit commandref ", "0.2.2" => "20.02.2024 correct commandref ", "0.2.1" => "18.02.2024 doOnError: print out faulty response, Forum:https://forum.fhem.de/index.php?msg=1303912 ", @@ -1434,8 +1435,8 @@ sub additionalReadings { my ($vmax, $vmin); - $readings->{averageCellVolt} = sprintf "%.3f", $readings->{packVolt} / $readings->{packCellcount} if(defined $readings->{packCellcount}); - $readings->{packSOC} = sprintf "%.2f", ($readings->{packCapacityRemain} / $readings->{packCapacity} * 100) if(defined $readings->{packCapacity}); + $readings->{averageCellVolt} = sprintf "%.3f", $readings->{packVolt} / $readings->{packCellcount} if($readings->{packCellcount}); + $readings->{packSOC} = sprintf "%.2f", ($readings->{packCapacityRemain} / $readings->{packCapacity} * 100) if($readings->{packCapacity}); $readings->{packPower} = sprintf "%.2f", $readings->{packCurrent} * $readings->{packVolt}; for (my $i=1; $i <= $readings->{packCellcount}; $i++) {