diff --git a/fhem/CHANGED b/fhem/CHANGED index d9c49d2be..bd32a8b21 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 + - bugfix: 76_SolarForecast: bugfix of version 1.43.3 - change: 76_SolarForecast: consumption fc calc switch from average to median - change: 76_SolarForecast: Attr graphicBeam1MaxVal, ctrlAreaFactorUsage are obsolete diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index 27cee9224..7926f0925 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -157,6 +157,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.43.4" => "14.01.2025 batsocslidereg: calculate the SoC as summary over all capacities in Wh, bugfix https://forum.fhem.de/index.php?msg=1330559 ", "1.43.3" => "13.01.2025 add Wiki icon in graphic header, _calcConsumptionForecast: switch calc from average to median, edit comref ", "1.43.2" => "12.01.2025 _batChargeRecmd: bugfix calc socwh, Attr graphicBeam1MaxVal, (experimental) ctrlAreaFactorUsage are obsolete ". "trackFlex now default in DWD Model, replace title Charging recommendation by Charging release ". @@ -487,17 +488,7 @@ my $pPath = '?format=txt'; my $cfile = 'controls_solarforecast.txt'; # Name des Controlfiles -# initiale Hashes für Stunden Consumption Forecast inkl. und exkl. Verbraucher -#my $conhfc = { "01" => 0, "02" => 0, "03" => 0, "04" => 0, "05" => 0, "06" => 0, "07" => 0, "08" => 0, -# "09" => 0, "10" => 0, "11" => 0, "12" => 0, "13" => 0, "14" => 0, "15" => 0, "16" => 0, -# "17" => 0, "18" => 0, "19" => 0, "20" => 0, "21" => 0, "22" => 0, "23" => 0, "24" => 0, -# }; - -#my $conhfcex = { "01" => 0, "02" => 0, "03" => 0, "04" => 0, "05" => 0, "06" => 0, "07" => 0, "08" => 0, -# "09" => 0, "10" => 0, "11" => 0, "12" => 0, "13" => 0, "14" => 0, "15" => 0, "16" => 0, -# "17" => 0, "18" => 0, "19" => 0, "20" => 0, "21" => 0, "22" => 0, "23" => 0, "24" => 0, -# }; - # mögliche Debug-Module + # mögliche Debug-Module my @dd = qw( aiProcess aiData apiCall @@ -9433,6 +9424,7 @@ sub _transferBatteryValues { my $pbosum = 0; my $bcapsum = 0; my $socsum; + my $socwhsum; delete $data{$name}{current}{batpowerinsum}; delete $data{$name}{current}{batpoweroutsum}; @@ -9444,8 +9436,6 @@ sub _transferBatteryValues { my ($err, $badev, $h) = isDeviceValid ( { name => $name, obj => 'setupBatteryDev'.$bn, method => 'attr' } ); next if($err); - $num++; - my ($pin,$piunit) = split ":", $h->{pin}; # Readingname/Unit für aktuelle Batterieladung my ($pou,$pounit) = split ":", $h->{pout}; # Readingname/Unit für aktuelle Batterieentladung my ($bin,$binunit) = split ":", $h->{intotal} // "-:-"; # Readingname/Unit der total in die Batterie eingespeisten Energie (Zähler) @@ -9592,13 +9582,17 @@ sub _transferBatteryValues { writeToHistory ( { paref => $paref, key => 'batsoc'.$bn, val => $soc, hour => $nhour } ); - $socsum += $soc; + $num++; + $socsum += $soc; + $socwhsum += BatteryVal ($name, $bn, 'binstcap', 0) * $soc / 100; # Batterie SoC in Wh + $pbisum += $pbi; $pbosum += $pbo; } if ($num) { - push @{$data{$name}{current}{batsocslidereg}}, $socsum / $num; # Schieberegister average SOC aller Batterien + my $soctotal = sprintf "%.0f", ($socwhsum / $bcapsum * 100) if($bcapsum); # resultierender SoC (%) aller Batterien als "eine" + push @{$data{$name}{current}{batsocslidereg}}, $soctotal; # Schieberegister average SOC aller Batterien limitArray ($data{$name}{current}{batsocslidereg}, $slidenummax); $data{$name}{current}{batpowerinsum} = $pbisum; # summarische laufende Batterieladung @@ -11913,7 +11907,7 @@ sub _calcConsumptionForecast { my $nhday = strftime "%a", localtime($utime); # Wochentagsname des NextHours Key my $nhhr = sprintf("%02d", (int (strftime "%H", localtime($utime))) + 1); # Stunde des Tages vom NextHours Key (01,02,...24) - my ($conhfc, $conhfcex); + my (@conhfc, @conhfcex); for my $m (sort{$a<=>$b} keys %{$data{$name}{pvhist}}) { next if($m eq $day); # next wenn gleicher Tag (Datum) wie heute @@ -11959,16 +11953,16 @@ sub _calcConsumptionForecast { } } - push @{$conhfcex->{"$nhhr"}}, ($hcon - $consumerco) if($hcon >= $consumerco); # prognostizierter Verbrauch (Median) Ex registrierter Verbraucher - push @{$conhfc->{"$nhhr"}}, $hcon; + push @conhfcex, ($hcon - $consumerco) if($hcon >= $consumerco); # prognostizierter Verbrauch (Median) Ex registrierter Verbraucher + push @conhfc, $hcon; $dnum++; } if ($dnum) { - my $conavgex = sprintf "%.0f", medianArray (\@{$conhfcex->{$nhhr}}) if(scalar @{$conhfcex->{$nhhr}}); + my $conavgex = sprintf "%.0f", medianArray (\@conhfcex) if(scalar @conhfcex); $data{$name}{nexthours}{$k}{confcEx} = $conavgex; - my $conavg = sprintf "%.0f", medianArray (\@{$conhfc->{$nhhr}}) if(scalar @{$conhfc->{$nhhr}}); + my $conavg = sprintf "%.0f", medianArray (\@conhfc) if(scalar @conhfc); $data{$name}{nexthours}{$k}{confc} = $conavg; # prognostizierter Verbrauch (Median) auf Grundlage aller gleicher Wochentage pro Stunde if (NexthoursVal ($hash, $k, 'today', 0)) { # nur Werte des aktuellen Tag speichern @@ -21231,7 +21225,8 @@ to ensure that the system configuration is correct.