98_ModbusSET.pm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. ##############################################
  2. ##############################################
  3. # $Id: 98_ModbusSET.pm 14230 2017-05-09 19:08:57Z StefanStrobel $
  4. #
  5. # fhem Modul für Wärmepumpen der Silent Serie von SET mit Modbus-Interface
  6. # verwendet Modbus.pm als Basismodul für die eigentliche Implementation des Protokolls.
  7. #
  8. # Siehe ModbusExample.pm für eine ausführlichere Infos zur Verwendung des Moduls
  9. # 98_Modbus.pm
  10. #
  11. #
  12. # This file is part of fhem.
  13. #
  14. # Fhem is free software: you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation, either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # Fhem is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27. ##############################################################################
  28. # Changelog:
  29. #
  30. # 2014-07-12 initial release
  31. # 2015-01-25 changes in sync with the changes in 98_Modbus.pm
  32. # 2015-01-26 more examples / comments on the keys in the parseInfo hash:
  33. # - unpack for packing and unpacking the values / data types in the Modbus frames
  34. # - len (for values like floats that span two registers)
  35. # - format
  36. # 2015-01-27 defLen im Modul-hash des logischen Moduls als Default
  37. # maxLen als Max für die Länge bei function code 3 (laut Standard 125)
  38. # 2015-01-31 new deviceInfo hash to bundle defaults and function code specific settings
  39. # added defaultpolldelay to parseInfo
  40. # 2015-02-16 added defPoll,defShowGet to deviceInfo,
  41. # defaultpoll in parseInfo, defPoll in deviceInfo und das entsprechende Attribut können auch auf "once"
  42. # gesetzt werden,
  43. # defaultpolldelay
  44. # defaultpolldelay bzw. das Attribut kann mit x beginnen und ist dann Multiplikator des Intervalls
  45. # 2015-02-17 Initialize, Define und Undef in das Basismodul verlagert
  46. # Abhängigkeit von Client-Definitionen entfernt.
  47. #
  48. # 2015-02-26 defaultpoll und defaultpolldelay umbenannt
  49. # attribute für timing umbenannt
  50. # 2017-05-09 added documentation summary
  51. #
  52. package main;
  53. use strict;
  54. use warnings;
  55. sub ModbusSET_Initialize($);
  56. my %SET10parseInfo = (
  57. "h256" => { reading => "Temp_Wasser_Ein", # name of the reading for this value
  58. name => "Pb1", # internal name of this register in the hardware doc
  59. expr => '$val / 10', # conversion of raw value to visible value
  60. },
  61. "h258" => { reading => "Temp_Wasser_Aus",
  62. name => "Pb2",
  63. expr => '$val / 10',
  64. },
  65. "h260" => { reading => "Temp_Verdampfer",
  66. name => "Pb3",
  67. expr => '$val / 10',
  68. },
  69. "h262" => { reading => "Temp_Luft",
  70. name => "Pb4",
  71. expr => '$val / 10',
  72. },
  73. "h770" => { reading => "Temp_Soll",
  74. name => "ST03",
  75. expr => '$val / 10',
  76. setexpr => '$val * 10', # expression to convert a set value to the internal value
  77. min => 10, # input validation for set: min value
  78. max => 32, # input validation for set: max value
  79. hint => "8,10,20,25,28,29,30,30.5,31,31.5,32",
  80. set => 1, # this value can be set
  81. },
  82. "h771" => { reading => "Hysterese", # Hex Adr 303
  83. name => "ST04",
  84. expr => '$val / 10',
  85. setexpr => '$val * 10',
  86. poll => "once", # only poll once (or after a set)
  87. min => 0.5,
  88. max => 3,
  89. set => 1,
  90. },
  91. "h777" => { reading => "Hyst_Mode", # Hex Adr 0309
  92. name => "ST10",
  93. map => "0:mittig, 1:oberhalb, 2:unterhalb",
  94. poll => "once", # only poll once (or after a set)
  95. set => 1,
  96. },
  97. "h801" => { reading => "Temp_Wasser_Ein_Off",
  98. name => "CF24",
  99. expr => '$val / 10',
  100. poll => 0,
  101. setexpr => '$val * 10',
  102. set => 1,
  103. },
  104. "h802" => { reading => "Temp_Wasser_Aus_Off",
  105. name => "CF25",
  106. expr => '$val / 10',
  107. poll => 0,
  108. setexpr => '$val * 10',
  109. set => 1,
  110. },
  111. "h803" => { reading => "Temp_Verdampfer_Off",
  112. name => "CF26",
  113. expr => '$val / 10',
  114. poll => 0,
  115. setexpr => '$val * 10',
  116. set => 1,
  117. },
  118. "h804" => { reading => "Temp_Luft_Off",
  119. name => "CF27",
  120. expr => '$val / 10',
  121. poll => 0,
  122. setexpr => '$val * 10',
  123. set => 1,
  124. },
  125. );
  126. my %SET10deviceInfo = (
  127. "timing" => {
  128. timeout => 2,
  129. commDelay => 0.7,
  130. sendDelay => 0.7,
  131. },
  132. "h" => {
  133. combine => 5,
  134. defShowGet => 1,
  135. defPoll => 1,
  136. defUnpack => "s>",
  137. },
  138. );
  139. #####################################
  140. sub
  141. ModbusSET_Initialize($)
  142. {
  143. my ($modHash) = @_;
  144. require "$attr{global}{modpath}/FHEM/98_Modbus.pm";
  145. $modHash->{parseInfo} = \%SET10parseInfo; # defines registers, inputs, coils etc. for this Modbus Defive
  146. $modHash->{deviceInfo} = \%SET10deviceInfo; # defines properties of the device like
  147. # defaults and supported function codes
  148. ModbusLD_Initialize($modHash); # Generic function of the Modbus module does the rest
  149. $modHash->{AttrList} = $modHash->{AttrList} . " " . # Standard Attributes like IODEv etc
  150. $modHash->{ObjAttrList} . " " . # Attributes to add or overwrite parseInfo definitions
  151. $modHash->{DevAttrList} . " " . # Attributes to add or overwrite devInfo definitions
  152. "poll-.* " . # overwrite poll with poll-ReadingName
  153. "polldelay-.* "; # overwrite polldelay with polldelay-ReadingName
  154. }
  155. 1;
  156. =pod
  157. =item device
  158. =item summary Module for heat pumps from SET or others using iChill IC121
  159. =item summary_DE Modul für SET Wärmepumpen und andere mit iChill IC121
  160. =begin html
  161. <a name="ModbusSET"></a>
  162. <h3>ModbusSET</h3>
  163. <ul>
  164. ModbusSET uses the low level Modbus module to provide a way to communicate with Silent 10 heat pumps from SET.
  165. It probably works with other heat pumps from SET as well and since the control device used in these heat pumps
  166. is an iChill IC121 from Dixell, it could even work for other heat pumps with this controller as well or with few
  167. changes. It defines the modbus holding registers for the temperature sensors and reads them in a defined interval.
  168. <br>
  169. <b>Prerequisites</b>
  170. <ul>
  171. <li>
  172. This module requires the basic Modbus module which itsef requires Device::SerialPort or Win32::SerialPort module.
  173. </li>
  174. </ul>
  175. <br>
  176. <a name="ModbusSETDefine"></a>
  177. <b>Define</b>
  178. <ul>
  179. <code>define &lt;name&gt; ModbusSET &lt;Id&gt; &lt;Interval&gt;</code>
  180. <br><br>
  181. The module connects to the heat pump with Modbus Id &lt;Id&gt; through an already defined modbus device and actively requests data from the heat pump every &lt;Interval&gt; seconds <br>
  182. <br>
  183. Example:<br>
  184. <br>
  185. <ul><code>define WP ModbusSET 1 60</code></ul>
  186. </ul>
  187. <br>
  188. <a name="ModbusSETConfiguration"></a>
  189. <b>Configuration of the module</b><br><br>
  190. <ul>
  191. apart from the modbus id and the interval which both are specified in the define command there is nothing that needs to be defined.
  192. However there are some attributes that can optionally be used to modify the behavior of the module. <br><br>
  193. The attributes that control which messages are sent / which data is requested every &lt;Interval&gt; seconds are:
  194. <pre>
  195. poll-Hyst_Mode
  196. poll-Temp_Luft
  197. poll-Temp_Wasser_Aus_Off
  198. poll-Temp_Wasser_Ein_Off
  199. poll-Temp_Wasser_Aus
  200. poll-Hysterese
  201. poll-Temp_Wasser_Ein
  202. poll-Temp_Soll
  203. poll-Temp_Luft_Off
  204. poll-Temp_Verdampfer
  205. poll-Temp_Verdampfer_Off
  206. </pre>
  207. if the attribute is set to 1, the corresponding data is requested every &lt;Interval&gt; seconds. If it is set to 0, then the data is not requested.
  208. by default the temperatures are requested if no attributes are set.<br>
  209. if some readings should be polled, but less frequently than the normal interval, you can specify a pollDelay-
  210. Attribute for the reading. <br>
  211. The pollDelay attribute allows to poll objects at a lower rate than the interval specified in the define command. you can either specify a time in seconds or number prefixed by "x" which means a multiple of the interval of the define command.<br>
  212. if you specify a normal numer then it is interpreted as minimal time between the last read and another automatic read. Please note that this does not create an individual interval timer. Instead the normal interval timer defined by the interval of the define command will check if this reading is due or not yet. So the effective interval will always be a multiple of the interval of the define.
  213. <br><br>
  214. Example:
  215. <pre>
  216. define WP ModbusSET 1 60
  217. attr WP poll-Temp_Soll 0
  218. attr WP pollDelay-Hysterese 300
  219. </pre>
  220. </ul>
  221. <a name="ModbusSETSet"></a>
  222. <b>Set-Commands</b><br>
  223. <ul>
  224. The following set options are available:
  225. <pre>
  226. Hysterese (defines the hysterese in Kelvin)
  227. Hyst_Mode (defines the interpretation of hysterese for the heating and can be set to mittig, oberhalb or unterhalb)
  228. Temp_Wasser_Aus_Off (offset of sensor in Kelvin - used to kalibrate)
  229. Temp_Wasser_Ein_Off (offset of sensor in Kelvin - used to kalibrate)
  230. Temp_Luft_Off (offset of sensor in Kelvin - used to kalibrate)
  231. Temp_Verdampfer_Off (offset of sensor in Kelvin - used to kalibrate)
  232. Temp_Soll (target temperature of the heating pump)
  233. </pre>
  234. </ul>
  235. <br>
  236. <a name="ModbusSETGet"></a>
  237. <b>Get-Commands</b><br>
  238. <ul>
  239. All readings are also available as Get commands. Internally a Get command triggers the corresponding
  240. request to the device and then interprets the data and returns the right field value. To avoid huge option lists in FHEMWEB, only the most important Get options
  241. are visible in FHEMWEB. However this can easily be changed since all the readings and protocol messages are internally defined in the modue in a data structure
  242. and to make a Reading visible as Get option only a little option (e.g. <code>showget => 1</code> has to be added to this data structure
  243. </ul>
  244. <br>
  245. <a name="ModbusSETattr"></a>
  246. <b>Attributes</b><br><br>
  247. <ul>
  248. <li><a href="#do_not_notify">do_not_notify</a></li>
  249. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  250. <br>
  251. <li><b>poll-Hyst_Mode</b></li>
  252. <li><b>poll-Temp_Luft</b></li>
  253. <li><b>poll-Temp_Wasser_Aus_Off</b></li>
  254. <li><b>poll-Temp_Wasser_Ein_Off</b></li>
  255. <li><b>poll-Temp_Wasser_Aus</b></li>
  256. <li><b>poll-Hysterese</b></li>
  257. <li><b>poll-Temp_Wasser_Ein</b></li>
  258. <li><b>poll-Temp_Soll</b></li>
  259. <li><b>poll-Temp_Luft_Off</b></li>
  260. <li><b>poll-Temp_Verdampfer</b></li>
  261. <li><b>poll-Temp_Verdampfer_Off</b></li>
  262. include a read request for the corresponding registers when sending requests every interval seconds <br>
  263. <li><b>pollDelay-*</b></li>
  264. set a delay for polling individual Readings. In case some readings should be polled less frequently than the
  265. normal delay specified during define. Specifying a pollDelay will not create an individual timer for
  266. polling this reading but check if the delay is over when the normal update interval is handled.<br>
  267. You can either specify a time in seconds or number prefixed by "x" which means a multiple of the interval of the define command.<br>
  268. If you specify a normal numer then it is interpreted as minimal time between the last read and another automatic read. Please note that this does not create an individual interval timer. Instead the normal interval timer defined by the interval of the define command will check if this reading is due or not yet. So the effective interval will always be a multiple of the interval of the define.
  269. <li><b>dev-timing-timeout</b></li>
  270. set the timeout for reads, defaults to 2 seconds <br>
  271. <li><b>dev-timing-minSendDelay</b></li>
  272. minimal delay between two requests sent to this device
  273. <li><b>dev-timing-minCommDelay</b></li>
  274. minimal delay between requests or receptions to/from this device
  275. </ul>
  276. <br>
  277. </ul>
  278. =end html
  279. =cut