From 080b457e173177c7fe2f20117a5b19f98f05da77 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Mon, 6 Jan 2020 20:14:39 +0000 Subject: [PATCH] 31_HUEDevice.pm: added mode reading git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20900 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/31_HUEDevice.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/FHEM/31_HUEDevice.pm b/FHEM/31_HUEDevice.pm index dad9062eb..c12919e95 100644 --- a/FHEM/31_HUEDevice.pm +++ b/FHEM/31_HUEDevice.pm @@ -207,7 +207,7 @@ HUEDevice_devStateIcon($) my $name = $hash->{NAME}; return ".*:light_question:toggle" if( !$hash->{helper}{reachable} ); - return ".*:light_question:toggle" if( defined($hash->{mode}) && $hash->{mode} ne 'homeautomation' ); + return ".*:light_question:toggle" if( ReadingsVal($name, 'mode', 'homeautomation') ne 'homeautomation' ); my $pct = ReadingsVal($name, 'pct', 100); my $subtype = AttrVal($name, 'subType', 'extcolordimmer' ); @@ -395,6 +395,8 @@ sub HUEDevice_Define($$) $hash->{helper}{battery} = -1; + $hash->{helper}{mode} = ''; + $attr{$name}{devStateIcon} = '{(HUEDevice_devStateIcon($name),"toggle")}' if( !defined( $attr{$name}{devStateIcon} ) ); my $icon_path = AttrVal("WEB", "iconPath", "default:fhemSVG:openautomation" ); @@ -1683,10 +1685,8 @@ HUEDevice_Parse($$) my $battery = undef; $battery = $config->{battery} if( defined($config->{battery}) ); - if( defined($hash->{mode}) - || ( defined($state->{mode}) && $state->{mode} ne 'homeautomation' ) ) { - $hash->{mode} = $state->{mode}; - } + my $mode = undef; + $mode = $state->{mode} if( $hash->{helper}{mode} || defined($state->{mode} && $state->{mode} ne 'homeautomation') ); if( defined($colormode) && $colormode ne $hash->{helper}{colormode} ) {readingsBulkUpdate($hash,"colormode",$colormode);} if( defined($bri) && $bri != $hash->{helper}{bri} ) {readingsBulkUpdate($hash,"bri",$bri);} @@ -1709,6 +1709,8 @@ HUEDevice_Parse($$) if( defined($battery) && $battery ne $hash->{helper}{battery} ) {readingsBulkUpdate($hash,"battery",$battery);} + if( defined($mode) && $mode ne $hash->{helper}{mode} ) {readingsBulkUpdate($hash,"mode",$mode);} + my $s = ''; my $pct = -1; if( defined($state->{'pct'}) ) { @@ -1760,6 +1762,8 @@ HUEDevice_Parse($$) $hash->{helper}{battery} = $battery if( defined($battery) ); + $hash->{helper}{mode} = $mode if( defined($mode) ); + $hash->{helper}{pct} = $pct; my $changed = $hash->{CHANGED}?1:0;