2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

76_SolarForecast: Attr flowGraphicControl new key h2consumerdist

git-svn-id: https://svn.fhem.de/fhem/trunk@29300 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2024-10-26 18:36:31 +00:00
parent 10f7630c79
commit 31c5a3f9f8
2 changed files with 67 additions and 49 deletions

View File

@ -1,5 +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: Attr flowGraphicControl new key h2consumerdist
- feature: 74_AutomowerConnect: new statistics values upTime, downTime
new setter getMessages, resetCuttingBladeUsageTime
added messages to listErrorStack

View File

@ -156,6 +156,8 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"1.37.3" => "25.10.2024 _flowGraphic: grid, dummy and battery displacement by kask ".
"Attr flowGraphicControl: new key h2consumerdist, animate=1 is default now ",
"1.37.2" => "24.10.2024 _flowGraphic: show Producer Row only if more than one Producer is defined ",
"1.37.1" => "23.10.2024 state: 'The setup routine is still incomplete' if setup is incomplete ".
"change: 'trackFlex' && \$wcc >= 80 to \$wcc >= 70, implement Rename function ".
@ -5645,6 +5647,7 @@ sub _attrflowGraphicControl { ## no critic "not used"
for my $av ( qw( animate
consumerdist
h2consumerdist
shift
showconsumer
showconsumerremaintime
@ -5664,6 +5667,7 @@ sub _attrflowGraphicControl { ## no critic "not used"
my $valid = {
animate => '0|1',
consumerdist => '[89]\d{1}|[1234]\d{2}|500',
h2consumerdist => '\d{1,3}',
shift => '-?[0-7]\d{0,1}|-?80',
size => '\d+',
showconsumer => '0|1',
@ -12142,13 +12146,14 @@ sub entryGraphic {
sheader => AttrNum ($name, 'graphicHeaderShow', 1), # Anzeigen des Grafik Headers
hdrDetail => AttrVal ($name, 'graphicHeaderDetail', 'all'), # ermöglicht den Inhalt zu begrenzen, um bspw. passgenau in ftui einzubetten
flowgsize => CurrentVal ($hash, 'size', $flowGSizedef), # Größe Energieflußgrafik
flowgani => CurrentVal ($hash, 'animate', 0), # Animation Energieflußgrafik
flowgani => CurrentVal ($hash, 'animate', 1), # Animation Energieflußgrafik
flowgshift => CurrentVal ($hash, 'shift', 0), # Verschiebung der Flußgrafikbox (muß negiert werden)
flowgcons => CurrentVal ($hash, 'showconsumer', 1), # Verbraucher in der Energieflußgrafik anzeigen
flowgconX => CurrentVal ($hash, 'showconsumerdummy', 1), # Dummyverbraucher in der Energieflußgrafik anzeigen
flowgconsPower => CurrentVal ($hash, 'showconsumerpower', 1), # Verbraucher Leistung in der Energieflußgrafik anzeigen
flowgconsTime => CurrentVal ($hash, 'showconsumerremaintime', 1), # Verbraucher Restlaufeit in der Energieflußgrafik anzeigen
flowgconsDist => CurrentVal ($hash, 'consumerdist', $fgCDdef), # Abstand Verbrauchericons zueinander
flowgh2cDist => CurrentVal ($hash, 'h2consumerdist', 0), # Erweiterung des vertikalen Abstandes Haus -> Consumer
genpvdva => AttrVal ($name, 'ctrlGenPVdeviation', 'daily'), # Methode der Abweichungsberechnung
lang => getLang ($hash),
debug => getDebug ($hash), # Debug Module
@ -14215,6 +14220,7 @@ sub _flowGraphic {
my $flowgconsPower = $paref->{flowgconsPower};
my $flowgPrdsPower = 1; # initial Producer akt. Erzeugung anzeigen
my $cdist = $paref->{flowgconsDist}; # Abstand Consumer zueinander
my $exth2cdist = $paref->{flowgh2cDist}; # vertikaler Abstand Home -> Consumer Zeile
my $lang = $paref->{lang};
my $cgc = ReadingsNum ($name, 'Current_GridConsumption', 0);
@ -14229,10 +14235,10 @@ sub _flowGraphic {
my $scale = $fgscaledef;
my $pdist = 130; # Abstand Producer zueinander
my $hasbat = 1; # initial Batterie vorhanden
my $lcp;
my ($lcp, $y_pos, $y_pos1);
my $stna = $name;
$stna =~ s/([0-9])/$hrepl{$1}/ge if($name =~ /[0-9]/xs); # V 1.37.1 Ziffern eliminieren, Forum: https://forum.fhem.de/index.php?msg=1323229
$stna =~ s/([0-9])/$hrepl{$1}/ge if($name =~ /[0-9]/xs); # V 1.37.1 Ziffern eliminieren, Forum: https://forum.fhem.de/index.php?msg=1323229
## definierte Producer + Inverter ermitteln und zusammenfassen
################################################################
@ -14284,9 +14290,9 @@ sub _flowGraphic {
my ($togrid, $tonode, $tobat) = __sortProducer ($pdcr); # lfn Producer sortiert nach ptyp und feed
my $psorted = {
'1togrid' => { xicon => -100, xchain => 350, ychain => 420, step => 70, count => scalar @{$togrid}, sorted => $togrid }, # Producer/PV nur zu Grid
'1togrid' => { xicon => -100, xchain => 150, ychain => 400, step => 30, count => scalar @{$togrid}, sorted => $togrid }, # Producer/PV nur zu Grid
'2tonode' => { xicon => 350, xchain => 700, ychain => 200, step => $pdist, count => scalar @{$tonode}, sorted => $tonode }, # Producer/PV zum Knoten
'3tobat' => { xicon => 750, xchain => 1100, ychain => 430, step => 40, count => scalar @{$tobat}, sorted => $tobat }, # Producer/PV nur zu Batterie
'3tobat' => { xicon => 750, xchain => 1370, ychain => 430, step => 30, count => scalar @{$tobat}, sorted => $tobat }, # Producer/PV nur zu Batterie
};
my $doproducerrow = 1;
@ -14294,10 +14300,10 @@ sub _flowGraphic {
## definierte Verbraucher ermitteln
#####################################
my $cnsmr = {}; # Hashref Consumer current power
my $cnsmr = {}; # Hashref Consumer current power
for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) { # definierte Verbraucher ermitteln
next if(isConsumerNoshow ($hash, $c) =~ /^[13]$/xs); # auszublendende Consumer nicht berücksichtigen
for my $c (sort{$a<=>$b} keys %{$data{$type}{$name}{consumers}}) { # definierte Verbraucher ermitteln
next if(isConsumerNoshow ($hash, $c) =~ /^[13]$/xs); # auszublendende Consumer nicht berücksichtigen
$cnsmr->{$c}{p} = ReadingsNum ($name, "consumer${c}_currentPower", 0);
$cnsmr->{$c}{ptyp} = 'consumer';
}
@ -14318,22 +14324,22 @@ sub _flowGraphic {
$soc = 0;
}
my $grid2home_style = $cgc ? "$stna active_sig" : "$stna inactive"; # cgc current GridConsumption
my $grid2home_style = $cgc ? "$stna active_sig" : "$stna inactive"; # cgc current GridConsumption
my $bat2home_style = $bat2home ? "$stna active_normal" : "$stna inactive";
my $cgc_direction = "M490,515 L670,590";
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 L490,515";
$cgc_direction = "M670,590 L250,515";
$node2grid -= $cgfo;
$cgc = $cgfo;
}
}
my $bat2home_direction = "M902,515 L730,590";
my $bat2home_direction = "M1200,515 L730,590";
my $node2bat = $batin;
if ($batin) { # Batterie wird geladen
@ -14342,7 +14348,7 @@ sub _flowGraphic {
if ($home2bat > 1) { # Batterieladung wird anteilig aus Hausnetz geladen
$node2bat -= $home2bat;
$bat2home_style = "$stna active_sig";
$bat2home_direction = "M730,590 L902,515";
$bat2home_direction = "M730,590 L1200,515";
$bat2home = $home2bat;
}
}
@ -14358,13 +14364,14 @@ sub _flowGraphic {
## SVG Box initialisieren mit Grid-Icon
#########################################
my $vbwidth = 800; # width and height specify the viewBox size
my $vbminx = -10 * $flowgshift; # min-x and min-y represent the smallest X and Y coordinates that the viewBox may have
my $vbminy = $doproducerrow ? -25 : 125; # Grafik höher positionieren wenn keine Poducerreihe angezeigt
my $vbwidth = 800; # width and height specify the viewBox size
my $vbminx = -10 * $flowgshift; # min-x and min-y represent the smallest X and Y coordinates that the viewBox may have
my $vbminy = $doproducerrow ? -25 : 125; # Grafik höher positionieren wenn keine Poducerreihe angezeigt
my $vbhight = !$flowgcons ? 380 :
!$flowgconsTime ? 590 :
610;
my $vbhight = !$flowgcons ? 380 :
!$flowgconsTime ? 590 :
610;
$vbhight += $exth2cdist;
if ($doproducerrow) {$vbhight += 100}; # Höhe Box vergrößern wenn Poducerreihe angezeigt
@ -14399,7 +14406,7 @@ sub _flowGraphic {
<svg xmlns="http://www.w3.org/2000/svg" viewBox="$vbox" style="$svgstyle" id="SVGPLOT_$stna">
<g id="grid_$stna" class="$grid_color" transform="translate(215,260),scale(3.0)">
<g id="grid_$stna" class="$grid_color" transform="translate(100,260),scale(3.0)">
<path d="M15.3,2H8.7L2,6.46V10H4V8H8v2.79l-4,9V22H6V20.59l6-3.27,6,3.27V22h2V19.79l-4-9V8h4v2h2V6.46ZM14,4V6H10V4ZM6.3,6,8,4.87V6Zm8,6L15,13.42,12,15,9,13.42,9.65,12ZM7.11,17.71,8.2,15.25l1.71.93Zm8.68-2.46,1.09,2.46-2.8-1.53ZM14,10H10V8h4Zm2-5.13L17.7,6H16Z"/>
</g>
END0
@ -14438,6 +14445,7 @@ END0
my $cons_left = 0;
my $consumer_start = 0;
my $currentPower = 0;
$y_pos = 505 + $exth2cdist;
if ($flowgcons) {
if ($consumercount % 2) {
@ -14466,7 +14474,7 @@ END0
$cicon = FW_makeImage ($cicon, '');
($scale, $cicon) = __normIconScale ($cicon, $name);
$ret .= qq{<g id="consumer_${c}_$stna" transform="translate($cons_left,505),scale($scale)">};
$ret .= qq{<g id="consumer_${c}_$stna" transform="translate($cons_left,$y_pos),scale($scale)">};
$ret .= "<title>$calias</title>".$cicon;
$ret .= '</g> ';
@ -14478,7 +14486,7 @@ END0
##################
if ($hasbat) {
$ret .= << "END1";
<g class="$bat_color" transform="translate(610,245),scale(.30) rotate (90)">
<g class="$bat_color" transform="translate(750,245),scale(.30) rotate (90)">
<path d="m 134.65625,89.15625 c -6.01649,0 -11,4.983509 -11,11 l 0,180 c 0,6.01649 4.98351,11 11,11 l 95.5,0 c 6.01631,0 11,-4.9825 11,-11 l 0,-180 c 0,-6.016491 -4.98351,-11 -11,-11 l -95.5,0 z m 0,10 95.5,0 c 0.60951,0 1,0.390491 1,1 l 0,180 c 0,0.6085 -0.39231,1 -1,1 l -95.5,0 c -0.60951,0 -1,-0.39049 -1,-1 l 0,-180 c 0,-0.609509 0.39049,-1 1,-1 z"/>
<path d="m 169.625,69.65625 c -6.01649,0 -11,4.983509 -11,11 l 0,14 10,0 0,-14 c 0,-0.609509 0.39049,-1 1,-1 l 25.5,0 c 0.60951,0 1,0.390491 1,1 l 0,14 10,0 0,-14 c 0,-6.016491 -4.98351,-11 -11,-11 l -25.5,0 z"/>
END1
@ -14507,7 +14515,7 @@ END1
my $dicon = FW_makeImage ($cicondef.$dumcol, '');
($scale, $dicon) = __normIconScale ($dicon, $name);
$ret .= qq{<g id="dummy_$stna" transform="translate(520,360),scale($scale)">};
$ret .= qq{<g id="dummy_$stna" transform="translate(660,360),scale($scale)">};
$ret .= "<title>$dumtxt</title>".$dicon;
$ret .= '</g> ';
}
@ -14520,7 +14528,7 @@ END1
$ret .= << "END2";
<g transform="translate(50,50),scale(0.5)" stroke-width="27" fill="none">
<path id="node2home_$stna" class="$node2home_style" d="M700,400 L700,580" />
<path id="node2grid_$stna" class="$node2grid_style" d="M670,400 L490,480" />
<path id="node2grid_$stna" class="$node2grid_style" d="M670,400 L250,480" />
<path id="grid2home_$stna" class="$grid2home_style" d="$cgc_direction" />
END2
@ -14528,7 +14536,7 @@ END2
##############################################
if ($hasbat) {
my $node2bat_style = $node2bat ? "$stna active_normal" : "$stna inactive";
my $batin_direction = $node2bat < 0 ? "M910,480 L730,400" : "M730,400 L910,480";
my $batin_direction = $node2bat < 0 ? "M1200,480 L730,400" : "M730,400 L1200,480";
$node2bat = abs $node2bat;
$ret .= << "END3";
@ -14549,7 +14557,7 @@ END3
#$chain_color = 'style="stroke: #DF0101;"';
}
$ret .= qq{<path id="home2dummy_$stna" class="$consumer_style" $chain_color d="M790,690 L930,690" />};
$ret .= qq{<path id="home2dummy_$stna" class="$consumer_style" $chain_color d="M790,690 L1200,690" />};
}
## Producer Laufketten - in Reihenfolge: zum Grid - zum Knoten - zur Batterie
@ -14596,6 +14604,7 @@ END3
$cons_left = $consumer_start * 2;
my $cons_left_start = 0;
my $distance_con = 65;
$y_pos = 880 + 2 * $exth2cdist;
if ($consumercount % 2) {
$cons_left_start = 700 - ($distance_con * ($consumercount -1) / 2);
@ -14624,7 +14633,7 @@ END3
$chain_color = 'style="stroke: #'.substr(Color::pahColor(0,50,100,$p,[0,255,0, 127,255,0, 255,255,0, 255,127,0, 255,0,0]),0,6).';"';
}
$ret .= qq{<path id="home2consumer_${c}_$stna" class="$consumer_style" $chain_color d="M$cons_left_start,780 L$cons_left,880" />};
$ret .= qq{<path id="home2consumer_${c}_$stna" class="$consumer_style" $chain_color d="M$cons_left_start,780 L$cons_left,$y_pos" />};
$cons_left += ($cdist * 2);
$cons_left_start += $distance_con;
}
@ -14633,15 +14642,15 @@ END3
## Textangaben an Grafikelementen
###################################
$cc_dummy = sprintf("%.0f", $cc_dummy); # Verbrauch Dummy-Consumer
$ret .= qq{<text class="$stna text" id="nodetxt_$stna" x="800" y="320" style="text-anchor: start;">$pnodesum</text>} if ($pnodesum > 0);
$ret .= qq{<text class="$stna text" id="batsoctxt_$stna" x="1110" y="520" style="text-anchor: start;">$soc %</text>} if ($hasbat); # Lage Text Batterieladungszustand
$ret .= qq{<text class="$stna text" id="node2hometxt_$stna" x="730" y="520" style="text-anchor: start;">$node2home</text>} if ($node2home);
$ret .= qq{<text class="$stna text" id="node2gridtxt_$stna" x="525" y="420" style="text-anchor: end;">$node2grid</text>} if ($node2grid);
$ret .= qq{<text class="$stna text" id="grid2hometxt_$stna" x="515" y="610" style="text-anchor: end;">$cgc</text>} if ($cgc);
$ret .= qq{<text class="$stna text" id="batouttxt_$stna" x="880" y="610" style="text-anchor: start;">$bat2home</text>} if ($bat2home && $hasbat);
$ret .= qq{<text class="$stna text" id="node2battxt_$stna" x="880" y="420" style="text-anchor: start;">$node2bat</text>} if ($node2bat && $hasbat);
$ret .= qq{<text class="$stna text" id="hometxt_$stna" x="600" y="710" style="text-anchor: end;">$cc</text>}; # Current_Consumption Anlage
$ret .= qq{<text class="$stna text" id="dummytxt_$stna" x="1085" y="710" style="text-anchor: start;">$cc_dummy</text>} if ($flowgconX && $flowgconsPower); # Current_Consumption Dummy
$ret .= qq{<text class="$stna text" id="nodetxt_$stna" x="800" y="320" style="text-anchor: start;">$pnodesum</text>} if ($pnodesum > 0);
$ret .= qq{<text class="$stna text" id="batsoctxt_$stna" x="1380" y="520" style="text-anchor: start;">$soc %</text>} if ($hasbat); # Lage Text Batterieladungszustand
$ret .= qq{<text class="$stna text" id="node2hometxt_$stna" x="730" y="520" style="text-anchor: start;">$node2home</text>} if ($node2home);
$ret .= qq{<text class="$stna text" id="node2gridtxt_$stna" x="420" y="420" style="text-anchor: end;">$node2grid</text>} if ($node2grid);
$ret .= qq{<text class="$stna text" id="grid2hometxt_$stna" x="420" y="610" style="text-anchor: end;">$cgc</text>} if ($cgc);
$ret .= qq{<text class="$stna text" id="batouttxt_$stna" x="1000" y="610" style="text-anchor: start;">$bat2home</text>} if ($bat2home && $hasbat);
$ret .= qq{<text class="$stna text" id="node2battxt_$stna" x="1000" y="420" style="text-anchor: start;">$node2bat</text>} if ($node2bat && $hasbat);
$ret .= qq{<text class="$stna text" id="hometxt_$stna" x="600" y="750" style="text-anchor: end;">$cc</text>}; # Current_Consumption Anlage
$ret .= qq{<text class="$stna text" id="dummytxt_$stna" x="1380" y="710" style="text-anchor: start;">$cc_dummy</text>} if ($flowgconX && $flowgconsPower); # Current_Consumption Dummy
## Textangabe Producer - in Reihenfolge: zum Grid - zum Knoten - zur Batterie
## Textangabe nur anzeigen wenn Producerzeile angezeigt werden soll
@ -14683,6 +14692,8 @@ END3
########################
if ($flowgcons) {
$cons_left = ($consumer_start * 2) - 50; # -XX -> Start Lage Consumer Beschriftung
$y_pos = 1110 + 2 * $exth2cdist;
$y_pos1 = 1170 + 2 * $exth2cdist;
for my $c (@consumers) {
$currentPower = sprintf "%.1f", $cnsmr->{$c}{p};
@ -14707,8 +14718,8 @@ END3
elsif ($lcp == 2) {$cons_left += 7 }
elsif ($lcp == 1) {$cons_left += 25}
$ret .= qq{<text class="$stna text" id="consumertxt_${c}_$stna" x="$cons_left" y="1110">$currentPower</text>} if ($flowgconsPower); # Lage Consumer Consumption
$ret .= qq{<text class="$stna text" id="consumertxt_time_${c}_$stna" x="$cons_left" y="1170">$consumerTime</text>} if ($flowgconsTime); # Lage Consumer Restlaufzeit
$ret .= qq{<text class="$stna text" id="consumertxt_${c}_$stna" x="$cons_left" y="$y_pos">$currentPower</text>} if($flowgconsPower); # Lage Consumer Consumption
$ret .= qq{<text class="$stna text" id="consumertxt_time_${c}_$stna" x="$cons_left" y="$y_pos1">$consumerTime</text>} if($flowgconsTime); # Lage Consumer Restlaufzeit
# Verbrauchszahl wieder zurück an den Ursprungspunkt
######################################################
@ -21111,11 +21122,14 @@ to ensure that the system configuration is correct.
<table>
<colgroup> <col width="26%"> <col width="74%"> </colgroup>
<tr><td> <b>animate</b> </td><td> Animates the energy flow graphic if displayed. (<a href="#SolarForecast-attr-graphicSelect">graphicSelect</a>) </td></tr>
<tr><td> </td><td><b>0</b> - Animation off, <b>1</b> - Animation on, default: 0 </td></tr>
<tr><td> </td><td><b>0</b> - Animation off, <b>1</b> - Animation on, default: 1 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>consumerdist</b> </td><td>Controls the distance between the consumer icons in the energy flow graphic. </td></tr>
<tr><td> <b>consumerdist</b> </td><td>Controls the distance between the consumer icons. </td></tr>
<tr><td> </td><td>Value: <b>80 ... 500</b>, default: 130 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>h2consumerdist</b> </td><td>Extension of the vertical distance between the house and the consumer icons. </td></tr>
<tr><td> </td><td>Value: <b>0 ... 999</b>, default: 0 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>shift</b> </td><td>Horizontal shift of the energy flow graph. </td></tr>
<tr><td> </td><td>Value: <b>-80 ... 80</b>, default: 0 </td></tr>
<tr><td> </td><td> </td></tr>
@ -23515,11 +23529,14 @@ die ordnungsgemäße Anlagenkonfiguration geprüft werden.
<table>
<colgroup> <col width="26%"> <col width="74%"> </colgroup>
<tr><td> <b>animate</b> </td><td> Animiert die Energieflußgrafik sofern angezeigt. (<a href="#SolarForecast-attr-graphicSelect">graphicSelect</a>) </td></tr>
<tr><td> </td><td><b>0</b> - Animation aus, <b>1</b> - Animation an, default: 0 </td></tr>
<tr><td> </td><td><b>0</b> - Animation aus, <b>1</b> - Animation an, default: 1 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>consumerdist</b> </td><td>Steuert den Abstand zwischen den Consumer-Icons in der Energieflußgrafik. </td></tr>
<tr><td> <b>consumerdist</b> </td><td>Steuert den Abstand zwischen den Verbraucher-Icons. </td></tr>
<tr><td> </td><td>Wert: <b>80 ... 500</b>, default: 130 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>h2consumerdist</b> </td><td>Erweiterung des vertikalen Abstandes zwischen dem Haus und den Verbraucher-Icons. </td></tr>
<tr><td> </td><td>Wert: <b>0 ... 999</b>, default: 0 </td></tr>
<tr><td> </td><td> </td></tr>
<tr><td> <b>shift</b> </td><td>Horizontale Verschiebung der Energieflußgrafik. </td></tr>
<tr><td> </td><td>Wert: <b>-80 ... 80</b>, default: 0 </td></tr>
<tr><td> </td><td> </td></tr>