76_SolarForecast: contrib Version 1.60.0

git-svn-id: https://svn.fhem.de/fhem/trunk@30464 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
DS_Starter
2025-10-31 13:52:31 +00:00
parent 2eea78434b
commit 87c62639c2

View File

@@ -12260,13 +12260,13 @@ sub __batChargeOptTargetPower {
my $nextnhr = $hsurp->{$nexthod}{nhr}; my $nextnhr = $hsurp->{$nexthod}{nhr};
my @remaining_hods = grep { int $_ >= int $hod } @sortedhods; my @remaining_hods = grep { int $_ >= int $hod } @sortedhods;
my $total = 0; my $remainingSurp = 0;
for my $h (@remaining_hods) { # Gesamtwert PV-Überschuß aller Stunden mit PV-Überschuß ermitteln for my $h (@remaining_hods) { # Gesamtwert PV-Überschuß aller Stunden mit PV-Überschuß ermitteln
my $val = $hsurp->{$h}{nhr} eq '00' my $val = $hsurp->{$h}{nhr} eq '00'
? $replacement // 0 ? $replacement // 0
: $hsurp->{$h}{surplswh}; : $hsurp->{$h}{surplswh};
$total += int $val; $remainingSurp += int $val;
} }
for my $sbn (sort { $a <=> $b } @batteries) { # jede Batterie for my $sbn (sort { $a <=> $b } @batteries) { # jede Batterie
@@ -12301,7 +12301,7 @@ sub __batChargeOptTargetPower {
my $runwhneed = $goalwh - $runwh; my $runwhneed = $goalwh - $runwh;
my $achievable = 1; my $achievable = 1;
if ($runwhneed > 0 && $total * $befficiency < $runwhneed) { # Erreichbarkeit des Ziels (benötigte Ladeenergie total) prüfen if ($runwhneed > 0 && $remainingSurp * $befficiency < $runwhneed) { # Erreichbarkeit des Ziels (benötigte Ladeenergie total) prüfen
$achievable = 0; $achievable = 0;
} }
@@ -12335,8 +12335,8 @@ sub __batChargeOptTargetPower {
## weiter mit Überschuß ## weiter mit Überschuß
######################### #########################
my $otpMargin = $hsurp->{$hod}{$sbn}{otpMargin}; my $otpMargin = $hsurp->{$hod}{$sbn}{otpMargin};
my $fref = ___batFindMinPhWh ($hsurp, \@remaining_hods, $runwhneed); my $fref = ___batFindMinPhWh ($hsurp, \@remaining_hods, $runwhneed, $replacement);
my $limpower = $achievable || $strategy eq 'optPower' my $limpower = $strategy eq 'optPower'
? min ($fref->{ph}, $spls) # Ladeleistung auf den kleineren Wert begrenzen (es kommen Nachberechnungen) ? min ($fref->{ph}, $spls) # Ladeleistung auf den kleineren Wert begrenzen (es kommen Nachberechnungen)
: $fref->{ph}; : $fref->{ph};
@@ -12355,7 +12355,7 @@ sub __batChargeOptTargetPower {
$bpinmax, $bpinmax,
$runwhneed, $runwhneed,
$otpMargin, $otpMargin,
$total $remainingSurp
); );
} }
@@ -12382,7 +12382,7 @@ sub __batChargeOptTargetPower {
$bpinmax, $bpinmax,
$runwhneed, $runwhneed,
$otpMargin, $otpMargin,
$total $remainingSurp
); );
$otp->{$sbn}{ratio} = sprintf ("%.2f", $ratio); $otp->{$sbn}{ratio} = sprintf ("%.2f", $ratio);
@@ -12427,15 +12427,21 @@ return ($hsurp, $otp);
# Forum: https://forum.fhem.de/index.php?msg=1349579 # Forum: https://forum.fhem.de/index.php?msg=1349579
################################################################ ################################################################
sub ___batAdjustPowerByMargin { sub ___batAdjustPowerByMargin {
my ($name, $limpower, $pinmax, $whneed, $otpMargin, $total) = @_; my ($name, $limpower, $pinmax, $whneed, $otpMargin, $remainingSurp) = @_;
my $pow;
my $ratio = 0; my $ratio = 0;
$ratio = $total * 100 / $whneed if($whneed); $ratio = $remainingSurp * 100 / $whneed if($whneed);
return ($pinmax, $ratio) if($limpower == $pinmax || $ratio <= 100); return ($pinmax, $ratio) if($limpower == $pinmax);
return ($limpower * (1 + $otpMargin / 100), $ratio) if($limpower == 0 || !$otpMargin || $ratio >= 100 + $otpMargin); return ($limpower * (1 + $otpMargin / 100), $ratio) if($limpower == 0 || !$otpMargin || $ratio >= 100 + $otpMargin);
my $pow = $pinmax - ($pinmax - $limpower) * ($ratio - 100) / $otpMargin; if ($ratio <= 100) {
$pow = $ratio <= 50 ? $pinmax : $limpower * (1 + $otpMargin / 100);
}
else {
$pow = $pinmax - ($pinmax - $limpower) * ($ratio - 100) / $otpMargin;
}
return ($pow, $ratio); return ($pow, $ratio);
} }
@@ -12490,7 +12496,7 @@ return $value;
# die vollständige Ausnutzung der vorhandenen Kapazität. # die vollständige Ausnutzung der vorhandenen Kapazität.
############################################################################################### ###############################################################################################
sub ___batFindMinPhWh { sub ___batFindMinPhWh {
my ($hsurp, $aref, $Ereq) = @_; my ($hsurp, $aref, $Ereq, $replacement) = @_;
my @hods = @$aref; my @hods = @$aref;
my $low = 0; my $low = 0;
@@ -12506,8 +12512,10 @@ sub ___batFindMinPhWh {
my $charged = 0; my $charged = 0;
for my $hod (@hods) { for my $hod (@hods) {
my $cap = $hsurp->{$hod}{surplswh}; my $nhr = $hsurp->{$hod}{nhr};
$charged += $mid < $cap ? $mid : $cap; next if(!defined $nhr);
my $cap = $nhr eq '00' ? int $replacement : $hsurp->{$hod}{surplswh};
$charged += min ($mid, $cap);
} }
$charged >= $Ereq ? ($high = $mid) : ($low = $mid); $charged >= $Ereq ? ($high = $mid) : ($low = $mid);