mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
76_SolarForecast: contrib 1.37.2
git-svn-id: https://svn.fhem.de/fhem/trunk@29287 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3e419d9e14
commit
2e8d960718
@ -156,6 +156,7 @@ BEGIN {
|
||||
|
||||
# Versions History intern
|
||||
my %vNotesIntern = (
|
||||
"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 ".
|
||||
"_flowGraphic: eliminate numbers in device name - Forum: https://forum.fhem.de/index.php?msg=1323229 ",
|
||||
@ -6394,7 +6395,8 @@ sub Delete {
|
||||
$csmcache.$name,
|
||||
$scpicache.$name,
|
||||
$airaw.$name,
|
||||
$aitrained.$name
|
||||
$aitrained.$name,
|
||||
$pvhexprtcsv.$name
|
||||
);
|
||||
|
||||
opendir (DIR, $cachedir);
|
||||
@ -6414,6 +6416,9 @@ sub Delete {
|
||||
if ($err) {
|
||||
Log3 ($name, 1, qq{$name - Message while deleting file "$f": $err});
|
||||
}
|
||||
else {
|
||||
Log3 ($name, 3, qq{$name - INFO - File "$f" successfully deleted.});
|
||||
}
|
||||
}
|
||||
|
||||
my $type = $hash->{TYPE};
|
||||
@ -14284,6 +14289,9 @@ sub _flowGraphic {
|
||||
'3tobat' => { xicon => 750, xchain => 1100, ychain => 430, step => 40, count => scalar @{$tobat}, sorted => $tobat }, # Producer/PV nur zu Batterie
|
||||
};
|
||||
|
||||
my $doproducerrow = 1;
|
||||
$doproducerrow = 0 if(!$psorted->{'1togrid'}{count} && !$psorted->{'3tobat'}{count} && $psorted->{'2tonode'}{count} == 1);
|
||||
|
||||
## definierte Verbraucher ermitteln
|
||||
#####################################
|
||||
my $cnsmr = {}; # Hashref Consumer current power
|
||||
@ -14352,13 +14360,13 @@ sub _flowGraphic {
|
||||
#########################################
|
||||
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 = -25;
|
||||
my $vbminy = $doproducerrow ? -25 : 125; # Grafik höher positionieren wenn keine Poducerreihe angezeigt
|
||||
|
||||
my $vbhight = !$flowgcons ? 380 :
|
||||
!$flowgconsTime ? 590 :
|
||||
610;
|
||||
|
||||
$vbhight += 100;
|
||||
if ($doproducerrow) {$vbhight += 100}; # Höhe Box vergrößern wenn Poducerreihe angezeigt
|
||||
|
||||
my $vbox = "$vbminx $vbminy $vbwidth $vbhight";
|
||||
my $svgstyle = 'width:98%; height:'.$flowgsize.'px;';
|
||||
@ -14398,61 +14406,32 @@ END0
|
||||
|
||||
## Producer Icon - in Reihenfolge: zum Grid - zum Knoten - zur Batterie
|
||||
#########################################################################
|
||||
for my $st (sort keys %{$psorted}) {
|
||||
my $left = 0;
|
||||
my $xicon = $psorted->{$st}{xicon};
|
||||
my $count = $psorted->{$st}{count};
|
||||
my @sorted = @{$psorted->{$st}{sorted}};
|
||||
$paref->{stna} = $stna;
|
||||
$paref->{pnodesum} = $pnodesum;
|
||||
$paref->{psorted} = $psorted;
|
||||
$paref->{pdcr} = $pdcr;
|
||||
$paref->{pdist} = $pdist;
|
||||
|
||||
if ($count % 2) {
|
||||
$xicon = $xicon - ($pdist * ($count - 1) / 2);
|
||||
if (!$doproducerrow) {
|
||||
$paref->{y_coord} = 165;
|
||||
$ret .= __addProducerIcon ($paref); # Producer Icons row einfügen
|
||||
}
|
||||
else {
|
||||
$xicon = $xicon - ($pdist / 2 * ($count - 1));
|
||||
else { # mehr als ein Producer vorhanden
|
||||
$paref->{y_coord} = 0;
|
||||
$ret .= __addProducerIcon ($paref); # Producer Icons row einfügen
|
||||
|
||||
$paref->{x_coord} = 360;
|
||||
$paref->{y_coord} = 165;
|
||||
$ret .= __addNodeIcon ($paref); # Knoten Icon
|
||||
}
|
||||
|
||||
$psorted->{$st}{start} = $xicon;
|
||||
$left = $xicon + 5;
|
||||
|
||||
for my $lfn (@sorted) {
|
||||
my $pn = $pdcr->{$lfn}{pn};
|
||||
my ($picon, $ptxt) = __substituteIcon ( { hash => $hash, # Icon des Producerdevices
|
||||
name => $name,
|
||||
pn => $pn,
|
||||
ptyp => $pdcr->{$lfn}{ptyp},
|
||||
don => NexthoursVal ($hash, 'NextHour00', 'DoN', 0), # Tag oder Nacht
|
||||
pcurr => $pdcr->{$lfn}{p},
|
||||
lang => $lang
|
||||
}
|
||||
);
|
||||
|
||||
$picon = FW_makeImage ($picon, '');
|
||||
($scale, $picon) = __normIconScale ($picon, $name);
|
||||
|
||||
$ret .= qq{<g id="producer_${pn}_$stna" fill="grey" transform="translate($left,0),scale($scale)">};
|
||||
$ret .= "<title>$ptxt</title>".$picon;
|
||||
$ret .= '</g> ';
|
||||
|
||||
$left += $pdist;
|
||||
}
|
||||
}
|
||||
|
||||
## Knoten Icon
|
||||
################
|
||||
my ($nicon, $ntxt) = __substituteIcon ( { hash => $hash,
|
||||
name => $name,
|
||||
ptyp => 'node',
|
||||
pcurr => $pnodesum,
|
||||
lang => $lang
|
||||
}
|
||||
);
|
||||
|
||||
$nicon = FW_makeImage ($nicon, '');
|
||||
($scale, $nicon) = __normIconScale ($nicon, $name);
|
||||
|
||||
$ret .= qq{<g id="node_$stna" transform="translate(360,165),scale($scale)">}; # translate(X-Koordinate,Y-Koordinate), scale(<Größe>)-> Koordinaten ändern sich bei Größenänderung
|
||||
$ret .= "<title>$ntxt</title>".$nicon;
|
||||
$ret .= '</g> ';
|
||||
delete $paref->{stna};
|
||||
delete $paref->{pnodesum};
|
||||
delete $paref->{psorted};
|
||||
delete $paref->{pdcr};
|
||||
delete $paref->{pdist};
|
||||
delete $paref->{x_coord};
|
||||
delete $paref->{y_coord};
|
||||
|
||||
## Consumer Liste und Icons in Grafik anzeigen
|
||||
################################################
|
||||
@ -14574,7 +14553,9 @@ END3
|
||||
}
|
||||
|
||||
## Producer Laufketten - in Reihenfolge: zum Grid - zum Knoten - zur Batterie
|
||||
## Laufkette nur anzeigen wenn Producerzeile angezeigt werden soll
|
||||
###############################################################################
|
||||
if ($doproducerrow) {
|
||||
for my $st (sort keys %{$psorted}) {
|
||||
my $left = $psorted->{$st}{start} * 2; # Übertrag aus Producer Icon Abschnitt
|
||||
my $count = $psorted->{$st}{count};
|
||||
@ -14607,6 +14588,7 @@ END3
|
||||
$xchain += $step;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## Consumer Laufketten
|
||||
########################
|
||||
@ -14662,7 +14644,9 @@ END3
|
||||
$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
|
||||
|
||||
## Textangabe Producer - in Reihenfolge: zum Grid - zum Knoten - zur Batterie
|
||||
## Textangabe nur anzeigen wenn Producerzeile angezeigt werden soll
|
||||
###############################################################################
|
||||
if ($doproducerrow) {
|
||||
for my $st (sort keys %{$psorted}) {
|
||||
my $left = $psorted->{$st}{start} * 2 - 70; # Übertrag aus Producer Icon Abschnitt, -XX -> Start Lage Producer Beschriftung
|
||||
my @sorted = @{$psorted->{$st}{sorted}};
|
||||
@ -14693,6 +14677,7 @@ END3
|
||||
$left += ($pdist * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
## Textangabe Consumer
|
||||
########################
|
||||
@ -14779,6 +14764,97 @@ sub __sortProducer {
|
||||
return (\@togrid, \@tonode, \@tobat);
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Producer Icon einfügen
|
||||
################################################################
|
||||
sub __addProducerIcon {
|
||||
my $paref = shift;
|
||||
my $hash = $paref->{hash};
|
||||
my $name = $paref->{name};
|
||||
my $lang = $paref->{lang};
|
||||
my $stna = $paref->{stna};
|
||||
my $psorted = $paref->{psorted};
|
||||
my $pdcr = $paref->{pdcr};
|
||||
my $pdist = $paref->{pdist};
|
||||
my $y_coord = $paref->{y_coord};
|
||||
|
||||
my ($scale, $ret);
|
||||
|
||||
for my $st (sort keys %{$psorted}) {
|
||||
my $left = 0;
|
||||
my $xicon = $psorted->{$st}{xicon};
|
||||
my $count = $psorted->{$st}{count};
|
||||
my @sorted = @{$psorted->{$st}{sorted}};
|
||||
|
||||
if ($count % 2) {
|
||||
$xicon = $xicon - ($pdist * ($count - 1) / 2);
|
||||
}
|
||||
else {
|
||||
$xicon = $xicon - ($pdist / 2 * ($count - 1));
|
||||
}
|
||||
|
||||
$psorted->{$st}{start} = $xicon;
|
||||
$left = $xicon + 5;
|
||||
|
||||
for my $lfn (@sorted) {
|
||||
my $pn = $pdcr->{$lfn}{pn};
|
||||
my ($picon, $ptxt) = __substituteIcon ( { hash => $hash, # Icon des Producerdevices
|
||||
name => $name,
|
||||
pn => $pn,
|
||||
ptyp => $pdcr->{$lfn}{ptyp},
|
||||
don => NexthoursVal ($hash, 'NextHour00', 'DoN', 0), # Tag oder Nacht
|
||||
pcurr => $pdcr->{$lfn}{p},
|
||||
lang => $lang
|
||||
}
|
||||
);
|
||||
|
||||
$picon = FW_makeImage ($picon, '');
|
||||
($scale, $picon) = __normIconScale ($picon, $name);
|
||||
|
||||
$ret .= qq{<g id="producer_${pn}_$stna" fill="grey" transform="translate($left,$y_coord),scale($scale)">};
|
||||
$ret .= "<title>$ptxt</title>".$picon;
|
||||
$ret .= '</g> ';
|
||||
|
||||
$left += $pdist;
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Knoten Icon einfügen
|
||||
################################################################
|
||||
sub __addNodeIcon {
|
||||
my $paref = shift;
|
||||
my $hash = $paref->{hash};
|
||||
my $name = $paref->{name};
|
||||
my $lang = $paref->{lang};
|
||||
my $stna = $paref->{stna};
|
||||
my $pnodesum = $paref->{pnodesum};
|
||||
my $x_coord = $paref->{x_coord};
|
||||
my $y_coord = $paref->{y_coord};
|
||||
|
||||
my $scale;
|
||||
|
||||
my ($nicon, $ntxt) = __substituteIcon ( { hash => $hash,
|
||||
name => $name,
|
||||
ptyp => 'node',
|
||||
pcurr => $pnodesum,
|
||||
lang => $lang
|
||||
}
|
||||
);
|
||||
|
||||
$nicon = FW_makeImage ($nicon, '');
|
||||
($scale, $nicon) = __normIconScale ($nicon, $name);
|
||||
|
||||
my $ret = qq{<g id="node_$stna" transform="translate($x_coord,$y_coord),scale($scale)">}; # translate(X-Koordinate,Y-Koordinate), scale(<Größe>)-> Koordinaten ändern sich bei Größenänderung
|
||||
$ret .= "<title>$ntxt</title>".$nicon;
|
||||
$ret .= '</g> ';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
################################################################
|
||||
# prüfe ob Icon + Farbe angegeben ist
|
||||
# und setze ggf. Ersatzwerte
|
||||
|
Loading…
Reference in New Issue
Block a user