From e8a50810965d5f8f46e2ec4870e78af54d3bd1e3 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Wed, 19 Jan 2022 08:19:33 +0000 Subject: [PATCH] 31_HUEDevice.pm: clear dynamics_status on power off git-svn-id: https://svn.fhem.de/fhem/trunk@25505 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/31_HUEDevice.pm | 42 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index 4a15294d4..8caf1bfbc 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -1952,31 +1952,33 @@ HUEDevice_Parse($$) if( defined($state->{'pct'}) ) { $pct = $state->{'pct'}; $s = $pct; - } elsif( $on ) - { - $s = 'on'; - if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",1);} - if( $bri < 0 || AttrVal($name, 'subType', 'dimmer') eq 'switch' ) { - $pct = 100; + } elsif( $on ) { + $s = 'on'; + if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",1);} - } else { - $pct = int($bri * 99 / 254 + 1); - if( $pct > 0 - && $pct < 100 ) { - $s = $dim_values{int($pct/7)}; - } - $s = 'off' if( $pct == 0 ); + if( $bri < 0 || AttrVal($name, 'subType', 'dimmer') eq 'switch' ) { + $pct = 100; + + } else { + $pct = int($bri * 99 / 254 + 1); + if( $pct > 0 + && $pct < 100 ) { + $s = $dim_values{int($pct/7)}; } + + $s = 'off' if( $pct == 0 ); + } - else - { - $on = 0; - $s = 'off'; - $pct = 0; - if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",0);} - } + } else { + $on = 0; + $s = 'off'; + $pct = 0; + if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",0);} + } + + $readings{dynamics_status} = 'none' if( !$on && defined($hash->{helper}{dynamics_status}) && !defined($readings{dynamics_status}) ); if( $pct != $hash->{helper}{pct} ) {readingsBulkUpdate($hash,"pct", $pct);} #if( $pct != $hash->{helper}{pct} ) {readingsBulkUpdate($hash,"level", $pct . ' %');}