From 94f9d4a9037d35f808cbb753dffe19a63ca698c1 Mon Sep 17 00:00:00 2001 From: justme-1968 Date: Fri, 13 Mar 2015 11:16:54 +0000 Subject: [PATCH] 30_HUEBridge.pm: added command to delete devices in the bridge for firmware version >= 1.7 git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@8202 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/30_HUEBridge.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/FHEM/30_HUEBridge.pm b/FHEM/30_HUEBridge.pm index 75968c168..d9b35de50 100644 --- a/FHEM/30_HUEBridge.pm +++ b/FHEM/30_HUEBridge.pm @@ -220,6 +220,22 @@ HUEBridge_Set($@) return undef; + } elsif($cmd eq 'delete') { + if( defined $defs{$arg} && $defs{$arg}{TYPE} eq 'HUEDevice' ) { + $arg = $defs{$arg}{ID}; + } + + my $code = $name ."-". $arg; + if( defined($modules{HUEDevice}{defptr}{$code}) ) { + CommandDelete( undef, "$modules{HUEDevice}{defptr}{$code}{NAME}" ); + CommandSave(undef,undef) if( AttrVal( "autocreate", "autosave", 1 ) ); + } + + my $result = HUEBridge_Call($hash, undef, "lights/$arg", undef, 'DELETE'); + return $result->{error}{description} if( $result->{error} ); + + return undef; + } elsif($cmd eq 'creategroup') { my @lights = (); @@ -262,7 +278,7 @@ HUEBridge_Set($@) return undef; } else { - my $list = "creategroup deletegroup autocreate:noArg statusRequest:noArg"; + my $list = "delete creategroup deletegroup autocreate:noArg statusRequest:noArg"; $list .= " swupdate:noArg" if( defined($hash->{updatestate}) && $hash->{updatestate} == 2 ); return "Unknown argument $cmd, choose one of $list"; } @@ -927,6 +943,8 @@ HUEBridge_HTTP_Request($$$@) Initiate the detection of new ZigBee devices. After aproximately one minute any newly detected devices can be listed with get devices and the corresponding fhem devices can be created by set autocreate. +
  • delete <name>|<id>
    + Deletes the given device in the bridge and deletes the associated fhem device.
  • creategroup <name> <light-1>[ <light-2>..<lignt-n>]
    Create a group out of <light-1>-<light-n> in the bridge. The lights can be given as fhem device names or bridge device numbers.