mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
91041cba1e
git-svn-id: https://svn.fhem.de/fhem/trunk@16366 2b470e98-0d58-463d-a4d8-8e2adae1ed80
85 lines
1.9 KiB
Perl
85 lines
1.9 KiB
Perl
|
|
# $Id$
|
|
package main;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
sub CommandCopy($$);
|
|
|
|
sub
|
|
copy_Initialize($)
|
|
{
|
|
my %lhash = ( Fn=>"CommandCopy",
|
|
Hlp=>"<orig name> <copy name> [<type dependent arguments>]" );
|
|
$cmds{copy} = \%lhash;
|
|
}
|
|
|
|
sub
|
|
CommandCopy($$)
|
|
{
|
|
my ($hash, $param) = @_;
|
|
|
|
my @args = split(/ +/,$param);
|
|
|
|
return "Usage: copy <orig name> <copy name> [<type dependent arguments>]" if (@args < 2);
|
|
|
|
my $d = $defs{$args[0]};
|
|
return "$args[0] not defined" if( !$d );
|
|
|
|
my $cmd = "$args[1] $d->{TYPE}";
|
|
if( $args[2] ) {
|
|
$cmd .= ' '. join( ' ', @args[2..@args-1]);
|
|
} else {
|
|
$cmd .= " $d->{DEF}" if( $d->{DEF} );
|
|
}
|
|
|
|
my $ret = CommandDefine($hash, $cmd );
|
|
return $ret if( $ret );
|
|
|
|
my $a = 'userattr';
|
|
if( $attr{$args[0]} && $attr{$args[0]}{$a} ) {
|
|
CommandAttr($hash, "$args[1] $a $attr{$args[0]}{$a}");
|
|
}
|
|
|
|
foreach my $a (keys %{$attr{$args[0]}}) {
|
|
next if( $a eq 'userattr' );
|
|
CommandAttr($hash, "$args[1] $a $attr{$args[0]}{$a}");
|
|
}
|
|
|
|
CallFn($args[1], "CopyFn", $args[0], $args[1]);
|
|
}
|
|
|
|
1;
|
|
|
|
=pod
|
|
=item command
|
|
=item summary copy a FHEM device
|
|
=item summary_DE kopiert ein FHEM Gerät
|
|
=begin html
|
|
|
|
<a name="copy"></a>
|
|
<h3>copy</h3>
|
|
<ul>
|
|
<code>copy <orig name> <copy name> [<type dependent arguments>]</code><br>
|
|
<br>
|
|
Create a copy of device <orig name> with the name <copy name>.<br>
|
|
If <type dependent arguments> are given they will replace the DEF of <orig name> for the creation of <copy name>.
|
|
</ul>
|
|
|
|
=end html
|
|
|
|
=begin html_DE
|
|
|
|
<a name="copy"></a>
|
|
<h3>copy</h3>
|
|
<ul>
|
|
<code>copy <orig name> <copy name> [<type dependent arguments>]</code><br>
|
|
<br>
|
|
Erzeugt eine Kopie des Device <orig name> mit dem namen <copy name>.<br>
|
|
Wenn <type dependent arguments> angegeben sind ersetzen die die DEF von <orig name> beim anlegen von <copy name>.
|
|
</ul>
|
|
|
|
=end html_DE
|
|
=cut
|