From 8ce45a9b347c49347c7a6cc2e37ae61bd5f07013 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Tue, 14 Sep 2021 18:54:06 +0000 Subject: [PATCH] 76_SolarForecast.pm: contrib 0.56.2 git-svn-id: https://svn.fhem.de/fhem/trunk@24973 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 35 ++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 31d6c2fc1..2e1621505 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -120,6 +120,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( + "0.56.2" => "14.09.2021 some fixes, new calculation of hourscsmeXX, new key minutescsmXX ", "0.56.1" => "12.09.2021 some fixes ", "0.56.0" => "11.09.2021 new Attr flowGraphicShowConsumer, extend calc consumer power consumption ", "0.55.3" => "08.09.2021 add powerthreshold to etotal key ", @@ -2659,7 +2660,7 @@ sub _manageConsumerData { if(!$paread){ my $timespan = $t - ConsumerVal ($hash, $c, "old_etottime", $t); my $delta = $etot - ConsumerVal ($hash, $c, "old_etotal", $etot); - $pcurr = sprintf("%.6f", $delta / (3600 * $timespan)) if($delta > 0); # Einheitenformel beachten !!: W = Wh / (3600 * s) + $pcurr = sprintf("%.6f", $delta / (3600 * $timespan)) if($delta); # Einheitenformel beachten !!: W = Wh / (3600 * s) $data{$type}{$name}{consumers}{$c}{old_etotal} = $etot; $data{$type}{$name}{consumers}{$c}{old_etottime} = $t; @@ -2667,7 +2668,7 @@ sub _manageConsumerData { push @$daref, "consumer${c}_currentPower<>". $pcurr." W"; } else { - deleteReadingspec ($hash, "consumer${c}_currentPower"); + deleteReadingspec ($hash, "consumer${c}_currentPower") if(!$enread); } if(defined $ehist && $etot >= $ehist && ($etot - $ehist) >= $pthreshold) { @@ -2745,6 +2746,12 @@ sub _manageConsumerData { setPVhistory ($paref); delete $paref->{histname}; + $paref->{val} = ceil ConsumerVal ($hash, $c, "minutesOn", 0); # Verbrauchsminuten akt. Stunde des Consumers + $paref->{nhour} = sprintf("%02d",$nhour); + $paref->{histname} = "minutescsm${c}"; + setPVhistory ($paref); + delete $paref->{histname}; + ## Durchschnittsverbrauch / Betriebszeit ermitteln + speichern ################################################################ my $consumerco = 0; @@ -3645,7 +3652,7 @@ sub _calcSummaries { my $surplus = int ($pvgen - $consumption); # aktueller Überschuß my $selfconsumptionrate = 0; my $autarkyrate = 0; - $selfconsumptionrate = sprintf("%.0f", $selfconsumption / $pvgen * 100) if($pvgen); + $selfconsumptionrate = sprintf("%.0f", $selfconsumption / $pvgen * 100) if($pvgen * 1 > 0); $autarkyrate = sprintf("%.0f", $selfconsumption / ($selfconsumption + $gcon) * 100) if($selfconsumption); $data{$type}{$name}{current}{consumption} = $consumption; @@ -5324,7 +5331,7 @@ END3 $ret .= qq{$cgc} if ($cgc); $ret .= qq{$batout} if ($batout && $hasbat); $ret .= qq{$batin} if ($batin && $hasbat); - # $ret .= qq{$cc}; # Current_Consumption Anlage + $ret .= qq{$cc}; # Current_Consumption Anlage ## get consumer list and display it in Graphics ################################################ @@ -6122,6 +6129,10 @@ sub setPVhistory { $data{$type}{$name}{pvhist}{$day}{99}{$histname} = $val; } + if($histname =~ /minutescsm[0-9]+$/xs) { # Anzahl Tageszyklen des Verbrauchers + $data{$type}{$name}{pvhist}{$day}{$nhour}{$histname} = $val; + } + if($histname eq "etotal") { # etotal des Wechselrichters $val = $etotal; $data{$type}{$name}{pvhist}{$day}{$nhour}{etotal} = $etotal; @@ -6227,10 +6238,11 @@ sub listDataPool { for my $c (1..$maxconsumer) { $c = sprintf "%02d", $c; my $nl = 0; - my $csmc = HistoryVal ($hash, $day, $key, "cyclescsm${c}", undef); - my $csmt = HistoryVal ($hash, $day, $key, "csmt${c}", undef); - my $csme = HistoryVal ($hash, $day, $key, "csme${c}", undef); - my $csmh = HistoryVal ($hash, $day, $key, "hourscsme${c}", undef); + my $csmc = HistoryVal ($hash, $day, $key, "cyclescsm${c}", undef); + my $csmt = HistoryVal ($hash, $day, $key, "csmt${c}", undef); + my $csme = HistoryVal ($hash, $day, $key, "csme${c}", undef); + my $csmm = HistoryVal ($hash, $day, $key, "minutescsm${c}", undef); + my $csmh = HistoryVal ($hash, $day, $key, "hourscsme${c}", undef); if(defined $csmc) { $csm .= "cyclescsm${c}: $csmc"; @@ -6249,6 +6261,12 @@ sub listDataPool { $nl = 1; } + if(defined $csmm) { + $csm .= ", " if($nl); + $csm .= "minutescsm${c}: $csmm"; + $nl = 1; + } + if(defined $csmh) { $csm .= ", " if($nl); $csm .= "hourscsme${c}: $csmh"; @@ -7446,6 +7464,7 @@ Ein/Ausschaltzeiten sowie deren Ausführung vom SolarForecast Modul übernehmen pvcorrf abgeleiteter Autokorrekturfaktor csmtXX Summe Energieverbrauch von ConsumerXX csmeXX Anteil der jeweiligen Stunde des Tages am Energieverbrauch von ConsumerXX + minutescsmXX Summe Aktivminuten in der Stunde von ConsumerXX hourscsmeXX Summe Aktivstunden von ConsumerXX am Tag cyclescsmXX Anzahl aktive Zyklen von ConsumerXX am Tag