diff --git a/FHEM/30_HUEBridge.pm b/FHEM/30_HUEBridge.pm index 4ecb16103..898074a32 100644 --- a/FHEM/30_HUEBridge.pm +++ b/FHEM/30_HUEBridge.pm @@ -114,8 +114,9 @@ HUEBridge_Read($) $code = $name ."-". $id if( $obj->{r} eq 'lights' ); $code = $name ."-S". $id if( $obj->{r} eq 'sensors' ); $code = $name ."-G". $id if( $obj->{r} eq 'groups' ); + $code = $name ."-G". $obj->{gid} if( $obj->{r} eq 'scenes' && $obj->{gid} ); if( !$code ) { - Log3 $name, 5, "$name: ignoring event: $code"; + Log3 $name, 5, "$name: ignoring event: $data"; return; } @@ -134,8 +135,11 @@ HUEBridge_Read($) } } elsif( $obj->{t} eq 'event' && $obj->{e} eq 'scene-called' ) { - Log3 $name, 5, "$name: todo: handle websocket scene-called $data"; - # trigger scene event ? + if( my $chash = $modules{HUEDevice}{defptr}{$code} ) { + #HUEDevice_Parse($chash, $obj); + HUEDevice_Parse($chash, { state => { scene => $obj->{scid} } } ); + #readingsSingleUpdate($hash, 'scene', $obj->{scid}, 1 ); + } } elsif( $obj->{t} eq 'event' && $obj->{e} eq 'added' ) { Log3 $name, 5, "$name: websocket add: $data"; @@ -1957,12 +1961,12 @@ HUEBridge_dispatch($$$;$) } - } elsif( $type =~ m/^lights\/(\d*)$/ ) { + } elsif( $type =~ m/^lights\/(\d+)$/ ) { if( HUEDevice_Parse($param->{chash}, $json) ) { HUEBridge_updateGroups($hash, $param->{chash}{ID}); } - } elsif( $type =~ m/^lights\/(\d*)\/bridgeupdatestate$/ ) { + } elsif( $type =~ m/^lights\/(\d+)\/bridgeupdatestate$/ ) { # only for https://github.com/bwssytems/ha-bridge # see https://forum.fhem.de/index.php/topic,11020.msg961555.html#msg961555 if( $queryAfterSet ) { @@ -1976,13 +1980,13 @@ HUEBridge_dispatch($$$;$) } } - } elsif( $type =~ m/^groups\/(\d*)$/ ) { + } elsif( $type =~ m/^groups\/(\d+)$/ ) { HUEDevice_Parse($param->{chash}, $json); - } elsif( $type =~ m/^sensors\/(\d*)$/ ) { + } elsif( $type =~ m/^sensors\/(\d+)$/ ) { HUEDevice_Parse($param->{chash}, $json); - } elsif( $type =~ m/^lights\/(\d*)\/state$/ ) { + } elsif( $type =~ m/^lights\/(\d+)\/state$/ ) { if( $queryAfterSet ) { my $chash = $param->{chash}; if( $chash->{helper}->{update_timeout} ) { @@ -1994,7 +1998,8 @@ HUEBridge_dispatch($$$;$) } } - } elsif( $type =~ m/^groups\/(\d*)\/action$/ ) { + } elsif( $type =~ m/^groups\/(\d+)\/action$/ + || $type =~ m/^groups\/(\d+)\/scenes\/(\d+)\/recall$/ ) { my $chash = $param->{chash}; if( $chash->{helper}->{update_timeout} ) { RemoveInternalTimer($chash); diff --git a/FHEM/31_HUEDevice.pm b/FHEM/31_HUEDevice.pm index fd44085b4..72404bbfb 100644 --- a/FHEM/31_HUEDevice.pm +++ b/FHEM/31_HUEDevice.pm @@ -1385,7 +1385,6 @@ HUEDevice_Parse($$) $hash->{helper}{json} = $result; if( $hash->{helper}->{devtype} eq 'G' ) { - #if( !defined($attr{$name}{subType}) && $hash->{type} ) { # if( $hash->{type} eq 'Room' ) { # $attr{$name}{subType} = 'room'; @@ -1608,8 +1607,8 @@ HUEDevice_Parse($$) $readings{valve} = ceil((100/255) * $state->{valve}) if( defined ($state->{valve}) ); } - $hash->{lastupdated} = ReadingsVal( $name, '.lastupdated', undef ) if( !$hash->{lastupdated} ); - $hash->{lastupdated_local} = ReadingsVal( $name, '.lastupdated_local', undef ) if( !$hash->{lastupdated_local} ); + $hash->{lastupdated} = ReadingsVal( $name, '.lastupdated', '' ) if( !$hash->{lastupdated} ); + $hash->{lastupdated_local} = ReadingsVal( $name, '.lastupdated_local', '' ) if( !$hash->{lastupdated_local} ); return undef if( $hash->{lastupdated} && $hash->{lastupdated} eq $lastupdated && (!$readings{state} || $readings{state} eq ReadingsVal( $name, 'state', '' )) );