mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
30_HUEBridge.pm: added set deletescene and get scenes detail
31_HUEDevice.pm: added (hue|sat|ct)(Up|Down) commands git-svn-id: https://svn.fhem.de/fhem/trunk@10450 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b768b29205
commit
ba54b39dbf
@ -1,5 +1,7 @@
|
||||
# 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.
|
||||
- feature: HUEbridge: added set deletescene and get scenes detail
|
||||
- feature: HUEDevice: added (hue|sat|ct)(Up|Down) commands
|
||||
- feature: 51_I2C_TSL2561: support non-blocking I2C-IO, especially when
|
||||
using Firmata over LAN
|
||||
- feature: FB_CALLLIST: new attribute answMachine-is-missed-call to treat
|
||||
|
@ -367,9 +367,17 @@ HUEBridge_Set($@)
|
||||
'lights' => HUEBridge_string2array($args[@args-1]),
|
||||
};
|
||||
|
||||
my $result = HUEBridge_Call($hash, undef, "scenes/$arg", $obj, 'PUT');
|
||||
my $result;
|
||||
if( 0 && $hash->{helper}{apiversion} && $hash->{helper}{apiversion} >= (1<<16) + (11<<8) ) {
|
||||
#FIXME: currently not supported. LightScene needs scene id.
|
||||
$obj->{recycle} = JSON::true if( $arg );
|
||||
$result = HUEBridge_Call($hash, undef, "scenes", $obj, 'POST');
|
||||
} else {
|
||||
$result = HUEBridge_Call($hash, undef, "scenes/$arg", $obj, 'PUT');
|
||||
}
|
||||
|
||||
if( $result->{success} ) {
|
||||
return "created $result->{success}{id}" if( $result->{success}{id} );
|
||||
return "created $arg";
|
||||
}
|
||||
|
||||
@ -399,6 +407,14 @@ HUEBridge_Set($@)
|
||||
|
||||
return undef;
|
||||
|
||||
} elsif($cmd eq 'deletescene') {
|
||||
return "usage: deletescene <id>" if( @args != 1 );
|
||||
|
||||
my $result = HUEBridge_Call($hash, undef, "scenes/$arg", undef, 'DELETE');
|
||||
return $result->{error}{description} if( $result->{error} );
|
||||
|
||||
return undef;
|
||||
|
||||
} elsif($cmd eq 'scene') {
|
||||
return "usage: scene <id>" if( @args != 1 );
|
||||
|
||||
@ -433,7 +449,7 @@ HUEBridge_Set($@)
|
||||
|
||||
|
||||
} else {
|
||||
my $list = "delete creategroup deletegroup savescene modifyscene scene deletewhitelist touchlink:noArg autodetect:noArg autocreate:noArg statusRequest:noArg";
|
||||
my $list = "delete creategroup deletegroup savescene deletescene modifyscene scene deletewhitelist touchlink:noArg autodetect:noArg autocreate:noArg statusRequest:noArg";
|
||||
$list .= " swupdate:noArg" if( defined($hash->{updatestate}) && $hash->{updatestate} =~ '^2' );
|
||||
return "Unknown argument $cmd, choose one of $list";
|
||||
}
|
||||
@ -442,7 +458,8 @@ HUEBridge_Set($@)
|
||||
sub
|
||||
HUEBridge_Get($@)
|
||||
{
|
||||
my ($hash, $name, $cmd) = @_;
|
||||
my ($hash, $name, $cmd, @args) = @_;
|
||||
my ($arg, @params) = @args;
|
||||
|
||||
return "$name: get needs at least one parameter" if( !defined($cmd) );
|
||||
|
||||
@ -479,9 +496,16 @@ HUEBridge_Get($@)
|
||||
my $result = HUEBridge_Call($hash, undef, 'scenes', undef);
|
||||
my $ret = "";
|
||||
foreach my $key ( sort {$a cmp $b} keys %{$result} ) {
|
||||
$ret .= sprintf( "%-20s %-20s %s\n", $key, $result->{$key}{name}, join( ",", @{$result->{$key}{lights}} ) );
|
||||
$ret .= sprintf( "%-20s %-20s", $key, $result->{$key}{name} );
|
||||
$ret .= sprintf( "%i %i %i %-20s %-20s", $result->{$key}{recycle}, $result->{$key}{locked},$result->{$key}{version}, $result->{$key}{owner}, $result->{$key}{lastupdated} ) if( $arg eq 'detail' );
|
||||
$ret .= sprintf( " %s\n", join( ",", @{$result->{$key}{lights}} ) );
|
||||
}
|
||||
if( $ret ) {
|
||||
my $header = sprintf( "%-20s %-20s", "ID", "NAME" );
|
||||
$header .= sprintf( "%s %s %s %-20s %-20s", "R", "L", "V", "OWNER", "LAST UPDATE" ) if( $arg eq 'detail' );
|
||||
$header .= sprintf( " %s\n", "LIGHTS" );
|
||||
$ret = $header . $ret;
|
||||
}
|
||||
$ret = sprintf( "%-20s %-20s %s\n", "ID", "NAME", "LIGHTS" ) .$ret if( $ret );
|
||||
return $ret;
|
||||
|
||||
} elsif($cmd eq 'sensors') {
|
||||
@ -1186,7 +1210,7 @@ HUEBridge_HTTP_Request($$$@)
|
||||
list the devices known to the bridge.</li>
|
||||
<li>groups<br>
|
||||
list the groups known to the bridge.</li>
|
||||
<li>scenes<br>
|
||||
<li>scenes [detail]<br>
|
||||
list the scenes known to the bridge.</li>
|
||||
<li>sensors<br>
|
||||
list the sensors known to the bridge.</li>
|
||||
|
@ -132,8 +132,8 @@ HUEDevice_devStateIcon($)
|
||||
#return ".*:$s:toggle" if( AttrVal($name, "model", "") eq "LWB004" );
|
||||
|
||||
|
||||
return ".*:$s@#".CommandGet("","$name RGB").":ct:hue:pct" if( $percent < 100 && AttrVal($name, "color-icons", 0) == 2 );
|
||||
return ".*:on@#".CommandGet("","$name rgb").":ct:hue:pct" if( AttrVal($name, "color-icons", 0) != 0 );
|
||||
return ".*:$s@#".CommandGet("","$name RGB").":toggle" if( $percent < 100 && AttrVal($name, "color-icons", 0) == 2 );
|
||||
return ".*:on@#".CommandGet("","$name rgb").":toggle" if( AttrVal($name, "color-icons", 0) != 0 );
|
||||
|
||||
return '<div style="width:32px;height:19px;'.
|
||||
'border:1px solid #fff;border-radius:8px;background-color:#'.CommandGet("","$name rgb").';"></div>';
|
||||
@ -359,6 +359,33 @@ HUEDevice_SetParam($$@)
|
||||
$defs{$name}->{helper}->{update_timeout} = 0;
|
||||
}
|
||||
|
||||
} elsif($cmd eq "satUp") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'sat_inc'} = 25;
|
||||
$obj->{'sat_inc'} = 0+$value if( defined($value) );
|
||||
} elsif($cmd eq "satDown") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'sat_inc'} = -25;
|
||||
$obj->{'sat_inc'} = 0+$value if( defined($value) );
|
||||
|
||||
} elsif($cmd eq "hueUp") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'hue_inc'} = 6553;
|
||||
$obj->{'hue_inc'} = 0+$value if( defined($value) );
|
||||
} elsif($cmd eq "hueDown") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'hue_inc'} = -6553;
|
||||
$obj->{'hue_inc'} = 0+$value if( defined($value) );
|
||||
|
||||
} elsif($cmd eq "ctUp") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'ct_inc'} = 16;
|
||||
$obj->{'ct_inc'} = 0+$value if( defined($value) );
|
||||
} elsif($cmd eq "ctDown") {
|
||||
$obj->{'on'} = JSON::true if( !$defs{$name}->{helper}{on} );
|
||||
$obj->{'ct_inc'} = -16;
|
||||
$obj->{'ct_inc'} = 0+$value if( defined($value) );
|
||||
|
||||
} elsif($cmd eq "ct") {
|
||||
$obj->{'on'} = JSON::true;
|
||||
$value = int(1000000/$value) if( $value > 1000 );
|
||||
@ -600,6 +627,7 @@ HUEDevice_Set($@)
|
||||
my $list = "off:noArg on:noArg toggle:noArg statusRequest:noArg";
|
||||
$list .= " pct:slider,0,1,100 bri:slider,0,1,254" if( $subtype =~ m/dimmer/ );
|
||||
$list .= " dimUp:noArg dimDown:noArg" if( !$hash->{helper}->{devtype} && $subtype =~ m/dimmer/ );
|
||||
$list .= " satUp:noArg satDown:noArg hueUp:noArg hueDown:noArg ctUp:noArg ctDown:noArg " if( $defs{$name}->{IODev}->{helper}{apiversion} && $defs{$name}->{IODev}->{helper}{apiversion} >= (1<<16) + (7<<8) );
|
||||
$list .= " rgb:colorpicker,RGB" if( $subtype =~ m/color/ );
|
||||
$list .= " color:colorpicker,CT,2000,1,6500 ct:colorpicker,CT,154,1,500" if( $subtype =~ m/ct|ext/ );
|
||||
$list .= " hue:colorpicker,HUE,0,1,65535 sat:slider,0,1,254 xy effect:none,colorloop" if( $subtype =~ m/color/ );
|
||||
@ -1132,10 +1160,16 @@ HUEDevice_Parse($$)
|
||||
<li>dimDown [delta]</li>
|
||||
<li>ct <value> [<ramp-time>]<br>
|
||||
set colortemperature to <value> in mireds (range is 154-500) or kelvin (rankge is 2000-6493).</li>
|
||||
<li>ctUp [delta]</li>
|
||||
<li>ctDown [delta]</li>
|
||||
<li>hue <value> [<ramp-time>]<br>
|
||||
set hue to <value>; range is 0-65535.</li>
|
||||
<li>humUp [delta]</li>
|
||||
<li>humDown [delta]</li>
|
||||
<li>sat <value> [<ramp-time>]<br>
|
||||
set saturation to <value>; range is 0-254.</li>
|
||||
<li>satUp [delta]</li>
|
||||
<li>satDown [delta]</li>
|
||||
<li>xy <x>,<y> [<ramp-time>]<br>
|
||||
set the xy color coordinates to <x>,<y></li>
|
||||
<li>alert [none|select|lselect]</li>
|
||||
|
Loading…
Reference in New Issue
Block a user