From 7dcd52f315580bdfb012a7f4afc1f3da9d010b3f Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 25 Jan 2025 13:53:04 +0000 Subject: [PATCH] 76_SolarForecast: new special readings todayBatInSum,todayBatOutSum git-svn-id: https://svn.fhem.de/fhem/trunk@29572 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 +- fhem/FHEM/76_SolarForecast.pm | 73 +++++++++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 8d7d9439e..15659d4b0 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,6 +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 - + - feature: 76_SolarForecast: new special readings todayBatInSum,todayBatOutSum - change: 73_AutoShuttersControl: Change version - feature: 76_SolarForecast: show historical battery SoC when displaying the battery in the bar graph diff --git a/fhem/FHEM/76_SolarForecast.pm b/fhem/FHEM/76_SolarForecast.pm index 2179029bd..13490fc24 100644 --- a/fhem/FHEM/76_SolarForecast.pm +++ b/fhem/FHEM/76_SolarForecast.pm @@ -159,6 +159,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "1.44.3" => "25.01.2025 Notification System: minor changes, special Readings todayBatInSum todayBatOutSum ", "1.44.2" => "23.01.2025 _batChargeRecmd: user storeffdef, show historical battery SoC when displaying the battery in the bar graph ", "1.44.1" => "20.01.2025 Notification system: minor fixes, integration of controls_solarforecast_messages_test/prod ". "Define: random start of Timer subs, consumerXX: consumer device may have specified an own alias ", @@ -500,7 +501,7 @@ my $cfile = 'controls_solarforecast.txt'; my $msgfiletest = 'controls_solarforecast_messages_test.txt'; # TEST Input-File Notification System my $msgfileprod = 'controls_solarforecast_messages_prod.txt'; # PRODUKTIVES Input-File Notification System my $pPath = '?format=txt'; # Download Format -my $gmfilerepeat = 4600; # Wiederholungsuntervall Aholen Message File aus contrib +my $gmfilerepeat = 4600; # Wiederholungsuntervall Abholen Message File aus contrib my $idxlimit = 900000; # Notification System: Indexe > $idxlimit sind reserviert für Steuerungsaufgaben my $messagefile = $msgfileprod; @@ -876,6 +877,8 @@ my %hqtxt = ( # H DE => qq{LINK wartet auf Solarvorhersagedaten ...
} }, wexso => { EN => qq{switched externally}, DE => qq{von extern umgeschaltet} }, + legimp => { EN => qq{Legend Importance: 1 - general Message, 2 - important Message, 3 - Error or Problem}, + DE => qq{Legende Wichtigkeit: 1 - allgemeine Mitteilung, 2 - wichtige Mitteilung, 3 - Fehler oder Problem} }, strok => { EN => qq{Congratulations 😊, the system configuration is error-free. Please note any information ().}, DE => qq{Herzlichen Glückwunsch 😊, die Anlagenkonfiguration ist fehlerfrei. Bitte eventuelle Hinweise () beachten.} }, strwn => { EN => qq{Looks quite good 😐, the system configuration is basically OK. Please note the warnings ().}, @@ -1140,7 +1143,7 @@ my %hef = ( "noSchedule" => { f => 1.00, m => 1.00, l => 1.00, mt => $defmintime }, ); -my %hcsr = ( # Funktiontemplate zur Erstellung optionaler Statistikreadings +my %hcsr = ( # Funktiontemplate zur Erstellung optionaler Statistikreadings currentAPIinterval => { fnr => 1, fn => \&StatusAPIVal, par => '', unit => '', def => 0 }, # par = Parameter zur spezifischen Verwendung lastretrieval_time => { fnr => 1, fn => \&StatusAPIVal, par => '', unit => '', def => '-' }, lastretrieval_timestamp => { fnr => 1, fn => \&StatusAPIVal, par => '', unit => '', def => '-' }, @@ -1165,6 +1168,8 @@ my %hcsr = ( todayGridConsumption => { fnr => 4, fn => \&CircularVal, par => 99, unit => '', def => 0 }, todayConsumptionForecast => { fnr => 4, fn => \&NexthoursVal, par => 'confc', unit => ' Wh', def => '-' }, conForecastTillNextSunrise => { fnr => 4, fn => \&NexthoursVal, par => 'confc', unit => ' Wh', def => 0 }, + todayBatInSum => { fnr => 4, fn => \&CircularVal, par => 99, unit => ' Wh', def => 0 }, + todayBatOutSum => { fnr => 4, fn => \&CircularVal, par => 99, unit => ' Wh', def => 0 }, ); for my $csr (1..$maxconsumer) { @@ -1195,13 +1200,13 @@ my %hcsr = ( $hcsr{'todayBatIn_'.$bn}{fnr} = 4; $hcsr{'todayBatIn_'.$bn}{fn} = \&CircularVal; $hcsr{'todayBatIn_'.$bn}{par} = 99; - $hcsr{'todayBatIn_'.$bn}{unit} = ''; + $hcsr{'todayBatIn_'.$bn}{unit} = ' Wh'; $hcsr{'todayBatIn_'.$bn}{def} = 0; $hcsr{'todayBatOut_'.$bn}{fnr} = 4; $hcsr{'todayBatOut_'.$bn}{fn} = \&CircularVal; $hcsr{'todayBatOut_'.$bn}{par} = 99; - $hcsr{'todayBatOut_'.$bn}{unit} = ''; + $hcsr{'todayBatOut_'.$bn}{unit} = ' Wh'; $hcsr{'todayBatOut_'.$bn}{def} = 0; } @@ -12794,25 +12799,55 @@ sub _genSpecialReadings { storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $dgcon).' Wh'); } + + if ($kpi eq 'todayBatInSum') { # Summe tägl. Ladeenergie (alle Batterien) + my $tdbisum = 0; + + for my $bn (1..$maxbatteries) { + $bn = sprintf "%02d", $bn; + + my $idbitot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'initdaybatintot'.$bn, $def); # initialer Tagesstartwert Batterie In total + my $cbitot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batintot'.$bn, $def); # aktuell total Batterieladung (Wh) + + $tdbisum += ($cbitot - $idbitot); + } + + storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $tdbisum).' '.$hcsr{$kpi}{unit}); + } + + if ($kpi eq 'todayBatOutSum') { # Summe tägl. Entadeenergie (alle Batterien) + my $tdbosum = 0; + + for my $bn (1..$maxbatteries) { + $bn = sprintf "%02d", $bn; + + my $idbotot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'initdaybatouttot'.$bn, $def); # initialer Tagesstartwert Batterie Out total + my $cbotot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batouttot'.$bn, $def); # aktuelles total Batterie Out + + $tdbosum += ($cbotot - $idbotot); + } + + storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $tdbosum).' '.$hcsr{$kpi}{unit}); + } if ($kpi =~ /todayBatIn_/xs) { my $bn = (split "_", $kpi)[1]; # Batterienummer extrahieren my $idbitot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'initdaybatintot'.$bn, $def); # initialer Tagesstartwert Batterie In total - my $cbitot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batintot'.$bn, $def); # aktuell total Batterieladung (Wh) + my $cbitot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batintot'.$bn, $def); # aktuell total Batterieladung (Wh) my $dbi = $cbitot - $idbitot; - storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $dbi).' Wh'); + storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $dbi).' '.$hcsr{$kpi}{unit}); } if ($kpi =~ /todayBatOut_/xs) { my $bn = (split "_", $kpi)[1]; # Batterienummer extrahieren my $idbotot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'initdaybatouttot'.$bn, $def); # initialer Tagesstartwert Batterie Out total - my $cbotot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batouttot'.$bn, $def); # aktuelles total Batterie Out + my $cbotot = &{$hcsr{$kpi}{fn}} ($hash, $hcsr{$kpi}{par}, 'batouttot'.$bn, $def); # aktuelles total Batterie Out my $dbo = $cbotot - $idbotot; - storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $dbo).' Wh'); + storeReading ($prpo.'_'.$kpi, (sprintf "%.1f", $dbo).' '.$hcsr{$kpi}{unit}); } if ($kpi eq 'dayAfterTomorrowPVforecast') { # PV Vorhersage Summe für Übermorgen (falls Werte vorhanden), Forum:#134226 @@ -16669,8 +16704,8 @@ sub fillupMessageSystem { next if($smi >= $idxlimit); $midx++; $data{$name}{messages}{$midx}{SV} = $data{$name}{preparedmessages}{$smi}{SV}; - $data{$name}{messages}{$midx}{DE} = $data{$name}{preparedmessages}{$smi}{DE}; - $data{$name}{messages}{$midx}{EN} = $data{$name}{preparedmessages}{$smi}{EN}; + $data{$name}{messages}{$midx}{DE} = encode ("utf8", $data{$name}{preparedmessages}{$smi}{DE}); + $data{$name}{messages}{$midx}{EN} = encode ("utf8", $data{$name}{preparedmessages}{$smi}{EN}); } $data{$name}{messages}{999000}{TS} = $data{$name}{filemessages}{999000}{TS} // 0; @@ -16743,7 +16778,8 @@ sub outputMessages { next if($key >= $idxlimit); $hc++; - my $enmsg = encode ("utf8", $data{$name}{messages}{$key}{$lang}); + #my $enmsg = encode ("utf8", $data{$name}{messages}{$key}{$lang}); + my $enmsg = $data{$name}{messages}{$key}{$lang}; $out .= qq{}; $out .= qq{ $key }; @@ -16760,10 +16796,11 @@ sub outputMessages { } } - $out .= qq{}; + $out .= qq{}; $out .= qq{}; $out .= "
"; + $out .= $hqtxt{legimp}{$lang}; return $out; } @@ -23336,8 +23373,10 @@ to ensure that the system configuration is correct. A call can contain multiple API requests. todayRemainingAPIcalls the number of radiation data API calls still possible on the current day todayRemainingAPIrequests the number of radiation data API requests still possible on the current day - todayBatInXX the energy charged into the battery XX on the current day - todayBatOutXX the energy taken from the battery XX on the current day + todayBatIn_XX the energy charged into the battery XX on the current day + todayBatInSum Total energy charged in all batteries on the current day + todayBatOut_XX the energy taken from the battery XX on the current day + todayBatOutSum Total energy drawn from all batteries on the current day
@@ -25826,8 +25865,10 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden. Ein Call kann mehrere API Requests enthalten. todayRemainingAPIcalls die Anzahl der am aktuellen Tag noch möglichen Strahlungsdaten-API Calls todayRemainingAPIrequests die Anzahl der am aktuellen Tag noch möglichen Strahlungsdaten-API Requests - todayBatInXX die am aktuellen Tag in die Batterie XX geladene Energie - todayBatOutXX die am aktuellen Tag aus der Batterie XX entnommene Energie + todayBatIn_XX die am aktuellen Tag in die Batterie XX geladene Energie + todayBatInSum Summe der am aktuellen Tag in alle Batterien geladene Energie + todayBatOut_XX die am aktuellen Tag aus der Batterie XX entnommene Energie + todayBatOutSum Summe der am aktuellen Tag aus allen Batterien entnommene Energie