mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-08 05:15:10 +00:00
added disable to bridge
git-svn-id: https://svn.fhem.de/fhem/trunk@4958 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
cddd8feac1
commit
c4ed3799ed
@ -31,7 +31,7 @@ sub HUEBridge_Initialize($)
|
||||
$hash->{SetFn} = "HUEBridge_Set";
|
||||
$hash->{GetFn} = "HUEBridge_Get";
|
||||
$hash->{UndefFn} = "HUEBridge_Undefine";
|
||||
$hash->{AttrList}= "key";
|
||||
$hash->{AttrList}= "key disable:1";
|
||||
}
|
||||
|
||||
sub
|
||||
@ -92,7 +92,7 @@ HUEBridge_Define($$)
|
||||
}
|
||||
|
||||
if( $init_done ) {
|
||||
HUEBridge_OpenDev( $hash );
|
||||
HUEBridge_OpenDev( $hash ) if( !AttrVal($name, "disable", 0) );
|
||||
}
|
||||
|
||||
return undef;
|
||||
@ -107,7 +107,7 @@ HUEBridge_Notify($$)
|
||||
return if($dev->{NAME} ne "global");
|
||||
return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
|
||||
|
||||
return if($attr{$name} && $attr{$name}{disable});
|
||||
return undef if( AttrVal($name, "disable", 0) );
|
||||
|
||||
HUEBridge_OpenDev($hash);
|
||||
|
||||
@ -390,6 +390,9 @@ sub HUEBridge_HTTP_Call($$$)
|
||||
my ($hash,$path,$obj) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
return undef if($attr{$name} && $attr{$name}{disable});
|
||||
#return { state => {reachable => 0 } } if($attr{$name} && $attr{$name}{disable});
|
||||
|
||||
my $uri = "http://" . $hash->{Host} . "/api";
|
||||
my $method = 'GET';
|
||||
if( defined($obj) ) {
|
||||
|
@ -613,9 +613,11 @@ HUEDevice_GetUpdate($)
|
||||
|
||||
my $result = HUEDevice_ReadFromServer($hash,$hash->{ID});
|
||||
if( !defined($result) ) {
|
||||
$hash->{helper}{reachable} = 0;
|
||||
$hash->{STATE} = "unknown";
|
||||
return;
|
||||
} elsif( $result->{'error'} ) {
|
||||
$hash->{helper}{reachable} = 0;
|
||||
$hash->{STATE} = $result->{'error'}->{'description'};
|
||||
return;
|
||||
}
|
||||
@ -690,7 +692,7 @@ HUEDevice_GetUpdate($)
|
||||
{
|
||||
$s = 'off';
|
||||
$percent = 0;
|
||||
if( $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",0);}
|
||||
if( $on && $on != $hash->{helper}{on} ) {readingsBulkUpdate($hash,"onoff",0);}
|
||||
}
|
||||
|
||||
if( $percent != $hash->{helper}{percent} ) {readingsBulkUpdate($hash,"level", $percent . ' %');}
|
||||
@ -698,11 +700,6 @@ HUEDevice_GetUpdate($)
|
||||
|
||||
$s = 'off' if( !$reachable );
|
||||
|
||||
if( $s ne $hash->{STATE} ) {readingsBulkUpdate($hash,"state",$s);}
|
||||
readingsEndUpdate($hash,defined($hash->{LOCAL} ? 0 : 1));
|
||||
|
||||
CommandTrigger( "", "$name RGB: ".CommandGet("","$name rgb") );
|
||||
|
||||
$hash->{helper}{on} = $on;
|
||||
$hash->{helper}{reachable} = $reachable;
|
||||
$hash->{helper}{colormode} = $colormode;
|
||||
@ -715,6 +712,12 @@ HUEDevice_GetUpdate($)
|
||||
$hash->{helper}{effect} = $effect;
|
||||
|
||||
$hash->{helper}{percent} = $percent;
|
||||
|
||||
if( $s ne $hash->{STATE} ) {readingsBulkUpdate($hash,"state",$s);}
|
||||
readingsEndUpdate($hash,defined($hash->{LOCAL} ? 0 : 1));
|
||||
|
||||
CommandTrigger( "", "$name RGB: ".CommandGet("","$name rgb") );
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user