76_SolarForecast: contrib Version 1.60.4
git-svn-id: https://svn.fhem.de/fhem/trunk@30523 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -12066,7 +12066,6 @@ sub _batChargeMgmt {
|
||||
$hsurp->{$fd}{$hod}{nhr} = $nhr;
|
||||
$hsurp->{$fd}{$hod}{speff} = $surpls; # effektiver PV Überschuß bzw. effektiver Verbrauch wenn < 0
|
||||
$hsurp->{$fd}{$hod}{surplswh} = $surplswh.'.'.$hod; # absoluter Überschuß in Wh der Stunde mit Sortierhilfe
|
||||
$hsurp->{$fd}{$hod}{$bn}{spday} = $spday; # (Rest)PV-Überschuß am laufenden Tag
|
||||
$hsurp->{$fd}{$hod}{$bn}{initsocwh} = $socwh; # durch LR fortgeschriebener SoC
|
||||
$hsurp->{$fd}{$hod}{$bn}{batinstcap} = $batinstcap; # installierte Batteriekapazität (Wh)
|
||||
$hsurp->{$fd}{$hod}{$bn}{goalwh} = $goalwh; # Ladeziel
|
||||
@@ -12164,7 +12163,7 @@ sub _batChargeMgmt {
|
||||
###########################################
|
||||
for my $shod (sort { $a <=> $b } keys %{$hopt}) {
|
||||
my $nhr = $hopt->{$shod}{nhr};
|
||||
my @batteries = grep { !/^(?:fd|speff|surplswh|nhr)$/xs } keys %{$hopt->{24}};
|
||||
my @batteries = grep { !/^(?:fd|speff|surplswh|spday|nhr)$/xs } keys %{$hopt->{24}};
|
||||
|
||||
for my $bat (sort @batteries) {
|
||||
next if(!defined $hopt->{$shod}{$bat}{batinstcap});
|
||||
@@ -12196,24 +12195,25 @@ sub _batChargeMgmt {
|
||||
## Debuglog OTP
|
||||
#################
|
||||
if ($paref->{debug} =~ /batteryManagement/ && $strategy ne 'loadRelease') {
|
||||
my $spday = $hopt->{$shod}{spday};
|
||||
my $lcintime = $hopt->{$shod}{$bat}{lcintime};
|
||||
my $spls = int $hopt->{$shod}{surplswh};
|
||||
my $pneedmin = $hopt->{$shod}{$bat}{pneedmin};
|
||||
my $ttt = $hopt->{$shod}{$bat}{stt};
|
||||
my $crel = $hopt->{$shod}{$bat}{loadrel};
|
||||
my $spday = $hopt->{$shod}{$bat}{spday};
|
||||
my $frefph = $hopt->{$shod}{$bat}{frefph} // '-';
|
||||
my $iter = $hopt->{$shod}{$bat}{iterations} // '-';
|
||||
|
||||
if ($nhr eq '00') {
|
||||
$pneedmin = $otp->{$bat}{target} // 0;
|
||||
my $ratio = $otp->{$bat}{ratio} // '<unknown>';
|
||||
my $remainSurp = $otp->{$bat}{remainingSurp} // '<unknown>';
|
||||
my $achievelog = $hopt->{$shod}{$bat}{achievelog};
|
||||
my $otpMargin = $hopt->{$shod}{$bat}{otpMargin};
|
||||
|
||||
Log3 ($name, 1, "$name DEBUG> ChargeOTP Bat $bat - used safety margin: $otpMargin %");
|
||||
Log3 ($name, 1, "$name DEBUG> ChargeOTP Bat $bat - $achievelog");
|
||||
Log3 ($name, 1, "$name DEBUG> ChargeOTP Bat $bat - current Ratio of surplus / energy requirement to achieve the load target: $ratio %") if($strategy eq 'smartPower');
|
||||
Log3 ($name, 1, "$name DEBUG> ChargeOTP Bat $bat - Ratio of remaining surplus $remainSurp Wh / energy requirement to achieve the load target: $ratio %") if($strategy eq 'smartPower');
|
||||
}
|
||||
|
||||
Log3 ($name, 1, "$name DEBUG> ChargeOTP Bat $bat $ttt - hod:$shod/$nhr, lr/lc:$crel/$lcintime, SocS/E:$ssocwh/$fcendwh Wh, SurpH/D:$spls/$spday Wh, OTP:$pneedmin/$frefph W");
|
||||
@@ -12281,10 +12281,10 @@ sub __batChargeOptTargetPower {
|
||||
#######################################################################
|
||||
my $replacement;
|
||||
|
||||
for my $k (keys %$hsurp) {
|
||||
my $nh = $hsurp->{$k}{nhr};
|
||||
for my $k (sort { $a <=> $b } keys %{$hsurp}) {
|
||||
my $nhr = $hsurp->{$k}{nhr};
|
||||
|
||||
if ($nh eq '00') {
|
||||
if ($nhr eq '00') {
|
||||
my $val = $hsurp->{$k}{surplswh};
|
||||
|
||||
if (defined $val && $val =~ /^(\d+)\.(\w+)$/) {
|
||||
@@ -12292,12 +12292,12 @@ sub __batChargeOptTargetPower {
|
||||
$replacement .= '.'.$2;
|
||||
}
|
||||
|
||||
last; # da Stunde 00 nur einmal vorkommt, können wir abbrechen
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
my $fipl = CurrentVal ($name, 'feedinPowerLimit', INFINITE);
|
||||
my @batteries = grep { !/^(?:fd|speff|surplswh|nhr)$/xs } keys %{$hsurp->{24}};
|
||||
my @batteries = grep { !/^(?:fd|speff|surplswh|spday|nhr)$/xs } keys %{$hsurp->{24}};
|
||||
my @sortedhods = sort { $hsurp->{$a}{surplswh} <=> $hsurp->{$b}{surplswh} } keys %{$hsurp}; # Stunden aufsteigend nach PV-Überschuß sortiert ohne Zeitgewichtung h 00
|
||||
|
||||
my ($fcendwh, $diff, $otp, $ratio);
|
||||
@@ -12315,6 +12315,7 @@ sub __batChargeOptTargetPower {
|
||||
$replacement,
|
||||
\@sortedhods
|
||||
);
|
||||
$hsurp->{$hod}{spday} = $remainingSurp_o; # PV Überschuß Resttag
|
||||
|
||||
my ($remainingSurp, $remainingHodsRef);
|
||||
|
||||
@@ -12365,15 +12366,15 @@ sub __batChargeOptTargetPower {
|
||||
my $runwhneed = $goalwh - $runwh;
|
||||
my $achievable = 1;
|
||||
|
||||
if ($runwhneed > 0 && $remainingSurp * $befficiency < $runwhneed) { # Erreichbarkeit des Ziels (benötigte Ladeenergie total) prüfen
|
||||
if ($runwhneed > 0 && $remainingSurp < ($runwhneed / $befficiency)) { # Erreichbarkeit des Ziels (benötigte Ladeenergie total) prüfen
|
||||
$achievable = 0;
|
||||
}
|
||||
|
||||
storeReading ('Battery_TargetAchievable_'.$sbn, $achievable) if($nhr eq '00');
|
||||
|
||||
$hsurp->{$hod}{$sbn}{loadrel} = $runwhneed > 0 ? 1 : 0; # Ladefreigabe abhängig von Ziel-SoC Erfüllung
|
||||
$hsurp->{$hod}{$sbn}{achievelog} = "charging target: $goalwh Wh, remaining: ".
|
||||
(sprintf "%.0f", $runwhneed).' Wh -> target likely achievable? '.
|
||||
$hsurp->{$hod}{$sbn}{achievelog} = "charging target: $goalwh Wh, E requirement incl. efficiency: ".
|
||||
(sprintf "%.0f", ($runwhneed / $befficiency)).' Wh -> target likely achievable? '.
|
||||
($achievable ? 'yes' : 'no');
|
||||
|
||||
## kein Überschuß
|
||||
@@ -12481,7 +12482,8 @@ sub __batChargeOptTargetPower {
|
||||
$befficiency
|
||||
);
|
||||
|
||||
$otp->{$sbn}{ratio} = sprintf ("%.2f", $ratio);
|
||||
$otp->{$sbn}{ratio} = sprintf ("%.2f", $ratio);
|
||||
$otp->{$sbn}{remainingSurp} = $remainingSurp;
|
||||
}
|
||||
|
||||
my $gfeedin = CurrentVal ($name, 'gridfeedin', 0); # aktuelle Netzeinspeisung
|
||||
@@ -12545,6 +12547,7 @@ sub ___batRemainHodsAndSurp {
|
||||
my $val = defined $hsurp->{$h}{nhr} && $hsurp->{$h}{nhr} eq '00'
|
||||
? int ($replacement) // 0
|
||||
: $hsurp->{$h}{surplswh};
|
||||
|
||||
$remainingSurp += int $val;
|
||||
}
|
||||
|
||||
@@ -12557,14 +12560,14 @@ return ($remainingSurp, \@remaining_hods);
|
||||
# Forum: https://forum.fhem.de/index.php?msg=1349579
|
||||
################################################################
|
||||
sub ___batAdjustPowerByMargin {
|
||||
my ($limpower, $pinmax, $whneed, $otpMargin, $remainingSurp, $befficiency) = @_;
|
||||
my ($limpower, $pinmax, $runwhneed, $otpMargin, $remainingSurp, $befficiency) = @_;
|
||||
|
||||
my $pow;
|
||||
my $ratio = 0;
|
||||
|
||||
return ($limpower, $ratio) if(!defined $whneed || $whneed <= 0);
|
||||
return ($limpower, $ratio) if(!defined $runwhneed || $runwhneed <= 0);
|
||||
|
||||
$ratio = $remainingSurp * 100 / ($whneed / $befficiency);
|
||||
$ratio = $remainingSurp * 100 / ($runwhneed / $befficiency);
|
||||
$limpower = min ($limpower, $pinmax); # limpower !> pinmax um invertierte Interpolation zu vermeiden
|
||||
|
||||
if ($limpower <= 0 || !$otpMargin) {$pow = $limpower}
|
||||
@@ -12713,6 +12716,8 @@ sub ___batFindMinPhWh {
|
||||
: $hsurp->{$_}{surplswh} // 0
|
||||
} @hods;
|
||||
|
||||
$max_cap //= 0;
|
||||
|
||||
return { ph => (sprintf "%.0f", $max_cap), iterations => $loop, blur => (sprintf "%.4f", 0) };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user