From efa5b14309c24a1b9c126472d8eaccfa7e0d3d6f Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 11 Jan 2025 13:25:00 +0000 Subject: [PATCH] 76_SolarForecast: fix interruptable key and some minor fixes git-svn-id: https://svn.fhem.de/fhem/trunk@29511 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/76_SolarForecast.pm | 28 +++++++++++++++------ fhem/contrib/DS_Starter/76_SolarForecast.pm | 28 +++++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index f50e4d15b..a6a1814e1 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -158,7 +158,8 @@ BEGIN { # Versions History intern my %vNotesIntern = ( "1.43.1" => "11.01.2025 _batChargeRecmd: bugfix PV daily surplus update, _collectAllRegConsumers: fix interruptable hysteresis ". - "__batRcmdOnBeam: show soc forecast for hour 00 and fix english translation ", + "__batRcmdOnBeam: show soc forecast for hour 00 and fix english translation ". + "_batChargeRecmd: consider battery capacity as part of total capacity ", "1.43.0" => "10.01.2025 graphicShowNight: add possible Time Sync of chart bar level 1 and the other ". "_addDynAttr: minor fix for graphicBeamXContent, new attr ctrlNextHoursSoCForecastReadings ", "1.42.0" => "07.01.2025 change socslidereg to batsocslidereg, _batChargeRecmd: add value to nexthours ". @@ -9884,23 +9885,25 @@ sub _batChargeRecmd { next if($err); my $batinstcap = BatteryVal ($hash, $bn, 'binstcap', 0); # installierte Batteriekapazität Wh - my $csoc = BatteryVal ($hash, $bn, 'bcharge', 0); # aktuelle Ladung in % - my $batoptsoc = ReadingsNum ($name, 'Battery_OptimumTargetSoC_'.$bn, 0); # aktueller optimierter SoC - + if (!$inplim || !$batinstcap) { debugLog ($paref, 'batteryManagement', "WARNING - The requirements for dynamic battery charge recommendation are not met. Exit."); return; } - my $cgbt = AttrVal ($name, 'ctrlBatSocManagement'.$bn, undef); - my $lowSoc = 0; + my $csoc = BatteryVal ($hash, $bn, 'bcharge', 0); # aktuelle Ladung in % + my $batoptsoc = ReadingsNum ($name, 'Battery_OptimumTargetSoC_'.$bn, 0); # aktueller optimierter SoC + my $cgbt = AttrVal ($name, 'ctrlBatSocManagement'.$bn, undef); + my $sf = __batCapShareFactor ($hash, $bn); # Anteilsfaktor der Batterie XX Kapazität an Gesamtkapazität + my $lowSoc = 0; if ($cgbt) { ($lowSoc) = __parseAttrBatSoc ($name, $cgbt); } - debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - Installed Battery capacity: $batinstcap Wh"); - + debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - Installed Battery capacity: $batinstcap Wh, Percentage of total capacity: ".(sprintf "%.1f", $sf*100)." %"); + debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - The PV generation, consumption and surplus listed below are based on the battery's share of the total capacity!"); + my $socwh = sprintf "%.0f", ($batinstcap * $csoc / 100); # aktueller SoC in Wh ## Auswertung für jede kommende Stunde @@ -9919,6 +9922,15 @@ sub _batChargeRecmd { my $rcmd = 0; # Ladeempfehlung 0 per Default my $spday = 0; + ## Aufteilung Energie auf Batterie XX im Verhältnis aller Bat + ############################################################### + $pvfc = sprintf "%.0f", $sf * $pvfc; + $confcss = sprintf "%.0f", $sf * $confcss; + $confc = sprintf "%.0f", $sf * $confc; + $rodpvfc = sprintf "%.0f", $sf * $rodpvfc; + $tomconfc = sprintf "%.0f", $sf * $tomconfc; + $tompvfc = sprintf "%.0f", $sf * $tompvfc; + ## (Rest) PV-Überschuß für den Tag #################################### if ($pvfc) { diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index f50e4d15b..a6a1814e1 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -158,7 +158,8 @@ BEGIN { # Versions History intern my %vNotesIntern = ( "1.43.1" => "11.01.2025 _batChargeRecmd: bugfix PV daily surplus update, _collectAllRegConsumers: fix interruptable hysteresis ". - "__batRcmdOnBeam: show soc forecast for hour 00 and fix english translation ", + "__batRcmdOnBeam: show soc forecast for hour 00 and fix english translation ". + "_batChargeRecmd: consider battery capacity as part of total capacity ", "1.43.0" => "10.01.2025 graphicShowNight: add possible Time Sync of chart bar level 1 and the other ". "_addDynAttr: minor fix for graphicBeamXContent, new attr ctrlNextHoursSoCForecastReadings ", "1.42.0" => "07.01.2025 change socslidereg to batsocslidereg, _batChargeRecmd: add value to nexthours ". @@ -9884,23 +9885,25 @@ sub _batChargeRecmd { next if($err); my $batinstcap = BatteryVal ($hash, $bn, 'binstcap', 0); # installierte Batteriekapazität Wh - my $csoc = BatteryVal ($hash, $bn, 'bcharge', 0); # aktuelle Ladung in % - my $batoptsoc = ReadingsNum ($name, 'Battery_OptimumTargetSoC_'.$bn, 0); # aktueller optimierter SoC - + if (!$inplim || !$batinstcap) { debugLog ($paref, 'batteryManagement', "WARNING - The requirements for dynamic battery charge recommendation are not met. Exit."); return; } - my $cgbt = AttrVal ($name, 'ctrlBatSocManagement'.$bn, undef); - my $lowSoc = 0; + my $csoc = BatteryVal ($hash, $bn, 'bcharge', 0); # aktuelle Ladung in % + my $batoptsoc = ReadingsNum ($name, 'Battery_OptimumTargetSoC_'.$bn, 0); # aktueller optimierter SoC + my $cgbt = AttrVal ($name, 'ctrlBatSocManagement'.$bn, undef); + my $sf = __batCapShareFactor ($hash, $bn); # Anteilsfaktor der Batterie XX Kapazität an Gesamtkapazität + my $lowSoc = 0; if ($cgbt) { ($lowSoc) = __parseAttrBatSoc ($name, $cgbt); } - debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - Installed Battery capacity: $batinstcap Wh"); - + debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - Installed Battery capacity: $batinstcap Wh, Percentage of total capacity: ".(sprintf "%.1f", $sf*100)." %"); + debugLog ($paref, 'batteryManagement', "Bat $bn Charge Rcmd - The PV generation, consumption and surplus listed below are based on the battery's share of the total capacity!"); + my $socwh = sprintf "%.0f", ($batinstcap * $csoc / 100); # aktueller SoC in Wh ## Auswertung für jede kommende Stunde @@ -9919,6 +9922,15 @@ sub _batChargeRecmd { my $rcmd = 0; # Ladeempfehlung 0 per Default my $spday = 0; + ## Aufteilung Energie auf Batterie XX im Verhältnis aller Bat + ############################################################### + $pvfc = sprintf "%.0f", $sf * $pvfc; + $confcss = sprintf "%.0f", $sf * $confcss; + $confc = sprintf "%.0f", $sf * $confc; + $rodpvfc = sprintf "%.0f", $sf * $rodpvfc; + $tomconfc = sprintf "%.0f", $sf * $tomconfc; + $tompvfc = sprintf "%.0f", $sf * $tompvfc; + ## (Rest) PV-Überschuß für den Tag #################################### if ($pvfc) {