98_copy.pm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # $Id: 98_copy.pm 16366 2018-03-09 21:33:00Z justme1968 $
  2. package main;
  3. use strict;
  4. use warnings;
  5. sub CommandCopy($$);
  6. sub
  7. copy_Initialize($)
  8. {
  9. my %lhash = ( Fn=>"CommandCopy",
  10. Hlp=>"<orig name> <copy name> [<type dependent arguments>]" );
  11. $cmds{copy} = \%lhash;
  12. }
  13. sub
  14. CommandCopy($$)
  15. {
  16. my ($hash, $param) = @_;
  17. my @args = split(/ +/,$param);
  18. return "Usage: copy <orig name> <copy name> [<type dependent arguments>]" if (@args < 2);
  19. my $d = $defs{$args[0]};
  20. return "$args[0] not defined" if( !$d );
  21. my $cmd = "$args[1] $d->{TYPE}";
  22. if( $args[2] ) {
  23. $cmd .= ' '. join( ' ', @args[2..@args-1]);
  24. } else {
  25. $cmd .= " $d->{DEF}" if( $d->{DEF} );
  26. }
  27. my $ret = CommandDefine($hash, $cmd );
  28. return $ret if( $ret );
  29. my $a = 'userattr';
  30. if( $attr{$args[0]} && $attr{$args[0]}{$a} ) {
  31. CommandAttr($hash, "$args[1] $a $attr{$args[0]}{$a}");
  32. }
  33. foreach my $a (keys %{$attr{$args[0]}}) {
  34. next if( $a eq 'userattr' );
  35. CommandAttr($hash, "$args[1] $a $attr{$args[0]}{$a}");
  36. }
  37. CallFn($args[1], "CopyFn", $args[0], $args[1]);
  38. }
  39. 1;
  40. =pod
  41. =item command
  42. =item summary copy a FHEM device
  43. =item summary_DE kopiert ein FHEM Ger&auml;t
  44. =begin html
  45. <a name="copy"></a>
  46. <h3>copy</h3>
  47. <ul>
  48. <code>copy &lt;orig name&gt; &lt;copy name&gt; [&lt;type dependent arguments&gt;]</code><br>
  49. <br>
  50. Create a copy of device &lt;orig name&gt; with the name &lt;copy name&gt;.<br>
  51. If &lt;type dependent arguments&gt; are given they will replace the DEF of &lt;orig name&gt; for the creation of &lt;copy name&gt;.
  52. </ul>
  53. =end html
  54. =begin html_DE
  55. <a name="copy"></a>
  56. <h3>copy</h3>
  57. <ul>
  58. <code>copy &lt;orig name&gt; &lt;copy name&gt; [&lt;type dependent arguments&gt;]</code><br>
  59. <br>
  60. Erzeugt eine Kopie des Device &lt;orig name&gt; mit dem namen &lt;copy name&gt;.<br>
  61. Wenn &lt;type dependent arguments&gt; angegeben sind ersetzen die die DEF von &lt;orig name&gt; beim anlegen von &lt;copy name&gt;.
  62. </ul>
  63. =end html_DE
  64. =cut