mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-17 23:46:03 +00:00
HUEbridge: added set touchlink
added get whitelist, set deletewhitelist new and extendet internals HUEDevice: dimUp&dimDown: use bri_inc if bridge firmware >= 1.7 don't send on with dimUp & dimDown if already on new and extendet internals git-svn-id: https://svn.fhem.de/fhem/trunk@9368 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
70eb9fa60c
commit
587b38ead6
@ -1,5 +1,11 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||||
# Do not insert empty lines here, update check depends on it.
|
# Do not insert empty lines here, update check depends on it.
|
||||||
|
- feature: HUEbridge: added et touchlink
|
||||||
|
added get whitelist, set deletewhitelist
|
||||||
|
new and extendet internals
|
||||||
|
- feature: HUEDevice: dimUp&dimDown: use bri_inc if bridge firmware >= 1.7
|
||||||
|
don't send on with dimUp & dimDown if already on
|
||||||
|
new and extendet internals
|
||||||
- feature: 71_YAMAHA_AVR: new set commands/readings for controlling
|
- feature: 71_YAMAHA_AVR: new set commands/readings for controlling
|
||||||
bass and treble (by dev0)
|
bass and treble (by dev0)
|
||||||
- feature: 66_ECMD: requestSeparator can be turned off
|
- feature: 66_ECMD: requestSeparator can be turned off
|
||||||
|
@ -164,9 +164,23 @@ sub HUEBridge_Undefine($$)
|
|||||||
sub HUEBridge_OpenDev($)
|
sub HUEBridge_OpenDev($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
HUEBridge_Detect($hash) if( defined($hash->{NUPNP}) );
|
HUEBridge_Detect($hash) if( defined($hash->{NUPNP}) );
|
||||||
|
|
||||||
|
my ($err,$ret) = HttpUtils_BlockingGet({
|
||||||
|
url => "http://$hash->{Host}/description.xml",
|
||||||
|
method => "GET",
|
||||||
|
timeout => 3,
|
||||||
|
});
|
||||||
|
|
||||||
|
if( defined($err) && $err ) {
|
||||||
|
Log3 $name, 3, "HUEBridge_Detect: error reading description: ".$err;
|
||||||
|
} else {
|
||||||
|
$ret =~ m/<modelName>([^<]*)/;
|
||||||
|
$hash->{modelName} = $1;
|
||||||
|
}
|
||||||
|
|
||||||
my $result = HUEBridge_Call($hash, undef, 'config', undef);
|
my $result = HUEBridge_Call($hash, undef, 'config', undef);
|
||||||
if( !defined($result) ) {
|
if( !defined($result) ) {
|
||||||
return undef;
|
return undef;
|
||||||
@ -237,6 +251,7 @@ HUEBridge_Set($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hash->{updatestate} = 3;
|
$hash->{updatestate} = 3;
|
||||||
|
$hash->{helper}{updatestate} = $hash->{updatestate};
|
||||||
$hash->{STATE} = "updating";
|
$hash->{STATE} = "updating";
|
||||||
return "starting update";
|
return "starting update";
|
||||||
|
|
||||||
@ -308,9 +323,27 @@ HUEBridge_Set($@)
|
|||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
|
|
||||||
|
} elsif($cmd eq 'deletewhitelist') {
|
||||||
|
|
||||||
|
my $result = HUEBridge_Call($hash, undef, "config/whitelist/$arg", undef, 'DELETE');
|
||||||
|
return $result->{error}{description} if( $result->{error} );
|
||||||
|
|
||||||
|
return undef;
|
||||||
|
|
||||||
|
} elsif($cmd eq 'touchlink') {
|
||||||
|
my $obj = { 'touchlink' => JSON::true };
|
||||||
|
|
||||||
|
my $result = HUEBridge_Call($hash, undef, 'config', $obj, 'PUT');
|
||||||
|
|
||||||
|
return undef if( $result->{success} );
|
||||||
|
|
||||||
|
return $result->{error}{description} if( $result->{error} );
|
||||||
|
return undef;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
my $list = "delete creategroup deletegroup autocreate:noArg statusRequest:noArg";
|
my $list = "delete creategroup deletegroup deletewhitlist touchlink autocreate:noArg statusRequest:noArg";
|
||||||
$list .= " swupdate:noArg" if( defined($hash->{updatestate}) && $hash->{updatestate} == 2 );
|
$list .= " swupdate:noArg" if( defined($hash->{updatestate}) && $hash->{updatestate} =~ '^2' );
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,8 +393,18 @@ HUEBridge_Get($@)
|
|||||||
$ret = sprintf( "%2s %-15s %-15s %-15s %s\n", "ID", "NAME", "FHEM", "TYPE", "LIGHTS" ) .$ret if( $ret );
|
$ret = sprintf( "%2s %-15s %-15s %-15s %s\n", "ID", "NAME", "FHEM", "TYPE", "LIGHTS" ) .$ret if( $ret );
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
|
} elsif($cmd eq 'whitelist') {
|
||||||
|
my $result = HUEBridge_Call($hash, undef, 'config', undef);
|
||||||
|
my $ret = "";
|
||||||
|
my $whitelist = $result->{whitelist};
|
||||||
|
foreach my $key ( sort {$whitelist->{$a}{'last use date'} cmp $whitelist->{$b}{'last use date'}} keys %{$whitelist} ) {
|
||||||
|
$ret .= sprintf( "%-20s %-20s %-30s %s\n", $whitelist->{$key}{'create date'}, , $whitelist->{$key}{'last use date'}, $whitelist->{$key}{name}, $key );
|
||||||
|
}
|
||||||
|
$ret = sprintf( "%-20s %-20s %-30s %s\n", "CREATE", "LAST USE", "NAME", "KEY" ) .$ret if( $ret );
|
||||||
|
return $ret;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return "Unknown argument $cmd, choose one of devices:noArg groups:noArg sensors:noArg";
|
return "Unknown argument $cmd, choose one of devices:noArg groups:noArg sensors:noArg whitelist:noArg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,19 +458,32 @@ HUEBridge_Parse($$)
|
|||||||
|
|
||||||
$hash->{name} = $result->{name};
|
$hash->{name} = $result->{name};
|
||||||
$hash->{swversion} = $result->{swversion};
|
$hash->{swversion} = $result->{swversion};
|
||||||
|
my @l = split( '\.', $result->{apiversion} );
|
||||||
|
$hash->{helper}{apiversion} = ($l[0] << 16) + ($l[1] << 8) + $l[2];
|
||||||
$hash->{apiversion} = $result->{apiversion};
|
$hash->{apiversion} = $result->{apiversion};
|
||||||
|
$hash->{zigbeechannel} = $result->{zigbeechannel};
|
||||||
|
|
||||||
if( defined( $result->{swupdate} ) ) {
|
if( defined( $result->{swupdate} ) ) {
|
||||||
my $txt = $result->{swupdate}->{text};
|
my $txt = $result->{swupdate}->{text};
|
||||||
readingsSingleUpdate($hash, "swupdate", $txt, 1) if( $txt && $txt ne ReadingsVal($name,"swupdate","") );
|
readingsSingleUpdate($hash, "swupdate", $txt, 1) if( $txt && $txt ne ReadingsVal($name,"swupdate","") );
|
||||||
if( defined($hash->{updatestate}) ){
|
if( defined($hash->{updatestate}) ){
|
||||||
$hash->{STATE} = "update done" if( $result->{swupdate}->{updatestate} == 0 && $hash->{updatestate} >= 2 );
|
$hash->{STATE} = "update done" if( $result->{swupdate}->{updatestate} == 0 && $hash->{helper}{updatestate} >= 2 );
|
||||||
$hash->{STATE} = "update failed" if( $result->{swupdate}->{updatestate} == 2 && $hash->{updatestate} == 3 );
|
$hash->{STATE} = "update failed" if( $result->{swupdate}->{updatestate} == 2 && $hash->{helper}{updatestate} == 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$hash->{updatestate} = $result->{swupdate}->{updatestate};
|
$hash->{updatestate} = $result->{swupdate}->{updatestate};
|
||||||
|
$hash->{helper}{updatestate} = $hash->{updatestate};
|
||||||
|
if( $result->{swupdate}->{devicetypes} ) {
|
||||||
|
my $devicetypes;
|
||||||
|
$devicetypes .= 'bridge' if( $result->{swupdate}->{devicetypes}->{bridge} );
|
||||||
|
$devicetypes .= ',' if( $devicetypes && scalar(@{$result->{swupdate}->{devicetypes}->{lights}}) );
|
||||||
|
$devicetypes .= join( ",", @{$result->{swupdate}->{devicetypes}->{lights}} ) if( $result->{swupdate}->{devicetypes}->{lights} );
|
||||||
|
|
||||||
|
$hash->{updatestate} .= " [$devicetypes]";
|
||||||
|
}
|
||||||
} elsif ( defined( $hash->{swupdate} ) ) {
|
} elsif ( defined( $hash->{swupdate} ) ) {
|
||||||
delete( $hash->{updatestate} );
|
delete( $hash->{updatestate} );
|
||||||
|
delete( $hash->{helper}{updatestate} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +631,7 @@ HUEBridge_Call($$$$;$)
|
|||||||
return $res if( !$blocking || defined($res) );
|
return $res if( !$blocking || defined($res) );
|
||||||
|
|
||||||
Log3 $name, 3, "HUEBridge_Call: failed, retrying";
|
Log3 $name, 3, "HUEBridge_Call: failed, retrying";
|
||||||
HUEBridge_Detect($hash);
|
HUEBridge_Detect($hash) if( defined($hash->{NUPNP}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Log3 $name, 3, "HUEBridge_Call: failed";
|
Log3 $name, 3, "HUEBridge_Call: failed";
|
||||||
@ -973,11 +1029,13 @@ HUEBridge_HTTP_Request($$$@)
|
|||||||
<b>Get</b>
|
<b>Get</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li>devices<br>
|
<li>devices<br>
|
||||||
list the devices known to the bridge.</li>
|
list the devices known to the bridge.</li>
|
||||||
<li>groups<br>
|
<li>groups<br>
|
||||||
list the groups known to the bridge.</li>
|
list the groups known to the bridge.</li>
|
||||||
<li>sensors<br>
|
<li>sensors<br>
|
||||||
list the sensors known to the bridge.</li>
|
list the sensors known to the bridge.</li>
|
||||||
|
<li>whitelist<br>
|
||||||
|
list the whitlist of the bridge.</li>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
|
|
||||||
<a name="HUEBridge_Set"></a>
|
<a name="HUEBridge_Set"></a>
|
||||||
@ -996,6 +1054,10 @@ HUEBridge_HTTP_Request($$$@)
|
|||||||
The lights can be given as fhem device names or bridge device numbers.</li>
|
The lights can be given as fhem device names or bridge device numbers.</li>
|
||||||
<li>deletegroup <name>|<id><br>
|
<li>deletegroup <name>|<id><br>
|
||||||
Deletes the given group in the bridge and deletes the associated fhem device.</li>
|
Deletes the given group in the bridge and deletes the associated fhem device.</li>
|
||||||
|
<li>deletwhitelist <key><br>
|
||||||
|
Deletes the given key from the whitelist in the bridge.</li>
|
||||||
|
<li>touchlink<br>
|
||||||
|
perform touchlink action</li>
|
||||||
<li>statusRequest<br>
|
<li>statusRequest<br>
|
||||||
Update bridge status.</li>
|
Update bridge status.</li>
|
||||||
<li>swupdate<br>
|
<li>swupdate<br>
|
||||||
|
@ -316,24 +316,40 @@ HUEDevice_SetParam($$@)
|
|||||||
$obj->{'transitiontime'} = $value2 * 10 if( defined($value2) );
|
$obj->{'transitiontime'} = $value2 * 10 if( defined($value2) );
|
||||||
|
|
||||||
} elsif($cmd eq "dimUp") {
|
} elsif($cmd eq "dimUp") {
|
||||||
my $bri = ReadingsVal($name,"bri","0");
|
if( $defs{$name}->{IODev}->{helper}{apiversion} && $defs{$name}->{IODev}->{helper}{apiversion} >= (1<<16) + (7<<8) ) {
|
||||||
$bri += 25;
|
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||||
$bri = 254 if( $bri > 254 );
|
$obj->{'bri_inc'} = 25;
|
||||||
$obj->{'on'} = JSON::true;
|
$obj->{'bri_inc'} = $value if( defined($value) );
|
||||||
$obj->{'bri'} = 0+$bri;
|
$obj->{'transitiontime'} = 1;
|
||||||
$obj->{'transitiontime'} = 1;
|
$defs{$name}->{helper}->{update_timeout} = 0;
|
||||||
#$obj->{'transitiontime'} = $value * 10 if( defined($value) );
|
} else {
|
||||||
$defs{$name}->{helper}->{update_timeout} = 0;
|
my $bri = ReadingsVal($name,"bri","0");
|
||||||
|
$bri += 25;
|
||||||
|
$bri = 254 if( $bri > 254 );
|
||||||
|
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||||
|
$obj->{'bri'} = 0+$bri;
|
||||||
|
$obj->{'transitiontime'} = 1;
|
||||||
|
#$obj->{'transitiontime'} = $value * 10 if( defined($value) );
|
||||||
|
$defs{$name}->{helper}->{update_timeout} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
} elsif($cmd eq "dimDown") {
|
} elsif($cmd eq "dimDown") {
|
||||||
my $bri = ReadingsVal($name,"bri","0");
|
if( $defs{$name}->{IODev}->{helper}{apiversion} && $defs{$name}->{IODev}->{helper}{apiversion} >= (1<<16) + (7<<8) ) {
|
||||||
$bri -= 25;
|
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||||
$bri = 0 if( $bri < 0 );
|
$obj->{'bri_inc'} = -25;
|
||||||
$obj->{'on'} = JSON::true;
|
$obj->{'bri_inc'} = -$value if( defined($value) );
|
||||||
$obj->{'bri'} = 0+$bri;
|
$obj->{'transitiontime'} = 1;
|
||||||
$obj->{'transitiontime'} = 1;
|
$defs{$name}->{helper}->{update_timeout} = 0;
|
||||||
#$obj->{'transitiontime'} = $value * 10 if( defined($value) );
|
} else {
|
||||||
$defs{$name}->{helper}->{update_timeout} = 0;
|
my $bri = ReadingsVal($name,"bri","0");
|
||||||
|
$bri -= 25;
|
||||||
|
$bri = 0 if( $bri < 0 );
|
||||||
|
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||||
|
$obj->{'bri'} = 0+$bri;
|
||||||
|
$obj->{'transitiontime'} = 1;
|
||||||
|
#$obj->{'transitiontime'} = $value * 10 if( defined($value) );
|
||||||
|
$defs{$name}->{helper}->{update_timeout} = 0;
|
||||||
|
}
|
||||||
|
|
||||||
} elsif($cmd eq "ct") {
|
} elsif($cmd eq "ct") {
|
||||||
$obj->{'on'} = JSON::true;
|
$obj->{'on'} = JSON::true;
|
||||||
@ -804,6 +820,7 @@ HUEDevice_Parse($$)
|
|||||||
|
|
||||||
$hash->{name} = $result->{'name'};
|
$hash->{name} = $result->{'name'};
|
||||||
$hash->{type} = $result->{'type'};
|
$hash->{type} = $result->{'type'};
|
||||||
|
$hash->{uniqueid} = $result->{'uniqueid'};
|
||||||
|
|
||||||
if( $hash->{helper}->{devtype} eq 'G' ) {
|
if( $hash->{helper}->{devtype} eq 'G' ) {
|
||||||
$hash->{lights} = join( ",", @{$result->{lights}} ) if( $result->{lights} );
|
$hash->{lights} = join( ",", @{$result->{lights}} ) if( $result->{lights} );
|
||||||
@ -822,8 +839,8 @@ HUEDevice_Parse($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hash->{modelid} = $result->{modelid};
|
$hash->{modelid} = $result->{modelid};
|
||||||
$hash->{uniqueid} = $result->{uniqueid};
|
|
||||||
$hash->{manufacturername} = $result->{manufacturername};
|
$hash->{manufacturername} = $result->{manufacturername};
|
||||||
|
$hash->{luminaireuniqueid} = $result->{luminaireuniqueid};
|
||||||
$hash->{swversion} = $result->{swversion};
|
$hash->{swversion} = $result->{swversion};
|
||||||
|
|
||||||
if( $hash->{helper}->{devtype} eq 'S' ) {
|
if( $hash->{helper}->{devtype} eq 'S' ) {
|
||||||
@ -1067,8 +1084,8 @@ HUEDevice_Parse($$)
|
|||||||
set colortemperature to <value> kelvin.</li>
|
set colortemperature to <value> kelvin.</li>
|
||||||
<li>bri <value> [<ramp-time>]<br>
|
<li>bri <value> [<ramp-time>]<br>
|
||||||
set brighness to <value>; range is 0-254.</li>
|
set brighness to <value>; range is 0-254.</li>
|
||||||
<li>dimUp</li>
|
<li>dimUp [delta]</li>
|
||||||
<li>dimDown</li>
|
<li>dimDown [delta]</li>
|
||||||
<li>ct <value> [<ramp-time>]<br>
|
<li>ct <value> [<ramp-time>]<br>
|
||||||
set colortemperature to <value> in mireds (range is 154-500) or kelvin (rankge is 2000-6493).</li>
|
set colortemperature to <value> in mireds (range is 154-500) or kelvin (rankge is 2000-6493).</li>
|
||||||
<li>hue <value> [<ramp-time>]<br>
|
<li>hue <value> [<ramp-time>]<br>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user