2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

allow autodetection of bridge with hue portal services

git-svn-id: https://svn.fhem.de/fhem/trunk@2893 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2013-03-11 17:49:48 +00:00
parent 0729c2a9cd
commit 979c95105c
2 changed files with 28 additions and 3 deletions

View File

@ -1,6 +1,7 @@
# Add changes at the top of the list. # Add changes at the top of the list.
- SVN - SVN
- change: 30_HUEDevice: allow autodetection of bridge with hue portal services
- feature: THRESHOLD Module by Damian - feature: THRESHOLD Module by Damian
- change: 30_HUEDevice: use new devStateIcon feature to show device color - change: 30_HUEDevice: use new devStateIcon feature to show device color
in room overview in room overview

View File

@ -44,10 +44,30 @@ sub HUEBridge_Define($$)
my @args = split("[ \t]+", $def); my @args = split("[ \t]+", $def);
return "Usage: define <name> HUEBridge <host> [interval]" if(@args < 3); return "Usage: define <name> HUEBridge [<host>] [interval]" if(@args < 2);
my ($name, $type, $host, $interval) = @args; my ($name, $type, $host, $interval) = @args;
if( !defined($host) ) {
my $ret = HUEBridge_HTTP_Request(0,"http://www.meethue.com/api/nupnp","GET",undef,undef,undef);
if( defined($ret) && $ret ne '' )
{
my $obj = decode_json($ret);
if( defined($obj->[0])
&& defined($obj->[0]->{'internalipaddress'}) ) {
}
$host = $obj->[0]->{'internalipaddress'};
}
if( !defined($host) ) {
return 'error detecting bridge.';
}
$hash->{DEF} = $host;
}
$interval= 300 unless defined($interval); $interval= 300 unless defined($interval);
if( $interval < 60 ) { $interval = 60; } if( $interval < 60 ) { $interval = 60; }
@ -142,7 +162,7 @@ HUEBridge_Get($@)
{ {
my ($hash, $name, $cmd) = @_; my ($hash, $name, $cmd) = @_;
return "$name: get needs at least one parameter" if( !defined($cmd) ); return "$name: get needs at least one parameter" if( !defined($cmd) );
# usage check # usage check
if($cmd eq 'devices') { if($cmd eq 'devices') {
@ -434,13 +454,17 @@ HUEBridge_HTTP_Request($$$@)
<a name="HUEBridge_Define_Define"></a> <a name="HUEBridge_Define_Define"></a>
<b>Define</b> <b>Define</b>
<ul> <ul>
<code>define &lt;name&gt; HUEBridge &lt;host&gt; [&lt;interval&gt;]</code><br> <code>define &lt;name&gt; HUEBridge [&lt;host&gt;] [&lt;interval&gt;]</code><br>
<br> <br>
Defines a HUEBridge device with address &lt;host&gt;.<br><br> Defines a HUEBridge device with address &lt;host&gt;.<br><br>
If [&lt;host&gt;] is not given the module will try to autodetect the bridge with the hue portal services.<br><br>
The bridge status will be updated every &lt;interval&gt; seconds. The default and minimum is 60.<br><br> The bridge status will be updated every &lt;interval&gt; seconds. The default and minimum is 60.<br><br>
After a new bridge is created the pair button on the bridge has to be pressed.<br><br>
Examples: Examples:
<ul> <ul>
<code>define bridge HUEBridge 10.0.1.1</code><br> <code>define bridge HUEBridge 10.0.1.1</code><br>