From 198435e4c28534e2e244463afca8bf82a56a0e88 Mon Sep 17 00:00:00 2001 From: martinp876 <> Date: Sun, 23 Mar 2014 21:46:39 +0000 Subject: [PATCH] change levelRange off handling git-svn-id: https://svn.fhem.de/fhem/trunk@5308 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_CUL_HM.pm | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/fhem/FHEM/10_CUL_HM.pm b/fhem/FHEM/10_CUL_HM.pm index 1e06e9ecb..b317fe872 100755 --- a/fhem/FHEM/10_CUL_HM.pm +++ b/fhem/FHEM/10_CUL_HM.pm @@ -1358,13 +1358,13 @@ sub CUL_HM_Parse($$) {######################################################### my $vl = ReadingsVal($vh->{NAME},"level","???"); my $vs = ($vl eq "100"?"on":($vl eq "0"?"off":"$vl")); my($clvlMin,$clvlMax)=split",",AttrVal($vh->{NAME}, "levelRange", "0,100"); - my $plc = int(($pl-$clvlMin)/($clvlMax - $clvlMin)*200)/2; + my $plc = int(($pl-$clvlMin)/($clvlMax - $clvlMin)*200+.99)/2; $vs = ($plc ne $vl)?"chn:$vs phys:$plc":$vs; push @evtEt,[$vh,1,"state:$vs"]; push @evtEt,[$vh,1,"phyLevel:$plc"]; } - $pl = int(($pl-$lvlMin)/($lvlMax - $lvlMin)*200)/2; + $pl = int(($pl-$lvlMin)/($lvlMax - $lvlMin)*200+.99)/2; push @evtEt,[$shash,1,"phyLevel:$pl"]; #phys level $physLvl = $pl; } @@ -1374,10 +1374,11 @@ sub CUL_HM_Parse($$) {######################################################### } } } - $val = int((($val-$lvlMin)/($lvlMax - $lvlMin))*200)/2; + my $pVal = $val;# necessary for roper 'off', not logical off + $val = int((($val-$lvlMin)/($lvlMax - $lvlMin))*200+.99)/2; $physLvl = ReadingsVal($name,"phyLevel",$val) if(!defined $physLvl); #not updated? use old or ignore - my $vs = ($val==100 ? "on":($val==0 ? "off":"$val")); # user string... + my $vs = ($val==100 ? "on":($pVal==0 ? "off":"$val")); # user string... push @evtEt,[$shash,1,"level:$val"]; push @evtEt,[$shash,1,"pct:$val"]; # duplicate to level - necessary for "slider" push @evtEt,[$shash,1,"deviceMsg:$vs$target"] if($chn ne "00"); @@ -3164,7 +3165,7 @@ sub CUL_HM_Set($@) {#+++++++++++++++++ set command+++++++++++++++++++++++++++++ $lvl = -1*$lvl if ($cmd eq "down"); $lvl += CUL_HM_getChnLvl($name); } - $lvl = ($lvl > $lvlMax)?$lvlMax:(($lvlMin < 0)?$lvlMin:$lvl); + $lvl = ($lvl > $lvlMax)?$lvlMax:(($lvl <= $lvlMin)?0:$lvl); if ($st eq "dimmer"){# at least blind cannot stand ramp time... if (!$a[3]){ @@ -7260,18 +7261,18 @@ sub CUL_HM_configUpdate($) {# mark entities with changed data Nevertheless - by definition - showInternalValues overrules expert.