76_SolarForecast: contrib version 1.59.0
git-svn-id: https://svn.fhem.de/fhem/trunk@30358 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -160,6 +160,8 @@ BEGIN {
|
|||||||
|
|
||||||
# Versions History intern
|
# Versions History intern
|
||||||
my %vNotesIntern = (
|
my %vNotesIntern = (
|
||||||
|
"1.59.0" => "06.10.2025 new sub __normIconBoxScale to fix problem with chromium engine > 140.x, Forum: https://forum.fhem.de/index.php?msg=1349058 ",
|
||||||
|
"1.58.8" => "06.10.2025 __batChargeOptTargetPower: minor Code change ",
|
||||||
"1.58.7" => "05.10.2025 fix negative SoC forecast when using optPower Forum: https://forum.fhem.de/index.php?msg=1348954 ",
|
"1.58.7" => "05.10.2025 fix negative SoC forecast when using optPower Forum: https://forum.fhem.de/index.php?msg=1348954 ",
|
||||||
"1.58.6" => "03.10.2025 __batChargeMgmt code changed, new sub ___batChargeSaveResults, remove reading Battery_ChargeRecommended_XX ".
|
"1.58.6" => "03.10.2025 __batChargeMgmt code changed, new sub ___batChargeSaveResults, remove reading Battery_ChargeRecommended_XX ".
|
||||||
"_calcReadingsTomorrowPVFc: bugfix generating readings of tomorrow ".
|
"_calcReadingsTomorrowPVFc: bugfix generating readings of tomorrow ".
|
||||||
@@ -503,7 +505,6 @@ use constant {
|
|||||||
B6FONTCOLDEF => '000000', # default Schriftfarbe Beam 6
|
B6FONTCOLDEF => '000000', # default Schriftfarbe Beam 6
|
||||||
FGCDDEF => 130, # Abstand Verbrauchericons zueinander
|
FGCDDEF => 130, # Abstand Verbrauchericons zueinander
|
||||||
|
|
||||||
FGSCALEDEF => 0.10, # Flußgrafik: Scale Normativ Icons
|
|
||||||
STROKCOLSTDDEF => 'darkorange', # Flußgrafik: Standardfarbe aktive normale Kette
|
STROKCOLSTDDEF => 'darkorange', # Flußgrafik: Standardfarbe aktive normale Kette
|
||||||
STROKCOLSIGDEF => 'red', # Flußgrafik: Standardfarbe aktive Signal-Kette
|
STROKCOLSIGDEF => 'red', # Flußgrafik: Standardfarbe aktive Signal-Kette
|
||||||
STROKCOLINADEF => 'gray', # Flußgrafik: Standardfarbe inaktive Kette
|
STROKCOLINADEF => 'gray', # Flußgrafik: Standardfarbe inaktive Kette
|
||||||
@@ -12083,10 +12084,10 @@ sub __batChargeOptTargetPower {
|
|||||||
my $fref = ___batFindMinPhWh ($hsurp, \@remaining_hods, $runwhneed, $befficiency);
|
my $fref = ___batFindMinPhWh ($hsurp, \@remaining_hods, $runwhneed, $befficiency);
|
||||||
my $needraw = min ($fref->{ph}, $spls); # Ladeleistung auf Surplus begrenzen
|
my $needraw = min ($fref->{ph}, $spls); # Ladeleistung auf Surplus begrenzen
|
||||||
|
|
||||||
$needraw *= 1 + ($otpMargin / 100); # 1. Sicherheitsaufschlag
|
|
||||||
$needraw = $bpinmax if(!$hsurp->{$hod}{$sbn}{lcintime});
|
$needraw = $bpinmax if(!$hsurp->{$hod}{$sbn}{lcintime});
|
||||||
$needraw = sprintf "%.0f", $needraw;
|
|
||||||
$needraw = max ($needraw, $bpinreduced); # Mindestladeleistung bpinreduced sicherstellen
|
$needraw = max ($needraw, $bpinreduced); # Mindestladeleistung bpinreduced sicherstellen
|
||||||
|
$needraw *= 1 + ($otpMargin / 100); # 1. Sicherheitsaufschlag
|
||||||
|
$needraw = sprintf "%.0f", $needraw;
|
||||||
$needraw = min ($needraw, $bpinmax); # Begrenzung auf max. mögliche Batterieleistung
|
$needraw = min ($needraw, $bpinmax); # Begrenzung auf max. mögliche Batterieleistung
|
||||||
|
|
||||||
$hsurp->{$hod}{$sbn}{pneedmin} = $needraw;
|
$hsurp->{$hod}{$sbn}{pneedmin} = $needraw;
|
||||||
@@ -18406,7 +18407,6 @@ sub _flowGraphic {
|
|||||||
my $cselfMetered = CurrentVal ($name, 'selfconsumption', 0);
|
my $cselfMetered = CurrentVal ($name, 'selfconsumption', 0);
|
||||||
my $showgenerators = CurrentVal ($name, 'showGenerators', 0); # Generatoren-Zeile anzeigen
|
my $showgenerators = CurrentVal ($name, 'showGenerators', 0); # Generatoren-Zeile anzeigen
|
||||||
|
|
||||||
my $scale = FGSCALEDEF;
|
|
||||||
my $stna = $name;
|
my $stna = $name;
|
||||||
$stna .= int (rand (1500));
|
$stna .= int (rand (1500));
|
||||||
|
|
||||||
@@ -18726,9 +18726,9 @@ END0
|
|||||||
);
|
);
|
||||||
|
|
||||||
$cicon = FW_makeImage ($cicon, '');
|
$cicon = FW_makeImage ($cicon, '');
|
||||||
($scale, $cicon) = __normIconScale ($name, $cicon);
|
$cicon = __normIconBoxScale ($cicon);
|
||||||
|
|
||||||
$ret .= qq{<g id="consumer_${c}_$stna" transform="translate($cons_left,$y_pos),scale($scale)">};
|
$ret .= qq{<g id="consumer_${c}_$stna" transform="translate($cons_left $y_pos)">};
|
||||||
$ret .= "<title>$calias</title>".$cicon;
|
$ret .= "<title>$calias</title>".$cicon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
|
|
||||||
@@ -18767,10 +18767,9 @@ END1
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hicon = FW_makeImage ($hicon, '');
|
$hicon = FW_makeImage ($hicon, '');
|
||||||
|
$hicon = __normIconBoxScale ($hicon);
|
||||||
|
|
||||||
($scale, $hicon) = __normIconScale ($name, $hicon);
|
$ret .= qq{<g id="home_$stna" transform="translate(368 360)">}; # translate(X-Koordinate,Y-Koordinate)
|
||||||
|
|
||||||
$ret .= qq{<g id="home_$stna" transform="translate(368,360),scale($scale)">}; # translate(X-Koordinate,Y-Koordinate), scale(<Größe>)-> Koordinaten ändern sich bei Größenänderung
|
|
||||||
$ret .= "<title>$hmtxt</title>".$hicon;
|
$ret .= "<title>$hmtxt</title>".$hicon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
|
|
||||||
@@ -18790,9 +18789,9 @@ END1
|
|||||||
|
|
||||||
|
|
||||||
$dicon = FW_makeImage ($dicon, '');
|
$dicon = FW_makeImage ($dicon, '');
|
||||||
($scale, $dicon) = __normIconScale ($name, $dicon);
|
$dicon = __normIconBoxScale ($dicon);
|
||||||
|
|
||||||
$ret .= qq{<g id="dummy_$stna" transform="translate(660,360),scale($scale)">};
|
$ret .= qq{<g id="dummy_$stna" transform="translate(660 360)">};
|
||||||
$ret .= "<title>$dumtxt</title>".$dicon;
|
$ret .= "<title>$dumtxt</title>".$dicon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
}
|
}
|
||||||
@@ -19228,7 +19227,7 @@ sub __addInputProducerIcon {
|
|||||||
my $showgenerators = $paref->{showgenerators};
|
my $showgenerators = $paref->{showgenerators};
|
||||||
|
|
||||||
my $don = NexthoursVal ($hash, 'NextHour00', 'DoN', 0);
|
my $don = NexthoursVal ($hash, 'NextHour00', 'DoN', 0);
|
||||||
my ($scale, $ret);
|
my $ret;
|
||||||
|
|
||||||
for my $st (sort keys %{$psorted}) { # jedes Mitglied @sorted des Gruppenarray ('1togrid', '2tonode', '3tobat') behandeln
|
for my $st (sort keys %{$psorted}) { # jedes Mitglied @sorted des Gruppenarray ('1togrid', '2tonode', '3tobat') behandeln
|
||||||
my $xstart = 0;
|
my $xstart = 0;
|
||||||
@@ -19270,9 +19269,9 @@ sub __addInputProducerIcon {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$genericon = FW_makeImage ($genericon, '');
|
$genericon = FW_makeImage ($genericon, '');
|
||||||
($scale, $genericon) = __normIconScale ($name, $genericon);
|
$genericon = __normIconBoxScale ($genericon);
|
||||||
|
|
||||||
$ret .= qq{<g id="generator_${pn}_$stna" fill="grey" transform="translate($xstart,$ystart),scale($scale)">};
|
$ret .= qq{<g id="generator_${pn}_$stna" fill="grey" transform="translate($xstart $ystart)">};
|
||||||
$ret .= "<title>$genertxt</title>".$genericon;
|
$ret .= "<title>$genertxt</title>".$genericon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
}
|
}
|
||||||
@@ -19289,9 +19288,9 @@ sub __addInputProducerIcon {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$picon = FW_makeImage ($picon, '');
|
$picon = FW_makeImage ($picon, '');
|
||||||
($scale, $picon) = __normIconScale ($name, $picon);
|
$picon = __normIconBoxScale ($picon);
|
||||||
|
|
||||||
$ret .= qq{<g id="producer_${pn}_$stna" fill="grey" transform="translate($xstart,$y_coord),scale($scale)">};
|
$ret .= qq{<g id="producer_${pn}_$stna" fill="grey" transform="translate($xstart $y_coord)">};
|
||||||
$ret .= "<title>$ptxt</title>".$picon;
|
$ret .= "<title>$ptxt</title>".$picon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
|
|
||||||
@@ -19316,8 +19315,6 @@ sub __addNodeIcon {
|
|||||||
my $x_coord = $paref->{x_coord};
|
my $x_coord = $paref->{x_coord};
|
||||||
my $y_coord = $paref->{y_coord};
|
my $y_coord = $paref->{y_coord};
|
||||||
|
|
||||||
my $scale;
|
|
||||||
|
|
||||||
my ($nicon, $ntxt) = __substituteIcon ( { hash => $hash,
|
my ($nicon, $ntxt) = __substituteIcon ( { hash => $hash,
|
||||||
name => $name,
|
name => $name,
|
||||||
ptyp => 'node',
|
ptyp => 'node',
|
||||||
@@ -19327,9 +19324,9 @@ sub __addNodeIcon {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$nicon = FW_makeImage ($nicon, '');
|
$nicon = FW_makeImage ($nicon, '');
|
||||||
($scale, $nicon) = __normIconScale ($name, $nicon);
|
$nicon = __normIconBoxScale ($nicon);
|
||||||
|
|
||||||
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
|
my $ret = qq{<g id="node_$stna" transform="translate($x_coord $y_coord)">}; # translate(X-Koordinate,Y-Koordinate)
|
||||||
$ret .= "<title>$ntxt</title>".$nicon;
|
$ret .= "<title>$ntxt</title>".$nicon;
|
||||||
$ret .= '</g> ';
|
$ret .= '</g> ';
|
||||||
|
|
||||||
@@ -19570,49 +19567,36 @@ return $p;
|
|||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# berechne Icon width, height auf Sollnormativ
|
# liefere skaliertes Icon in einer normierten Viewbox
|
||||||
# width: 470pt
|
|
||||||
# height: 470pt
|
|
||||||
# scale: 0.10 Normativ FGSCALEDEF
|
|
||||||
################################################################
|
################################################################
|
||||||
sub __normIconScale {
|
sub __normIconBoxScale {
|
||||||
my $name = shift;
|
|
||||||
my $icon = shift;
|
my $icon = shift;
|
||||||
my $dim = shift // 470; # Dimension
|
my $size = shift // 72;
|
||||||
|
my $pad = shift // 0;
|
||||||
|
|
||||||
my $hscale = FGSCALEDEF; # Scale Normativ
|
return $icon unless $icon =~ m{<svg\b([^>]*)>(.*?)</svg>}si;
|
||||||
my $wscale = FGSCALEDEF;
|
my ($attr_str, $inner) = ($1, $2); # Extrahiere SVG-Attribute und Innen-Inhalt
|
||||||
my ($width, $wunit) = $icon =~ /width="(\d+\.\d+|\d+)(.*?)"/xs;
|
# - $1 enthält alles zwischen '<svg' und '>'
|
||||||
my ($height, $hunit) = $icon =~ /height="(\d+\.\d+|\d+)(.*?)"/xs;
|
# - $2 enthält den gesamten Inner-HTML-Bereich
|
||||||
|
|
||||||
return ($hscale, $icon) if(!$width || !$height);
|
$attr_str =~ s/\b(?:width|height)\s*=\s*"[^"]*"//gi; # Entferne bestehende Breiten-/Höhen-Attribute
|
||||||
|
|
||||||
$wscale = $hunit eq 'pt' ? $dim * $wscale / $width :
|
my ($x, $y, $w, $h) = (0, 0, 100, 100); # Lese viewBox-Werte oder nutze Default (0,0,100,100)
|
||||||
$hunit eq 'px' ? $dim * $wscale / $width * 0.96 :
|
|
||||||
$hunit eq 'in' ? $dim * $wscale / $width * 0.0138889 :
|
|
||||||
$hunit eq 'mm' ? $dim * $wscale / $width * 0.352778 :
|
|
||||||
$hunit eq 'cm' ? $dim * $wscale / $width * 0.0352778 :
|
|
||||||
$hunit eq 'pc' ? $dim * $wscale / $width * 0.0833333 :
|
|
||||||
$wscale;
|
|
||||||
|
|
||||||
$hscale = $hunit eq 'pt' ? $dim * $hscale / $height :
|
if ($attr_str =~ /\bviewBox\s*=\s*"([\d.\-]+)\s+([\d.\-]+)\s+([\d.\-]+)\s+([\d.\-]+)"/i) {
|
||||||
$hunit eq 'px' ? $dim * $hscale / $height * 0.96 :
|
($x, $y, $w, $h) = ($1, $2, $3, $4);
|
||||||
$hunit eq 'in' ? $dim * $hscale / $height * 0.0138889 :
|
}
|
||||||
$hunit eq 'mm' ? $dim * $hscale / $height * 0.352778 :
|
|
||||||
$hunit eq 'cm' ? $dim * $hscale / $height * 0.0352778 :
|
|
||||||
$hunit eq 'pc' ? $dim * $hscale / $height * 0.0833333 :
|
|
||||||
$hscale;
|
|
||||||
|
|
||||||
$wscale = sprintf "%.2f", $wscale;
|
my $scale = sprintf '%.4f', ( $size / ($w > $h ? $w : $h) ); # Berechne Skalierung und Versatz
|
||||||
$hscale = sprintf "%.2f", $hscale;
|
my $ox = sprintf '%.1f', ( ($size - $w * $scale) / 2 - $x * $scale ); # zentriert den Inhalt in einem Kasten mit Seitenlänge $size
|
||||||
|
my $oy = sprintf '%.1f', ( ($size - $h * $scale) / 2 - $y * $scale );
|
||||||
|
|
||||||
my $widthnormpt = (sprintf "%.0f", ($dim * (1 + $wscale))).'pt'; # Breite auf Normativ in pt skaliert
|
$ox += $pad; # fügt $pad ViewBox-Einheiten Rand links bzw. oben hinzu.
|
||||||
my $heightnormpt = (sprintf "%.0f", ($dim * (1 + $hscale))).'pt'; # Höhe auf Normativ in pt skaliert
|
$oy += $pad;
|
||||||
|
|
||||||
$icon =~ s/width="(.*?)"/width="$widthnormpt"/;
|
my $inner = qq{<g transform="translate($ox $oy) scale($scale)">}.$inner.'</g>'; # gib Inner-Content zurück, umgeben von der Transform-Gruppe
|
||||||
$icon =~ s/height="(.*?)"/height="$heightnormpt"/;
|
|
||||||
|
|
||||||
return (FGSCALEDEF, $icon);
|
return $inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user