10_IT.pm 72 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  1. ######################################################
  2. # InterTechno Switch Manager as FHM-Module
  3. #
  4. # (c) Olaf Droegehorn / DHS-Computertechnik GmbH
  5. # (c) Björn Hempel
  6. #
  7. # Published under GNU GPL License
  8. #
  9. # $Id: 10_IT.pm 14852 2017-08-06 08:48:24Z bjoernh $
  10. #
  11. ######################################################
  12. package main;
  13. use strict;
  14. use warnings;
  15. #use Data::Dumper qw(Dumper);
  16. use SetExtensions;
  17. my %codes = (
  18. "XMIToff" => "off",
  19. "XMITon" => "on", # Set to previous dim value (before switching it off)
  20. "00" => "off",
  21. "01" => "dim06%",
  22. "02" => "dim12%",
  23. "03" => "dim18%",
  24. "04" => "dim25%",
  25. "05" => "dim31%",
  26. "06" => "dim37%",
  27. "07" => "dim43%",
  28. "08" => "dim50%",
  29. "09" => "dim56%",
  30. "0a" => "dim62%",
  31. "0b" => "dim68%",
  32. "0c" => "dim75%",
  33. "0d" => "dim81%",
  34. "0e" => "dim87%",
  35. "0f" => "dim93%",
  36. "10" => "dim100%",
  37. "XMITdimup" => "dimup",
  38. "XMITdimdown" => "dimdown",
  39. "99" => "on-till",
  40. );
  41. my %codes_he800 = (
  42. "XMIToff" => "off",
  43. "XMITon" => "on", # Set to previous dim value (before switching it off)
  44. "00" => "off",
  45. #"01" => "last-dim-on",
  46. "02" => "dim12%",
  47. "03" => "dim25%",
  48. "04" => "dim37%",
  49. "05" => "dim50%",
  50. "06" => "dim62%",
  51. "07" => "dim75%",
  52. "08" => "dim87%",
  53. "09" => "dim100%",
  54. "XMITdimup" => "dimup",
  55. "XMITdimdown" => "dimdown",
  56. "99" => "on-till",
  57. );
  58. my %it_c2b;
  59. my %it_c2b_he800;
  60. my $it_defrepetition = 6; ## Default number of InterTechno Repetitions
  61. my %models = (
  62. itremote => 'sender',
  63. itswitch => 'simple',
  64. itdimmer => 'dimmer',
  65. ev1527 => 'ev1527',
  66. );
  67. my %bintotristate=(
  68. "00" => "0",
  69. "01" => "F",
  70. "10" => "D",
  71. "11" => "1"
  72. );
  73. my %bintotristateV3=(
  74. "10" => "1",
  75. "01" => "0",
  76. "00" => "D"
  77. );
  78. my %bintotristateHE=(
  79. "10" => "1",
  80. "01" => "0",
  81. "11" => "2",
  82. "00" => "D"
  83. );
  84. my %ev_action = (
  85. "on" => "0011",
  86. "off" => "0000"
  87. );
  88. sub bin2dec {
  89. unpack("N", pack("B32", substr("0" x 32 . shift, -32)));
  90. }
  91. sub bin2dec64 {
  92. unpack("N", pack("B32", substr("0" x 64 . shift, -64)));
  93. }
  94. sub
  95. IT_Initialize($)
  96. {
  97. my ($hash) = @_;
  98. foreach my $k (keys %codes) {
  99. $it_c2b{$codes{$k}} = $k;
  100. }
  101. foreach my $k (keys %codes_he800) {
  102. $it_c2b_he800{$codes_he800{$k}} = $k;
  103. }
  104. $hash->{Match} = "^i......";
  105. $hash->{SetFn} = "IT_Set";
  106. #$hash->{StateFn} = "IT_SetState";
  107. $hash->{DefFn} = "IT_Define";
  108. $hash->{UndefFn} = "IT_Undef";
  109. $hash->{ParseFn} = "IT_Parse";
  110. $hash->{AttrFn} = "IT_Attr";
  111. $hash->{AttrList} = "IODev ITfrequency ITrepetition ITclock switch_rfmode:1,0 do_not_notify:1,0 ignore:0,1 protocol:V1,V3,HE_EU,SBC_FreeTec,HE800 SIGNALduinoProtocolId userV1setCodes unit group dummy:1,0 " .
  112. "$readingFnAttributes " .
  113. "model:".join(",", sort keys %models);
  114. $hash->{AutoCreate}=
  115. { "IT.*" => { GPLOT => "", FILTER => "%NAME", autocreateThreshold => "2:30"} };
  116. }
  117. #####################################
  118. sub
  119. IT_SetState($$$$)
  120. {
  121. my ($hash, $tim, $vt, $val) = @_;
  122. return undef;
  123. $val = $1 if($val =~ m/^(.*) \d+$/);
  124. return "Undefined value $val" if(!defined($it_c2b{$val}));
  125. }
  126. #############################
  127. sub
  128. IT_Do_On_Till($@)
  129. {
  130. my ($hash, $name, @a) = @_;
  131. return "Timespec (HH:MM[:SS]) needed for the on-till command" if(@a != 3);
  132. my ($err, $hr, $min, $sec, $fn) = GetTimeSpec($a[2]);
  133. return $err if($err);
  134. my @lt = localtime;
  135. my $hms_till = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
  136. my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
  137. if($hms_now ge $hms_till) {
  138. Log 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
  139. return "";
  140. }
  141. my @b = ("on");
  142. IT_Set($hash, $name, @b);
  143. my $tname = $hash->{NAME} . "_till";
  144. CommandDelete(undef, $tname) if($defs{$tname});
  145. CommandDefine(undef, "$tname at $hms_till set $name off");
  146. }
  147. ###################################
  148. sub
  149. IT_Set($@)
  150. {
  151. my ($hash, $name, @a) = @_;
  152. my $ret = undef;
  153. my $na = int(@a);
  154. my $message;
  155. return "no set value specified" if($na < 1);
  156. # return, if this is a dummy device
  157. return "Dummydevice $hash->{NAME}: will not set data" if(IsDummy($hash->{NAME}));
  158. my $list = "";
  159. $list .= "off:noArg on:noArg " if( AttrVal($name, "model", "") ne "itremote" );
  160. if ($hash->{userV1setCodes}) {
  161. if ($hash->{READINGS}{protocol}{VAL} eq "EV1527" || $hash->{READINGS}{protocol}{VAL} eq "V1") {
  162. foreach my $setCode (keys %{$hash->{userV1setCodes}}) {
  163. $list .= "$setCode:noArg ";
  164. }
  165. }
  166. }
  167. my $c = $it_c2b{$a[0]};
  168. if ($hash->{READINGS}{protocol}{VAL} eq "V3") {
  169. if($na > 1 && $a[0] eq "dim") {
  170. $a[0] = ($a[1] eq "0" ? "off" : sprintf("dim%02d%%",$a[1]) );
  171. splice @a, 1, 1;
  172. $na = int(@a);
  173. } elsif ($na == 2 && ($a[0] =~ /dim/)) {
  174. return "Bad time spec" if($na == 2 && $a[1] !~ m/^\d*\.?\d+$/);
  175. my $val;
  176. #$a[0] = ($a[1] eq "0" ? "off" : sprintf("dim%02d%%",$a[1]) );
  177. #splice @a, 1, 1;
  178. #$na = int(@a);
  179. if($na == 2) { # Timed command.
  180. $c = sprintf("%02X", (hex($c) | 0x20)); # Set the extension bit
  181. ########################
  182. # Calculating the time.
  183. LOOP: for(my $i = 0; $i <= 12; $i++) {
  184. for(my $j = 0; $j <= 15; $j++) {
  185. $val = (2**$i)*$j*0.25;
  186. if($val >= $a[1]) {
  187. if($val != $a[1]) {
  188. Log3 $name, 2, "$name: changing timeout to $val from $a[1]";
  189. }
  190. $c .= sprintf("%x%x", $i, $j);
  191. last LOOP;
  192. }
  193. }
  194. }
  195. Log3 $hash ,2, "$name: NOT Implemented now!";
  196. return "Specified timeout too large, max is 15360" if(length($c) == 2);
  197. }
  198. }
  199. $list = (join(" ", sort keys %it_c2b) . " dim:slider,0,6.25,100")
  200. if( AttrVal($name, "model", "") eq "itdimmer" );
  201. } elsif ($hash->{READINGS}{protocol}{VAL} eq "HE800") {
  202. $c = $it_c2b_he800{$a[0]};
  203. if($na > 1 && $a[0] eq "dim") {
  204. $a[0] = ($a[1] eq "0" ? "off" : sprintf("dim%02d%%",$a[1]) );
  205. splice @a, 1, 1;
  206. $na = int(@a);
  207. }
  208. $list = (join(" ", sort keys %it_c2b_he800) . " dim:slider,0,12.5,100")
  209. if( AttrVal($name, "model", "") eq "itdimmer" );
  210. } else {
  211. $list .= "dimup:noArg dimdown:noArg on-till" if( AttrVal($name, "model", "") eq "itdimmer" );
  212. }
  213. #if ($hash->{READINGS}{protocol}{VAL} eq "HE800") {
  214. # $list .= " learn_on_codes:noArg learn_off_codes:noArg";
  215. #}
  216. return SetExtensions($hash, $list, $name, @a) if( $a[0] eq "?" );
  217. return SetExtensions($hash, $list, $name, @a) if( !grep( $_ =~ /^\Q$a[0]\E($|:)/, split( ' ', $list ) ) );
  218. return IT_Do_On_Till($hash, $name, @a) if($a[0] eq "on-till");
  219. return "Bad time spec" if($na == 2 && $a[1] !~ m/^\d*\.?\d+$/);
  220. my $io = $hash->{IODev};
  221. my $v = $name ." ". join(" ", @a);
  222. ## Log that we are going to switch InterTechno
  223. Log3 $hash, 3, "$io->{NAME} IT_set: $v";
  224. my (undef, $cmd) = split(" ", $v, 2); # Not interested in the name...
  225. # Look for all devices with the same code, and set state, timestamp
  226. my $code;
  227. if ($hash->{READINGS}{protocol}{VAL} eq "EV1527") { # beim EV1527 darf der code nicht aus dem $hash->{XMIT} geholt werden
  228. $code = "$hash->{CODE}{1}";
  229. } else {
  230. $code = "$hash->{XMIT}";
  231. }
  232. foreach my $n (keys %{ $modules{IT}{defptr}{$code} }) {
  233. my $lh = $modules{IT}{defptr}{$code}{$n};
  234. #$lh->{STATE} = $cmd;
  235. if ($hash->{READINGS}{protocol}{VAL} eq "HE800") {
  236. my $count = $hash->{"count"};
  237. $count = $count + 1;
  238. if ($count > 3) {
  239. $count = 0;
  240. }
  241. $hash->{"count"} = $count;
  242. # }
  243. }
  244. if ($hash->{READINGS}{protocol}{VAL} eq "V3" || $hash->{READINGS}{protocol}{VAL} eq "HE800") {
  245. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  246. if ($cmd eq "on") {
  247. my $lastDimVal = $hash->{READINGS}{lastDimValue}{VAL};
  248. if ($lastDimVal ne "") {
  249. #$cmd = $lastDimVal;
  250. #readingsSingleUpdate($lh, "state", $lastDimVal,1);
  251. readingsSingleUpdate($lh, "dim", substr($lastDimVal, 3, -1),1);
  252. } else {
  253. readingsSingleUpdate($lh, "dim", "100",1);
  254. }
  255. readingsSingleUpdate($lh, "state", "on",1);
  256. } elsif ($cmd eq "off") {
  257. readingsSingleUpdate($lh, "dim", "0",1);
  258. readingsSingleUpdate($lh, "state", "off",1);
  259. } else {
  260. if ($cmd eq "dim100%") {
  261. $lh->{STATE} = "on";
  262. readingsSingleUpdate($lh, "state", "on",1);
  263. } elsif ($cmd eq "dim00%") {
  264. $lh->{STATE} = "off";
  265. readingsSingleUpdate($lh, "lastDimValue", "",1);
  266. readingsSingleUpdate($lh, "state", "off",1);
  267. #} elsif ($cmd eq "last-dim-on") {
  268. # $cmd = AttrVal($name, "lastDimValue", "");
  269. # readingsSingleUpdate($lh, "state", $cmd,1);
  270. } else {
  271. readingsSingleUpdate($lh, "state", $cmd,1);
  272. }
  273. if ($cmd eq "dimup") {
  274. readingsSingleUpdate($lh, "lastDimValue", "dim100%",1);
  275. } elsif ($cmd eq "dimdown") {
  276. if ($hash->{READINGS}{protocol}{VAL} eq "HE800") {
  277. readingsSingleUpdate($lh, "lastDimValue", "dim12%",1);
  278. } else {
  279. readingsSingleUpdate($lh, "lastDimValue", "dim06%",1);
  280. }
  281. } else {
  282. readingsSingleUpdate($lh, "lastDimValue", $cmd,1);
  283. }
  284. }
  285. } else {
  286. readingsSingleUpdate($lh, "state", $cmd,1);
  287. }
  288. } else {
  289. readingsSingleUpdate($lh, "state", $cmd,1);
  290. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  291. readingsSingleUpdate($lh,"dim",$cmd,1);
  292. }
  293. }
  294. }
  295. Log3 $hash, 5, "$io->{NAME} IT_set: Type=" . $io->{TYPE} . ' Protocol=' . $hash->{READINGS}{protocol}{VAL};
  296. if ($io->{TYPE} ne "SIGNALduino") {
  297. # das IODev ist kein SIGNALduino
  298. ## Do we need to change RFMode to SlowRF??
  299. if(defined($attr{$name}) && defined($attr{$name}{"switch_rfmode"})) {
  300. if ($attr{$name}{"switch_rfmode"} eq "1") { # do we need to change RFMode of IODev
  301. my $ret = CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "SlowRF"));
  302. }
  303. }
  304. ## Do we need to change ITClock ?? }
  305. if(defined($attr{$name}) && defined($attr{$name}{"ITclock"})) {
  306. #$message = "isc".$attr{$name}{"ITclock"};
  307. #CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
  308. $message = $attr{$name}{"ITclock"};
  309. CallFn($io->{NAME}, "SetFn", $io, ($hash->{NAME}, "ITClock", $message));
  310. Log3 $hash, 3, "IT set ITclock: $message for $io->{NAME}";
  311. }
  312. ## Do we need to change ITrepetition ??
  313. if(defined($attr{$name}) && defined($attr{$name}{"ITrepetition"})) {
  314. $message = "isr".$attr{$name}{"ITrepetition"};
  315. CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
  316. Log3 $hash,4, "IT set ITrepetition: $message for $io->{NAME}";
  317. }
  318. ## Do we need to change ITfrequency ??
  319. if(defined($attr{$name}) && defined($attr{$name}{"ITfrequency"})) {
  320. my $f = $attr{$name}{"ITfrequency"}/26*65536;
  321. my $f2 = sprintf("%02x", $f / 65536);
  322. my $f1 = sprintf("%02x", int($f % 65536) / 256);
  323. my $f0 = sprintf("%02x", $f % 256);
  324. my $arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
  325. Log3 $hash, 3, "Setting ITfrequency (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
  326. CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "if$f2$f1$f0"));
  327. }
  328. }
  329. if ($hash->{READINGS}{protocol}{VAL} eq "V3") {
  330. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  331. my @itvalues = split(' ', $v);
  332. if ($itvalues[1] eq "dimup") {
  333. $a[0] = "dim100%";
  334. readingsSingleUpdate($hash, "state", $itvalues[1],1);
  335. readingsSingleUpdate($hash, "dim", 100, 1);
  336. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}."D".$hash->{READINGS}{unit}{VAL}."1111");
  337. } elsif ($itvalues[1] eq "dimdown") {
  338. $a[0] = "dim06%";
  339. readingsSingleUpdate($hash, "state", $itvalues[1],1);
  340. readingsSingleUpdate($hash, "dim", 6, 1);
  341. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}."D".$hash->{READINGS}{unit}{VAL}."0000");
  342. } elsif ($itvalues[1] =~ /dim/) {
  343. my $dperc = substr($itvalues[1], 3, -1);
  344. my $dec = (15*$dperc)/100;
  345. my $bin = sprintf ("%b",$dec);
  346. while (length($bin) < 4) {
  347. # suffix 0
  348. $bin = '0'.$bin;
  349. }
  350. readingsSingleUpdate($hash, "dim", $dperc, 1);
  351. if ($dperc == 0) {
  352. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}."0".$hash->{READINGS}{unit}{VAL});
  353. } else {
  354. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}."D".$hash->{READINGS}{unit}{VAL}.$bin);
  355. }
  356. } else {
  357. my $stateVal;
  358. if ($a[0] eq "off") {
  359. $stateVal = "0";
  360. } else {
  361. $stateVal = $hash->{$c};
  362. readingsSingleUpdate($hash, "lastDimValue", "",1);
  363. }
  364. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}.$stateVal.$hash->{READINGS}{unit}{VAL});
  365. }
  366. } else {
  367. $message = "is".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-5).$hash->{READINGS}{group}{VAL}.$hash->{$c}.$hash->{READINGS}{unit}{VAL});
  368. }
  369. } elsif ($hash->{READINGS}{protocol}{VAL} eq "HE_EU") {
  370. my $masterVal = "11";
  371. if ($hash->{READINGS}{mode}{VAL} eq "master") {
  372. if ($hash->{$c} eq "01") {
  373. $masterVal = "01";
  374. }
  375. }
  376. $message = "ise".uc(substr($hash->{XMIT},0,length($hash->{XMIT})-7).$hash->{$c}.$masterVal.$hash->{READINGS}{unit}{VAL});
  377. } elsif ($hash->{READINGS}{protocol}{VAL} eq "HE800") {
  378. my $cVal;
  379. my $mode;
  380. my @mn;
  381. my $msg;
  382. my %he800MapingTable = (
  383. 12 => 2,
  384. 25 => 3,
  385. 37 => 4,
  386. 50 => 5,
  387. 62 => 6,
  388. 75 => 7,
  389. 87 => 8,
  390. 100 => 9,
  391. );
  392. (undef, $cVal) = split(" ", $v, 2); # Not interested in the name...
  393. my @key = (9, 6, 3, 8, 10, 0, 2, 12, 4, 14, 7, 5, 1, 15, 11, 13, 9); # cryptokey
  394. my $rollingCode = $hash->{"count"};
  395. if ($rollingCode > 3) {
  396. $rollingCode = 0;
  397. }
  398. my $oldMode = 0;
  399. if ($cVal eq "on") {
  400. my $sendVal = $hash->{READINGS}{"on_" . $rollingCode}{VAL};
  401. if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
  402. $message = "ish".uc($sendVal);
  403. $oldMode = 1;
  404. Log3 $hash,4, "Use old Mode sendVal $sendVal ";
  405. } else {
  406. readingsSingleUpdate($hash, "lastDimValue", "",1);
  407. $mode = 1;
  408. }
  409. } elsif ($cVal eq "off") {
  410. my $sendVal = $hash->{READINGS}{"off_" . $rollingCode}{VAL};
  411. if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
  412. $message = "ish".uc($sendVal);
  413. $oldMode = 1;
  414. Log3 $hash,4, "Use old Mode sendVal $sendVal ";
  415. } else {
  416. $mode = 0;
  417. }
  418. } else {
  419. Log3 $hash,5, "mode is DIM MODE: $v Model: " . AttrVal($name, "model", "");
  420. # DIM Mode
  421. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  422. my @itvalues = split(' ', $v);
  423. if ($itvalues[1] eq "dimup") {
  424. readingsSingleUpdate($hash, "state", $itvalues[1],1);
  425. readingsSingleUpdate($hash, "dim", 100, 1);
  426. $mode = 9;
  427. } elsif ($itvalues[1] eq "dimdown") {
  428. readingsSingleUpdate($hash, "state", $itvalues[1],1);
  429. readingsSingleUpdate($hash, "dim", 12, 1);
  430. $mode = 2;
  431. } else {
  432. if ($itvalues[1] =~ /dim/) {
  433. my $dperc = substr($itvalues[1], 3, -1);
  434. #my $dperc = $itvalues[2];
  435. my $dec = $he800MapingTable{$dperc};
  436. my $bin = sprintf ("%b",$dec);
  437. while (length($bin) < 4) {
  438. # suffix 0
  439. $bin = '0'.$bin;
  440. }
  441. readingsSingleUpdate($hash, "dim", $dperc, 1);
  442. if ($dperc == 0) {
  443. $mode = 0;
  444. } else {
  445. $mode = $dec;
  446. }
  447. }
  448. }
  449. }
  450. }
  451. #}
  452. if ($oldMode == 0) {
  453. Log3 $hash,5, "mode is $mode";
  454. my @XMIT_split = split(/_/,$hash->{XMIT});
  455. my $receiverID = $XMIT_split[1];
  456. my $transmitterID = $XMIT_split[0];
  457. #encrypt
  458. $mn[0] = $XMIT_split[1]; # mn[0] = iiiib i=receiver-ID
  459. $mn[1] = ($rollingCode << 2) & 15; # 2 lowest bits of rolling-code
  460. if ($mode > 0) { # ON or OFF
  461. $mn[1] |= 2; # mn[1] = rrs0b r=rolling-code, s=ON/OFF, 0=const 0?
  462. }
  463. $mn[2] = $transmitterID & 15; # mn[2..5] = ttttb t=txID in nibbles -> 4x ttttb
  464. $mn[3] = ($transmitterID >> 4) & 15;
  465. $mn[4] = ($transmitterID >> 8) & 15;
  466. $mn[5] = ($transmitterID >> 12) & 15;
  467. if ($mode >= 2 && $mode <= 9) { # mn[6] = dpppb d = dim ON/OFF, p=%dim/10 - 1
  468. $mn[6] = $mode - 2; # dim: 0=10%..7=80%
  469. $mn[6] |= 8; # dim: ON
  470. } else {
  471. $mn[6] = 0; # dim: OFF
  472. }
  473. #XOR encryption 2 rounds
  474. for (my $r=0; $r<=1; $r++){ # 2 encryption rounds
  475. $mn[0] = $key[ $mn[0]-$r+1]; # encrypt first nibble
  476. my $i = 0;
  477. for ($i=1; $i<=5 ; $i++){ # encrypt 4 nibbles
  478. $mn[$i] = $key[($mn[$i] ^ $mn[$i-1])-$r+1]; # crypted with predecessor & key
  479. }
  480. }
  481. $mn[6] = $mn[6] ^ 9; # no encryption
  482. $msg = ($mn[6] << 0x18) | ($mn[5] << 0x14) | # copy the encrypted nibbles in output buffer
  483. ($mn[4] << 0x10) | ($mn[3] << 0x0c) |
  484. ($mn[2] << 0x08) | ($mn[1] << 0x04) | $mn[0];
  485. $msg = ($msg >> 2) | (($msg & 3) << 0x1a); # shift 2 bits right & copy lowest 2 bits of cbuf[0] in msg bit 27/28
  486. $msg = ~$msg & 0xFFFFFFF;
  487. my $bin1=sprintf("%024b",$msg);
  488. while (length($bin1) < 28) {
  489. # suffix 0
  490. $bin1 = '0'.$bin1;
  491. }
  492. my $bin = $bin1;# . $bin3;
  493. Log3 $hash,4, "msg $msg - bin1 $bin1";
  494. $message = "ish".uc($bin);
  495. }
  496. } else {
  497. my $onoffcode;
  498. if (defined($c)) {
  499. $onoffcode = $hash->{$c};
  500. } else {
  501. if ($hash->{userV1setCodes}) {
  502. $onoffcode = $hash->{userV1setCodes}{$a[0]};
  503. }
  504. }
  505. if (length($onoffcode) == 4 && $hash->{READINGS}{protocol}{VAL} ne 'SBC_FreeTec') { # EV1527
  506. $onoffcode = $bintotristate{substr($onoffcode,0,2)} . $bintotristate{substr($onoffcode,2,2)};
  507. }
  508. $message = "is".uc($hash->{XMIT}.$onoffcode);
  509. }
  510. if ($io->{TYPE} ne "SIGNALduino") {
  511. # das IODev ist kein SIGNALduino
  512. ## Send Message to IODev and wait for correct answer
  513. my $msg = CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
  514. Log3 $hash,5,"IT_Set: GetFn(raw): message = $message Antwort = $msg";
  515. if ($msg =~ m/raw => $message/) {
  516. Log 4, "ITSet: Answer from $io->{NAME}: $msg";
  517. } else {
  518. Log 2, "IT IODev device didn't answer is command correctly: $msg";
  519. }
  520. ## Do we need to change ITrepetition back??
  521. if(defined($attr{$name}) && defined($attr{$name}{"ITrepetition"})) {
  522. $message = "isr".$it_defrepetition;
  523. CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
  524. Log3 $hash, 3, "IT set ITrepetition back: $message for $io->{NAME}";
  525. }
  526. ## Do we need to change ITfrequency back??
  527. if(defined($attr{$name}) && defined($attr{$name}{"ITfrequency"})) {
  528. Log3 $hash,4 ,"Setting ITfrequency back to 433.92 MHz";
  529. CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "if0"));
  530. }
  531. ## Do we need to change ITClock back??
  532. if(defined($attr{$name}) && defined($attr{$name}{"ITclock"}))
  533. {
  534. Log3 $hash, 3, "Setting ITClock back to 420";
  535. #CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "sic250"));
  536. CallFn($io->{NAME}, "SetFn", $io, ($hash->{NAME}, "ITClock", "420"));
  537. }
  538. ## Do we need to change RFMode back to HomeMatic??
  539. if(defined($attr{$name}) && defined($attr{$name}{"switch_rfmode"})) {
  540. if ($attr{$name}{"switch_rfmode"} eq "1") { # do we need to change RFMode of IODev
  541. my $ret = CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "HomeMatic"));
  542. }
  543. }
  544. } else { # SIGNALduino
  545. my $SignalRepeats = AttrVal($name,'ITrepetition', '6');
  546. my $ITClock = AttrVal($name,'ITclock', undef);
  547. my $f = AttrVal($name,'ITfrequency',undef);
  548. my $ITfrequency = '';
  549. my $protocolId;
  550. if (defined($f)) {
  551. $f = $f / 26 * 65536;
  552. my $f2 = sprintf("%02x", $f / 65536);
  553. my $f1 = sprintf("%02x", int($f % 65536) / 256);
  554. my $f0 = sprintf("%02x", $f % 256);
  555. my $arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
  556. Log3 $hash, 3, "$io->{NAME} IT_set: Setting ITfrequency (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
  557. $ITfrequency = "#F$f2$f1$f0";
  558. }
  559. if (defined($ITClock)) {
  560. $ITClock = '#C' . $ITClock;
  561. } else {
  562. $ITClock = '';
  563. }
  564. $protocolId = AttrVal($name,'SIGNALduinoProtocolId', undef);
  565. if (defined($protocolId)) {
  566. $protocolId = 'P' . $protocolId . '#';
  567. } else {
  568. if ($hash->{READINGS}{protocol}{VAL} eq "V3") {
  569. $protocolId = 'P17#';
  570. } else {
  571. $protocolId = 'P3#'; # IT V1
  572. }
  573. }
  574. if ($hash->{READINGS}{protocol}{VAL} ne "EV1527" && $hash->{READINGS}{protocol}{VAL} ne "V1" && $hash->{READINGS}{protocol}{VAL} ne 'SBC_FreeTec') { # bei ITv1, SBC_FreeTec und EV1527 wird das "is" am Anfang nicht entfernt
  575. $message = substr($message,2);
  576. if (substr($message,0,1) eq "h") { # h entfernen falls am am Anfang
  577. $message = substr($message,1);
  578. }
  579. }
  580. Log3 $hash, 4, "$io->{NAME} IT_set: sendMsg=" . $protocolId . $message . '#R' . $SignalRepeats . $ITClock . $ITfrequency;
  581. IOWrite($hash, 'sendMsg', $protocolId . $message . '#R' . $SignalRepeats . $ITClock . $ITfrequency);
  582. }
  583. return $ret;
  584. }
  585. #############################
  586. sub
  587. IT_Define($$)
  588. {
  589. my ($hash, $def) = @_;
  590. my @a = split("[ \t][ \t]*", $def);
  591. # calculate transmit code from IT A-P rotary switches
  592. if($a[2] =~ /^([A-O])(([0]{0,1}[1-9])|(1[0-6]))$/i) {
  593. my %it_1st = (
  594. "A","0000","B","F000","C","0F00","D","FF00","E","00F0","F","F0F0",
  595. "G","0FF0","H","FFF0","I","000F","J","F00F","K","0F0F","L","FF0F",
  596. "M","00FF","N","F0FF","O","0FFF","P","FFFF"
  597. );
  598. my %it_2nd = (
  599. 1 ,"0000",2 ,"F000",3 ,"0F00",4 ,"FF00",5 ,"00F0",6 ,"F0F0",
  600. 7 ,"0FF0",8 ,"FFF0",9 ,"000F",10,"F00F",11,"0F0F",12,"FF0F",
  601. 13,"00FF",14,"F0FF",15,"0FFF",16,"FFFF"
  602. );
  603. $a[2] = $it_1st{$1}.$it_2nd{int($2)}."0F";
  604. defined $a[3] or $a[3] = "FF";
  605. defined $a[4] or $a[4] = "F0";
  606. defined $a[5] or $a[5] = "0F";
  607. defined $a[6] or $a[6] = "00";
  608. }
  609. # calculate transmit code from FLS 100 I,II,III,IV rotary switches
  610. if($a[2] =~ /^(I|II|III|IV)([1-4])$/i) {
  611. my %fls_1st = ("I","0FFF","II","F0FF","III","FF0F","IV","FFF0" );
  612. my %fls_2nd = (1 ,"0FFF",2 ,"F0FF",3 ,"FF0F",4 ,"FFF0");
  613. $a[2] = $fls_1st{$1}.$fls_2nd{int($2)}."0F";
  614. defined $a[3] or $a[3] = "FF";
  615. defined $a[4] or $a[4] = "F0";
  616. defined $a[5] or $a[5] = "0F";
  617. defined $a[6] or $a[6] = "00";
  618. }
  619. my $u = "wrong syntax: define <name> IT 10-bit-housecode " .
  620. "off-code on-code [dimup-code] [dimdown-code] or for protocol V3 " .
  621. "define <name> IT <26 bit Address> <1 bit group bit> <4 bit unit>";
  622. return $u if(int(@a) < 3);
  623. my $housecode;
  624. my $oncode;
  625. my $offcode;
  626. my $unitCode;
  627. my $groupBit;
  628. my $name = $a[0];
  629. if ($a[3] eq "HE800") {
  630. # OLD, do not use anymore
  631. $housecode = $a[2];
  632. $hash->{READINGS}{protocol}{VAL} = 'HE800';
  633. $hash->{"count"} = '0';
  634. $oncode = "N/A";
  635. $offcode = "N/A";
  636. $unitCode="N/A";
  637. #return "FALSE";
  638. } elsif ($a[2] eq "HE800") {
  639. $housecode = ($a[3] + 0) . "_" . ($a[4] + 0);
  640. $hash->{READINGS}{protocol}{VAL} = 'HE800';
  641. $hash->{"count"} = '0';
  642. $oncode = "N/A";
  643. $offcode = "N/A";
  644. $unitCode="N/A";
  645. #return "FALSE";
  646. } elsif (length($a[2]) == 26) {
  647. # Is Protocol V3
  648. return "Define $a[0]: wrong ITv3-Code format: specify a 26 digits 0/1 "
  649. if( ($a[2] !~ m/^[0-1]{26}$/i) );
  650. return "Define $a[0]: wrong Bit Group format: specify a 1 digits 0/1 "
  651. if( ($a[3] !~ m/^[0-1]{1}$/i) );
  652. return "Define $a[0]: wrong Unit format: specify 4 digits 0/1 "
  653. if( ($a[4] !~ m/^[0-1]{4}$/i) );
  654. #return "Define $a[0]: wrong on/off/dimm format: specify a 1 digits 0/1/d "
  655. # if( ($a[3] !~ m/^[d0-1]{1}$/i) );
  656. $housecode=$a[2].$a[3].$a[4];
  657. $groupBit=$a[3];
  658. $unitCode=$a[4];
  659. $oncode = 1;
  660. $offcode = 0;
  661. $hash->{READINGS}{protocol}{VAL} = 'V3';
  662. $hash->{READINGS}{unit}{VAL} = $unitCode;
  663. $hash->{READINGS}{group}{VAL} = $groupBit;
  664. } elsif (length($a[2]) == 46) { # HE_EU
  665. return "Define $a[0]: wrong IT-Code format: specify a 29 digits 0/1 "
  666. if( ($a[2] !~ m/^[0-1]{46}$/i) );
  667. return "Define $a[0]: wrong group format: specify a 1 digits 0/1 "
  668. if( ($a[3] !~ m/^[0-1]{1}$/i) );
  669. return "Define $a[0]: wrong unit format: specify a 7 digits 0/1 "
  670. if( ($a[4] !~ m/^[0-1]{7}$/i) );
  671. $housecode = $a[2].$a[4];
  672. $groupBit = $a[3];
  673. $unitCode=$a[4];
  674. if ($groupBit == "1") {
  675. # looks like a master key
  676. $hash->{READINGS}{mode}{VAL} = "master";
  677. $oncode = "01";
  678. $offcode = "00";
  679. } else {
  680. $hash->{READINGS}{mode}{VAL} = "single";
  681. $oncode = "10";
  682. $offcode = "01";
  683. }
  684. $hash->{READINGS}{unit}{VAL} = $unitCode;
  685. $hash->{READINGS}{protocol}{VAL} = 'HE_EU';
  686. } elsif (length($a[2]) == 10 && (substr($a[2],0,4) eq '1527' || AttrVal($name, "model", "") eq "ev1527" || length($a[3]) == 4)) {
  687. # Is Protocol EV1527
  688. #Log3 $hash,2,"ITdefine 1527: $name a3=" . $a[3];
  689. $housecode = $a[2];
  690. if (substr($housecode,0,4) eq '1527') {
  691. my $evcode;
  692. my $bincode = sprintf("%020b",hex(substr($housecode,5)));
  693. for (my $n=0; $n<20; $n=$n+2) {
  694. $evcode = $evcode . $bintotristate{substr($bincode,$n,2)};
  695. }
  696. $hash->{XMIT} = lc($evcode);
  697. } else {
  698. $hash->{XMIT} = lc($housecode);
  699. }
  700. return "Define $a[0]: wrong dimup-code format: specify a 4 digits 0/1 "
  701. if ( ($a[3] !~ m/^[0-1]{4}$/i) );
  702. return "Define $a[0]: wrong dimup-code format: specify a 4 digits 0/1 "
  703. if ( ($a[4] !~ m/^[0-1]{4}$/i) );
  704. $oncode = $a[3];
  705. $offcode = $a[4];
  706. $hash->{READINGS}{protocol}{VAL} = 'EV1527';
  707. } elsif (length($a[2]) == 8) { # SBC, FreeTec
  708. return "Define $a[0]: wrong IT-Code format: specify a 8 digits 0/1/f "
  709. if( ($a[2] !~ m/^[f0-1]{8}$/i) );
  710. return "Define $a[0]: wrong ON format: specify a 4 digits 0/1/f "
  711. if( ($a[3] !~ m/^[f0-1]{4}$/i) );
  712. return "Define $a[0]: wrong OFF format: specify a 4 digits 0/1/f "
  713. if( ($a[4] !~ m/^[f0-1]{4}$/i) );
  714. $housecode = $a[2];
  715. $oncode = $a[3];
  716. $offcode = $a[4];
  717. $hash->{READINGS}{protocol}{VAL} = 'SBC_FreeTec';
  718. } else {
  719. #Log3 $hash,2,"ITdefine v1: $name";
  720. return "Define $a[0]: wrong IT-Code format: specify a 10 digits 0/1/f "
  721. if( ($a[2] !~ m/^[f0-1]{10}$/i) );
  722. return "Define $a[0]: wrong ON format: specify a 2 digits 0/1/f/d "
  723. if( ($a[3] !~ m/^[df0-1]{2}$/i) );
  724. return "Define $a[0]: wrong OFF format: specify a 2 digits 0/1/f/d "
  725. if( ($a[4] !~ m/^[df0-1]{2}$/i) );
  726. $housecode = $a[2];
  727. $oncode = $a[3];
  728. $offcode = $a[4];
  729. $hash->{READINGS}{protocol}{VAL} = 'V1';
  730. }
  731. if ($hash->{READINGS}{protocol}{VAL} ne 'EV1527') {
  732. $hash->{XMIT} = lc($housecode);
  733. }
  734. $hash->{$it_c2b{"on"}} = lc($oncode);
  735. $hash->{$it_c2b{"off"}} = lc($offcode);
  736. if (int(@a) > 5) {
  737. if (length($a[5]) != 4) { # kein EV1527
  738. return "Define $a[0]: wrong dimup-code format: specify a 2 digits 0/1/f/d "
  739. if( ($a[5] !~ m/^[df0-1]{2}$/i) );
  740. } else {
  741. return "Define $a[0]: wrong dimup-code format: specify a 4 digits 0/1 "
  742. if( ($a[5] !~ m/^[0-1]{4}$/i) );
  743. }
  744. $hash->{$it_c2b{"dimup"}} = lc($a[5]);
  745. if (int(@a) == 7) {
  746. if (length($a[6]) != 4) { # kein EV1527
  747. return "Define $a[0]: wrong dimdown-code format: specify a 2 digits 0/1/f/d "
  748. if( ($a[6] !~ m/^[df0-1]{2}$/i) );
  749. } else {
  750. return "Define $a[0]: wrong dimup-code format: specify a 4 digits 0/1 "
  751. if( ($a[6] !~ m/^[0-1]{4}$/i) );
  752. }
  753. }
  754. $hash->{$it_c2b{"dimdown"}} = lc($a[6]);
  755. } else {
  756. $hash->{$it_c2b{"dimup"}} = "00";
  757. $hash->{$it_c2b{"dimdown"}} = "00";
  758. }
  759. my $code = lc($housecode);
  760. my $ncode = 1;
  761. $hash->{CODE}{$ncode++} = $code;
  762. $modules{IT}{defptr}{$code}{$name} = $hash;
  763. AssignIoPort($hash);
  764. }
  765. #############################
  766. sub
  767. IT_Undef($$)
  768. {
  769. my ($hash, $name) = @_;
  770. foreach my $c (keys %{ $hash->{CODE} } ) {
  771. $c = $hash->{CODE}{$c};
  772. # As after a rename the $name my be different from the $defptr{$c}{$n}
  773. # we look for the hash.
  774. foreach my $dname (keys %{ $modules{IT}{defptr}{$c} }) {
  775. delete($modules{IT}{defptr}{$c}{$dname})
  776. if($modules{IT}{defptr}{$c}{$dname} == $hash);
  777. }
  778. }
  779. return undef;
  780. }
  781. sub
  782. IT_Parse($$)
  783. {
  784. my ($hash, $msg) = @_;
  785. my $ioname = $hash->{NAME};
  786. my $housecode;
  787. my $transmittercode;
  788. my $dimCode;
  789. my $unitCode;
  790. my $groupBit;
  791. my $onoffcode;
  792. my $def;
  793. my $newstate;
  794. my @list;
  795. if ((substr($msg, 0, 1)) ne 'i') {
  796. Log3 $hash,4,"$ioname IT: message not supported by IT \"$msg\"!";
  797. return undef;
  798. }
  799. if (length($msg) != 7 && length($msg) != 12 && length($msg) != 17 && length($msg) != 19 && length($msg) != 20) {
  800. Log3 $hash,3,"$ioname IT: message \"$msg\" (" . length($msg) . ") too short!";
  801. return undef;
  802. }
  803. Log3 $hash,4,"$ioname IT: message \"$msg\" (" . length($msg) . ")";
  804. my $bin = undef;
  805. my $isDimMode = 0;
  806. if (length($msg) == 17) { # IT V3
  807. my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8)));
  808. while (length($bin1) < 32) {
  809. # suffix 0
  810. $bin1 = '0'.$bin1;
  811. }
  812. my $bin2=sprintf("%024b",hex(substr($msg,1+8,length($msg)-1)));
  813. while (length($bin2) < 32) {
  814. # suffix 0
  815. $bin2 = '0'.$bin2;
  816. }
  817. $bin = $bin1 . $bin2;
  818. Log3 $hash,4,"$ioname ITv3: bin message \"$bin\" (" . length($bin) . ")";
  819. } elsif (length($msg) == 19 ) { # IT V3 Dimm
  820. my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8-8)));
  821. while (length($bin1) < 32) {
  822. # suffix 0
  823. $bin1 = '0'.$bin1;
  824. }
  825. my $bin2=sprintf("%024b",hex(substr($msg,1+2,length($msg)-1-8-2)));
  826. while (length($bin2) < 32) {
  827. # suffix 0
  828. $bin2 = '0'.$bin2;
  829. }
  830. my $bin3=sprintf("%024b",hex(substr($msg,1+8+2,length($msg)-1)));
  831. while (length($bin3) < 32) {
  832. # suffix 0
  833. $bin3 = '0'.$bin3;
  834. }
  835. $bin = substr($bin1 . $bin2 . $bin3,24,length($bin1 . $bin2 . $bin3)-1);
  836. Log3 $hash,4,"$ioname ITv3dimm: bin message \"$bin\" (" . length($bin) . ")";
  837. } elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
  838. #Log3 undef,3,"HEX Part1: " . substr($msg,2,8);
  839. my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
  840. while (length($bin1) < 32) {
  841. # suffix 0
  842. $bin1 = '0'.$bin1;
  843. }
  844. #Log3 undef,3,"HEX Part2: " . substr($msg,2+8,7);
  845. my $bin2=sprintf("%024b",hex(substr($msg,2+8,7)));
  846. #$bin2 = substr($bin2,4);
  847. while (length($bin2) < 28) {
  848. # suffix 0
  849. $bin2 = '0'.$bin2;
  850. }
  851. $bin = $bin1 . $bin2;# . $bin3;
  852. } elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800
  853. my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
  854. while (length($bin1) < 32) {
  855. # suffix 0
  856. $bin1 = '0'.$bin1;
  857. }
  858. $bin = $bin1;# . $bin3;
  859. } else { # IT
  860. $bin=sprintf("%024b",hex(substr($msg,1,length($msg)-1)));
  861. }
  862. if ((length($bin) % 2) != 0) {
  863. # suffix 0
  864. $bin = '0'.$bin;
  865. }
  866. my $binorg = $bin;
  867. my $msgcode="";
  868. if (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800;
  869. $msgcode=substr($bin, 0, 28);
  870. } elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU;
  871. $msgcode=substr($bin, 0, 57);
  872. } else {
  873. while (length($bin)>=2) {
  874. if (length($msg) == 7) {
  875. if (substr($bin,0,2) != "10") {
  876. $msgcode=$msgcode.$bintotristate{substr($bin,0,2)};
  877. } else {
  878. if (length($msgcode) >= 10) {
  879. Log3 $hash,5,"$ioname IT Parse bintotristate: msgcode=$msgcode, unknown tristate in onoff-code. is evtl a EV1527 sensor";
  880. # $msgcode = substr($msgcode,0,10) . '00';
  881. $msgcode = substr($msgcode,0,10) . $bintotristate{substr($binorg,20,2)} . $bintotristate{substr($binorg,22,2)};
  882. } else {
  883. $msgcode = "";
  884. }
  885. last;
  886. #Log3 $hash,4,"$ioname IT:unknown tristate in \"$bin\"";
  887. #return "unknown tristate in \"$bin\""
  888. }
  889. } elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
  890. $msgcode=$msgcode.$bintotristateHE{substr($bin,0,2)};
  891. } else {
  892. $msgcode=$msgcode.$bintotristateV3{substr($bin,0,2)};
  893. }
  894. $bin=substr($bin,2,length($bin)-2);
  895. }
  896. }
  897. Log3 $hash,4,"$ioname IT: msgcode \"$msgcode\" (" . length($msgcode) . ") bin = $binorg";
  898. my $isEV1527 = undef;
  899. if (length($msg) == 7) {
  900. if ($msgcode) { # ITv1 or SBC_FreeTec
  901. my $sbcFreeTec = substr($msgcode,0,8);
  902. if (defined($modules{IT}{defptr}{lc("$sbcFreeTec")}) || substr($msg,6, 1) eq '0' && substr($msgcode,8,2) ne 'FF') { # SBC_FreeTec
  903. $housecode=$sbcFreeTec;
  904. $onoffcode=substr($msgcode,length($msgcode)-4,4);
  905. Log3 $hash,5,"$ioname IT: SBC_FreeTec housecode = $housecode onoffcode = $onoffcode";
  906. } else { # ITv1
  907. $housecode=substr($msgcode,0,10);
  908. $onoffcode=substr($msgcode,length($msgcode)-2,2);
  909. Log3 $hash,5,"$ioname IT: V1 housecode = $housecode onoffcode = $onoffcode";
  910. }
  911. } else {
  912. $isEV1527 = 1;
  913. $housecode = '1527x' . sprintf("%05x", oct("0b".substr($binorg,0,20)));
  914. $onoffcode = substr($binorg, 20);
  915. Log3 $hash,5,"$ioname IT: EV1527 housecode = $housecode onoffcode = $onoffcode";
  916. }
  917. } elsif (length($msg) == 17 || length($msg) == 19) {
  918. $groupBit=substr($msgcode,26,1);
  919. $onoffcode=substr($msgcode,27,1);
  920. $unitCode=substr($msgcode,28,4);
  921. $housecode=substr($msgcode,0,26).$groupBit.$unitCode;
  922. if (length($msg) == 19) {
  923. $dimCode=substr($msgcode,32,4);
  924. }
  925. } elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
  926. $onoffcode=substr($msgcode,46,2);
  927. $groupBit=substr($msgcode,48,2);
  928. $unitCode=substr($msgcode,50,7);
  929. $housecode=substr($msgcode,0,46).$unitCode;
  930. } elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800
  931. #$housecode=substr($msgcode,0,6).substr($msgcode,26,2);
  932. #$onoffcode=0;
  933. Log3 $hash,4,"$ioname IT: msg:" . $msg . " msgcode:" . substr($msg, 2, 8) ;
  934. my $msgVal = hex(substr($msg, 2, 8));
  935. my @mn;
  936. my $receiverID;
  937. my $mode;
  938. my @ikey = (5, 12, 6, 2, 8, 11, 1, 10, 3, 0, 4, 14, 7, 15, 9, 13); #invers cryptokey (exchanged index & value)
  939. Log3 $hash,4,"$ioname IT: HEX:" . $msg . " DEC:" . $msgVal ;
  940. $msgVal = ~($msgVal >> 4) & 0xFFFFFFF;
  941. Log3 $hash,4,"$ioname IT: DEC:" . $msgVal ;
  942. $msgVal = (($msgVal << 2) & 0x0FFFFFFF) | (($msgVal & 0xC000000) >> 0x1a); # shift 2 bits left & copy bit 27/28 to bit 1/2
  943. Log3 $hash,4,"$ioname IT: DEC:" . $msgVal ;
  944. $mn[0] = $msgVal & 0x0000000F;
  945. $mn[1] = ($msgVal & 0x000000F0) >> 0x4;
  946. $mn[2] = ($msgVal & 0x00000F00) >> 0x8;
  947. $mn[3] = ($msgVal & 0x0000F000) >> 0xc;
  948. $mn[4] = ($msgVal & 0x000F0000) >> 0x10;
  949. $mn[5] = ($msgVal & 0x00F00000) >> 0x14;
  950. $mn[6] = ($msgVal & 0x0F000000) >> 0x18;
  951. $mn[6] = $mn[6] ^ 9; # no decryption
  952. Log3 $hash,4,"$ioname IT: mn: @mn";
  953. # XOR decryption 2 rounds
  954. my $r = 0;
  955. for ($r=0; $r<=1; $r++){ # 2 decryption rounds
  956. my $i = 5;
  957. for ($i=5; $i>=1 ; $i--){ # decrypt 4 nibbles
  958. $mn[$i] = (($ikey[$mn[$i]]-$r) & 0x0F) ^ $mn[$i-1]; # decrypted with predecessor & key
  959. }
  960. $mn[0] = ($ikey[$mn[0]]-$r) & 0x0F; #decrypt first nibble
  961. }
  962. Log3 $hash,4,"$ioname IT: mn: @mn ";
  963. $receiverID = $mn[0];
  964. $mode = ((($mn[1]>>1) & 1) + ($mn[6] & 0x7) + (($mn[6] & 0x8) >> 3));
  965. my $rollingCode = ($mn[1] >> 2);
  966. my $transmitterID = (($mn[5] << 12) + ($mn[4] << 8) + ($mn[3] << 4) + $mn[2]);
  967. $housecode = $transmitterID . "_" . $receiverID;
  968. $transmittercode = $transmitterID;
  969. $unitCode = $receiverID;
  970. $onoffcode = $mode;
  971. Log3 $hash,4,"receiverID : " . $receiverID ; # receiver-ID [0]1..15, 0=Broadcast 1-15 (HE844A button# 1-4 & MASTER=0, HE850 UNIT# 1-15, HE853 = 1)
  972. Log3 $hash,4,"OFF/ON/DIM : " . $mode ; # 0=OFF 1=ON, 2=10%dim..9=80%dim (no 90%dim!)
  973. Log3 $hash,4,"Rolling-Code : " . $rollingCode ; # rolling-code 0-3 (differentiate new message from repeated message)
  974. Log3 $hash,4,"Transmitter-ID: " . $transmitterID ; # unique transmitter-ID [0]1..65535 (0 valid?, 65535 or lower limit?)
  975. } else {
  976. Log3 $hash,4,"$ioname IT: Wrong IT message received: $msgcode";
  977. return undef;
  978. }
  979. if(!defined($modules{IT}{defptr}{lc("$housecode")})) {
  980. if(length($msg) == 7) {
  981. Log3 $hash,4,"$ioname IT: $housecode not defined (Switch code: $onoffcode)";
  982. #return "$housecode not defined (Switch code: $onoffcode)!";
  983. my $tmpOffCode;
  984. my $tmpOnCode;
  985. if (!defined($isEV1527)) { # itv1
  986. if ($onoffcode eq "F0") { # on code IT
  987. Log3 $hash,3,"$ioname IT: For autocreate please use the on button.";
  988. return undef;
  989. }
  990. $tmpOffCode = "F0";
  991. $tmpOnCode = "0F";
  992. if ($onoffcode eq "FF") { # on code IT
  993. $tmpOnCode = "FF";
  994. }
  995. } else { # ev1527
  996. $tmpOffCode = $ev_action{'off'};
  997. #$tmpOnCode = $ev_action{'on'};
  998. $tmpOnCode = $onoffcode;
  999. }
  1000. if (length($housecode) == 8){
  1001. $tmpOffCode = '1000';
  1002. $tmpOnCode = '0100';
  1003. }
  1004. return "UNDEFINED IT_$housecode IT $housecode $tmpOnCode $tmpOffCode" if(!$def);
  1005. } elsif (length($msg) == 20) { # HE_EU
  1006. my $isGroupCode = '0';
  1007. if (($onoffcode == '01' && $groupBit == '01') || ($onoffcode == '00' && $groupBit == '11')) {
  1008. # Group Code found
  1009. $isGroupCode = '1';
  1010. }
  1011. Log3 $hash,2,"$ioname IT: $housecode not defined (Address: ".substr($msgcode,0,46)." Unit: $unitCode Switch code: $onoffcode GroupCode: $isGroupCode)";
  1012. #return "$housecode not defined (Address: ".substr($msgcode,0,26)." Group: $groupBit Unit: $unitCode Switch code: $onoffcode)!";
  1013. return "UNDEFINED IT_$housecode IT " . substr($msgcode,0,46) . " $isGroupCode $unitCode" if(!$def);
  1014. } elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HE800
  1015. Log3 $hash,2,"$ioname IT: $housecode not defined (HE800)";
  1016. return "UNDEFINED IT_HE800_$housecode IT " . "HE800 $transmittercode $unitCode" if(!$def);
  1017. } else {
  1018. my $hexCode = sprintf("%x", oct("0b".$housecode));
  1019. Log3 $hash,2,"$ioname IT: IT_V3_$hexCode ($housecode) not defined (Address: ".substr($msgcode,0,26)." Group: $groupBit Unit: $unitCode Switch code: $onoffcode)";
  1020. return "UNDEFINED IT_V3_$hexCode IT " . substr($msgcode,0,26) . " $groupBit $unitCode" if(!$def);
  1021. }
  1022. }
  1023. $def=$modules{IT}{defptr}{lc($housecode)};
  1024. #$lh->{"learn"} = 'ON';
  1025. foreach my $name (keys %{$def}) {
  1026. next if (IsIgnored($name));
  1027. if (length($msg) == 17 || length($msg) == 19) {
  1028. if ($def->{$name}->{READINGS}{group}{VAL} != $groupBit || $def->{$name}->{READINGS}{unit}{VAL} != $unitCode) {
  1029. next;
  1030. }
  1031. } elsif (length($msg) == 7 && !defined($isEV1527) && AttrVal($name, "model", "") eq "ev1527") {
  1032. $onoffcode = substr($binorg, 20);
  1033. $def->{$name}->{READINGS}{protocol}{VAL} = 'EV1527';
  1034. Log3 $hash,4,"$ioname IT EV1527: " . $def->{$name}{NAME} . ', on code=' . $def->{$name}->{$it_c2b{"on"}} . ", Switch code=$onoffcode";
  1035. }
  1036. if ($def->{$name}->{READINGS}{protocol}{VAL} eq 'HE800') {
  1037. my %he800MapingTable = (
  1038. 2 => 12,
  1039. 3 => 25,
  1040. 4 => 37,
  1041. 5 => 50,
  1042. 6 => 62,
  1043. 7 => 75,
  1044. 8 => 87,
  1045. 9 => 100,
  1046. );
  1047. if ($onoffcode == 0) {
  1048. # OFF
  1049. my $actState = $hash->{READINGS}{state}{VAL};
  1050. $newstate="off";
  1051. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1052. readingsSingleUpdate($def->{$name},"dim",0,1);
  1053. }
  1054. } elsif ($onoffcode == 1) {
  1055. # On
  1056. $newstate="on";
  1057. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1058. my $lastDimVal = $def->{$name}->{READINGS}{lastDimValue}{VAL};
  1059. if (defined $lastDimVal && $lastDimVal ne "") {
  1060. my $dperc = substr($lastDimVal, 3, -1);
  1061. readingsSingleUpdate($def->{$name},"dim",$dperc,1);
  1062. readingsSingleUpdate($def->{$name}, "lastDimValue", "",1);
  1063. } else {
  1064. readingsSingleUpdate($def->{$name},"dim",100,1);
  1065. }
  1066. }
  1067. } else {
  1068. my $binVal = $he800MapingTable{$onoffcode};
  1069. $binVal = int($binVal);
  1070. $newstate = sprintf("dim%02d%%",$binVal);
  1071. readingsSingleUpdate($def->{$name},"dim",$binVal,1);
  1072. readingsSingleUpdate($def->{$name}, "lastDimValue", $newstate,1);
  1073. Log3 $hash,4,"$ioname HE800: onoffcode $onoffcode newstate " . $newstate;
  1074. #if ($binVal == 100) {
  1075. # $newstate="on";
  1076. #} els
  1077. if ($binVal == 0) {
  1078. $newstate="off";
  1079. }
  1080. }
  1081. } elsif ($def->{$name}->{$it_c2b{"on"}} eq lc($onoffcode)) {
  1082. $newstate="on";
  1083. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1084. my $lastDimVal = $def->{$name}->{READINGS}{lastDimValue}{VAL};
  1085. if (defined $lastDimVal && $lastDimVal ne "") {
  1086. my $dperc = substr($lastDimVal, 3, -1);
  1087. readingsSingleUpdate($def->{$name},"dim",$dperc,1);
  1088. readingsSingleUpdate($def->{$name}, "lastDimValue", "",1);
  1089. } else {
  1090. readingsSingleUpdate($def->{$name},"dim",100,1);
  1091. }
  1092. }
  1093. } elsif ($def->{$name}->{$it_c2b{"off"}} eq lc($onoffcode)) {
  1094. $newstate="off";
  1095. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1096. readingsSingleUpdate($def->{$name},"dim",0,1);
  1097. }
  1098. } elsif ($def->{$name}->{$it_c2b{"dimup"}} eq lc($onoffcode)) {
  1099. $newstate="dimup";
  1100. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1101. readingsSingleUpdate($def->{$name},"dim","dimup",1);
  1102. }
  1103. } elsif ($def->{$name}->{$it_c2b{"dimdown"}} eq lc($onoffcode)) {
  1104. $newstate="dimdown";
  1105. if( AttrVal($name, "model", "") eq "itdimmer" ) {
  1106. readingsSingleUpdate($def->{$name},"dim","dimdown",1);
  1107. }
  1108. } elsif ('d' eq lc($onoffcode)) {
  1109. # dim
  1110. my $binVal = ((bin2dec($dimCode)+1)*100)/16;
  1111. $binVal = int($binVal);
  1112. $newstate = sprintf("dim%02d%%",$binVal);
  1113. readingsSingleUpdate($def->{$name},"dim",$binVal,1);
  1114. readingsSingleUpdate($def->{$name}, "lastDimValue", $newstate,1);
  1115. if ($binVal == 100) {
  1116. $newstate="on";
  1117. } elsif ($binVal == 0) {
  1118. $newstate="off";
  1119. }
  1120. } else {
  1121. Log3 $def->{$name}{NAME},3,"$ioname IT: Code $onoffcode not supported by $def->{$name}{NAME}.";
  1122. next;
  1123. }
  1124. Log3 $def->{$name}{NAME},3,"$ioname IT: $def->{$name}{NAME} ".$def->{$name}->{STATE}."->".$newstate;
  1125. push(@list,$def->{$name}{NAME});
  1126. readingsSingleUpdate($def->{$name},"state",$newstate,1);
  1127. }
  1128. return @list;
  1129. }
  1130. sub IT_Attr(@)
  1131. {
  1132. my ($cmd,$name,$aName,$aVal) = @_;
  1133. my $hash = $defs{$name};
  1134. my $ret;
  1135. #Log3 $hash, 4, "$name IT_Attr: Calling Getting Attr sub with args: $cmd $aName = $aVal";
  1136. if( $aName eq 'model' && $aVal eq 'ev1527') {
  1137. #Log3 $hash, 4, "$name IT_Attr: ev1527";
  1138. $hash->{READINGS}{protocol}{VAL} = 'EV1527';
  1139. } elsif ( $aName eq 'userV1setCodes') {
  1140. my @array = split(" ",$aVal);
  1141. $hash->{userV1setCodes} = undef;
  1142. foreach my $item(@array) {
  1143. my ($i,$j)= split(/:/, $item);
  1144. $ret = "$i wrong chars in setname (only [0-9a-zA-Z-_])"
  1145. if ( ($i !~ m/^[0-9a-z-_]+$/i) );
  1146. if (length($j) != 4) { # kein EV1527
  1147. $ret = "$j wrong setcode format: specify a 2 digits 0/1/f/d "
  1148. if( ($j !~ m/^[df0-1]{2}$/i) );
  1149. } else {
  1150. $ret = "$j wrong setcode format: specify a 4 digits 0/1 "
  1151. if( ($j !~ m/^[0-1]{4}$/i) );
  1152. }
  1153. last if (defined($ret));
  1154. $hash->{userV1setCodes}{$i} = $j;
  1155. }
  1156. }
  1157. return $ret;
  1158. }
  1159. 1;
  1160. =pod
  1161. =item summary supports Intertechno protocol version 1 and version 3 devices
  1162. =item summary_DE unterstuetzt Intertechno Protocol Version 1 und Version 3 Geraete
  1163. =begin html
  1164. <a name="IT"></a>
  1165. <h3>IT - InterTechno</h3>
  1166. <ul>
  1167. The InterTechno 433MHZ protocol is used by a wide range of devices, which are either of
  1168. the sender/sensor or the receiver/actuator category.
  1169. Momentarily, we are able to send and receive InterTechno commands.
  1170. Supported devices are switches, dimmers, etc. through an <a href="#CUL">CUL</a> or <a href="#SIGNALduino">SIGNALduino</a> device (this must be defined first).<br>
  1171. This module supports the version 1 and version 3 of the Intertechno protocol.
  1172. Newly found devices are added into the category "IT" by autocreate.
  1173. Hint: IT protocol 1 devices are only created when pressing the on-button twice within 30 seconds.
  1174. <br><br>
  1175. <a name="ITdefine"></a>
  1176. <b>Define</b>
  1177. <ul>
  1178. <code>define &lt;name&gt; IT &lt;housecode&gt; &lt;on-code&gt; &lt;off-code&gt;
  1179. [&lt;dimup-code&gt;] [&lt;dimdown-code&gt;] </code>
  1180. <br>or<br>
  1181. <code>define &lt;name&gt; IT &lt;ITRotarySwitches|FLS100RotarySwitches&gt; </code>
  1182. <br>or<br>
  1183. <code>define &lt;name&gt; IT &lt;address 26 Bit&gt; &lt;group bit&gt; &lt;unit Code&gt;</code>
  1184. <br>or<br>
  1185. <code>define &lt;name&gt; IT HE800 &lt;Transmitter ID&gt; &lt;Receiver ID&gt;</code>
  1186. <br><br>
  1187. The value of &lt;housecode&gt; is a 10-digit InterTechno Code, consisting of 0/1/F (co called tri-state format). These digits depend on the device you are using.
  1188. <br>
  1189. Bit 11 and 12 are used for switching/dimming. Different manufacturers are using
  1190. different bit-codes. You specifiy here the 2-digit code for off/on/dimup/dimdown
  1191. using the tri state format, i.e., 0/1/F.
  1192. <br>
  1193. The value of ITRotarySwitches consists of the value of the alpha switch A-P and
  1194. the numeric switch 1-16 as set on the intertechno device (for example A1 or G12). Please use the Wiki for more information how
  1195. to decode your device.
  1196. <br>
  1197. The value of FLS100RotarySwitches consist of the value of the I,II,II,IV switch
  1198. and the numeric 1,2,3,4 switch (for example I2 or IV4).
  1199. <br>
  1200. The value of ITRotarySwitches and FLS100RotarySwitches are internaly translated
  1201. into a houscode value.
  1202. <br>
  1203. For the Intertechno protocol 3 the housecode consists of 26 numbers. Additionally 4 numbers are used as unit code as well as
  1204. group code.
  1205. <br>
  1206. To add a new device in Fhem: define IT myITSwitch IT <Adresse 26 Bit> <Group bit> <Unit Code>
  1207. <br><br>
  1208. <b>Intertechno protocol 1 (ITv1)</b>
  1209. <ul>
  1210. <li><code>&lt;housecode&gt;</code> 10 numbers in tri state format (i.e., either 0/1/F) depending on the device.</li>
  1211. <li><code>&lt;on-code&gt; &lt;off-code&gt;</code> 2 numbers in quad state format (0/1/F/D), containing the on-format;
  1212. this number is added to the &lt;housecode&gt; to get the 12-number IT command that is acutally send.</li>
  1213. <li>optional <code>&lt;dimup-code&gt; &lt;dimdown-code&gt;</code> 2 numbers in quad state format (0/1/F/D),
  1214. contains the command for dimming;
  1215. this number is added to the &lt;housecode&gt; to define tha actual 12-number sending command.</li>
  1216. <li>Notice: orginal ITv1 devices are only defined using the on command.</li>
  1217. <li>Devices which are nt orignal ITv1 devices cen be defined as follows:</li><br>
  1218. To autocreate press twice "on" within 30 seconds. The Log gives:<br>
  1219. <code>2016.11.27 11:47:37.753 4: sduinoD IT: 001F001000 not defined (Switch code: <b>11</b>)</code><br>
  1220. <code>2016.11.27 11:47:37.755 2: autocreate: define IT_001F001000 IT 001F001000 0F F0</code><br><br>
  1221. Now press "off" or any other button:<br>
  1222. <code>2016.11.27 11:48:32.004 3: sduinoD IT: Code <b>1D</b> not supported by IT_001F001000.</code><br><br>
  1223. Because this is not original Intertechno, the on/off code in the list is not correct and has to be changed. This can be done as follows<br>
  1224. <code>DEF 001F001000 <b>11 1D</b></code><br><br>
  1225. <li> <b>EV1527</b></li>
  1226. If the housecode does not contain a valid (10) ITv1 tri state code, autocreate will define the deviceas EV1527.<br>
  1227. <code>&lt;housecode&gt;</code> 1527xabcde , abcde is the collected housecode in hex format<br>
  1228. <code>&lt;on-code&gt; &lt;off-code&gt;</code> 4 numbers bin number (0/1) containing the on command;
  1229. this number is added to the housecode to get the entire 12-number sending command.<br>
  1230. optional <code>&lt;dimup-code&gt; &lt;dimdown-code&gt;</code> 4 numbers in bin format (0/1),
  1231. contains the command for dimming up or down;
  1232. this number is added to the housecode to get the entire 12-number sending command.<br><br>
  1233. If the device was autocreated the on/off- as well as the dimcode has to be adapted.<br>
  1234. </ul>
  1235. <br>
  1236. <b>SBC_FreeTec</b><br>
  1237. <ul>
  1238. <li><code>&lt;housecode&gt;</code> 8 numbers in tri state format (0/1/F), depending from the used device.</li>
  1239. <li><code>&lt;on-code&gt;</code> 4 numbers in tri state format, contains the on-command;
  1240. this number is added to the housecode to form the 12-number sending command.</li>
  1241. <li><code>&lt;off-code&gt;</code> 4 numbers in tri state format, contains the off-command;
  1242. this number is added to the housecode to get the 12-number sending command.</li>
  1243. </ul>
  1244. <br>
  1245. <b>HE800</b><br>
  1246. <ul>
  1247. <li><code>&lt;Transmitter ID&gt;</code> unique transmitter ID (1..65535)</li>
  1248. <li><code>&lt;Receiver ID&gt;</code> receiver ID [0]1..15, 0=Broadcast 1-15 (HE844A button# 1-4 & MASTER=0, HE850 UNIT# 1-15, HE853 = 1)</li>
  1249. </ul>
  1250. <br>
  1251. Examples:
  1252. <ul>
  1253. <code>define lamp IT 01FF010101 11 00 01 10</code><br>
  1254. <code>define roll1 IT 111111111F 11 00 01 10</code><br>
  1255. <code>define otherlamp IT 000000000F 11 10 00 00</code><br>
  1256. <code>define otherroll1 IT FFFFFFF00F 11 10</code><br>
  1257. <code>define IT_1527xe0fec IT 1527xe0fec 1001 0000</code><br>
  1258. <code>define SBC_FreeTec_Steck1 IT FFF00FFF 000F 0000</code><br>
  1259. <code>define itswitch1 IT A1</code><br>
  1260. <code>define lamp IT J10</code><br>
  1261. <code>define flsswitch1 IT IV1</code><br>
  1262. <code>define lamp IT II2</code><br>
  1263. <code>define HE800_TID1_SW1 IT HE800 1 1</code><br>
  1264. </ul>
  1265. <br>
  1266. For Intertechno protocol 3 the &lt;housecode&gt; is a 26-digits number.
  1267. Additionaly there is a 4-digits &lt;unit code&gt; and a 1-digit &lt;group code&gt;.
  1268. <ul>
  1269. <li><code>&lt;address&gt;</code> is a 26 digit number (0/1)</li>
  1270. <li><code>&lt;group&gt;</code> is a 1 digit number (0/1)</li>
  1271. <li><code>&lt;unit&gt;</code> is a 4 digit number (0/1)</li>
  1272. </ul>
  1273. <br>
  1274. Examples:
  1275. <ul>
  1276. <code>define myITSwitch IT 00111100110101010110011111 0 0000</code>
  1277. </ul>
  1278. </ul>
  1279. <br>
  1280. <a name="ITset"></a>
  1281. <b>Set </b>
  1282. <ul>
  1283. <code>set &lt;name&gt; &lt;value&gt; [&lt;time&gt]</code>
  1284. <br><br>
  1285. where <code>value</code> is one of:<br>
  1286. <pre>
  1287. dimdown
  1288. dimup
  1289. off
  1290. on
  1291. on-till # Special, see the note
  1292. dim06% dim12% dim18% dim25% dim31% dim37% dim43% dim50%
  1293. dim56% dim62% dim68% dim75% dim81% dim87% dim93% dim100%<br>
  1294. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  1295. </pre>
  1296. Examples:
  1297. <ul>
  1298. <code>set lamp on</code><br>
  1299. <code>set lamp1,lamp2,lamp3 on</code><br>
  1300. <code>set lamp1-lamp3 on</code><br>
  1301. <code>set lamp off</code><br>
  1302. </ul>
  1303. <br>
  1304. Notes:
  1305. <ul>
  1306. <li>on-till requires an absolute time in the "at" format (HH:MM:SS, HH:MM
  1307. or { &lt;perl code&gt; }, where the perl-code returns a time specification).
  1308. If the current time is greater than the specified time, the
  1309. command is ignored, else an "on" command is generated, and for the
  1310. given "till-time" an off command is scheduleld via the at command.
  1311. </li>
  1312. </ul>
  1313. </ul>
  1314. <br>
  1315. <b>Get</b> <ul>N/A</ul><br>
  1316. <a name="ITattr"></a>
  1317. <b>Attributes</b>
  1318. <ul>
  1319. <a name="IODev"></a>
  1320. <li>IODev<br>
  1321. Set the IO device which will be used to send signals
  1322. for this device. An example for the physical device is a CUL or the SIGNALduino.
  1323. Note: On startup, fhem WILL NOT automatically assign an
  1324. IODevice to the Intertechno device! The attribute IODev needs ALLWAYS to be set manually!</li><br>
  1325. <a name="eventMap"></a>
  1326. <li>eventMap<br>
  1327. Replace event names and set arguments. The value of this attribute
  1328. consists of a list of space separated values. Each value is a colon
  1329. separated pair. The first part specifies the value to be replaced, the second
  1330. the new/desired value. In order to use spaces in the new/desired values it is necessary to inform Fhem about the new separating character. This is done by using a slash(/) or comma(,)
  1331. as first character, then the values are not separated by space but by this character.
  1332. Examples:
  1333. <ul><code>
  1334. attr store eventMap on:open off:closed<br>
  1335. attr store eventMap /on-for-timer 10:open/off:closed/<br>
  1336. set store open
  1337. </code></ul>
  1338. </li><br>
  1339. <li><a href="#do_not_notify">do_not_notify</a></li><br>
  1340. <a name="attrdummy"></a>
  1341. <li>dummy<br>
  1342. Set the device attribute dummy to define devices which should not
  1343. output any radio signals. Associated notifys will be executed if
  1344. the signal is received. Used e.g. to react to a code from a sender, but
  1345. it will not emit radio signal if triggered in the web frontend.
  1346. </li><br>
  1347. <li><a href="#loglevel">loglevel</a></li><br>
  1348. <li><a href="#showtime">showtime</a></li><br>
  1349. <li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
  1350. <a name="model"></a>
  1351. <li>model<br>
  1352. The model attribute denotes the type of the device.
  1353. This attribute will (currently) not be used by Fhem directly.
  1354. It can be used by e.g. external programs or web interfaces to
  1355. distinguish classes of devices and send the appropriate commands
  1356. (e.g. "on" or "off" to a switch, "dim..%" to dimmers etc.).
  1357. The spelling of the model should match the modelname used in the
  1358. documentation that comes which the device. The name should consist of
  1359. lower-case characters without spaces. Valid characters are
  1360. <code>a-z 0-9</code> and <code>-</code> (dash),
  1361. other characters should not be used. Here is a list of "official"
  1362. devices:<br>
  1363. <b>Sender/Sensor</b>: itremote<br>
  1364. <b>Dimmer</b>: itdimmer<br>
  1365. <b>Receiver/Actor</b>: itswitch<br>
  1366. <b>EV1527</b>: ev1527
  1367. </li><br>
  1368. <a name="ignore"></a>
  1369. <li>ignore<br>
  1370. Ignore this device, e.g., if it belongs to your neighbour. The device
  1371. will not trigger any FileLogs/notifys, issued commands will be silently
  1372. ignored (no RF signal will be sent out, just like for the <a
  1373. href="#attrdummy">dummy</a> attribute). The device will not appear in the
  1374. list command (only if it is explicitely asked for it), nor will it
  1375. be affected by commands which use wildcards or attributes as name specifiers
  1376. (see <a href="#devspec">devspec</a>). You still get them with the
  1377. "ignored=1" special devspec.
  1378. </li><br>
  1379. <a name="ITclock"></a>
  1380. <li>ITclock<br>
  1381. IT clock is the smallest time length of any pulse while sending the Intertechno V1 protocol.<br>
  1382. Any signal of the IT protocol typically consists of a sequence of HIGHs and LOWs with a particular time length. These lengths usually have a ratio of 1:3 (if, for example, LOW has a pulse length of X then HIGH has a pulse length of 3*X).<br>
  1383. The default value of original IT devices is 250. Other vendors use sometimes a different value; nevertheless ITclock should only be changed if you encounter problems using this device in Fhem.<br>
  1384. - In order to discover the correct ITclock using a SIGNALduino: After pressing a button at a remote the received raw signal can be found in the log as well as in the device view of the IT-device, for example<br>
  1385. MS;P0=357;P2=-1128;P3=1155;P4=-428;P5=-11420;D=05023402020202020202020202020202020202023402340234;CP=0;SP=5;<br>
  1386. The number after "CP=" shows the pattern number of the clock, so e.g. follows from CP=0 --> P0, which defines at the beginning of the message, hence the clock was 357 (microseconds).<br>
  1387. - at the CUL can the ITclock found out from the raw messages (X31).
  1388. </li><br>
  1389. <a name="ITfrequency"></a> </li>
  1390. <li>ITfrequency<br>
  1391. Sets the frequency of the sender.
  1392. </li><br>
  1393. <a name="ITrepetition"></a>
  1394. <li>ITrepetition<br>
  1395. Sets the number of repitions (default=6).
  1396. </li><br>
  1397. <a name="userV1setCodes"></a>
  1398. <li>userV1setCodes<br>
  1399. If an ITv1 protocol is used indivual setcodes can be added. Example:
  1400. <ul><code>
  1401. attr lamp userV1setCodes red:FD blue:1F<br>
  1402. attr lamp userV1setCodes up:1001 down:1000 stop:1011
  1403. </code></ul>
  1404. </li><br>
  1405. <a name="SIGNALduinoProtocolId"></a>
  1406. <li>SIGNALduinoProtocolId<br>
  1407. Using this attribute the protocol ID can be choosen if one uses a SIGNALduino.
  1408. </li><br>
  1409. </ul>
  1410. <br>
  1411. <a name="ITevents"></a>
  1412. <b>Generated events:</b>
  1413. <ul>
  1414. The IT device generates the following events.
  1415. <li>on</li>
  1416. <li>off</li>
  1417. <li>dimdown</li>
  1418. <li>dimup<br></li>
  1419. <li>dim06% dim12% dim18% dim25% dim31% dim37% dim43% dim50%<br>
  1420. dim56% dim62% dim68% dim75% dim81% dim87% dim93% dim100%<br></li>
  1421. Which event is sent dependents on the device and can sometimes configured on
  1422. the device.
  1423. </ul>
  1424. </ul>
  1425. =end html
  1426. =begin html_DE
  1427. <a name="IT"></a>
  1428. <h3>IT - InterTechno</h3>
  1429. <ul>
  1430. Das InterTechno 433MHZ Protokoll wird von einer Vielzahl von Ger&auml;ten
  1431. benutzt. Diese geh&ouml;ren entweder zur Kategorie Sender/Sensoren oder zur
  1432. Kategorie Empf&auml;nger/Aktoren. Es ist das Senden sowie das Empfangen von InterTechno
  1433. Befehlen m&ouml;glich. Ger&auml;ten k&ouml;tnnen z.B.
  1434. Schalter, Dimmer usw. sein.
  1435. Von diesem Modul wird sowohl das Protolkoll 1 sowie das Protokoll 3 unterst&uuml;tzt.
  1436. Neu empfangene Pakete werden per autocreate in Fhem unter der Kategorie IT angelegt.
  1437. Hinweis: F&uuml;r ein AutoCreate muss die Taste innerhalb von 30 Sek 2 mal gedr&uuml;ckt werden.
  1438. <br>
  1439. <br>
  1440. <a name="ITdefine"></a>
  1441. <b>Define</b>
  1442. <ul>
  1443. <code>define &lt;name&gt; IT &lt;housecode&gt; &lt;on-code&gt; &lt;off-code&gt;
  1444. [&lt;dimup-code&gt;] [&lt;dimdown-code&gt;] </code>
  1445. <br>oder<br>
  1446. <code>define &lt;name&gt; IT &lt;ITRotarySwitches|FLS100RotarySwitches&gt; </code>
  1447. <br>oder<br>
  1448. <code>define &lt;name&gt; IT &lt;Adresse 26 Bit&gt; &lt;Group bit&gt; &lt;Unit Code&gt;</code>
  1449. <br>oder<br>
  1450. <code>define &lt;name&gt; IT HE800 &lt;Transmitter ID&gt; &lt;Receiver ID&gt;</code>
  1451. <br><br>
  1452. Der Wert von Hauscode ist abh&auml;ngig vom verwendeten Ger&auml;t und besteht aus zehn Ziffern InterTechno-Code Protokoll 1.
  1453. Da dieser ein tri-State-Protokoll ist, k&ouml;nnen die Ziffern jeweils die Werte 0/1/F annehmen.
  1454. <br>
  1455. Bit 11/12 werden f&uuml;r Schalten oder Dimmen verwendet. Da die Hersteller verschiedene Codes verwenden, k&ouml;nnen hier die
  1456. (2-stelligen) Codes f&uuml;r an, aus, heller und dunkler (on/off/dimup/dimdown) als tri-State-Ziffern (0/1/F) festgelegt werden.
  1457. <br>
  1458. Der Wert des ITRotary-Schalters setzt sich aus dem Wert des Buchstaben-Schalters A-P und dem numerischen Schalter 1-16
  1459. des InterTechno-Ger&auml;tes zusammen, z.B. A1 oder G12.
  1460. <br>
  1461. Der Wert des FLS100Rotary-Schalters setzt sich aus dem Wert des Schalters I,II,II,IV und dem numerischen Schalter 1-4
  1462. des InterTechno-Ger&auml;tes zusammen, z.B. I2 oder IV4.
  1463. <br>
  1464. Die Werte der ITRotary-Schalter und FLS100Rotary-Schalter werden intern in Hauscode-Werte umgewandelt.
  1465. <br>
  1466. F&uuml;r Intertechno Protokoll 3 besteht der Hauscode aus 26 Ziffern. Zus&auml;tzlich werden noch 4 Ziffern als Unit Code sowie eine Ziffer als Group code ben&ouml;tigt.
  1467. <br>
  1468. Neues IT Element in FHEM anlegen: define IT myITSwitch IT <Adresse 26 Bit> <Group bit> <Unit Code>
  1469. <br><br>
  1470. <b>Intertechno Protokoll 1 (ITv1)</b>
  1471. <ul>
  1472. <li><code>&lt;housecode&gt;</code> 10 Ziffern lange tri-State-Zahl (0/1/F) abh&auml;ngig vom benutzten Ger&auml;t.</li>
  1473. <li><code>&lt;on-code&gt; &lt;off-code&gt;</code> jeweils 2 Ziffern lange quad-State-Zahl (0/1/F/D), die den Einschaltbefehl enth&auml;lt;
  1474. die Zahl wird an den &lt;housecode&gt; angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.</li>
  1475. <li>optional <code>&lt;dimup-code&gt; &lt;dimdown-code&gt;</code> jeweils 2 Ziffern lange quad-State-Zahl (0/1/F/D),
  1476. die den Befehl zum Herauf- und Herunterregeln enth&auml;lt;
  1477. die Zahl wird an den &lt;housecode&gt; angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.</li>
  1478. <li>Hinweis: orginal ITv1 devices werden nur beim on Befehl angelegt.</li>
  1479. <li>Die nicht orginal ITv1 devices k&ouml;nnen wie folgt angelegt werden:</li><br>
  1480. Zum anlegen mit autocreate 2 mal auf "on" dr&uuml;cken:<br>
  1481. <code>2016.11.27 11:47:37.753 4: sduinoD IT: 001F001000 not defined (Switch code: <b>11</b>)</code><br>
  1482. <code>2016.11.27 11:47:37.755 2: autocreate: define IT_001F001000 IT 001F001000 0F F0</code><br><br>
  1483. Nun auf "off" oder eine andere Taste dr&uuml;cken:<br>
  1484. <code>2016.11.27 11:48:32.004 3: sduinoD IT: Code <b>1D</b> not supported by IT_001F001000.</code><br><br>
  1485. Da dies keine orginal Intertechno Steckdose ist, passt der on/off code im define nicht und muss angepasst werden<br>
  1486. <code>DEF 001F001000 <b>11 1D</b></code><br><br>
  1487. <li> <b>EV1527</b></li>
  1488. Wenn im housecode ein nicht g&uuml;ltiger (10) ITv1 Tristatecode enthalten ist, dann wird es per autocreate als EV1527 angelegt.<br>
  1489. <code>&lt;housecode&gt;</code> 1527xabcde , abcde ist der empfangene housecode im Hex Format<br>
  1490. <code>&lt;on-code&gt; &lt;off-code&gt;</code> jeweils 4 Ziffern lange Bin Zahl (0/1), die den Einschaltbefehl enth&auml;lt;
  1491. die Zahl wird an den housecode angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.<br>
  1492. optional <code>&lt;dimup-code&gt; &lt;dimdown-code&gt;</code> jeweils 4 Ziffern lange Bin Zahl (0/1),
  1493. die den Befehl zum Herauf- und Herunterregeln enth&auml;lt;
  1494. die Zahl wird an den housecode angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.<br><br>
  1495. Nach dem anlegen per autocreate muss noch der on/off- und optional der dimcode beim define (DEF) angepasst werden.<br>
  1496. </ul>
  1497. <br>
  1498. <b>SBC_FreeTec</b><br>
  1499. <ul>
  1500. <li><code>&lt;housecode&gt;</code> 8 Ziffern lange tri-State-Zahl (0/1/F) abh&auml;ngig vom benutzten Ger&auml;t.</li>
  1501. <li><code>&lt;on-code&gt;</code> 4 Ziffern lange tri-State-Zahl, die den Einschaltbefehl enth&auml;lt;
  1502. die Zahl wird an den housecode angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.</li>
  1503. <li><code>&lt;off-code&gt;</code> 4 Ziffern lange tri-State-Zahl, die den Ausschaltbefehl enth&auml;lt;
  1504. die Zahl wird an den housecode angef&uuml;gt, um den 12-stelligen IT-Sendebefehl zu bilden.</li>
  1505. </ul>
  1506. <br>
  1507. <b>HE800</b><br>
  1508. <ul>
  1509. <li><code>&lt;Transmitter ID&gt;</code> Eindeutige Transmitter-ID (1..65535)</li>
  1510. <li><code>&lt;Receiver ID&gt;</code> Receiver-ID [0]1..15, 0=Broadcast 1-15 (HE844A button# 1-4 & MASTER=0, HE850 UNIT# 1-15, HE853 = 1)</li>
  1511. </ul>
  1512. <br>
  1513. Beispiele:
  1514. <ul>
  1515. <code>define lamp IT 01FF010101 11 00 01 10</code><br>
  1516. <code>define roll1 IT 111111111F 11 00 01 10</code><br>
  1517. <code>define otherlamp IT 000000000F 11 10 00 00</code><br>
  1518. <code>define otherroll1 IT FFFFFFF00F 11 10</code><br>
  1519. <code>define IT_1527xe0fec IT 1527xe0fec 1001 0000</code><br>
  1520. <code>define SBC_FreeTec_Steck1 IT FFF00FFF 000F 0000</code><br>
  1521. <code>define itswitch1 IT A1</code><br>
  1522. <code>define lamp IT J10</code><br>
  1523. <code>define flsswitch1 IT IV1</code><br>
  1524. <code>define lamp IT II2</code><br>
  1525. <code>define HE800_TID1_SW1 IT HE800 1 1</code><br>
  1526. </ul>
  1527. <br>
  1528. F&uuml;r <b>Intertechno Protokoll 3 (ITv3)</b> ist der &lt;housecode&gt; eine 26-stellige Zahl. Zus&auml;tzlich wird noch ein 1 stelliger Gruppen-Code, sowie
  1529. ein 4-stelliger &lt;unit code&gt; verwendet.
  1530. <ul>
  1531. <li><code>&lt;address&gt;</code> ist eine 26-stellige Nummer (0/1)</li>
  1532. <li><code>&lt;group&gt;</code> ist eine 1-stellige Nummer (0/1)</li>
  1533. <li><code>&lt;unit&gt;</code> ist eine 4-stellige Nummer (0/1)</li>
  1534. </ul>
  1535. <br>
  1536. Beispiele:
  1537. <ul>
  1538. <code>define myITSwitch IT 00111100110101010110011111 0 0000</code>
  1539. </ul>
  1540. </ul>
  1541. <br>
  1542. <a name="ITset"></a>
  1543. <b>Set </b>
  1544. <ul>
  1545. <code>set &lt;name&gt; &lt;value&gt; [&lt;time&gt]</code>
  1546. <br><br>
  1547. wobei <code>value</code> eines der folgenden Schl&uuml;sselw&ouml;rter ist:<br>
  1548. <pre>
  1549. dimdown
  1550. dimup
  1551. off
  1552. on
  1553. on-till # siehe Anmerkungen
  1554. <li>Die <a href="#setExtensions">set extensions</a> werden unterst&uuml;tzt.</li>
  1555. </pre>
  1556. Beispiele:
  1557. <ul>
  1558. <code>set lamp on</code><br>
  1559. <code>set lamp1,lamp2,lamp3 on</code><br>
  1560. <code>set lamp1-lamp3 on</code><br>
  1561. <code>set lamp off</code><br>
  1562. </ul>
  1563. <br>
  1564. Anmerkungen:
  1565. <ul>
  1566. <li>on-till erfordert eine Zeitangabe im "at"-Format (HH:MM:SS, HH:MM
  1567. oder { &lt;perl code&gt; }, wobei dieser Perl-Code eine Zeitangabe zur&uuml;ckgibt).
  1568. Ist die aktuelle Zeit gr&ouml;&szlig;er als die Zeitangabe, wird der Befehl verworfen,
  1569. andernfalls wird ein Einschaltbefehl gesendet und f&uuml;r die Zeitangabe ein
  1570. Ausschaltbefehl mittels "at"-Befehl angelegt.
  1571. </li>
  1572. </ul>
  1573. </ul>
  1574. <br>
  1575. <b>Get</b> <ul>N/A (nicht vorhanden)</ul><br>
  1576. <a name="ITattr"></a>
  1577. <b>Attributes</b>
  1578. <ul>
  1579. <a name="IODev"></a>
  1580. <li>IODev<br>
  1581. Spezifiziert das physische Ger&auml;t, das die Ausstrahlung der Befehle f&uuml;r das
  1582. "logische" Ger&auml;t ausf&uuml;hrt. Ein Beispiel f&uuml;r ein physisches Ger&auml;t ist ein CUL oder ein SIGNALduino.<br>
  1583. Anmerkung: Beim Start weist fhem einem InterTechno-Ger&auml;t kein IO-Ger&auml;t zu.
  1584. Das Attribut IODev ist daher IMMER zu setzen.</li><br>
  1585. <a name="eventMap"></a>
  1586. <li>eventMap<br>
  1587. Ersetzt Namen von Ereignissen (wie on und off) und set-Parametern. Die Liste besteht dabei
  1588. aus mit Doppelpunkt verbundenen Wertepaaren, die durch Leerzeichen getrennt
  1589. sind. Der erste Teil des Wertepaares ist der zu ersetzende Wert, der zweite der neue/gew&uuml;nschte Wert.
  1590. Man kann Leerzeichen innerhalb der neuen/gewünschten Werte verwenden, muss dann aber Fhem signalisieren, dass das die Werte nicht mehr durch Leerzeichen getrennt werden. Die geschieht, indem das erste Zeichen der Werteliste ein Komma (,) oder ein Schr&auml;gsstrich (/) wird. Dieses Komma bzw der Schrägstrich werden dann als Listenzeichen verwendet. Beispiele:
  1591. <ul><code>
  1592. attr store eventMap on:open off:closed<br>
  1593. attr store eventMap /on-for-timer 10:open/off:closed/<br>
  1594. set store open
  1595. </code></ul>
  1596. </li><br>
  1597. <li><a href="#do_not_notify">do_not_notify</a></li><br>
  1598. <a name="attrdummy"></a>
  1599. <li>dummy<br>
  1600. Mit der Eigenschaft dummy lassen sich Ger&auml;te definieren, die keine physikalischen Befehle
  1601. senden sollen. Verkn&uuml;pfte notifys werden trotzdem ausgef&uuml;hrt. Damit kann z.B. auf Sendebefehle
  1602. reagiert werden, die &uuml;ber die Weboberfl&auml;che ausgel&ouml;st wurden, ohne dass der Befehl physikalisch
  1603. gesendet wurde.
  1604. </li><br>
  1605. <li><a href="#loglevel">loglevel</a></li><br>
  1606. <li><a href="#showtime">showtime</a></li><br>
  1607. <li><a href="#readingFnAttributes">readingFnAttributes</a></li><br>
  1608. <a name="model"></a>
  1609. <li>model<br>
  1610. Hiermit kann das Modell des IT-Ger&auml;ts n&auml;her beschrieben werden. Diese
  1611. Eigenschaft wird (im Moment) nicht von Fhem ausgewertet.
  1612. Mit Hilfe dieser Information k&ouml;nnen externe Programme oder Web-Interfaces
  1613. Ger&auml;teklassen unterscheiden, um geeignete Kommandos zu senden (z.B. "on"
  1614. oder "off" an Schalter, aber "dim..%" an Dimmer usw.). Die Schreibweise
  1615. der Modellbezeichnung sollten der dem Ger&auml;t mitgelieferten Dokumentation
  1616. in Kleinbuchstaben ohne Leerzeichen entsprechen.
  1617. Andere Zeichen als <code>a-z 0-9</code> und <code>-</code> (Bindestrich)
  1618. sollten vermieden werden. Dies ist die Liste der "offiziellen" Modelltypen:<br>
  1619. <b>Sender/Sensor</b>: itremote<br>
  1620. <b>Dimmer</b>: itdimmer<br>
  1621. <b>Empf&auml;nger/Actor</b>: itswitch<br>
  1622. <b>EV1527</b>: ev1527
  1623. </li><br>
  1624. <a name="ignore"></a>
  1625. <li>ignore<br>
  1626. Durch das Setzen dieser Eigenschaft wird das Ger&auml;t nicht durch Fhem beachtet,
  1627. z.B. weil es einem Nachbarn geh&ouml;rt. Aktivit&auml;ten dieses Ger&auml;tes erzeugen weder
  1628. Log-Eintr&auml;ge noch reagieren notifys darauf, erzeugte Kommandos werden ignoriert
  1629. (wie bei Verwendung des Attributes <a href="#attrdummy">dummy</a> werden keine
  1630. Signale gesendet). Das Ger&auml;t ist weder in der Ausgabe des list-Befehls enthalten
  1631. (au&szlig;er es wird explizit aufgerufen), noch wird es bei Befehlen ber&uuml;cksichtigt,
  1632. die mit Platzhaltern in Namensangaben arbeiten (siehe <a href="#devspec">devspec</a>).
  1633. Sie werden weiterhin mit der speziellen devspec (Ger&auml;tebeschreibung) "ignored=1" gefunden.
  1634. </li><br>
  1635. <a name="ITclock"></a>
  1636. <li>ITclock<br>
  1637. ITclock ist die kleinste Basispulsl&auml;nge beim Senden des Intertechno V1 Protokolls.<br>
  1638. Ein Signal beim IT-Protokoll besteht immer aus einer Sequenz von HIGH und LOW, die mit einer bestimmten Pulsl&auml;nge gesendet werden. Typischerweise stehen die Pulsl&auml;ngen dabei im Verh&auml;ltnis 1:3 (also z.B. LOW=Basispulsl&auml;nge und HIGH=3*Basispulsl&auml;nge).<br>
  1639. Voreingestellt ist 250 für Original-IT-Ger&auml;te. Andere Hersteller verwenden manchmal andere Werte, dennoch sollte ITclock nur dann ver&auml;ndert werden, wenn es Probleme beim Schalten mit Fhem gibt. Achten Sie in dem Fall auch darauf, ob nicht vielleicht das Signal zu schwach ist oder gest&ouml;rt wird, um regelm&auml;ssig empfangen zu werden.<br>
  1640. - Hier ist eine Beschreibung für die Ermittlung des ITclock beim Signalduino: Nach Dr&uuml;cken einer Taste an der Fernbedienung steht die empfangene raw Nachricht im log und in der device-Ansicht des IT-device, also etwa<br>
  1641. MS;P0=357;P2=-1128;P3=1155;P4=-428;P5=-11420;D=05023402020202020202020202020202020202023402340234;CP=0;SP=5;<br>
  1642. Die Ziffer hinter "CP=" gibt die Pattern-Nr des clock an, also z.B. folgt aus CP=0 --> P0, das am Anfang der Nachricht definiert ist, hier ist also die clock 357.<br>
  1643. - Beim CUL kann die ITclock aus den raw Daten (X31) ermittelt werden.
  1644. </li><br>
  1645. <a name="ITfrequency"></a> </li>
  1646. <li>ITfrequency<br>
  1647. Setzt die Sendefrequenz.
  1648. </li><br>
  1649. <a name="ITrepetition"></a>
  1650. <li>ITrepetition<br>
  1651. Setzt die Sendewiederholungen (Default=6).
  1652. </li><br>
  1653. <a name="userV1setCodes"></a>
  1654. <li>userV1setCodes<br>
  1655. Damit k&ouml;nnen beim ITv1 Protokoll eigene setcodes zugef&uuml;gt werden. Beispiele:
  1656. <ul><code>
  1657. attr lamp userV1setCodes rot:FD blau:1F<br>
  1658. attr lamp userV1setCodes hoch:1001 runter:1000 stop:1011
  1659. </code></ul>
  1660. </li><br>
  1661. <a name="SIGNALduinoProtocolId"></a>
  1662. <li>SIGNALduinoProtocolId<br>
  1663. Damit kann beim Senden mit dem SIGNALduino eine Protocol-Id gew&auml;hlt werden.
  1664. </li><br>
  1665. </ul>
  1666. <br>
  1667. <a name="ITevents"></a>
  1668. <b>Erzeugte Ereignisse (Events):</b>
  1669. <ul>
  1670. Ein IT-Ger&auml;t kann folgende Ereignisse generieren:
  1671. <li>on</li>
  1672. <li>off</li>
  1673. <li>dimdown</li>
  1674. <li>dimup<br></li>
  1675. Welche Ereignisse erzeugt werden ist ger&auml;teabh&auml;ngig und kann evtl. eingestellt werden.
  1676. </ul>
  1677. </ul>
  1678. =end html_DE
  1679. =cut