mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
30_HUEBridge.pm: added pollDevices 2
31_HUEDevice.pm: allow optional polling intervall for groups git-svn-id: https://svn.fhem.de/fhem/trunk@12864 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b6bce5dbd4
commit
37b4c925b8
@ -40,7 +40,7 @@ sub HUEBridge_Initialize($)
|
||||
$hash->{GetFn} = "HUEBridge_Get";
|
||||
$hash->{AttrFn} = "HUEBridge_Attr";
|
||||
$hash->{UndefFn} = "HUEBridge_Undefine";
|
||||
$hash->{AttrList} = "key disable:1 disabledForIntervals httpUtils:1,0 noshutdown:1,0 pollDevices:1,0 queryAfterSet:1,0 $readingFnAttributes";
|
||||
$hash->{AttrList} = "key disable:1 disabledForIntervals httpUtils:1,0 noshutdown:1,0 pollDevices:1,2,0 queryAfterSet:1,0 $readingFnAttributes";
|
||||
}
|
||||
|
||||
sub
|
||||
@ -775,9 +775,10 @@ HUEBridge_GetUpdate($)
|
||||
|
||||
my $type;
|
||||
my $result;
|
||||
if( AttrVal($name,"pollDevices",1) ) {
|
||||
my $poll_devices = AttrVal($name, "pollDevices", 1);
|
||||
if( $poll_devices ) {
|
||||
my ($now) = gettimeofday();
|
||||
if( $hash->{LOCAL} || $now - $hash->{helper}{last_config_timestamp} > 300 ) {
|
||||
if( $poll_devices > 1 || $hash->{LOCAL} || $now - $hash->{helper}{last_config_timestamp} > 300 ) {
|
||||
$result = HUEBridge_Call($hash, $hash, undef, undef);
|
||||
$hash->{helper}{last_config_timestamp} = $now;
|
||||
} else {
|
||||
@ -1614,7 +1615,9 @@ HUEBridge_Attr($$$)
|
||||
<li><a href="#disable">disable</a></li>
|
||||
<li><a href="#disabledForIntervals">disabledForIntervals</a></li>
|
||||
<li>pollDevices<br>
|
||||
the bridge will poll all devices instead of each device itself. default is 1.</li>
|
||||
1 -> the bridge will poll all lights in one go instead of each device polling itself independently<br>
|
||||
2 -> the bridge will poll all devices in one go instead of each device polling itself independently<br>
|
||||
default is 1.</li>
|
||||
<li>queryAfterSet<br>
|
||||
the bridge will request the real device state after a set command. default is 1.</li>
|
||||
<li>noshutdown<br>
|
||||
|
@ -273,17 +273,19 @@ sub HUEDevice_Define($$)
|
||||
|
||||
$modules{HUEDevice}{defptr}{$code} = $hash;
|
||||
|
||||
if( AttrVal($iodev, "pollDevices", undef) ) {
|
||||
$interval = 0 unless defined($interval);
|
||||
} else {
|
||||
if( AttrVal($iodev, "pollDevices", 1) ) {
|
||||
$interval = undef unless defined($interval);
|
||||
|
||||
} elsif( !$hash->{helper}->{devtype} || $hash->{helper}->{devtype} ne 'G' ) {
|
||||
$interval = 60 unless defined($interval);
|
||||
|
||||
}
|
||||
|
||||
$args[3] = "" if( !defined( $args[3] ) );
|
||||
if( !$hash->{helper}->{devtype} ) {
|
||||
$hash->{DEF} = "$id $args[3] IODev=$iodev" if( $iodev );
|
||||
|
||||
$interval = 60 if( $interval && $interval < 10 );
|
||||
$interval = 60 if( defined($interval) && $interval < 10 );
|
||||
$hash->{INTERVAL} = $interval;
|
||||
|
||||
$hash->{helper}{on} = -1;
|
||||
@ -308,6 +310,9 @@ sub HUEDevice_Define($$)
|
||||
} elsif( $hash->{helper}->{devtype} eq 'G' ) {
|
||||
$hash->{DEF} = "group $id $args[3] IODev=$iodev" if( $iodev );
|
||||
|
||||
$interval = 60 if( defined($interval) && $interval < 10 );
|
||||
$hash->{INTERVAL} = $interval;
|
||||
|
||||
$hash->{helper}{all_on} = -1;
|
||||
$hash->{helper}{any_on} = -1;
|
||||
|
||||
@ -321,7 +326,7 @@ sub HUEDevice_Define($$)
|
||||
} elsif( $hash->{helper}->{devtype} eq 'S' ) {
|
||||
$hash->{DEF} = "sensor $id $args[3] IODev=$iodev" if( $iodev );
|
||||
|
||||
$interval = 60 if( $interval && $interval < 1 );
|
||||
$interval = 60 if( defined($interval) && $interval < 1 );
|
||||
$hash->{INTERVAL} = $interval;
|
||||
|
||||
}
|
||||
@ -754,7 +759,7 @@ HUEDevice_Set($@)
|
||||
return undef;
|
||||
}
|
||||
|
||||
$hash->{".triggerUsed"} = 1 if( $hash->{helper}->{devtype} ne 'G' );
|
||||
$hash->{".triggerUsed"} = 1;
|
||||
return undef if( !defined($result) );
|
||||
|
||||
if( $hash->{helper}->{update_timeout} == -1 ) {
|
||||
@ -997,7 +1002,6 @@ HUEDevice_GetUpdate($)
|
||||
|
||||
HUEDevice_Parse($hash,$result);
|
||||
|
||||
return undef;
|
||||
} elsif( $hash->{helper}->{devtype} eq 'S' ) {
|
||||
}
|
||||
|
||||
@ -1006,6 +1010,8 @@ HUEDevice_GetUpdate($)
|
||||
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "HUEDevice_GetUpdate", $hash, 0) if( $hash->{INTERVAL} );
|
||||
}
|
||||
|
||||
return undef if( $hash->{helper}->{devtype} eq 'G' );
|
||||
|
||||
my $result = HUEDevice_ReadFromServer($hash,$hash->{ID});
|
||||
if( !defined($result) ) {
|
||||
$hash->{helper}{reachable} = 0;
|
||||
@ -1066,7 +1072,6 @@ HUEDevice_Parse($$)
|
||||
$hash->{uniqueid} = $result->{uniqueid} if( defined($result->{uniqueid}) );
|
||||
|
||||
if( $hash->{helper}->{devtype} eq 'G' ) {
|
||||
$hash->{STATE} = 'Initialized';
|
||||
if( $result->{lights} ) {
|
||||
$hash->{lights} = join( ",", @{$result->{lights}} );
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user