98_InfratecOut.pm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ################################################################
  2. #
  3. # $Id:$
  4. #
  5. # (c) 2015 Copyright: Wzut
  6. # forum : http://forum.fhem.de/index.php/topic,34131.0.html
  7. # All rights reserved
  8. #
  9. # This code is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. # The GNU General Public License can be found at
  14. # http://www.gnu.org/copyleft/gpl.html.
  15. # A copy is found in the textfile GPL.txt and important notices to the license
  16. # from the author is found in LICENSE.txt distributed with these scripts.
  17. # This script is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU General Public License for more details.
  21. #
  22. ################################################################
  23. # Changelog:
  24. package main;
  25. use strict;
  26. use warnings;
  27. use SetExtensions;
  28. sub InfratecOut_Initialize($)
  29. {
  30. my ($hash) = @_;
  31. $hash->{SetFn} = "InfratecOut_Set";
  32. $hash->{DefFn} = "InfratecOut_Define";
  33. $hash->{UndefFn} = "InfratecOut_Undef";
  34. $hash->{AttrList} = $readingFnAttributes;
  35. }
  36. ###################################
  37. sub InfratecOut_Define($$)
  38. {
  39. my ($hash, $def) = @_;
  40. my $name = $hash->{NAME};
  41. my @a = split("[ \t][ \t]*", $def);
  42. return "wrong syntax: use define $name InfratecOut <Device> <Out#>" if(int(@a) < 4);
  43. my $parent = $a[2];
  44. my $socket = $a[3];
  45. $hash->{IODEV} = $parent;
  46. $hash->{SOCKETNR} = $socket;
  47. $modules{InfratecOut}{defptr}{$parent.$socket} = $hash;
  48. if (defined($attr{$parent}{room})) { $attr{$name}{room} = $attr{$parent}{room}; }
  49. my $currentstate = ReadingsVal($parent, $name, "defined");
  50. $hash->{STATE} = $currentstate ;
  51. return undef;
  52. }
  53. ###################################
  54. sub InfratecOut_Undef($$)
  55. {
  56. my ($hash, undef) = @_;
  57. my $parent = $hash->{IODEV};
  58. my $socket = $hash->{SOCKETNR};
  59. delete $modules{InfratecOut}{defptr}{$parent.$socket} ;
  60. return undef;
  61. }
  62. ###################################
  63. sub InfratecOut_Set($@)
  64. {
  65. my ($hash, $name , @a) = @_;
  66. my $cmd = $a[0];
  67. my $cmdList = "off:noArg on:noArg toggle:noArg";
  68. return "$name, no set value specified" if(int(@a) < 1);
  69. return "$name, I/O device not found please define InfratecPM device first" if(!defined($hash->{IODEV}));
  70. if($cmd =~ /^(on|off|toggle)$/) # nur diese drei Kommandos kennt es selbst
  71. {
  72. CommandSet(undef,$hash->{IODEV}." Out".$hash->{SOCKETNR}. " $cmd");
  73. return undef;
  74. }
  75. return SetExtensions($hash,$cmdList,$name,@a);
  76. }
  77. #####################################
  78. 1;
  79. =pod
  80. =begin html
  81. <a name="InfratecOut"></a>
  82. <h3>InfratecOut</h3>
  83. <ul>
  84. <table><tr><td>
  85. sub device for InfratecPM module
  86. </td></tr></table>
  87. <a name="InfratecOutdefine"></a>
  88. <b>Define</b>
  89. <ul>
  90. <code>define &lt;name&gt; InfratecOut &lt;InfratecPM device&gt; &lt;Out #&gt;</code>
  91. </ul>
  92. </ul>
  93. =end html