89_HEATRONIC.pm 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  1. ###############################################################################
  2. # $Id: 89_HEATRONIC.pm 10358 2016-01-04 14:53:12Z heikoranft $
  3. ###############################################################################
  4. # This module is based on a work of Norbert S. described on
  5. # http://www.mikrocontroller.net/topic/317004
  6. #
  7. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. #
  15. ###############################################################################
  16. ###############################################################################
  17. # Changelog:
  18. #
  19. # 2014-06-10 initial version
  20. # 2014-06-10 wrong calculation of ch_Toutside
  21. # 2014-06-11 wrong calculation of sol_Tcylinder_bottom
  22. # 2014-06-11 logging telegram when error occurs
  23. # 2014-06-12 new telegrams found: 9000ff0000d3020000a600 / 9000ff0000d3010000aa00
  24. # 2014-06-12 documentation
  25. # 2014-06-13 new telegrams with unknown length 9900ff00...
  26. # 2014-06-14 disabled controller data with length 11 and 19
  27. # 2014-06-15 error in handling controller data
  28. # 2014-06-17 telegram length from 2014-06-13 determined: 9 Bytes, switching
  29. # heating mode (comfort, eco, frost) at specified time
  30. # 2014-06-22 new: sub HEATRONIC_TimeDiff, interval_ch_time,
  31. # interval_ch_Tflow_measured, interval_dhw_Tmeasured,
  32. # interval_dhw_Tcylinder, minDiff_ch_Tflow_measured
  33. # 2014-06-29 logging messages 9000ff00
  34. # 2014-07-03 found the reason for some weird controller data: the short message
  35. # with 9 Bytes accidentally has the correct CRC with length of 17 Bytes
  36. # -> fixed problem
  37. # 2016-01-03 implemented patch created by Norbert S. junky-zs@gmx.de
  38. # (thanks to Norbert)
  39. # new function 'HEATRONIC_Set'
  40. # new intenal functions 'WriteHC_Trequested', 'WriteHC_mode'
  41. # new: proxy server handling
  42. # fixed negative values of sol_Tcollector
  43. # 2016-01-03 new: ch_code
  44. # 2016-01-04 fixed bug in define
  45. # TODO:
  46. # - $debug
  47. # - $interval: time between messages in secs
  48. # - ersetzen -> $hash->{buffer} .= unpack('H*',$buf)
  49. # - Abfrage in der Form =~ "ff1002(.{4})(.*)1003(.{4})ff(.*)" ??
  50. # Problem: Erkennung anderer Längen
  51. # list of abbreviations:
  52. # ch = central heating
  53. # hc = heating circuit
  54. # dhw = domestic hot water
  55. # sol = solar
  56. # T = temperatur
  57. #### examples for fhem.cfg and using heater-set functionality ####
  58. #
  59. # define Betriebsart dummy
  60. # attr Betriebsart eventMap auto:auto comfort:heizen eco:sparen frost:frost
  61. # attr Betriebsart room Heiz-System
  62. # attr Betriebsart webCmd auto:comfort:eco:frost
  63. # define notify_Betriebsart notify Betriebsart {\
  64. # my $modus=Value("Betriebsart");; \
  65. # {fhem("set Heizung hc1_mode_requested $modus")};; \
  66. # }
  67. # define Heizen_Sollniveau dummy
  68. # attr Heizen_Sollniveau setList state:slider,10,0.5,30,1
  69. # attr Heizen_Sollniveau webCmd state
  70. # attr Heizen_Sollniveau room Heiz-System
  71. # define notify_Heizen_Sollniveau notify Heizen_Sollniveau {\
  72. # my $value=Value("Heizen_Sollniveau");; \
  73. # {fhem("set Heizung hc1_Trequested $value")};; \
  74. # }
  75. ####
  76. #
  77. package main;
  78. use strict;
  79. use warnings;
  80. use Time::HiRes qw(gettimeofday time);
  81. use IO::File;
  82. sub HEATRONIC_Initialize($);
  83. sub HEATRONIC_Define($$);
  84. sub HEATRONIC_Undef($$);
  85. #sub HEATRONIC_Attr(@);
  86. sub HEATRONIC_Read($);
  87. sub HEATRONIC_Set($@);
  88. sub HEATRONIC_WriteHC_Trequested($$);
  89. sub HEATRONIC_WriteHC_mode($$);
  90. sub HEATRONIC_DecodeMsg_CH1($$$);
  91. sub HEATRONIC_DecodeMsg_CH2($$$);
  92. sub HEATRONIC_DecodeMsg_HC($$$);
  93. sub HEATRONIC_DecodeMsg_DHW($$$);
  94. sub HEATRONIC_DecodeMsg_REQ($$$);
  95. sub HEATRONIC_DecodeMsg_DT($$$);
  96. sub HEATRONIC_DecodeMsg_SOL($$$);
  97. sub HEATRONIC_CRCtest($$$);
  98. sub HEATRONIC_CRCget($);
  99. sub HEATRONIC_timeDiff($);
  100. my @crc_table = qw( 0x00 0x02 0x04 0x06 0x08 0x0a 0x0c 0x0e 0x10 0x12 0x14 0x16 0x18 0x1a 0x1c 0x1e
  101. 0x20 0x22 0x24 0x26 0x28 0x2a 0x2c 0x2e 0x30 0x32 0x34 0x36 0x38 0x3a 0x3c 0x3e
  102. 0x40 0x42 0x44 0x46 0x48 0x4a 0x4c 0x4e 0x50 0x52 0x54 0x56 0x58 0x5a 0x5c 0x5e
  103. 0x60 0x62 0x64 0x66 0x68 0x6a 0x6c 0x6e 0x70 0x72 0x74 0x76 0x78 0x7a 0x7c 0x7e
  104. 0x80 0x82 0x84 0x86 0x88 0x8a 0x8c 0x8e 0x90 0x92 0x94 0x96 0x98 0x9a 0x9c 0x9e
  105. 0xa0 0xa2 0xa4 0xa6 0xa8 0xaa 0xac 0xae 0xb0 0xb2 0xb4 0xb6 0xb8 0xba 0xbc 0xbe
  106. 0xc0 0xc2 0xc4 0xc6 0xc8 0xca 0xcc 0xce 0xd0 0xd2 0xd4 0xd6 0xd8 0xda 0xdc 0xde
  107. 0xe0 0xe2 0xe4 0xe6 0xe8 0xea 0xec 0xee 0xf0 0xf2 0xf4 0xf6 0xf8 0xfa 0xfc 0xfe
  108. 0x19 0x1b 0x1d 0x1f 0x11 0x13 0x15 0x17 0x09 0x0b 0x0d 0x0f 0x01 0x03 0x05 0x07
  109. 0x39 0x3b 0x3d 0x3f 0x31 0x33 0x35 0x37 0x29 0x2b 0x2d 0x2f 0x21 0x23 0x25 0x27
  110. 0x59 0x5b 0x5d 0x5f 0x51 0x53 0x55 0x57 0x49 0x4b 0x4d 0x4f 0x41 0x43 0x45 0x47
  111. 0x79 0x7b 0x7d 0x7f 0x71 0x73 0x75 0x77 0x69 0x6b 0x6d 0x6f 0x61 0x63 0x65 0x67
  112. 0x99 0x9b 0x9d 0x9f 0x91 0x93 0x95 0x97 0x89 0x8b 0x8d 0x8f 0x81 0x83 0x85 0x87
  113. 0xb9 0xbb 0xbd 0xbf 0xb1 0xb3 0xb5 0xb7 0xa9 0xab 0xad 0xaf 0xa1 0xa3 0xa5 0xa7
  114. 0xd9 0xdb 0xdd 0xdf 0xd1 0xd3 0xd5 0xd7 0xc9 0xcb 0xcd 0xcf 0xc1 0xc3 0xc5 0xc7
  115. 0xf9 0xfb 0xfd 0xff 0xf1 0xf3 0xf5 0xf7 0xe9 0xeb 0xed 0xef 0xe1 0xe3 0xe5 0xe7 );
  116. my $buffer = "";
  117. my $fh;
  118. #my $debug;
  119. my $interval_ch_time;
  120. #define serial device (0) or proxy-server (1)
  121. my $PROXY_SERVER = 0;
  122. # set telegramms and values
  123. my %HEATRONIC_sets = (
  124. "hc1_mode_requested" => {OPT => ""}, # values are set in 'HEATRONIC_Initialize'
  125. "hc1_Trequested" => {OPT => ":slider,10,0.5,30,1"}, # min 10, 0.5 celsius stepwith, max 30 celsius
  126. );
  127. my %HEATRONIC_set_mode_requested = (
  128. "frost" => 1,
  129. "eco" => 2,
  130. "comfort" => 3,
  131. "auto" => 4
  132. );
  133. sub
  134. HEATRONIC_Initialize($)
  135. {
  136. my ($hash) = @_;
  137. require "$attr{global}{modpath}/FHEM/DevIo.pm";
  138. $hash->{DefFn} = "HEATRONIC_Define";
  139. $hash->{UndefFn} = "HEATRONIC_Undef";
  140. # $hash->{AttrFn} = "HEATRONIC_Attr";
  141. $hash->{ReadFn} = "HEATRONIC_Read";
  142. $hash->{SetFn} = "HEATRONIC_Set";
  143. $hash->{AttrList} =
  144. "do_not_notify:1,0 loglevel:0,1,2,3,4,5,6 "
  145. ."log88001800:0,1 "
  146. ."log88003400:0,1 "
  147. ."log9000FF00:0,1 "
  148. ."interval_ch_time:0,60,300,600,900,1800,3600,7200,43200,86400 "
  149. ."interval_ch_Tflow_measured:0,15,30,60,300,600,900,1800,3600,7200,43200,86400 "
  150. ."interval_dhw_Tmeasured:0,15,30,60,300,600,900,1800,3600,7200,43200,86400 "
  151. ."interval_dhw_Tcylinder:0,15,30,60,300,600,900,1800,3600,7200,43200,86400 "
  152. ."minDiff_ch_Tflow_measured:0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0 "
  153. ."binary_operation:OR,AND "
  154. . $readingFnAttributes;
  155. # set option-list
  156. my $optionList = join(",", sort keys %HEATRONIC_set_mode_requested);
  157. $HEATRONIC_sets{"hc1_mode_requested"}{OPT} = ":$optionList";
  158. }
  159. # if fmt =~"m/_betriebsart$/"
  160. #
  161. sub
  162. HEATRONIC_Define($$)
  163. {
  164. my ($hash, $def) = @_;
  165. my @a = split("[ \t][ \t]*", $def);
  166. if(@a != 3) {
  167. my $msg = "wrong syntax: define <name> HEATRONIC <devicename> or define <name> HEATRONIC <proxy-server IP-adr:port> ";
  168. Log3 $hash, 2, $msg;
  169. return $msg;
  170. }
  171. #Close Device to initialize properly
  172. if (index($a[2], ':') == -1) {
  173. delete $hash->{USBDev} if($hash->{USBDev});
  174. delete $hash->{FD};
  175. }
  176. else {
  177. ###proxy-server IP-adr and port found
  178. $PROXY_SERVER = 1;
  179. }
  180. DevIo_CloseDev($hash);
  181. my $name=$a[0];
  182. my $dev =$a[2];
  183. ###START###### Writing values to global hash ###############################################################START####
  184. $hash->{STATE} = "defined";
  185. $hash->{DeviceName} = $dev;
  186. $hash->{status}{FlagWritingSequence} = 0;
  187. ####END####### Writing values to global hash ################################################################END#####
  188. my $ret = DevIo_OpenDev($hash,0,"HEATRONIC_DoInit");
  189. # my $ret = DevIo_OpenDev($hash,0,0);
  190. $fh = IO::File->new("/opt/fhem/log/junkers.log",">");
  191. return $ret;
  192. }
  193. sub
  194. HEATRONIC_Undef($$)
  195. {
  196. my ( $hash, $arg ) = @_;
  197. my $name = $hash->{NAME};
  198. DevIo_CloseDev($hash);
  199. RemoveInternalTimer($hash);
  200. undef $fh;
  201. return undef;
  202. }
  203. sub
  204. HEATRONIC_DoInit($)
  205. {
  206. my ($hash) = @_;
  207. my $name = $hash->{NAME};
  208. if ($PROXY_SERVER == 1)
  209. {
  210. my $init = unpack('C/a', "\02RX");
  211. #Send 'RX'-client registration to proxy
  212. DevIo_SimpleWrite($hash, $init, 0);
  213. }
  214. $defs{$name}{STATE} = "initialized";
  215. return undef;
  216. }
  217. #sub
  218. #HEATRONIC_Attr(@)
  219. #{
  220. # my ($cmd, $name, $attrName, $attrVal) = @_;
  221. # my $hash = $defs{$name};
  222. # my $ret;
  223. #}
  224. sub
  225. HEATRONIC_Read($)
  226. {
  227. my $hash = shift;
  228. my $name = $hash->{NAME};
  229. my $x;
  230. my $value;
  231. my $length;
  232. my $position = 0;
  233. # $debug = AttrVal($name, "debug", 0);
  234. # $interval_ch_time = AttrVal($name, "interval_ch_time", undef);
  235. ############################
  236. # read data
  237. my $buf = DevIo_SimpleRead($hash);
  238. return if (!defined($buf));
  239. # $fh->print($buf);
  240. # $fh->flush();
  241. $buffer .= unpack('H*',$buf);
  242. #############################
  243. # parse messages
  244. # request data
  245. if ($buffer =~ "88000700")
  246. {
  247. $position = index($buffer,"88000700");
  248. $length = 21;
  249. if (length(substr($buffer,$position)) >= $length*2)
  250. {
  251. $value = HEATRONIC_DecodeMsg_REQ($hash,$buffer,$length);
  252. if (defined($value))
  253. {
  254. substr($buffer,$position,$length*2) = "";
  255. $buffer = "";
  256. }
  257. else
  258. {
  259. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'Request'";
  260. Log3 $name, 3, substr($buffer,$position,$length*2) . HEATRONIC_CRCget(substr($buffer,$position,$length*2));
  261. substr($buffer,$position,$length*2) = "";
  262. $buffer = "";
  263. }
  264. }
  265. }
  266. # vessel data
  267. elsif ($buffer =~ "88001800")
  268. {
  269. $position = index($buffer,"88001800");
  270. # 7D
  271. # if (length(substr($buffer,$position)) >= 32);
  272. # if (substr())
  273. $length = 33; # length 31 or 33 Bytes
  274. if (length(substr($buffer,$position)) >= $length*2)
  275. {
  276. $value = HEATRONIC_DecodeMsg_CH1($hash,substr($buffer,$position,$length*2),$length);
  277. if (!defined($value))
  278. {
  279. $length = 31;
  280. $value = HEATRONIC_DecodeMsg_CH1($hash,substr($buffer,$position,$length*2),$length);
  281. if (defined($value))
  282. {
  283. # nicht alles löschen, da Länge kleiner
  284. substr($buffer,$position,$length*2) = "";
  285. }
  286. else
  287. {
  288. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'vessal data'";
  289. Log3 $name, 3, substr($buffer,$position,$length*2) . HEATRONIC_CRCget(substr($buffer,$position,$length*2));
  290. Log3 $name, 3, substr($buffer,$position,33*2) . HEATRONIC_CRCget(substr($buffer,$position,33*2));
  291. substr($buffer,$position,$length*2) = "";
  292. $buffer = "";
  293. }
  294. }
  295. else
  296. {
  297. substr($buffer,$position,$length*2) = "";
  298. $buffer = "";
  299. }
  300. }
  301. }
  302. # heating circuit data
  303. elsif ($buffer =~ "88001900")
  304. {
  305. $position = index($buffer,"88001900");
  306. $length = 33;
  307. if (length(substr($buffer,$position)) >= $length*2)
  308. {
  309. # Bsp: 88 00 19 00 00 d1 80 00 80 00 00 00 00 00 00 01 fc 00 06 44 00 00 00 00 04 e0 00 01 d4 80 00 a0 00
  310. $value = HEATRONIC_DecodeMsg_CH2($hash,substr($buffer,$position,$length*2),$length);
  311. if (defined($value))
  312. {
  313. substr($buffer,$position,$length*2) = "";
  314. $buffer = "";
  315. }
  316. else
  317. {
  318. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'heating circuit data'";
  319. Log3 $name, 3, substr($buffer,$position,$length*2) . HEATRONIC_CRCget(substr($buffer,$position,$length*2));
  320. substr($buffer,$position,$length*2) = "";
  321. $buffer = "";
  322. }
  323. }
  324. }
  325. # domestic hot water data
  326. elsif ($buffer =~ "88003400")
  327. {
  328. $position = index($buffer,"88003400");
  329. # length 22, 23 or 25 Bytes
  330. $length = 25;
  331. if (length(substr($buffer,$position)) >= $length*2)
  332. {
  333. $value = HEATRONIC_DecodeMsg_DHW($hash,substr($buffer,$position,$length*2),$length);
  334. if (!defined($value))
  335. {
  336. $length = 23;
  337. $value = HEATRONIC_DecodeMsg_DHW($hash,substr($buffer,$position,$length*2),$length);
  338. if (!defined($value))
  339. {
  340. $length = 22;
  341. $value = HEATRONIC_DecodeMsg_DHW($hash,substr($buffer,$position,$length*2),$length);
  342. }
  343. }
  344. if(defined($value))
  345. {
  346. # don't delete everything because of different lengths
  347. substr($buffer,$position,$length*2) = "";
  348. }
  349. else
  350. {
  351. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'domestic hot water data'";
  352. Log3 $name, 3, substr($buffer,$position,25*2) . HEATRONIC_CRCget(substr($buffer,$position,25*2));
  353. substr($buffer,$position,$length*2) = "";
  354. }
  355. }
  356. }
  357. # date / time data
  358. elsif ($buffer =~ "90000600")
  359. {
  360. $position = index($buffer,"90000600");
  361. $length = 14;
  362. if (length(substr($buffer,$position)) >= $length*2)
  363. {
  364. $value = HEATRONIC_DecodeMsg_DT($hash,substr($buffer,$position,$length*2),$length);
  365. if (defined($value))
  366. {
  367. substr($buffer,$position,$length*2) = "";
  368. $buffer = "";
  369. }
  370. else
  371. {
  372. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'date / time data'";
  373. Log3 $name, 3, substr($buffer,$position,$length*2) . HEATRONIC_CRCget(substr($buffer,$position,$length*2));
  374. substr($buffer,$position,$length*2) = "";
  375. $buffer = "";
  376. }
  377. }
  378. }
  379. # controller data (FW1xy / FW2xy)
  380. elsif ($buffer =~ "9000ff00")
  381. {
  382. $position = index($buffer,"9000ff00");
  383. $length = 17;
  384. if (length(substr($buffer,$position)) >= $length*2)
  385. {
  386. my $logging = AttrVal($name, "log9000FF00", 0);
  387. $value = HEATRONIC_DecodeMsg_HC($hash,substr($buffer,$position,$length*2),$length);
  388. if (!defined($value))
  389. {
  390. # 9000ff0000d3020000a600 / 9000ff0000d3010000aa00
  391. # from 23:00 to 05:00 first value, second value otherwise
  392. $length = 11;
  393. $value = HEATRONIC_DecodeMsg_HC($hash,substr($buffer,$position,$length*2),$length);
  394. if (!defined($value))
  395. {
  396. # 2014-06-13 found new messages: 9000ff00006f02c4000, 9000ff00006f03c5000
  397. # at 22:00, 06:00
  398. $length = 9;
  399. $value = HEATRONIC_DecodeMsg_HC($hash,substr($buffer,$position,$length*2),$length);
  400. }
  401. }
  402. if ($logging == 1)
  403. {
  404. my $fh_logging = IO::File->new("/opt/fhem/log/j9000FF00.log",">>");
  405. $fh_logging->print(strftime("%Y-%m-%d %H:%M:%S",localtime()) . ": " . substr($buffer,$position,$length*2) . "\n");
  406. $fh_logging->flush();
  407. undef $fh_logging;
  408. }
  409. if (defined($value))
  410. {
  411. # don't delete everything because of different lengths
  412. substr($buffer,$position,$length*2) = "";
  413. }
  414. else
  415. {
  416. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'controller data'";
  417. Log3 $name, 3, substr($buffer,$position,17*2) . HEATRONIC_CRCget(substr($buffer,$position,17*2));
  418. substr($buffer,$position,$length*2) = "";
  419. }
  420. }
  421. }
  422. # Telegramm: Lastschaltmodul #1 (IPM)
  423. elsif ($buffer =~ "a000ff00")
  424. {
  425. }
  426. # Telegramm: Lastschaltmodul #2 (IPM)
  427. elsif ($buffer =~ "a100ff00")
  428. {
  429. }
  430. # solar data (ISM)
  431. elsif ($buffer =~ "b000ff00")
  432. {
  433. $position = index($buffer,"b000ff00");
  434. $length = 21;
  435. if (length(substr($buffer,$position)) >= $length*2)
  436. {
  437. $value = HEATRONIC_DecodeMsg_SOL($hash,substr($buffer,$position,$length*2),$length);
  438. if (defined($value))
  439. {
  440. substr($buffer,$position,$length*2) = "";
  441. $buffer = "";
  442. }
  443. else
  444. {
  445. Log3 $name, 3, "HEATRONIC error: Cannot handle message 'solar data'";
  446. Log3 $name, 3, substr($buffer,$position,$length*2) . HEATRONIC_CRCget(substr($buffer,$position,$length*2));
  447. substr($buffer,$position,$length*2) = "";
  448. $buffer = "";
  449. }
  450. }
  451. }
  452. }
  453. sub
  454. HEATRONIC_Set($@)
  455. {
  456. my ($hash, @a) = @_;
  457. my $name = $hash->{NAME};
  458. my $log_str="";
  459. my $call_rtn=0;
  460. return "\"set $name\" needs at least an argument" if(@a < 2);
  461. if(!defined($HEATRONIC_sets{$a[1]})) {
  462. my $msg = "";
  463. foreach my $para (sort keys %HEATRONIC_sets) {
  464. $msg .= " $para" . $HEATRONIC_sets{$para}{OPT};
  465. }
  466. return "Unknown argument $a[1], choose one of" . $msg;
  467. }
  468. my ($val, $numeric_val);
  469. # check available 'value' as parameter at first
  470. return "\"set $name $a[1]\" needs at least one parameter" if(@a < 2);
  471. $val = $a[2];
  472. $numeric_val = ($val =~ m/^[.0-9]+$/);
  473. if($a[1] =~ m/^hc.*Trequested$/) {
  474. $log_str = "Argument must be numeric (between 10 and 30)";
  475. # do error-handling if any
  476. Log3 ($name, 1, $log_str) if(!$numeric_val || $val < 10 || $val > 30);
  477. return $log_str if(!$numeric_val || $val < 10 || $val > 30);
  478. # execute command
  479. $val *= 2;
  480. $call_rtn = HEATRONIC_WriteHC_Trequested($hash, $val);
  481. if ($call_rtn == 0) {
  482. # repeat one time if failed
  483. $call_rtn = HEATRONIC_WriteHC_Trequested($hash, $val);
  484. }
  485. # log command
  486. $log_str = "HEATRONIC_WriteHC_Trequested".$a[2]." using value:".$val." success:".$call_rtn;
  487. Log3 ($name, 5, $log_str);
  488. }
  489. elsif($a[1] =~ m/_mode_requested/) {
  490. $val = $HEATRONIC_set_mode_requested{$val};
  491. $log_str = "Unknown parameter for $a[1], use one of ".join(" ", sort keys %HEATRONIC_set_mode_requested);
  492. # do error-handling if any
  493. Log3 ($name, 1, $log_str) if(!defined($val));
  494. return $log_str if(!defined($val));
  495. # execute command
  496. $call_rtn = HEATRONIC_WriteHC_mode($hash, $val);
  497. if ($call_rtn == 0) {
  498. # repeat one time if failed
  499. $call_rtn = HEATRONIC_WriteHC_mode($hash, $val);
  500. }
  501. # log command
  502. $log_str = "HEATRONIC_WriteHC_mode:".$a[2]." using value:".$val." success:".$call_rtn;
  503. Log3 ($name, 5, $log_str);
  504. }
  505. else {
  506. Log3 $name, 3, "HEATRONIC_Set error: Cannot handle parameter";
  507. return "HEATRONIC_Set error: Cannot handle parameter";
  508. }
  509. }
  510. sub
  511. HEATRONIC_WriteHC_Trequested($$)
  512. {
  513. my ($hash, $trequested) = @_;
  514. my $name = $hash->{NAME};
  515. if (!defined($hash)) {
  516. return undef;
  517. }
  518. # do not write if flag is set
  519. if ($hash->{status}{FlagWritingSequence} == 1) {
  520. return 0;
  521. }
  522. $hash->{status}{FlagWritingSequence} = 1;
  523. ## send 1. netcom-bytes to 'ht_pitiny' | 'ht_piduino' (ht_transceiver)
  524. # header= '#', <length> ,'!' ,'S' ,0x11
  525. # header= 0x23,(len(data)+3),0x21,0x53,0x11
  526. # data = 0x10,0xff,0x11,0x00,0x65,tsoll
  527. # block=header+data
  528. my $block1 = "230921531110FF110065" . sprintf("%02x",$trequested);
  529. DevIo_SimpleWrite($hash, $block1, 1);
  530. ## send 2. netcom-bytes to 'ht_pitiny' | 'ht_piduino' (ht_transceiver)
  531. # header= 0x23,(len(data)+3),0x21,0x53,0x11
  532. # data = 0x10,0xff,0x07,0x00,0x79,tsoll
  533. # block=header+data
  534. my $block2 = "230921531110FF070079" . sprintf("%02x",$trequested);
  535. DevIo_SimpleWrite($hash, $block2, 1);
  536. $hash->{status}{FlagWritingSequence} = 0;
  537. return 1;
  538. }
  539. sub
  540. HEATRONIC_WriteHC_mode($$)
  541. {
  542. my ($hash, $mode_requested) = @_;
  543. my $name = $hash->{NAME};
  544. if (!defined($hash)) {
  545. return undef;
  546. }
  547. # do not write if flag is set
  548. if ($hash->{status}{FlagWritingSequence} == 1) {
  549. return 0;
  550. }
  551. $hash->{status}{FlagWritingSequence} = 1;
  552. ## send 1. netcom-bytes to 'ht_pitiny' | 'ht_piduino' (ht_transceiver)
  553. # header= '#', <length> ,'!' ,'S' ,0x11
  554. # header= 0x23,(len(data)+3),0x21,0x53,0x11
  555. # data = 0x10,0xff,0x0e,0x00,0x65,mode_requested
  556. # block=header+data
  557. my $block1 = "230921531110FF0E0065" . sprintf("%02x",$mode_requested);
  558. DevIo_SimpleWrite($hash, $block1, 1);
  559. ## send 2. netcom-bytes to 'ht_pitiny' | 'ht_piduino' (ht_transceiver)
  560. # header= 0x23,(len(data)+3),0x21,0x53,0x11
  561. # data = 0x10,0xff,0x04,0x00,0x79,mode_requested
  562. # block=header+data
  563. my $block2 = "230921531110FF040079" . sprintf("%02x",$mode_requested);
  564. DevIo_SimpleWrite($hash, $block2, 1);
  565. $hash->{status}{FlagWritingSequence} = 0;
  566. return 1;
  567. }
  568. sub
  569. HEATRONIC_DecodeMsg_CH1($$$)
  570. {
  571. my ($hash,$string,$length) = @_;
  572. my $name = $hash->{NAME};
  573. if (defined(HEATRONIC_CRCtest($hash,$string,$length)))
  574. {
  575. my $ch_Tflow_desired = hex(substr($string,4*2,2));
  576. my $ch_Tflow_measured = hex(substr($string,5*2,4))/10;
  577. my $ch_Treturn = hex(substr($string,17*2,4))/10;
  578. my $ch_Tmixer = hex(substr($string,13*2,4))/10;
  579. my $ch_burner_power = hex(substr($string,8*2,2));
  580. my $ch_burner_operation = (hex(substr($string,9*2,2)) & 0x08) ? 1 : 0;
  581. my $ch_pump_heating = (hex(substr($string,11*2,2)) & 0x20) ? 1 : 0;
  582. my $ch_pump_cylinder = (hex(substr($string,11*2,2)) & 0x40) ? 1 : 0;
  583. my $ch_pump_circulation = (hex(substr($string,11*2,2)) & 0x80) ? 1 : 0;
  584. my $ch_burner_fan = (hex(substr($string,11*2,2)) & 0x01) ? 1 : 0;
  585. my $ch_mode = (hex(substr($string,9*2,2)) & 0x03);
  586. my $ch_code = hex(substr($string,24*2,4));
  587. my $ch_22_num = hex(substr($string,22*2,2));
  588. my $ch_23_num = hex(substr($string,23*2,2));
  589. my $ch_22_char = ($ch_22_num == 0) ? "0" : chr($ch_22_num);
  590. my $ch_23_char = ($ch_23_num == 0) ? "0" : chr($ch_23_num);
  591. my $ch_error = $ch_22_char . $ch_23_char;
  592. my $ch_Tflow_measuredTS = ReadingsTimestamp( $name, "ch_Tflow_measured", undef );
  593. my $interval_ch_Tflow_measured = AttrVal($name, "interval_ch_Tflow_measured", -1);
  594. my $minDiff_ch_Tflow_measured = AttrVal($name, "minDiff_ch_Tflow_measured", 0);
  595. my $ch_Tflow_measuredOldVal = ReadingsVal( $name, "ch_Tflow_measured",0);
  596. readingsBeginUpdate($hash);
  597. readingsBulkUpdate($hash, "ch_Tflow_desired", $ch_Tflow_desired);
  598. if (!defined($ch_Tflow_measuredTS))
  599. {
  600. $interval_ch_Tflow_measured = -1;
  601. }
  602. if ($interval_ch_Tflow_measured != 0 )
  603. {
  604. if (($interval_ch_Tflow_measured > 0) && (HEATRONIC_timeDiff($ch_Tflow_measuredTS) >= $interval_ch_Tflow_measured) || $interval_ch_Tflow_measured == -1)
  605. {
  606. if (abs($ch_Tflow_measuredOldVal-$ch_Tflow_measured) >= $minDiff_ch_Tflow_measured)
  607. {
  608. readingsBulkUpdate($hash, "ch_Tflow_measured", sprintf("%.1f",$ch_Tflow_measured));
  609. }
  610. }
  611. }
  612. readingsBulkUpdate($hash, "ch_Treturn", ($ch_Treturn*10 == 0x8000) ? "0.0" : sprintf("%.1f",$ch_Treturn));
  613. readingsBulkUpdate($hash, "ch_Tmixer", ($ch_Tmixer*10 == 0x8000) ? "0.0" : sprintf("%.1f", $ch_Tmixer));
  614. readingsBulkUpdate($hash, "ch_mode", $ch_mode);
  615. readingsBulkUpdate($hash, "ch_burner_fan", $ch_burner_fan);
  616. readingsBulkUpdate($hash, "ch_burner_operation", $ch_burner_operation);
  617. readingsBulkUpdate($hash, "ch_pump_heating", $ch_pump_heating);
  618. readingsBulkUpdate($hash, "ch_pump_cylinder", $ch_pump_cylinder);
  619. readingsBulkUpdate($hash, "ch_pump_circulation", $ch_pump_circulation);
  620. readingsBulkUpdate($hash, "ch_burner_power", $ch_burner_power);
  621. readingsBulkUpdate($hash, "ch_code", $ch_code);
  622. readingsBulkUpdate($hash, "ch_error", $ch_error);
  623. readingsEndUpdate($hash,1);
  624. return 1;
  625. }
  626. else
  627. {
  628. return undef;
  629. }
  630. }
  631. sub
  632. HEATRONIC_DecodeMsg_CH2($$$)
  633. {
  634. my ($hash,$string,$length) = @_;
  635. my $name = $hash->{NAME};
  636. if (defined(HEATRONIC_CRCtest($hash,$string, $length)))
  637. {
  638. my $ch_Toutside = hex(substr($string,4*2,2));
  639. if ($ch_Toutside != 255) { $ch_Toutside = ($ch_Toutside * 256 + hex(substr($string,5*2,2))) / 10 }
  640. else {$ch_Toutside = (255 - hex(substr($string,5*2,2)))/-10;}
  641. my $ch_runtime_tot = hex(substr($string,17*2,6));
  642. my $ch_runtime_ch = hex(substr($string,23*2,6));
  643. my $ch_starts_tot = hex(substr($string,14*2,6));
  644. my $ch_starts_ch = hex(substr($string,26*2,6));
  645. my $ch_pump_heating_power = hex(substr($string,13*2,2));
  646. readingsBeginUpdate($hash);
  647. readingsBulkUpdate($hash, "ch_Toutside", sprintf("%.1f",$ch_Toutside));
  648. readingsBulkUpdate($hash, "ch_runtime_tot", $ch_runtime_tot);
  649. readingsBulkUpdate($hash, "ch_runtime_ch", $ch_runtime_ch);
  650. readingsBulkUpdate($hash, "ch_starts_tot", $ch_starts_tot);
  651. readingsBulkUpdate($hash, "ch_starts_ch", $ch_starts_ch);
  652. readingsBulkUpdate($hash, "ch_pump_heating_power", $ch_pump_heating_power);
  653. readingsEndUpdate($hash,1);
  654. return 1;
  655. }
  656. else
  657. {
  658. return undef;
  659. }
  660. }
  661. sub
  662. HEATRONIC_DecodeMsg_HC($$$)
  663. {
  664. my ($hash,$string,$length) = @_;
  665. my $name = $hash->{NAME};
  666. my $type;
  667. my $prefix = "hc1_";
  668. my $hc_Tdesired;
  669. my $hc_Tmeasured;
  670. if (defined(HEATRONIC_CRCtest($hash,$string, $length)))
  671. {
  672. # Messages of length 11 Bytes are unknown -> no handling
  673. if ($length == 11)
  674. { return 1; }
  675. $type = hex(substr($string,5*2,2));
  676. if ($type == 111) { $prefix = "hc1_";}
  677. elsif($type == 112) { $prefix = "hc2_"; }
  678. elsif($type == 114) { $prefix = "hc3_"; }
  679. elsif($type == 116) { $prefix = "hc4_"; }
  680. elsif($type == 211) { return 1; }
  681. if ($length != 9)
  682. {
  683. $hc_Tdesired = hex(substr($string,8*2,4))/10;
  684. $hc_Tmeasured = hex(substr($string,10*2,4))/10;
  685. }
  686. my $hc_mode = hex(substr($string,6*2,2));
  687. readingsBeginUpdate($hash);
  688. if ($length != 9)
  689. {
  690. readingsBulkUpdate($hash, $prefix . "Tdesired", sprintf("%.1f",$hc_Tdesired));
  691. readingsBulkUpdate($hash, $prefix . "Tmeasured", sprintf("%.1f",$hc_Tmeasured));
  692. }
  693. readingsBulkUpdate($hash, $prefix . "mode", $hc_mode);
  694. readingsEndUpdate($hash,1);
  695. return 1;
  696. }
  697. else
  698. {
  699. return undef;
  700. }
  701. }
  702. sub
  703. HEATRONIC_DecodeMsg_DHW($$$)
  704. {
  705. my ($hash,$string,$length) = @_;
  706. my $name = $hash->{NAME};
  707. if (defined(HEATRONIC_CRCtest($hash,$string, $length)))
  708. {
  709. my $dhw_Tdesired = hex(substr($string,4*2,2));
  710. my $dhw_Tmeasured = hex(substr($string,5*2,4))/10;
  711. my $dhw_Tcylinder = hex(substr($string,7*2,4))/10;
  712. my $ch_runtime_dhw = hex(substr($string,14*2,6));
  713. my $ch_starts_dhw = hex(substr($string,17*2,6));
  714. my $dhw_charge_once = (hex(substr($string,9*2,2)) & 0x02) ? 1 : 0;
  715. my $dhw_thermal_desinfection = (hex(substr($string,9*2,2)) & 0x04) ? 1 : 0;
  716. my $dhw_generating = (hex(substr($string,9*2,2)) & 0x08) ? 1 : 0;
  717. my $dhw_boost_charge = (hex(substr($string,9*2,2)) & 0x10) ? 1 : 0;
  718. my $dhw_Tok = (hex(substr($string,9*2,2)) & 0x20) ? 1 : 0;
  719. my $dhw_TmeasuredTS = ReadingsTimestamp( $name, "dhw_Tmeasured", undef );
  720. my $interval_dhw_Tmeasured = AttrVal($name, "interval_dhw_Tmeasured", -1);
  721. my $dhw_TcylinderTS = ReadingsTimestamp( $name, "dhw_Tcylinder", undef );
  722. my $interval_dhw_Tcylinder = AttrVal($name, "interval_dhw_Tcylinder", -1);
  723. readingsBeginUpdate($hash);
  724. readingsBulkUpdate($hash, "dhw_Tdesired", $dhw_Tdesired);
  725. if (!defined($dhw_TmeasuredTS))
  726. {
  727. $interval_dhw_Tmeasured = -1;
  728. }
  729. if ($interval_dhw_Tmeasured != 0)
  730. {
  731. if (($interval_dhw_Tmeasured > 0) && (HEATRONIC_timeDiff($dhw_TmeasuredTS) >= $interval_dhw_Tmeasured) || $interval_dhw_Tmeasured == -1)
  732. {
  733. readingsBulkUpdate($hash, "dhw_Tmeasured", sprintf("%.1f",$dhw_Tmeasured));
  734. }
  735. }
  736. if (!defined($dhw_Tcylinder))
  737. {
  738. $interval_dhw_Tcylinder = -1;
  739. }
  740. if ($interval_dhw_Tcylinder != 0)
  741. {
  742. if (($interval_dhw_Tcylinder > 0) && (HEATRONIC_timeDiff($dhw_TcylinderTS) >= $interval_dhw_Tcylinder) || $interval_dhw_Tcylinder == -1)
  743. {
  744. readingsBulkUpdate($hash, "dhw_Tcylinder", sprintf("%.1f",$dhw_Tcylinder));
  745. }
  746. }
  747. readingsBulkUpdate($hash, "ch_runtime_dhw", $ch_runtime_dhw);
  748. readingsBulkUpdate($hash, "ch_starts_dhw", $ch_starts_dhw);
  749. readingsEndUpdate($hash,1);
  750. return 1;
  751. }
  752. else
  753. {
  754. return undef;
  755. }
  756. }
  757. sub
  758. HEATRONIC_DecodeMsg_REQ($$$)
  759. {
  760. my ($hash,$string,$length) = @_;
  761. return 1;
  762. }
  763. sub
  764. HEATRONIC_DecodeMsg_DT($$$)
  765. {
  766. my ($hash,$string,$length) = @_;
  767. my $name = $hash->{NAME};
  768. my $ch_timeTS = ReadingsTimestamp( $name, "ch_time", undef );
  769. my $interval_ch_time = AttrVal($name, "interval_ch_time", -1);
  770. if (defined(HEATRONIC_CRCtest($hash,$string,$length)))
  771. {
  772. my $year = 2000 + hex(substr($string,4*2,2));
  773. my $month = hex(substr($string,5*2,2));
  774. my $day = hex(substr($string,7*2,2));
  775. my $hours = hex(substr($string,6*2,2));
  776. my $min = hex(substr($string,8*2,2));
  777. my $sec = hex(substr($string,9*2,2));
  778. my $dow = hex(substr($string,10*2,2));
  779. # my $dst = (hex(substr($string,11*2,2)) & 0x01) ? "dst" : "";
  780. if (!defined($ch_timeTS))
  781. {
  782. $interval_ch_time = -1;
  783. }
  784. if ($interval_ch_time != 0)
  785. {
  786. if (($interval_ch_time > 0) && (HEATRONIC_timeDiff($ch_timeTS) < $interval_ch_time))
  787. {
  788. return 1;
  789. }
  790. readingsBeginUpdate($hash);
  791. readingsBulkUpdate($hash, "ch_time", sprintf("%4d-%02d-%02d %02d:%02d:%02d", $year, $month, $day, $hours, $min, $sec ));
  792. readingsEndUpdate($hash,1);
  793. }
  794. return 1;
  795. }
  796. else
  797. {
  798. return undef;
  799. }
  800. }
  801. sub
  802. HEATRONIC_DecodeMsg_SOL($$$)
  803. {
  804. my ($hash,$string,$length) = @_;
  805. my $name = $hash->{NAME};
  806. my $type;
  807. if (defined(HEATRONIC_CRCtest($hash,$string,$length)))
  808. {
  809. my $sol_Tcollector = 0;
  810. my $sol_Tcylinder_bottom = 0;
  811. if (hex(substr($string,5*2,2)) == 3)
  812. {
  813. $sol_Tcollector = hex(substr($string,10*2,2));
  814. if ($sol_Tcollector != 255)
  815. {
  816. $sol_Tcollector = ($sol_Tcollector * 256 + hex(substr($string,11*2,2)))/10;
  817. }
  818. else
  819. {
  820. $sol_Tcollector = (255-hex(substr($string,11*2,2)))/-10;
  821. }
  822. $sol_Tcylinder_bottom = hex(substr($string,12*2,4))/10;
  823. my $sol_pump = (hex(substr($string,14*2,2)) & 0x01) ? 1 : 0;
  824. my $sol_yield_last_hour = hex(substr($string,8*2,4));
  825. my $sol_yield_2 = hex(substr($string,6*2,4));
  826. my $sol_runtime = hex(substr($string,17*2,4));
  827. readingsBeginUpdate($hash);
  828. readingsBulkUpdate($hash, "sol_Tcollector", $sol_Tcollector);
  829. readingsBulkUpdate($hash, "sol_Tcylinder_bottom", $sol_Tcylinder_bottom);
  830. readingsBulkUpdate($hash, "sol_yield_last_hour", $sol_yield_last_hour);
  831. readingsBulkUpdate($hash, "sol_yield_2", $sol_yield_2);
  832. readingsBulkUpdate($hash, "sol_pump", $sol_pump);
  833. readingsBulkUpdate($hash, "sol_runtime", $sol_runtime);
  834. readingsEndUpdate($hash,1);
  835. return 1;
  836. }
  837. elsif (hex(substr($string,5*2,2)) == 4)
  838. {
  839. my $hybrid_buffer = hex(substr($string,6*2,4));
  840. my $hybrid_sysinput = hex(substr($string,8*2,4));
  841. readingsBeginUpdate($hash);
  842. readingsBulkUpdate($hash, "sol_Thybrid_buffer", $hybrid_buffer);
  843. readingsBulkUpdate($hash, "sol_Thybrid_sysinput", $hybrid_sysinput);
  844. readingsEndUpdate($hash,1);
  845. return 1;
  846. }
  847. }
  848. else
  849. {
  850. return undef;
  851. }
  852. }
  853. sub
  854. HEATRONIC_CRCtest($$$)
  855. {
  856. my ($hash,$string, $length) = @_;
  857. my $crc = 0;
  858. my $i;
  859. return undef if ($length < 3);
  860. for $i (0 .. $length-3)
  861. {
  862. $crc = hex($crc_table[$crc]);
  863. $crc ^= hex(substr($string,$i*2,2));
  864. }
  865. if ($crc == hex(substr($string,$length*2-4,2)))
  866. {
  867. return 1;
  868. }
  869. else
  870. {
  871. return undef;
  872. }
  873. }
  874. sub
  875. HEATRONIC_CRCget($)
  876. {
  877. my ($string) = @_;
  878. my $crc = 0;
  879. my $i;
  880. my $length = length($string)/2;
  881. for $i (0 .. $length-3)
  882. {
  883. $crc = hex($crc_table[$crc]);
  884. $crc ^= hex(substr($string,$i*2,2));
  885. }
  886. return "(".sprintf("%02x",$crc) . "/" . substr($string,$length*2-4,2) .")";
  887. }
  888. sub
  889. HEATRONIC_timeDiff($) {
  890. my ($strTS)=@_;
  891. my $serTS = (defined($strTS) && $strTS ne "") ? time_str2num($strTS) : gettimeofday();
  892. my $timeDiff = gettimeofday()- $serTS;
  893. $timeDiff=0 if ( $timeDiff<0);
  894. return $timeDiff;
  895. }
  896. 1;
  897. =pod
  898. =begin html
  899. <a name="HEATRONIC"></a>
  900. <h3>HEATRONIC</h3>
  901. <ul>
  902. The HEATRONIC module interprets messages received from the HT-Bus of a Junkers Boiler. <br/>
  903. Possible Adapters are described in http://www.mikrocontroller.net/topic/317004 (only in german).
  904. <br/><br/>
  905. <a name="HEATRONIC_Define"></a>
  906. <B>Define:</B><br/>
  907. <ul><code>define &lt;name&gt; HEATRONIC &lt;serial-device | &lt;proxy-server IP-address:port&gt;</code>
  908. <B>Example for serial-device:</B></br>
  909. <ul>
  910. <code> define Boiler HEATRONIC /dev/ttyUSB0@9600</code>
  911. </ul><br/>
  912. <B>Example for proxy-server:</B></br>
  913. <ul>
  914. <code> define Boiler HEATRONIC 192.168.2.11:8088</code>
  915. </ul></ul><br/>
  916. <a name="HEATRONIC_set"><b>Set:</b></a>
  917. <ul>
  918. <code>set &lt;name&gt; &lt;param&gt; &lt;value&gt;</code><br/>
  919. <ul>(only possible with ht_pitiny- or ht_piduino-adapters)</ul><br/>
  920. where param is one of:
  921. <ul>
  922. <li>hc1_Trequired &lt;temp&gt;<br>
  923. sets the 'heating' temperature-niveau for heating circuit 1 (permanent)<br/>
  924. 0.5 celsius resolution - temperature between 10 and 30 celsius
  925. </li>
  926. <li>hc1_mode [ auto | comfort | eco | frost ]<br>
  927. sets the working mode for heating circuit 1<br>
  928. <ul>
  929. <li>auto : the timer program is active and the summer configuration is in effect</li>
  930. <li>comfort: manual by 'comfort' working mode, no timer program is in effect</li>
  931. <li>eco : manual by 'eco' working mode, no timer program is in effect</li>
  932. <li>frost : manual by 'frost' working mode, no timer program is in effect</li>
  933. </ul></li>
  934. </ul><br/>
  935. Examples:
  936. <ul>
  937. <code>set Boiler hc1_Trequired 22.5</code><br>
  938. <code>set Boiler hc1_mode eco</code>
  939. </ul><br/>
  940. </ul><br/>
  941. <a name="HEATRONIC_attributes"><b>Attributes:</b></a>
  942. <ul>
  943. <li><B>interval_ch_time, interval_ch_Tflow_measured, interval_dhw_Tmeasured, interval_dhw_Tcylinder</B><br/>
  944. interval (in seconds) to update the corresponding values
  945. </li><br/>
  946. <li><B>minDiff_ch_Tflow_measured</B><br/>
  947. minimal difference (in degrees, e.g. 0.2) to update the corresponding values
  948. </li><br/>
  949. </ul>
  950. <a name="HEATRONIC_readings"><b>Readings:</b></a>
  951. <ul>
  952. <li><B>ch_Tflow_desired</B><br/>
  953. required flow temperature (in domestic hot water mode value of max vessel temperature)<br>
  954. </li><br/>
  955. <li><B>ch_Tflow_measured</B><br/>
  956. current measured flow temperature
  957. </li><br/>
  958. <li><B>ch_Treturn</B><br/>
  959. current measured return temperature
  960. </li><br/>
  961. <li><B>ch_Tmixer</B><br/>
  962. current measured mixer temperature
  963. </li><br/>
  964. <li><B>ch_mode</B><br/>
  965. current operation mode (0=off, 1=heating, 2=domestic hot water)
  966. </li><br/>
  967. <li><B>ch_code</B><br/>
  968. current operation code or extended error code (see manual of boiler)
  969. </li><br/>
  970. <li><B>ch_code</B><br/>
  971. error code (see manual of boiler)
  972. </li><br/>
  973. <li><B>ch_burner_fan</B><br/>
  974. status of burner fan (0=off, 1=running)
  975. </li><br/>
  976. <li><B>ch_burner_operation</B><br/>
  977. burner status (0=off, 1=on)
  978. </li><br/>
  979. <li><B>ch_pump_heating</B><br/>
  980. status of the heating pump(0=off, 1=running)
  981. </li><br/>
  982. <li><B>ch_pump_cylinder</B><br/>
  983. status of cylinder loading pump (0=off, 1=running)
  984. </li><br/>
  985. <li><B>ch_pump_circulation</B><br/>
  986. status of circulation pump (0=off, 1=running)
  987. </li><br/>
  988. <li><B>ch_burner_power</B><br/>
  989. burner power in percent
  990. </li><br/>
  991. <li><B>ch_pump_heating_power</B><br/>
  992. power of heating power in percent
  993. </li><br/>
  994. <li><B>ch_Toutside</B><br/>
  995. outside temperature
  996. </li><br/>
  997. <li><B>ch_runtime_total</B><br/>
  998. runtime of burner in minutes (heating and domestic hot water)
  999. </li><br/>
  1000. <li><B>ch_runtime_ch</B><br/>
  1001. runtime of burner in minutes (heating only)
  1002. </li><br/>
  1003. <li><B>ch_runtime_dhw</B><br/>
  1004. runtime of burner in minutes (domestic hot water only)
  1005. </li><br/>
  1006. <li><B>ch_starts_tot</B><br/>
  1007. count of burner operations (heating and domestic hot water)
  1008. </li><br/>
  1009. <li><B>ch_starts_ch</B><br/>
  1010. count of burner operations (heating only)
  1011. </li><br/>
  1012. <li><B>ch_starts_dhw</B><br/>
  1013. count of burner operations (domestic hot water only)
  1014. </li><br/>
  1015. <li><B>ch_time</B><br/>
  1016. system time of boiler
  1017. </li><br/>
  1018. <li><B>hc1_Tdesired .. hc4_Tdesired</B><br/>
  1019. required room temperature for heating circuit 1-4
  1020. </li><br/>
  1021. <li><B>hc1_Tmeasured .. hc4_Tmeasured</B><br/>
  1022. current measured room temperature for heating circuit 1-4
  1023. </li><br/>
  1024. <li><B>hc1_Tmode .. hc4_Tmode</B><br/>
  1025. operating mode for heating circuit 1-4
  1026. </li><br/>
  1027. <li><B>dhw_Tdesired</B><br/>
  1028. required domestic hot water temperature
  1029. </li><br/>
  1030. <li><B>dhw_Tmeasured</B><br/>
  1031. current measured domestic hot water temperature
  1032. </li><br/>
  1033. <li><B>dhw_Tcylinder</B><br/>
  1034. current measured domestic hot water temperature at the top of the cylinder
  1035. </li><br/>
  1036. <li><B>sol_Tcollector</B><br/>
  1037. temperature of collector groupp 1
  1038. </li><br/>
  1039. <li><B>sol_Tcylinder_bottom</B><br/>
  1040. temperature at the bottom of solar cylinder
  1041. </li><br/>
  1042. <li><B>sol_yield_last_hour</B><br/>
  1043. yield of collector in the last hour
  1044. </li><br/>
  1045. <li><B>sol_yield_2</B><br/>
  1046. This value is unkown at the moment. The name can be changed later.
  1047. </li><br/>
  1048. <li><B>sol_pump</B><br/>
  1049. status of solar circuit pump (0=off, 1=running)
  1050. </li><br/>
  1051. <li><B>sol_runtime</B><br/>
  1052. runtime of solar pump in minutes
  1053. </li><br/>
  1054. </ul>
  1055. </ul>
  1056. =end html
  1057. =begin html_DE
  1058. <a name="HEATRONIC"></a>
  1059. <h3>HEATRONIC</h3>
  1060. <ul>
  1061. Das HEATRONIC Modul wertet die Nachrichten aus, die &uuml;ber den HT-Bus von einer Junkers-Heizung &uuml;bertragen werden.<br/>
  1062. M&ouml;gliche Adapter werden unter http://www.mikrocontroller.net/topic/317004 vorgestellt.<br/><br/>
  1063. <a name="HEATRONIC_Define"></a>
  1064. <B>Define:</B><br/>
  1065. <ul><code>define &lt;name&gt; HEATRONIC &lt;serial-device&gt; | &lt;proxy-server IP-Adresse:port&gt;</code><br/><br/>
  1066. <B>Beispiel f&uuml;r serielles Ger&auml;t:</B></br>
  1067. <ul>
  1068. <code> define Heizung HEATRONIC /dev/ttyUSB0@9600</code>
  1069. </ul><br/>
  1070. <B>Beispiel f&uuml;r Proxy-Server:</B></br>
  1071. <ul>
  1072. <code> define Heizung HEATRONIC 192.168.2.11:8088</code>
  1073. </ul></ul><br/>
  1074. <a name="HEATRONIC_set"><b>Set:</b></a>
  1075. <ul>
  1076. <code>set &lt;name&gt; &lt;param&gt; &lt;value&gt;</code>
  1077. <br><ul>(nur mit ht_pitiny- oder ht_piduino-Adapter m&ouml;glich)</ul>
  1078. <br>
  1079. wobei die Parameter folgende Werte haben:
  1080. <ul>
  1081. <li>hc1_Trequired &lt;temp&gt;<br>
  1082. Setzt das 'Heizen' Temperatur-Niveau f&uuml;r Heizkreis 1 (permanent)<br>
  1083. Aufl&ouml;sung 0.5 Celsius, Bereich: 10 bis 30 Celsius
  1084. </li>
  1085. <li>hc1_mode [ auto | comfort | eco | frost ]<br>
  1086. Setzt die Betriebsart des Heizkreises 1<br>
  1087. <ul>
  1088. <li>auto : Das Timerprogramm und die Sommerzeit-Umschaltung sind aktiv </li>
  1089. <li>comfort: Manueller 'comfort' Mode, Timerprogramm deaktiv</li>
  1090. <li>eco : Manueller 'eco' Mode, Timerprogramm deaktiv</li>
  1091. <li>frost : Manueller 'frost' Mode, Timerprogramm deaktiv</li>
  1092. </ul></li>
  1093. </ul>
  1094. <br>
  1095. Beispiele:
  1096. <ul>
  1097. <code>set Boiler hc1_Trequired 22.5</code><br>
  1098. <code>set Boiler hc1_mode eco</code>
  1099. </ul>
  1100. <br>
  1101. </ul>
  1102. <br>
  1103. <a name="HEATRONIC_attributes"><b>Attributes:</b></a>
  1104. <ul>
  1105. <li><B>interval_ch_time, interval_ch_Tflow_measured, interval_dhw_Tmeasured, interval_dhw_Tcylinder</B><br/>
  1106. Intervall (in Sekunden) zum Update der entsprechenden Werte
  1107. </li><br/>
  1108. <li><B>minDiff_ch_Tflow_measured</B><br/>
  1109. Minimaldifferenz (in Grad, z.B. 0.2) zum Update der entsprechenden Werte
  1110. </li><br/>
  1111. </ul>
  1112. <a name="HEATRONIC_readings"><b>Readings:</b></a>
  1113. <ul>
  1114. <li><B>ch_Tflow_desired</B><br/>
  1115. ben&ouml;tigte Vorlauf-Temperatur (im Warmwasser-Modus max. Kesseltemperatur)
  1116. </li><br/>
  1117. <li><B>ch_Tflow_measured</B><br/>
  1118. aktuell gemessene Vorlauf-Temperatur
  1119. </li><br/>
  1120. <li><B>ch_Treturn</B><br/>
  1121. aktuell gemessene R&uuml;cklauf-Temperatur
  1122. </li><br/>
  1123. <li><B>ch_Tmixer</B><br/>
  1124. aktuell gemessene Mischer-Temperatur
  1125. </li><br/>
  1126. <li><B>ch_mode</B><br/>
  1127. aktueller Betriebsmodus (0=aus, 1=Heizen, 2=Warmwasser)
  1128. </li><br/>
  1129. <li><B>ch_code</B><br/>
  1130. aktueller Betriebs-Code oder erweiterter Störungs-Code (siehe Heizungs-Anleitung)
  1131. </li><br/>
  1132. <li><B>ch_code</B><br/>
  1133. Störungs-Code (siehe Heizungs-Anleitung)
  1134. </li><br/>
  1135. <li><B>ch_burner_fan</B><br/>
  1136. Status Brenner-Gebl&auml;se (0=aus, 1=l&auml;uft)
  1137. </li><br/>
  1138. <li><B>ch_burner_operation</B><br/>
  1139. Brenner-Status (0=off, 1=an)
  1140. </li><br/>
  1141. <li><B>ch_pump_heating</B><br/>
  1142. Status der Heizungspumpe(0=aus, 1=l&auml;uft)
  1143. </li><br/>
  1144. <li><B>ch_pump_cylinder</B><br/>
  1145. Status der Speicherladepumpe (0=aus, 1=l&auml;uft)
  1146. </li><br/>
  1147. <li><B>ch_pump_circulation</B><br/>
  1148. Status der Zirkulationspumpe (0=aus, 1=l&auml;uft)
  1149. </li><br/>
  1150. <li><B>ch_burner_power</B><br/>
  1151. Brennerleistung in Prozent
  1152. </li><br/>
  1153. <li><B>ch_pump_heating_power</B><br/>
  1154. Leistung der Heizungspumpe in Prozent
  1155. </li><br/>
  1156. <li><B>ch_Toutside</B><br/>
  1157. Au&szlig;entemperatur
  1158. </li><br/>
  1159. <li><B>ch_runtime_total</B><br/>
  1160. Brennerlaufzeit in Minuten (Heizen und Warmwasser)
  1161. </li><br/>
  1162. <li><B>ch_runtime_ch</B><br/>
  1163. Brennerlaufzeit in Minuten (nur Heizen)
  1164. </li><br/>
  1165. <li><B>ch_runtime_dhw</B><br/>
  1166. Brennerlaufzeit in Minuten (nur Warmwasser)
  1167. </li><br/>
  1168. <li><B>ch_starts_tot</B><br/>
  1169. Anzahl der Brennerstarts (Heizen und Warmwasser)
  1170. </li><br/>
  1171. <li><B>ch_starts_ch</B><br/>
  1172. Anzahl der Brennerstarts (nur Heizen)
  1173. </li><br/>
  1174. <li><B>ch_starts_dhw</B><br/>
  1175. Anzahl der Brennerstarts (nur Warmwasser)
  1176. </li><br/>
  1177. <li><B>ch_time</B><br/>
  1178. Systemzeit der Heizung
  1179. </li><br/>
  1180. <li><B>hc1_Tdesired .. hc4_Tdesired</B><br/>
  1181. ben&ouml;tigte Raumtemperatur Heizkreis 1-4
  1182. </li><br/>
  1183. <li><B>hc1_Tmeasured .. hc4_Tmeasured</B><br/>
  1184. aktuell gemessene Raumtemperatur Heizkreis 1-4
  1185. </li><br/>
  1186. <li><B>hc1_Tmode .. hc4_Tmode</B><br/>
  1187. Betriebsmodus Heizkreis 1-4
  1188. </li><br/>
  1189. <li><B>dhw_Tdesired</B><br/>
  1190. ben&ouml;tigte Warmwasser-Temperatur
  1191. </li><br/>
  1192. <li><B>dhw_Tmeasured</B><br/>
  1193. aktuell gemessene Warmwasser-Temperatur
  1194. </li><br/>
  1195. <li><B>dhw_Tcylinder</B><br/>
  1196. aktuell gemessene Warmwasser-Temperatur Speicher oben
  1197. </li><br/>
  1198. <li><B>sol_Tcollector</B><br/>
  1199. Temperatur Kollektorgruppe 1
  1200. </li><br/>
  1201. <li><B>sol_Tcylinder_bottom</B><br/>
  1202. Temperatur Solarspeicher unten
  1203. </li><br/>
  1204. <li><B>sol_yield_last_hour</B><br/>
  1205. Kollektorertrag der letzten Stunde
  1206. </li><br/>
  1207. <li><B>sol_yield_2</B><br/>
  1208. Der Wert ist noch nicht bekannt. Der Name kann sich noch &auml;ndern.
  1209. </li><br/>
  1210. <li><B>sol_pump</B><br/>
  1211. Status der Solarpumpe (0=off, 1=l&auml;uft)
  1212. </li><br/>
  1213. <li><B>sol_runtime</B><br/>
  1214. Laufzeit der Solarpumpe in Minuten
  1215. </li><br/>
  1216. </ul>
  1217. </ul>
  1218. =end html_DE
  1219. =cut