From 280f508a5235f06f07c97b87ae9f6be48f3f9158 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Tue, 7 Jan 2020 18:46:55 +0000 Subject: [PATCH] 31_HUEDevice.pm: addes scene reading to deCONZ groups git-svn-id: https://svn.fhem.de/fhem/trunk@20906 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/31_HUEDevice.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fhem/FHEM/31_HUEDevice.pm b/fhem/FHEM/31_HUEDevice.pm index 64df30dfa..010e6ca49 100644 --- a/fhem/FHEM/31_HUEDevice.pm +++ b/fhem/FHEM/31_HUEDevice.pm @@ -613,9 +613,10 @@ HUEDevice_SetParam($$@) } elsif( $cmd eq "rgb" && $value =~ m/^(..)(..)(..)/) { my( $r, $g, $b ) = (hex($1)/255.0, hex($2)/255.0, hex($3)/255.0); + my $hash = $defs{$name}; if( $name && ( !AttrVal($name, "model", undef) || AttrVal($name, "model", undef) eq 'LLC020' - || ($hash->{IODev} && $hash->{IODev}{TYPE} eq 'tradfri' ) ) ) { + || ($hash && $hash->{IODev} && $hash->{IODev}{TYPE} eq 'tradfri' ) ) ) { my( $h, $s, $v ) = Color::rgb2hsv($r,$g,$b); $obj->{'on'} = JSON::true; @@ -1338,8 +1339,6 @@ HUEDevice_Parse($$) $hash->{class} = $result->{class} if( defined($result->{class}) ); $hash->{uniqueid} = $result->{uniqueid} if( defined($result->{uniqueid}) ); - $hash->{helper}{scenes} = $result->{scenes} if( defined($result->{scenes}) ); - $hash->{helper}{json} = $result; if( $hash->{helper}->{devtype} eq 'G' ) { @@ -1353,6 +1352,8 @@ HUEDevice_Parse($$) # } #} + $hash->{helper}{scenes} = $result->{scenes} if( defined($result->{scenes}) ); + if( $result->{lights} ) { $hash->{helper}{lights} = {map {$_=>1} @{$result->{lights}}}; $hash->{lights} = join( ",", sort { $a <=> $b } @{$result->{lights}} ); @@ -1386,6 +1387,18 @@ HUEDevice_Parse($$) $readings{reachable} = $state->{reachable}?1:0 if( defined($state->{reachable}) ); + $readings{scene} = $state->{scene}; + if( defined($readings{scene}) ) { + if( my $scenes = $hash->{helper}{scenes} ) { + for my $scene (@{$scenes}) { + if( $readings{scene} == $scene->{id} ) { + $readings{scene} = $scene->{name}; + last; + } + } + } + } + my $s = ''; my $pct = -1; my $on = $state->{on}; $readings{on} = $hash->{helper}{onoff} if( !defined($on) );