39_siri.pm 2.7 KB

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