2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

30_HUEBridge.pm,31_HUEDevice.pm: preparation to parse bridge answert to PUT instead of polling

git-svn-id: https://svn.fhem.de/fhem/trunk@9378 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2015-10-04 20:23:21 +00:00
parent e76b6c6afa
commit da6ccee1a9
2 changed files with 38 additions and 13 deletions

View File

@ -578,8 +578,33 @@ sub HUEBridge_ProcessResponse($$)
my $error = $obj->[0]->{error}->{'description'}; my $error = $obj->[0]->{error}->{'description'};
$hash->{STATE} = $error; $hash->{STATE} = $error;
}
Log3 $name, 3, $error; if( 0 ) {
my %json = ();
foreach my $item (@{$obj}) {
if( my $success = $item->{success} ) {
foreach my $key ( keys %{$success} ) {
my @l = split( '/', $key );
if( $l[1] eq 'lights' && $l[3] eq 'state' ) {
$json{$l[2]}->{state}->{$l[4]} = $success->{$key};
}
}
} elsif( my $error = $item->{error} ) {
my $msg = $error->{'description'};
Log3 $name, 3, $msg;
}
}
#Log 3, Dumper \%json;
foreach my $id ( keys %json ) {
my $code = $name ."-". $id;
if( my $chash = $modules{HUEDevice}{defptr}{$code} ) {
$json{$id}->{state}->{reachable} = 1;
HUEDevice_Parse( $chash, $json{$id} );
}
}
} }
return ($obj->[0]); return ($obj->[0]);

View File

@ -984,16 +984,16 @@ HUEDevice_Parse($$)
$s = 'unreachable' if( !$reachable ); $s = 'unreachable' if( !$reachable );
$hash->{helper}{on} = $on; $hash->{helper}{on} = $on if( defined($on) );
$hash->{helper}{reachable} = $reachable; $hash->{helper}{reachable} = $reachable if( defined($reachable) );
$hash->{helper}{colormode} = $colormode; $hash->{helper}{colormode} = $colormode if( defined($colormode) );
$hash->{helper}{bri} = $bri; $hash->{helper}{bri} = $bri if( defined($bri) );
$hash->{helper}{ct} = $ct; $hash->{helper}{ct} = $ct if( defined($ct) );
$hash->{helper}{hue} = $hue; $hash->{helper}{hue} = $hue if( defined($hue) );
$hash->{helper}{sat} = $sat; $hash->{helper}{sat} = $sat if( defined($sat) );
$hash->{helper}{xy} = $xy; $hash->{helper}{xy} = $xy if( defined($xy) );
$hash->{helper}{alert} = $alert; $hash->{helper}{alert} = $alert if( defined($alert) );
$hash->{helper}{effect} = $effect; $hash->{helper}{effect} = $effect if( defined($effect) );
$hash->{helper}{percent} = $percent; $hash->{helper}{percent} = $percent;