35_SWAP_0000002200000008.pm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # $Id: 35_SWAP_0000002200000008.pm 10297 2015-12-29 19:04:09Z justme1968 $
  2. package main;
  3. use strict;
  4. use warnings;
  5. use constant { REG_DESIRED => '0D',
  6. REG_TEXT => '0E', };
  7. sub
  8. SWAP_0000002200000008_Initialize($)
  9. {
  10. my ($hash) = @_;
  11. require "$attr{global}{modpath}/FHEM/34_SWAP.pm";
  12. $hash->{SWAP_SetFn} = "SWAP_0000002200000008_Set";
  13. $hash->{SWAP_SetList} = { desired => 1,
  14. text => undef, };
  15. #$hash->{SWAP_GetFn} = "SWAP_0000002200000008_Get";
  16. #$hash->{SWAP_GetList} = { };
  17. #$hash->{SWAP_ParseFn} = "SWAP_0000002200000008_Parse";
  18. my $ret = SWAP_Initialize($hash);
  19. return $ret;
  20. }
  21. sub
  22. SWAP_0000002200000008_Parse($$$$)
  23. {
  24. my ($hash, $reg, $func, $data) = @_;
  25. my $name = $hash->{NAME};
  26. }
  27. sub
  28. SWAP_0000002200000008_Set($@)
  29. {
  30. my ($hash, $name, $cmd, $arg, $arg2, $arg3) = @_;
  31. if( $cmd eq "desired" ) {
  32. $arg += 50;
  33. $arg *= 10;
  34. my $value = sprintf( "%04X", int($arg) );
  35. return( "regSet", REG_DESIRED, $value );
  36. } elsif( $cmd eq "text" ) {
  37. my $text = "000000000000000000000000000000000000000000000000";
  38. $arg .= " ". $arg2 if( defined($arg2) );
  39. $arg .= " ". $arg3 if( defined($arg3) );
  40. for( my $i = 0; $i < length($arg); ++$i) {
  41. last if( $i >= 18 );
  42. substr( $text, 2*$i, 2, sprintf( "%02X", ord(substr($arg, $i, 1) ) ) );
  43. }
  44. return( "regSet", REG_TEXT, "FFFE" . "02" . $text );
  45. }
  46. return undef;
  47. }
  48. sub
  49. SWAP_0000002200000008_Get($@)
  50. {
  51. my ($hash, $name, $cmd, @a) = @_;
  52. return undef;
  53. }
  54. 1;
  55. =pod
  56. =begin html
  57. <a name="SWAP_0000002200000008"></a>
  58. <h3>SWAP_0000002200000008</h3>
  59. <ul>
  60. Module for the justme version of the panstamp indoor multi sensor board (sketch product code 0000002200000008).
  61. <br><br>
  62. <a name="SWAP_0000002200000008_Define"></a>
  63. <b>Define</b>
  64. <ul>
  65. <code>define &lt;name&gt; SWAP_0000002200000008 &lt;ID&gt; 0000002200000008</code> <br>
  66. <br>
  67. </ul>
  68. <br>
  69. <a name="SWAP_0000002200000008_Set"></a>
  70. <b>Set </b>
  71. all SWAP set commands and:
  72. <ul>
  73. <li>desired &lt;value&gt;<br>
  74. sets the desired temperature to &lt;value&gt;</li>
  75. <li>text &lt;text&gt;<br>
  76. displays text</li>
  77. </ul><br>
  78. <a name="SWAP_0000002200000008_Get"></a>
  79. <b>Get</b>
  80. all SWAP get commands and:
  81. <ul>
  82. </ul><br>
  83. <a name="SWAP_0000002200000008_Attr"></a>
  84. <b>Attributes</b>
  85. <ul>
  86. <li>ProductCode<br>
  87. must be 0000002200000008</li><br>
  88. </ul><br>
  89. </ul>
  90. =end html
  91. =cut