39_siri.pm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # $Id: 39_siri.pm 12629 2016-11-22 19:48:19Z justme1968 $
  2. package main;
  3. use strict;
  4. use warnings;
  5. #use IO::Socket::INET;
  6. sub
  7. siri_Initialize($)
  8. {
  9. my ($hash) = @_;
  10. #$hash->{ReadFn} = "siri_Read";
  11. $hash->{DefFn} = "siri_Define";
  12. #$hash->{NOTIFYDEV} = "global";
  13. #$hash->{NotifyFn} = "siri_Notify";
  14. $hash->{UndefFn} = "siri_Undefine";
  15. #$hash->{SetFn} = "siri_Set";
  16. #$hash->{GetFn} = "siri_Get";
  17. #$hash->{AttrFn} = "siri_Attr";
  18. $hash->{AttrList} = "$readingFnAttributes";
  19. }
  20. #####################################
  21. sub
  22. siri_Define($$)
  23. {
  24. my ($hash, $def) = @_;
  25. my @a = split("[ \t][ \t]*", $def);
  26. return "Usage: define <name> siri" if(@a != 2);
  27. my $name = $a[0];
  28. $hash->{NAME} = $name;
  29. my $d = $modules{$hash->{TYPE}}{defptr};
  30. return "$hash->{TYPE} device already defined as $d->{NAME}." if( defined($d) );
  31. $modules{$hash->{TYPE}}{defptr} = $hash;
  32. addToAttrList("$hash->{TYPE}Name");
  33. $hash->{STATE} = 'active';
  34. return undef;
  35. }
  36. sub
  37. siri_Notify($$)
  38. {
  39. my ($hash,$dev) = @_;
  40. return if($dev->{NAME} ne "global");
  41. return if(!grep(m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}}));
  42. return undef;
  43. }
  44. sub
  45. siri_Undefine($$)
  46. {
  47. my ($hash, $arg) = @_;
  48. delete $modules{$hash->{TYPE}}{defptr};
  49. return undef;
  50. }
  51. sub
  52. siri_Set($$@)
  53. {
  54. my ($hash, $name, $cmd, @args) = @_;
  55. my $list = "";
  56. return "Unknown argument $cmd, choose one of $list";
  57. }
  58. sub
  59. siri_Get($$@)
  60. {
  61. my ($hash, $name, $cmd) = @_;
  62. my $list = "";
  63. return "Unknown argument $cmd, choose one of $list";
  64. }
  65. sub
  66. siri_Parse($$;$)
  67. {
  68. my ($hash,$data,$peerhost) = @_;
  69. my $name = $hash->{NAME};
  70. }
  71. sub
  72. siri_Read($)
  73. {
  74. my ($hash) = @_;
  75. my $name = $hash->{NAME};
  76. my $len;
  77. my $buf;
  78. $len = $hash->{CD}->recv($buf, 1024);
  79. if( !defined($len) || !$len ) {
  80. Log 1, "!!!!!!!!!!";
  81. return;
  82. }
  83. siri_Parse($hash, $buf, $hash->{CD}->peerhost);
  84. }
  85. sub
  86. siri_Attr($$$)
  87. {
  88. my ($cmd, $name, $attrName, $attrVal) = @_;
  89. my $orig = $attrVal;
  90. my $hash = $defs{$name};
  91. if( $attrName eq "disable" ) {
  92. }
  93. if( $cmd eq 'set' ) {
  94. if( $orig ne $attrVal ) {
  95. $attr{$name}{$attrName} = $attrVal;
  96. return $attrName ." set to ". $attrVal;
  97. }
  98. }
  99. return;
  100. }
  101. 1;
  102. =pod
  103. =item summary Module to control the FHEM/Siri integration
  104. =item summary_DE Modul zur Konfiguration der FHEM/Siri Integration
  105. =begin html
  106. <a name="siri"></a>
  107. <h3>siri</h3>
  108. <ul>
  109. Module to control the FHEM/Siri integration.<br><br>
  110. Notes:
  111. <ul>
  112. <li><br>
  113. </li>
  114. </ul>
  115. <a name="siri_Attr"></a>
  116. <b>Attr</b>
  117. <ul>
  118. <li>siriName<br>
  119. The name to use for a device with siri.</li>
  120. </ul>
  121. </ul><br>
  122. =end html
  123. =cut