From bd092720c308ef00a7f247fb4b6cff2e78de1d47 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sun, 14 Mar 2021 07:47:14 +0000 Subject: [PATCH] 76_SolarForecast.pm: contrib 0.10.0 git-svn-id: https://svn.fhem.de/fhem/trunk@23961 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index edf1ecc9b..72ab62367 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -2667,11 +2667,17 @@ sub calcFromHistory { unshift @efa, $k[$ei]; $ei--; } + + my $anzavg = scalar(@efa); + + if($anzavg) { + Log3 ($name, 4, "$name - PV History -> Day $day has index $idx. Days ($calcd) for calc: ".join " ",@efa); + } + else { # vermeide Fehler: Illegal division by zero + Log3 ($name, 4, "$name - PV History -> Day $day has index $idx. Use only current day for average calc"); + return; + } - Log3 ($name, 4, "$name - PV History -> Day $day has index $idx. Days ($calcd) for calc: ".join " ",@efa); - - # my $pvhh = $data{$type}{$name}{pvhist}; - my $anzavg = scalar(@efa); my ($pvrl,$pvfc) = (0,0); for my $dayfa (@efa) { @@ -2881,7 +2887,7 @@ return; } ################################################################ -# alle Readings eines Devices oder nur Reaging-Regex +# alle Readings eines Devices oder nur Reading-Regex # löschen ################################################################ sub deleteReadingspec {