From 0af46e70d9cace4162c9b826042949069123d021 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Tue, 7 Jan 2025 16:34:13 +0000 Subject: [PATCH] 76_SolarForecast: contrib 1.42.0 git-svn-id: https://svn.fhem.de/fhem/trunk@29494 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/76_SolarForecast.pm | 74 ++++++++++++--------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/fhem/contrib/DS_Starter/76_SolarForecast.pm b/fhem/contrib/DS_Starter/76_SolarForecast.pm index 10e48c02e..17a42d90b 100644 --- a/fhem/contrib/DS_Starter/76_SolarForecast.pm +++ b/fhem/contrib/DS_Starter/76_SolarForecast.pm @@ -15018,9 +15018,9 @@ sub _flowGraphic { $bat2home += $bat2homepow if(defined $bat2homepow); push @batsoc, ReadingsNum ($name, 'Current_BatCharge_'.$bn, 0); - } + } - $soc = avgArray (\@batsoc, scalar @batsoc) if(@batsoc); + $soc = avgArray (\@batsoc, scalar @batsoc) if(@batsoc); if (!defined $batin && !defined $bat2home) { $hasbat = 0; @@ -15029,6 +15029,14 @@ sub _flowGraphic { $soc = 0; } + ## Resultierende von Laden und Entladen berechnen + ################################################### + my $x = $batin - $bat2home; # können theoretisch gleich groß sein -> 0 setzen und Resultierende neu berechnen + $batin = 0; + $bat2home = 0; + + if ($x > 0) { $batin = $x; } else { $bat2home = abs $x; } # es darf nur $batin ODER $bat2home mit einem Wert > 0 geben + my $bat_color = $soc < 26 ? "$stna bat25" : $soc < 76 ? "$stna bat50" : "$stna bat75"; @@ -15078,6 +15086,37 @@ sub _flowGraphic { } } + ## Batterie Werte verarbeiten + ############################### + my $grid2home_style = $cgc ? "$stna active_sig" : "$stna inactive"; # cgc current GridConsumption + my $bat2home_style = $bat2home ? "$stna active_normal" : "$stna inactive"; + my $cgc_direction = "M250,515 L670,590"; + + if ($bat2home) { # Batterie wird entladen + my $cgfo = $node2grid - $pv2node; # pv2node -> PV-Erzeugung Inverter für das Hausnetz + + if ($cgfo > 1) { + $grid2home_style = "$stna active_normal"; + $cgc_direction = "M670,590 L250,515"; + $node2grid -= $cgfo; + $cgc = $cgfo; + } + } + + my $bat2home_direction = "M1200,515 L730,590"; + my $node2bat = $batin; + + if ($batin) { # Batterie wird geladen + my $home2bat = $batin - ($pv2node + $pv2bat); + + if ($home2bat > 1) { # Batterieladung wird anteilig aus Hausnetz geladen + $node2bat -= $home2bat; + $bat2home_style = "$stna active_sig"; + $bat2home_direction = "M730,590 L1200,515"; + $bat2home = $home2bat; + } + } + ## Producer Koordninaten Steuerhash ##################################### my ($togrid, $tonode, $tobat) = __sortProducer ($pdcr); # lfn Producer sortiert nach ptyp und feed @@ -15104,37 +15143,6 @@ sub _flowGraphic { my $consumercount = keys %{$cnsmr}; my @consumers = sort{$a<=>$b} keys %{$cnsmr}; - ## Batterie Werte verarbeiten - ############################### - my $grid2home_style = $cgc ? "$stna active_sig" : "$stna inactive"; # cgc current GridConsumption - my $bat2home_style = $bat2home ? "$stna active_normal" : "$stna inactive"; - my $cgc_direction = "M250,515 L670,590"; - - if ($bat2home) { # Batterie wird ins Haus entladen - my $cgfo = $node2grid - $pv2node; - - if ($cgfo > 1) { - $grid2home_style = "$stna active_normal"; - $cgc_direction = "M670,590 L250,515"; - $node2grid -= $cgfo; - $cgc = $cgfo; - } - } - - my $bat2home_direction = "M1200,515 L730,590"; - my $node2bat = $batin; - - if ($batin) { # Batterie wird geladen - my $home2bat = $batin - ($pv2node + $pv2bat); - - if ($home2bat > 1) { # Batterieladung wird anteilig aus Hausnetz geladen - $node2bat -= $home2bat; - $bat2home_style = "$stna active_sig"; - $bat2home_direction = "M730,590 L1200,515"; - $bat2home = $home2bat; - } - } - ## Werte / SteuerungVars anpassen ################################### my $pnodesum = __normDecPlaces ($ppall + $pv2node); # Erzeugung Summe im Knoten