diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm index 98fb98493..1ab2f9f5c 100644 --- a/fhem/FHEM/98_DOIF.pm +++ b/fhem/FHEM/98_DOIF.pm @@ -1364,7 +1364,6 @@ sub collect_setValue } } } - } } } @@ -1372,10 +1371,9 @@ sub collect_setValue $hash->{collect}{"$name $reading"}{$hours}{last_slot}=$slot_nr; } - 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; - } + #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; $hash->{collect}{"$name $reading"}{$hours}{time}=$seconds; @@ -4456,7 +4454,7 @@ sub get_color { sub card { - my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$sizePlot,$model,$lightness) = @_; + my ($collect,$header,$icon,$min,$max,$minColor,$maxColor,$unit,$func,$decfont,$prop,$model,$lightness) = @_; my $val=${$collect}{value}; my $a=@{$collect}{values}; my $last_value=${$collect}{last_value}; @@ -4473,12 +4471,16 @@ sub card my $bheight=88; my $htrans=0; - + $minVal=$val if (!defined $minVal); + $maxVal=$val if (!defined $maxVal); + my $out; my ($ic,$iscale,$ix,$iy,$rotate); - my ($size,$plot); - ($size,$plot)=split (/,/,$sizePlot) if (defined $sizePlot); + my ($size,$plot,$steps); + ($size,$plot,$steps)=split (/,/,$prop) if (defined $prop); + $plot = "" if (!defined $plot); + $steps = "" if (!defined $steps); my ($dec,$fontformat,$unitformat); ($dec,$fontformat,$unitformat)=split (/,/,$decfont) if (defined $decfont); @@ -4537,20 +4539,20 @@ sub card my $nullOpacity; my $minPlot; my $maxPlot; + my $scaling=0; -## if (defined $plot and $plot eq "autoscale" and $minVal ne $maxVal) { - if (!defined $plot and $minVal ne $maxVal) { - $minPlot=($val < $minVal ? $val : $minVal); - $maxPlot=($val > $maxVal ? $val : $maxVal); + if ($plot ne "1" and $minVal ne $maxVal) { + $scaling=1; + $minPlot=($val < $minVal ? $val : $minVal); + $maxPlot=($val > $maxVal ? $val : $maxVal); } else { - $minPlot=($min < 0 and $minVal > 0) ? 0:$min; - $maxPlot=($max > 0 and $maxVal < 0) ? 0:$max; + $minPlot=($min < 0 and $minVal > 0) ? 0:$min; + $maxPlot=($max > 0 and $maxVal < 0) ? 0:$max; } my ($m,$n)=m_n($minPlot,0,$maxPlot,50); - - my $currColor; - ($currColor,$minColor,$maxColor)=get_color($value,$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; @@ -4615,7 +4617,7 @@ sub card } $out.= sprintf('',$htrans); $out.=''; - $out.= ''; + $out.= ''; $out.= ''; my $points=""; my $v; @@ -4647,12 +4649,12 @@ sub card for (my $i=$j;$i<@{$a};$i++) { if (defined ${$a}[$i]) { - $points.="$i,".$last." " if (!defined ${$a}[$i-1]); + $points.="$i,".$last." " if (!defined ${$a}[$i-1] or $steps eq "1"); # or $i-2 >= 0 and !defined ${$a}[$i-2] or $i-3 >= 0 and !defined ${$a}[$i-3] or $i-4 >= 0 and !defined ${$a}[$i-4]); $last=(50-int((${$a}[$i]*$m+$n)*10)/10); $points.="$i,".$last." "; } } - $points.="60,".(50-int(($val*$m+$n)*10)/10)." "; + #$points.="60,".(50-int(($val*$m+$n)*10)/10)." "; $out.=sprintf('',$topValColor,$bottomValColor,(defined $lr ? $lr:0),$topValColor,$bottomValColor,(defined $lr ? $lr:0)); @@ -4663,31 +4665,50 @@ sub card $out.=sprintf('',$y,$y); } - for (my $i=1;$i<=4;$i++) { - my $x=$i*15-0.5; - $out.=sprintf('',$x,$xpos+1.5,$x,$xpos-1.5); - } - $out.= sprintf('',$xpos,$xpos); - - $out.=sprintf('',$maxValSlot,(50-int((${$a}[$maxValSlot]*$m+$n)*10)/10),color($maxValColor,$ln)) if (defined $maxVal and $maxValSlot != 59); - $out.=sprintf(',',$minValSlot,(50-int((${$a}[$minValSlot]*$m+$n)*10)/10),color($minValColor,$ln)) if (defined $minVal and $minValSlot != 59); - $out.=sprintf(' ',(50-int(($val*$m+$n)*10)/10),color($currColor,$ln)); + $out.=sprintf('',$maxValSlot,(50-int((${$a}[$maxValSlot]*$m+$n)*10)/10),color($maxValColor,$ln)) if (defined $maxValSlot and $maxValSlot != 59); + $out.=sprintf(',',$minValSlot,(50-int((${$a}[$minValSlot]*$m+$n)*10)/10),color($minValColor,$ln)) if (defined $minValSlot and $minValSlot != 59); + $out.=sprintf(' ',(50-int(($val*$m+$n)*10)/10),color($currColor,$ln)); for (my $i=0;$i<=4;$i++) { my $value=($maxPlot-$minPlot)*(1-$i*0.25)+$minPlot; my ($color)= get_color($value,$min,$max,$minColor,$maxColor,$func); - $out.= sprintf('%s',$i*12.5+2,color($color,$lmm),"",sprintf($format,$value)); + $out.= sprintf('%s',$i*12.5+2,color($color,$lmm),"",sprintf(($scaling ? $format : "%s"),$value)); } - ## $out.= sprintf('%s',color($maxPlotColor,$lmm),"",$maxPlot); - ## $out.= sprintf('%s',color($minPlotColor,$lmm),"",$minPlot); - ## $out.= sprintf('%s',$xpos+3,color($nullColor,$lmm),"",0) if (defined $nullColor); - for (my $i=0;$i<=4;$i++) { - $out.=sprintf('%s',$i*15-1,::strftime("%H:%M",localtime($time-$hours*3600*(1-$i*0.25)))); + my $timebeginn=$time-$hours*3600; + + my $scale; + if ($hours % 6 == 0) { + $scale=$hours/6; } - # $out.=sprintf('%s',::strftime("%H:",localtime($time-$hours*3600))); - ## $out.=sprintf('%s',::strftime("%H:%M",localtime($time-$hours))); + + if (defined $scale) { + my ($sec,$minutes,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime($timebeginn); + my $beginhour=int($hour/$scale)*$scale; + my $diffminutes=($hour-$beginhour)*60+$minutes; + my $pos=int ($diffminutes/($scale*60)*100)/10; + +# for (my $i=1;$i<=4;$i++) { +# my $x=$i*15-0.5; +# $out.=sprintf('',$x,$xpos+1.5,$x,$xpos-1.5); +# } + $out.=sprintf('%02d',$beginhour) if ($pos == 0); + for (my $i=0;$i<=5;$i++) { + my $hour=$beginhour+($i+1)*$scale; + $hour=($hour >= 24 ? $hour % 24:$hour); + my $x=$i*10-$pos+9.5; + $out.=sprintf('',$x,$xpos+1.5,$x,$xpos-1.5); + $out.=sprintf('%02d',$x,$hour); + } + } else { + for (my $i=0;$i<=3;$i++) { + my $x=($i+1)*20-0.5; + $out.=sprintf('%s',$i*20-1,::strftime("%H:%M",localtime($time-$hours*3600*(1-$i/3)))); + $out.=sprintf('',$x,$xpos+1.5,$x,$xpos-1.5); + } + } + $out.= ''; $out.= ''; @@ -4698,11 +4719,11 @@ sub card $out.=sprintf('%s',::strftime("%H:%M:%S",localtime($time))); - if (defined $maxVal) { + if (defined $maxValTime) { $out.= sprintf('▲%s',::strftime("%H:%M",localtime($maxValTime))); $out.= sprintf('%s',color($maxValColor,$lmm),"",sprintf($format,$maxVal)); } - if (defined $minVal) { + if (defined $minValTime) { $out.= sprintf('• ▼%s',::strftime("%H:%M",localtime($minValTime))); $out.= sprintf('%s',color($minValColor,$lmm),"",sprintf($format,$minVal)); }