2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 05:16:45 +00:00

31_HUEDevice.pm: better handling of pct reading for switches

git-svn-id: https://svn.fhem.de/fhem/trunk@11354 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2016-04-30 23:07:37 +00:00
parent da80a0e859
commit 0ebe3d6919

View File

@ -1111,13 +1111,17 @@ HUEDevice_Parse($$)
$s = 'on';
if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",1);}
if( $bri >= 0 && AttrVal($name, 'subType', 'dimmer') ne 'switch' ) {
if( $bri < 0 || AttrVal($name, 'subType', 'dimmer') eq 'switch' ) {
$percent = 100;
} else {
$percent = int($bri * 99 / 254 + 1);
if( $percent > 0
&& $percent < 100 ) {
$s = $dim_values{int($percent/7)};
}
$s = 'off' if( $percent == 0 );
}
}
else
@ -1128,7 +1132,7 @@ HUEDevice_Parse($$)
if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",0);}
}
if( $percent != -1 && $percent != $hash->{helper}{percent} ) {readingsBulkUpdate($hash,"pct", $percent);}
if( $percent != $hash->{helper}{percent} ) {readingsBulkUpdate($hash,"pct", $percent);}
#if( $percent != $hash->{helper}{percent} ) {readingsBulkUpdate($hash,"level", $percent . ' %');}
$s = 'unreachable' if( !$reachable );