From cb362fbc7c8b8fe55984a0cef248232453ada335 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Sun, 9 Jan 2022 15:42:33 +0000 Subject: [PATCH] 31_HUEDevice.pm: create .associatedWith git-svn-id: https://svn.fhem.de/fhem/trunk@25444 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/31_HUEDevice.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index f014a7e4c..28e019825 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -504,7 +504,7 @@ sub HUEDevice_Undefine($$) RemoveInternalTimer($hash); my $code = $hash->{ID}; - $code = $hash->{IODev}->{NAME} ."-". $code if( defined($hash->{IODev}) ); + $code = $hash->{IODev}->{NAME} ."-". $code if( defined($hash->{IODev}) ); delete($modules{HUEDevice}{defptr}{$code}); @@ -1491,10 +1491,25 @@ HUEDevice_Parse($$) if( $result->{lights} ) { $hash->{helper}{lights} = {map {$_=>1} @{$result->{lights}}}; - $hash->{lights} = join( ",", sort { $a <=> $b } @{$result->{lights}} ); + my $lights = join( ",", sort { $a <=> $b } @{$result->{lights}} ); + if( $lights ne $hash->{lights} ) { + $hash->{lights} = $lights; + + my $lights = join (' ', map( { my $code = $_; + $code = $hash->{IODev}->{NAME} ."-". $code if( defined($hash->{IODev}) ); + $modules{HUEDevice}{defptr}{$code}{NAME} } @{$result->{lights}}) ); + #readingsSingleUpdate($hash,"rgb", $rgb,1); + setReadingsVal( $hash, ".associatedWith", $lights, TimeNow() ); + } + + } elsif( defined($result->{lights}) ) { + $hash->{lights} = ''; + $hash->{helper}{lights} = {}; + CommandDeleteReading( undef, "$name .associatedWith" ); + } else { - #$hash->{helper}{lights} = {}; #$hash->{lights} = ''; + #$hash->{helper}{lights} = {}; } if( ref($result->{state}) eq 'HASH' ) {