diff --git a/FHEM/98_DOIF.pm b/FHEM/98_DOIF.pm
index efafab8c5..d77853b7d 100644
--- a/FHEM/98_DOIF.pm
+++ b/FHEM/98_DOIF.pm
@@ -1343,43 +1343,41 @@ sub collect_setValue
if (defined $hash->{collect}{"$name $reading"}{$hours}{last_slot}) {
$diff_slots=$slot_nr-$hash->{collect}{"$name $reading"}{$hours}{last_slot};
if ($diff_slots > 0) {
+ $hash->{collect}{"$name $reading"}{$hours}{last_value}=undef;
if ($diff_slots >= $dim) {
- my $lastval;
-# my $lasttime;
for (my $i=@{$va}-1;$i>=0;$i--) {
if (defined (${$va}[$i])) {
- $lastval=${$va}[$i];
-# $lasttime=${$ta}[$i];
+ $hash->{collect}{"$name $reading"}{$hours}{last_value}=${$va}[$i];
last;
}
}
@{$va}=();
@{$ta}=();
- if (defined $lastval) {
- ${$va}[0]=$lastval;
-# ${$ta}[0]=$lasttime;
- }
} else {
my @rv=splice (@{$va},0,$diff_slots);
my @rt=splice (@{$ta},0,$diff_slots);
if (!defined (${$va}[0])) {
for (my $i=@rv-1;$i>=0;$i--) {
if (defined ($rv[$i])) {
- ${$va}[0]=$rv[$i];
+ $hash->{collect}{"$name $reading"}{$hours}{last_value}=$rv[$i];
last;
- # ${$ta}[0]=$rt[$i];
}
}
}
+
}
}
}
if ($diff_slots > 0) {
$hash->{collect}{"$name $reading"}{$hours}{last_slot}=$slot_nr;
}
- ${$va}[$dim-1]=$r;
+
+ if ($diff_slots > 0 or $r > 0 and $r > ${$va}[$dim-1] or $r < 0 and $r < ${$va}[$dim-1]) {
+ ${$va}[$dim-1]=$r;
+ ${$ta}[$dim-1]=$seconds;
+ }
+
$hash->{collect}{"$name $reading"}{$hours}{value}=$r;
- ${$ta}[$dim-1]=$seconds;
$hash->{collect}{"$name $reading"}{$hours}{time}=$seconds;
for (my $i=0;$i<@{$va};$i++) {
@@ -1399,8 +1397,8 @@ sub collect_setValue
}
}
}
- $hash->{collect}{"$name $reading"}{$hours}{max_value_plot}=(defined ${$va}[0] and ${$va}[0]>$maxVal) ? ${$va}[0]:$maxVal;
- $hash->{collect}{"$name $reading"}{$hours}{min_value_plot}=(defined ${$va}[0] and ${$va}[0]<$minVal) ? ${$va}[0]:$minVal;
+## $hash->{collect}{"$name $reading"}{$hours}{max_value_plot}=(defined ${$va}[0] and ${$va}[0]>$maxVal) ? ${$va}[0]:$maxVal;
+## $hash->{collect}{"$name $reading"}{$hours}{min_value_plot}=(defined ${$va}[0] and ${$va}[0]<$minVal) ? ${$va}[0]:$minVal;
$hash->{collect}{"$name $reading"}{$hours}{max_value}=$maxVal;
$hash->{collect}{"$name $reading"}{$hours}{max_value_time}=$maxValTime;
@@ -4458,30 +4456,29 @@ sub get_color {
sub card
{
- my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$size,$model,$lightness) = @_;
+ my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$sizePlot,$model,$lightness) = @_;
my $val=${$collect}{value};
my $a=@{$collect}{values};
+ my $last_value=${$collect}{last_value};
my $maxVal = ${$collect}{max_value};
- my $maxValPlot = ${$collect}{max_value_plot};
my $maxValTime = ${$collect}{max_value_time};
my $maxValSlot = ${$collect}{max_value_slot};
+
my $minVal = ${$collect}{min_value};
- my $minValPlot = ${$collect}{min_value_plot};
my $minValTime = ${$collect}{min_value_time};
my $minValSlot = ${$collect}{min_value_slot};
my $hours = ${$collect}{hours};
my $time = ${$collect}{time};
- $maxValPlot=$val if (!defined $maxValPlot);
- $minValPlot=$val if (!defined $minValPlot);
-
my $bwidth=160;
my $bheight=88;
my $htrans=0;
+
my $out;
- ## my $trans=0;
my ($ic,$iscale,$ix,$iy,$rotate);
- ##my $minCol=$minColor;
+
+ my ($size,$plot);
+ ($size,$plot)=split (/,/,$sizePlot) if (defined $sizePlot);
my ($dec,$fontformat,$unitformat);
($dec,$fontformat,$unitformat)=split (/,/,$decfont) if (defined $decfont);
@@ -4498,11 +4495,10 @@ sub card
$unit="" if (!defined $unit);
if (defined $header) {
- $htrans = 28;
- $bheight += 28;
+ $htrans = 24;
+ $bheight += 24;
}
- ##my $height=$bheight;
$min=0 if (!defined $min);
$max=100 if (!defined $max);
@@ -4512,17 +4508,14 @@ sub card
$value=$max if($value>$max);
$value=$min if ($value<$min);
- $size=100 if (!defined $size);
+ $size=130 if (!defined $size or $size eq "");
my ($maxValColor)=get_color($maxVal,$min,$max,$minColor,$maxColor,$func);
my ($minValColor)=get_color($minVal,$min,$max,$minColor,$maxColor,$func);
- my ($maxValPlotColor)=get_color($maxValPlot,$min,$max,$minColor,$maxColor,$func);
- my ($minValPlotColor)=get_color($minValPlot,$min,$max,$minColor,$maxColor,$func);
- my $currColor;
- ($currColor,$minColor,$maxColor)=get_color($value,$min,$max,$minColor,$maxColor,$func);
+
if (defined ($icon)) {
($ic,$iscale,$ix,$iy,$rotate)=split(",",$icon);
@@ -4542,21 +4535,28 @@ sub card
my $bottomVal;
my $bottomOpacity;
my $nullOpacity;
- my $minPlot=($min < 0 and $minValPlot > 0) ? 0:$min;
- my $maxPlot=($max > 0 and $maxValPlot < 0) ? 0:$max;
+ my $minPlot;
+ my $maxPlot;
+
+## if (defined $plot and $plot eq "autoscale" and $minVal ne $maxVal) {
+ if (!defined $plot and $minVal ne $maxVal) {
+ $minPlot=$minVal;
+ $maxPlot=$maxVal;
+ } else {
+ $minPlot=($min < 0 and $minVal > 0) ? 0:$min;
+ $maxPlot=($max > 0 and $maxVal < 0) ? 0:$max;
+ }
- ##my $maxPlot=($maxValPlot < $max/2.1) ? $max/2:$max;
my ($m,$n)=m_n($minPlot,0,$maxPlot,50);
- ($minColor)= get_color($minPlot,$min,$max,$minColor,$maxColor,$func);
- ($maxColor)= get_color($maxPlot,$min,$max,$minColor,$maxColor,$func);
+ my $currColor;
+ ($currColor,$minColor,$maxColor)=get_color($value,$min,$max,$minColor,$maxColor,$func);
if ($minPlot < 0 and $maxPlot > 0) {
$xpos=50-int($n*10)/10;
- $topVal=($maxValPlot > 0 ? $maxValPlot : 0);
- $bottomVal=($minValPlot < 0 ? $minValPlot : 0);
+ $topVal=($maxVal > 0 ? $maxVal : 0);
+ $bottomVal=($minVal < 0 ? $minVal : 0);
($nullColor)=get_color(0,$min,$max,$minColor,$maxColor,$func);
- ##$nullProp=int ($maxValPlot/($maxValPlot-$minValPlot)*10)/10 if ($maxValPlot != $minValPlot);
$nullProp=int ($topVal/($topVal-$bottomVal)*100)/100 if ($bottomVal<0 and $topVal>0);
$topOpacity=($topVal==0 ? 0 : 0.25);
$bottomOpacity=($bottomVal==0 ? 0: 0.25);
@@ -4566,10 +4566,10 @@ sub card
$topVal=$maxPlot;
$topOpacity=0.0;
$bottomOpacity=0.25;
- $bottomVal=$minValPlot;
+ $bottomVal=$minVal;
} else {
$xpos=50;
- $topVal=$maxValPlot;
+ $topVal=$maxVal;
$topOpacity=0.25;
$bottomOpacity=0.0;
$bottomVal=$minPlot;
@@ -4598,67 +4598,105 @@ sub card
$out.= sprintf('',$bwidth-2,$bheight);
if (defined $header) {
- $out.= sprintf('%s',$header_style,$header_txt);
+ $out.= sprintf('%s',$header_style,$header_txt);
if (defined $icon and $icon ne "" and $icon ne " ") {
my $svg_icon=::FW_makeImage($ic);
- if(!($svg_icon =~ s/\sheight="[^"]*"/ height="22"/)) {
- $svg_icon =~ s/svg/svg height="22"/
+ if(!($svg_icon =~ s/\sheight="[^"]*"/ height="20"/)) {
+ $svg_icon =~ s/svg/svg height="20"/
}
- if(!($svg_icon =~ s/\swidth="[^"]*"/ width="22"/)) {
- $svg_icon =~ s/svg/svg width="22"/
+ if(!($svg_icon =~ s/\swidth="[^"]*"/ width="20"/)) {
+ $svg_icon =~ s/svg/svg width="20"/
}
- $out.='';
+ $out.='';
$out.= $svg_icon;
$out.='';
}
- $out.='';
+ $out.='';
}
$out.= sprintf('',$htrans);
$out.='';
$out.= '';
- $out.='';
+ $out.='';
$out.= ui_Table::ring($val,$min,$max,$minColor,$maxColor,$unit,100,$func,$decfont,$model,$lightness,undef,(defined $header or !defined $icon) ? undef: $icon);
$out.='';
+
+ $out.=sprintf('%s',::strftime("%H:%M:%S",localtime($time)));
+
if (defined $maxVal) {
$out.= sprintf('▲%s',::strftime("%H:%M",localtime($maxValTime)));