mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-26 10:34:52 +00:00
30_HUEBridge, 31_HUEDevice: added deCONZ scenes (by shadowghost)
git-svn-id: https://svn.fhem.de/fhem/trunk@20676 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
356755cec3
commit
da835931ff
@ -1,5 +1,6 @@
|
|||||||
# 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: 30_HUEBridge, 31_HUEDevice: added deCONZ scenes (by shadowghost)
|
||||||
- feature: 14_SD_RSL.PM: support for setExtensions added
|
- feature: 14_SD_RSL.PM: support for setExtensions added
|
||||||
- change: 59_Weather: delete table options in commandref
|
- change: 59_Weather: delete table options in commandref
|
||||||
- bugfix: 73_AutoShuttersControl: fix Commandref, skip ExternalTrigger Drive
|
- bugfix: 73_AutoShuttersControl: fix Commandref, skip ExternalTrigger Drive
|
||||||
|
@ -522,6 +522,31 @@ HUEBridge_scene2id($$)
|
|||||||
|
|
||||||
return '<unknown>';
|
return '<unknown>';
|
||||||
}
|
}
|
||||||
|
sub
|
||||||
|
HUEBridge_scene2id_deCONZ($$)
|
||||||
|
{
|
||||||
|
my ($hash,$id) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
#Log3 $name, 4, "HUEBridge_scene2id_deCONZ: $id, hash: " . Dumper $hash;
|
||||||
|
$hash = $defs{$hash} if( ref($hash) ne 'HASH' );
|
||||||
|
return undef if( !$hash );
|
||||||
|
|
||||||
|
if( $id =~ m/\[id=(.*)\]$/ ) {
|
||||||
|
$id = $1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( my $scenes = $hash->{scenes} ) {
|
||||||
|
$id = lc($id);
|
||||||
|
$id =~ s/\((.*)\)$/\\\($1\\\)/;
|
||||||
|
for my $scene ( @{$scenes} ) {
|
||||||
|
#Log3 $name, 4, "HUEBridge_scene2id_deCONZ scene:". Dumper $scene;
|
||||||
|
return $scene->{id} if( lc($scene->{name}) =~ m/^$id$/ );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<unknown>';
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
HUEbridge_groupOfLights($$)
|
HUEbridge_groupOfLights($$)
|
||||||
{
|
{
|
||||||
@ -1330,7 +1355,7 @@ HUEBridge_updateGroups($$)
|
|||||||
#Log 1, "$hue $sat $bri";
|
#Log 1, "$hue $sat $bri";
|
||||||
$readings{colormode} = 'hs';
|
$readings{colormode} = 'hs';
|
||||||
$readings{hue} = int($hue * 65535);
|
$readings{hue} = int($hue * 65535);
|
||||||
$readings{sat} = int($sat * 254/ $count + 0.5);
|
$readings{sat} = int($sat * 254 / $count + 0.5);
|
||||||
|
|
||||||
$readings{bri} = int($bri * 254 / $count + 0.5);
|
$readings{bri} = int($bri * 254 / $count + 0.5);
|
||||||
$readings{pct} = int($bri * 100 / $count + 0.5);
|
$readings{pct} = int($bri * 100 / $count + 0.5);
|
||||||
|
@ -741,11 +741,21 @@ HUEDevice_Set($@)
|
|||||||
} elsif( $cmd eq 'scene' ) {
|
} elsif( $cmd eq 'scene' ) {
|
||||||
return "usage: scene <id>|<name>" if( !@args );
|
return "usage: scene <id>|<name>" if( !@args );
|
||||||
my $arg = join( ' ', @args );
|
my $arg = join( ' ', @args );
|
||||||
$arg = HUEBridge_scene2id($hash->{IODev}, $arg) if( $hash->{IODev} && $hash->{IODev}{TYPE} eq 'HUEBridge' );
|
my $deConz;
|
||||||
|
if( $hash->{IODev} && $hash->{IODev}{TYPE} eq 'HUEBridge' ) {
|
||||||
|
if( $hash->{IODev}{modelid} eq 'deCONZ' ) {
|
||||||
|
$deConz = 1;
|
||||||
|
$arg = HUEBridge_scene2id_deCONZ($hash, $arg);
|
||||||
|
} else {
|
||||||
|
$arg = HUEBridge_scene2id($hash->{IODev}, $arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $obj = {'scene' => $arg};
|
my $obj = {'scene' => $arg};
|
||||||
$hash->{helper}->{update} = 1;
|
$hash->{helper}->{update} = 1;
|
||||||
my $result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/action",$obj);
|
my $result;
|
||||||
|
$result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/action",$obj) if( !$deConz );
|
||||||
|
$result = HUEDevice_ReadFromServer($hash,"$hash->{ID}/scenes/$arg/recall",$obj) if( $deConz );
|
||||||
return $result->{error}{description} if( $result->{error} );
|
return $result->{error}{description} if( $result->{error} );
|
||||||
|
|
||||||
if( defined($result) && $result->{'error'} ) {
|
if( defined($result) && $result->{'error'} ) {
|
||||||
@ -991,7 +1001,18 @@ HUEDevice_Set($@)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( my $scenes = $hash->{IODev}{helper}{scenes} ) {
|
if( $hash->{IODev} && $hash->{IODev}{modelid} ne 'deCONZ' ) {
|
||||||
|
if( my $scenes = $hash->{scenes} ) {
|
||||||
|
my @names;
|
||||||
|
for my $scene (@{$scenes}) {
|
||||||
|
push(@names, $scene->{name});
|
||||||
|
}
|
||||||
|
# my $s_scenes = join (",",(my $names = map { $_->{name}} @$scenes));
|
||||||
|
my $s_scenes = join (',', @names);
|
||||||
|
$list .= " scene:".$s_scenes;
|
||||||
|
}
|
||||||
|
|
||||||
|
} elsif( my $scenes = $hash->{IODev}{helper}{scenes} ) {
|
||||||
local *containsOneOfMyLights = sub($) {
|
local *containsOneOfMyLights = sub($) {
|
||||||
return 1 if( !defined($hash->{helper}{lights}) );
|
return 1 if( !defined($hash->{helper}{lights}) );
|
||||||
|
|
||||||
@ -1014,8 +1035,10 @@ HUEDevice_Set($@)
|
|||||||
$scene =~ s/ /#/g; $scene;
|
$scene =~ s/ /#/g; $scene;
|
||||||
}
|
}
|
||||||
} keys %{$scenes} );
|
} keys %{$scenes} );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$list .= " scene";
|
$list .= " scene";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetExtensions($hash, $list, $name, @aa);
|
return SetExtensions($hash, $list, $name, @aa);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user