From efef531fec65f28ac446713ce712ec28de384349 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 8 Apr 2024 09:45:00 +0000 Subject: [PATCH] 98_SVG.pm: evaluate fixedrange if enclosed in {} (Forum #137800) git-svn-id: https://svn.fhem.de/fhem/trunk@28771 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_SVG.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fhem/FHEM/98_SVG.pm b/fhem/FHEM/98_SVG.pm index 41919df19..0cfa09778 100644 --- a/fhem/FHEM/98_SVG.pm +++ b/fhem/FHEM/98_SVG.pm @@ -960,12 +960,13 @@ SVG_calcOffsets($$) my $frx; #fixedrange with offset if($defs{$wl}) { $fr = AttrVal($wl, "fixedrange", undef); + $fr = AnalyzePerlCommand(undef,$1) if($fr && $fr =~ m/^{(.*)}$/); #137800 if($fr) { if($fr =~ "^(hour|qday|day|week|month|year)" || - $fr =~ m/^\d+hour/ || #fixedrange with offset + $fr =~ m/^\d+hour/ || $fr =~ m/^\d+day/ || $fr =~ m/^\d+year/ ) { - $frx=$fr; #fixedrange with offset + $frx = $fr; } else { my @range = split(" ", $fr); @@ -996,8 +997,11 @@ SVG_calcOffsets($$) $zoom = "day" if(!$zoom); $zoom = $fr if(defined($fr)); $zoom = $frx if ($frx); #fixedrange with offset - my @zrange = split(" ", $zoom); #fixedrange with offset - if(defined($zrange[1])) { $off += $zrange[1]; $zoom=$zrange[0]; } #fixedrange with offset + my @zrange = split(" ", $zoom); + if(defined($zrange[1])) { + $off += $zrange[1]; + $zoom=$zrange[0]; + } my $endPlotNow = (SVG_Attr($FW_wname, $wl, "endPlotNow", undef) && !$st); if($zoom =~ m/^(\d+)?hour/) { @@ -2664,8 +2668,10 @@ plotAsPng(@) If given, the optional integer parameter offset refers to a different period (e.g. last year: fixedrange year -1, 2 days ago: fixedrange day - -2). + -2).
+ If the attribute value is enclosed in {}, then it is evaluated first as + a perl expression.
@@ -2962,8 +2968,10 @@ plotAsPng(@) die anderen mit einem Zoom über eine Woche. Der optionale ganzzahlige Parameter [offset] setzt ein anderes Zeitintervall (z.B. letztes Jahr: fixedrange year -1, vorgestern: - fixedrange day -2). + fixedrange day -2).
+ Falls der Attributwert in {} eingeschlossen ist, dann wird er vor der + weiteren Verarbeitung als Perl-Ausdruck ausgewertet.