99_dumpdef.pm 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/usr/bin/perl
  2. ##############################################
  3. #
  4. # VarDump for FHEM-Devices
  5. #
  6. ##############################################
  7. #
  8. # Copyright notice
  9. #
  10. # (c) 2009 - 2010
  11. # Copyright: Axel Rieger (fhem BEI anax PUNKT info)
  12. # All rights reserved
  13. #
  14. # This script free software; you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation; either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # The GNU General Public License can be found at
  20. # http://www.gnu.org/copyleft/gpl.html.
  21. # A copy is found in the textfile GPL.txt and important notices to the license
  22. # from the author is found in LICENSE.txt distributed with these scripts.
  23. #
  24. # This script is distributed in the hope that it will be useful,
  25. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. # GNU General Public License for more details.
  28. #
  29. ##############################################
  30. # Installation
  31. # 99_dumpdef.pm ins FHEM-Verzeichis kopieren
  32. # dann: "reload 99_dumpdef.pm"
  33. ##############################################
  34. # Aufruf: dumpdef "DEVICE-NAME"
  35. ##############################################
  36. # Aufruf: dumpdef <XXX>
  37. # <MOD> = %modules
  38. # <SEL> = %selectlist
  39. # <VAL> = %value
  40. # <CMD> = %cmds
  41. # <DAT> = %data
  42. ##############################################
  43. package main;
  44. use strict;
  45. use warnings;
  46. use POSIX;
  47. use Data::Dumper;
  48. use vars qw(%data);
  49. use vars qw(%cmds);
  50. use vars qw(%attr);
  51. use vars qw(%defs);
  52. use vars qw(%modules);
  53. use vars qw(%selectlist);
  54. sub Commanddumpdef($);
  55. #####################################
  56. sub
  57. dumpdef_Initialize($)
  58. {
  59. my %lhash = ( Fn=>"Commanddumpdef",
  60. Hlp=>"Dump <devspec> to FHEMWEB & LOG" );
  61. $cmds{dumpdef} = \%lhash;
  62. }
  63. #####################################
  64. sub Commanddumpdef($)
  65. {
  66. my ($cl, $d) = @_;
  67. # $d = $a[1];
  68. return "Usage: dumpdef <DeviceName>" if(!$d);
  69. my($package, $filename, $line, $subroutine) = caller(3);
  70. my $r = "CALLER => $package: $filename LINE: $line SUB: $subroutine \n";
  71. $r .= "SUB-NAME: " .(caller(0))[3] . "\n";
  72. $r .= "--------------------------------------------------------------------------------\n";
  73. $Data::Dumper::Maxdepth = 4;
  74. if($d eq "CMD") {$r .= Dumper(%cmds) . "\n"; return $r; }
  75. if($d eq "DAT") {$r .= Dumper(%data) . "\n"; return $r; }
  76. if($d eq "MOD") {$r .= Dumper(%modules) . "\n"; return $r; }
  77. if($d eq "SEL") {$r .= Dumper(%selectlist) . "\n"; return $r; }
  78. if($d eq "DEF") {$r .= Dumper(%defs) . "\n"; return $r; }
  79. if(!defined($defs{$d})) {
  80. return "Unkown Device";}
  81. $r .= "DUMP-DEVICE: $d \n";
  82. $r .= Dumper($defs{$d}) . "\n";
  83. $r .= "--------------------------------------------------------------------------------\n";
  84. $r .= "DUMP-DEVICE-ATTR \n";
  85. $r .= Dumper($attr{$d}) . "\n";
  86. $r .= "--------------------------------------------------------------------------------\n";
  87. $r .= "DUMP-DEVICE-Module \n";
  88. $r .= Dumper($modules{$defs{$d}{TYPE}}) . "\n";
  89. return $r;
  90. }
  91. 1;
  92. =pod
  93. =begin html
  94. <a name="dumpdef"></a>
  95. <h3>dumpdef</h3>
  96. <ul>
  97. <code>dumpdef &lt;options&gt;</code>
  98. <br><br>
  99. Data::Dumper for FHEM-Devices/Hashes<br><br>
  100. Dumps the content of &lt;options&gt; to FHEMWEB<br><br>
  101. Options:<br><br>
  102. <ul>
  103. <table>
  104. <tr><td><code>FHEM-DEVICENAME</code></td><td>=></td><td><code>%defs{FHEM-DEVICENAME}+%attr{FHEM-DEVICENAME}</code></td></tr>
  105. <tr><td><code>MOD</code></td><td>=></td><td><code>%modules</code></td></tr>
  106. <tr><td><code>SEL</code></td><td>=></td><td><code>%selectlist</code></td></tr>
  107. <tr><td><code>DAT</code></td><td>=></td><td><code>%data</code></td></tr>
  108. <tr><td><code>CMD</code></td><td>=></td><td><code>%cmd</code></td></tr>
  109. </table>
  110. </ul>
  111. <br><br>
  112. Example:
  113. <ul><br>
  114. <pre>dumpdef TEST
  115. CALLER => main: /opt/fhz/FHEM/01_FHEMWEB.pm LINE: 194 SUB: main::FW_AnswerCall
  116. SUB-NAME: main::Commanddumpdef
  117. DUMP-DEVICE: TEST
  118. $VAR1 = {
  119. 'IODev' => {},
  120. 'NAME' => 'TEST',
  121. 'NR' => 64,
  122. 'STATE' => '???',
  123. 'TYPE' => 'dummy'
  124. };
  125. DUMP-DEVICE-ATTR
  126. $VAR1 = {
  127. 'room' => 'DEF_DUMMY,GRP.TEST'
  128. };
  129. </pre>
  130. </ul>
  131. </ul>
  132. =end html
  133. =cut