98_ModbusSET.pm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. ##############################################
  2. ##############################################
  3. # $Id: 98_ModbusSET.pm 10628 2016-01-25 18:47:26Z ststrobel $
  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. #
  51. package main;
  52. use strict;
  53. use warnings;
  54. sub ModbusSET_Initialize($);
  55. my %SET10parseInfo = (
  56. "h256" => { reading => "Temp_Wasser_Ein", # name of the reading for this value
  57. name => "Pb1", # internal name of this register in the hardware doc
  58. expr => '$val / 10', # conversion of raw value to visible value
  59. },
  60. "h258" => { reading => "Temp_Wasser_Aus",
  61. name => "Pb2",
  62. expr => '$val / 10',
  63. },
  64. "h260" => { reading => "Temp_Verdampfer",
  65. name => "Pb3",
  66. expr => '$val / 10',
  67. },
  68. "h262" => { reading => "Temp_Luft",
  69. name => "Pb4",
  70. expr => '$val / 10',
  71. },
  72. "h770" => { reading => "Temp_Soll",
  73. name => "ST03",
  74. expr => '$val / 10',
  75. setexpr => '$val * 10', # expression to convert a set value to the internal value
  76. min => 10, # input validation for set: min value
  77. max => 32, # input validation for set: max value
  78. hint => "8,10,20,25,28,29,30,30.5,31,31.5,32",
  79. set => 1, # this value can be set
  80. },
  81. "h771" => { reading => "Hysterese", # Hex Adr 303
  82. name => "ST04",
  83. expr => '$val / 10',
  84. setexpr => '$val * 10',
  85. poll => "once", # only poll once (or after a set)
  86. min => 0.5,
  87. max => 3,
  88. set => 1,
  89. },
  90. "h777" => { reading => "Hyst_Mode", # Hex Adr 0309
  91. name => "ST10",
  92. map => "0:mittig, 1:oberhalb, 2:unterhalb",
  93. poll => "once", # only poll once (or after a set)
  94. set => 1,
  95. },
  96. "h801" => { reading => "Temp_Wasser_Ein_Off",
  97. name => "CF24",
  98. expr => '$val / 10',
  99. poll => 0,
  100. setexpr => '$val * 10',
  101. set => 1,
  102. },
  103. "h802" => { reading => "Temp_Wasser_Aus_Off",
  104. name => "CF25",
  105. expr => '$val / 10',
  106. poll => 0,
  107. setexpr => '$val * 10',
  108. set => 1,
  109. },
  110. "h803" => { reading => "Temp_Verdampfer_Off",
  111. name => "CF26",
  112. expr => '$val / 10',
  113. poll => 0,
  114. setexpr => '$val * 10',
  115. set => 1,
  116. },
  117. "h804" => { reading => "Temp_Luft_Off",
  118. name => "CF27",
  119. expr => '$val / 10',
  120. poll => 0,
  121. setexpr => '$val * 10',
  122. set => 1,
  123. },
  124. );
  125. my %SET10deviceInfo = (
  126. "timing" => {
  127. timeout => 2,
  128. commDelay => 0.7,
  129. sendDelay => 0.7,
  130. },
  131. "h" => {
  132. combine => 5,
  133. defShowGet => 1,
  134. defPoll => 1,
  135. defUnpack => "s>",
  136. },
  137. );
  138. #####################################
  139. sub
  140. ModbusSET_Initialize($)
  141. {
  142. my ($modHash) = @_;
  143. require "$attr{global}{modpath}/FHEM/98_Modbus.pm";
  144. $modHash->{parseInfo} = \%SET10parseInfo; # defines registers, inputs, coils etc. for this Modbus Defive
  145. $modHash->{deviceInfo} = \%SET10deviceInfo; # defines properties of the device like
  146. # defaults and supported function codes
  147. ModbusLD_Initialize($modHash); # Generic function of the Modbus module does the rest
  148. $modHash->{AttrList} = $modHash->{AttrList} . " " . # Standard Attributes like IODEv etc
  149. $modHash->{ObjAttrList} . " " . # Attributes to add or overwrite parseInfo definitions
  150. $modHash->{DevAttrList} . " " . # Attributes to add or overwrite devInfo definitions
  151. "poll-.* " . # overwrite poll with poll-ReadingName
  152. "polldelay-.* "; # overwrite polldelay with polldelay-ReadingName
  153. }
  154. 1;
  155. =pod
  156. =begin html
  157. <a name="ModbusSET"></a>
  158. <h3>ModbusSET</h3>
  159. <ul>
  160. ModbusSET uses the low level Modbus module to provide a way to communicate with Silent 10 heat pumps from SET.
  161. It probably works with other heat pumps from SET as well and since the control device used in these heat pumps
  162. is an iChill IC121 from Dixell, it could even work for other heat pumps with this controller as well or with few
  163. changes. It defines the modbus holding registers for the temperature sensors and reads them in a defined interval.
  164. <br>
  165. <b>Prerequisites</b>
  166. <ul>
  167. <li>
  168. This module requires the basic Modbus module which itsef requires Device::SerialPort or Win32::SerialPort module.
  169. </li>
  170. </ul>
  171. <br>
  172. <a name="ModbusSETDefine"></a>
  173. <b>Define</b>
  174. <ul>
  175. <code>define &lt;name&gt; ModbusSET &lt;Id&gt; &lt;Interval&gt;</code>
  176. <br><br>
  177. 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>
  178. <br>
  179. Example:<br>
  180. <br>
  181. <ul><code>define WP ModbusSET 1 60</code></ul>
  182. </ul>
  183. <br>
  184. <a name="ModbusSETConfiguration"></a>
  185. <b>Configuration of the module</b><br><br>
  186. <ul>
  187. apart from the modbus id and the interval which both are specified in the define command there is nothing that needs to be defined.
  188. However there are some attributes that can optionally be used to modify the behavior of the module. <br><br>
  189. The attributes that control which messages are sent / which data is requested every &lt;Interval&gt; seconds are:
  190. <pre>
  191. poll-Hyst_Mode
  192. poll-Temp_Luft
  193. poll-Temp_Wasser_Aus_Off
  194. poll-Temp_Wasser_Ein_Off
  195. poll-Temp_Wasser_Aus
  196. poll-Hysterese
  197. poll-Temp_Wasser_Ein
  198. poll-Temp_Soll
  199. poll-Temp_Luft_Off
  200. poll-Temp_Verdampfer
  201. poll-Temp_Verdampfer_Off
  202. </pre>
  203. 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.
  204. by default the temperatures are requested if no attributes are set.<br>
  205. if some readings should be polled, but less frequently than the normal interval, you can specify a pollDelay-
  206. Attribute for the reading. <br>
  207. 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>
  208. 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.
  209. <br><br>
  210. Example:
  211. <pre>
  212. define WP ModbusSET 1 60
  213. attr WP poll-Temp_Soll 0
  214. attr WP pollDelay-Hysterese 300
  215. </pre>
  216. </ul>
  217. <a name="ModbusSETSet"></a>
  218. <b>Set-Commands</b><br>
  219. <ul>
  220. The following set options are available:
  221. <pre>
  222. Hysterese (defines the hysterese in Kelvin)
  223. Hyst_Mode (defines the interpretation of hysterese for the heating and can be set to mittig, oberhalb or unterhalb)
  224. Temp_Wasser_Aus_Off (offset of sensor in Kelvin - used to kalibrate)
  225. Temp_Wasser_Ein_Off (offset of sensor in Kelvin - used to kalibrate)
  226. Temp_Luft_Off (offset of sensor in Kelvin - used to kalibrate)
  227. Temp_Verdampfer_Off (offset of sensor in Kelvin - used to kalibrate)
  228. Temp_Soll (target temperature of the heating pump)
  229. </pre>
  230. </ul>
  231. <br>
  232. <a name="ModbusSETGet"></a>
  233. <b>Get-Commands</b><br>
  234. <ul>
  235. All readings are also available as Get commands. Internally a Get command triggers the corresponding
  236. 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
  237. 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
  238. 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
  239. </ul>
  240. <br>
  241. <a name="ModbusSETattr"></a>
  242. <b>Attributes</b><br><br>
  243. <ul>
  244. <li><a href="#do_not_notify">do_not_notify</a></li>
  245. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  246. <br>
  247. <li><b>poll-Hyst_Mode</b></li>
  248. <li><b>poll-Temp_Luft</b></li>
  249. <li><b>poll-Temp_Wasser_Aus_Off</b></li>
  250. <li><b>poll-Temp_Wasser_Ein_Off</b></li>
  251. <li><b>poll-Temp_Wasser_Aus</b></li>
  252. <li><b>poll-Hysterese</b></li>
  253. <li><b>poll-Temp_Wasser_Ein</b></li>
  254. <li><b>poll-Temp_Soll</b></li>
  255. <li><b>poll-Temp_Luft_Off</b></li>
  256. <li><b>poll-Temp_Verdampfer</b></li>
  257. <li><b>poll-Temp_Verdampfer_Off</b></li>
  258. include a read request for the corresponding registers when sending requests every interval seconds <br>
  259. <li><b>pollDelay-*</b></li>
  260. set a delay for polling individual Readings. In case some readings should be polled less frequently than the
  261. normal delay specified during define. Specifying a pollDelay will not create an individual timer for
  262. polling this reading but check if the delay is over when the normal update interval is handled.<br>
  263. 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>
  264. 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.
  265. <li><b>dev-timing-timeout</b></li>
  266. set the timeout for reads, defaults to 2 seconds <br>
  267. <li><b>dev-timing-minSendDelay</b></li>
  268. minimal delay between two requests sent to this device
  269. <li><b>dev-timing-minCommDelay</b></li>
  270. minimal delay between requests or receptions to/from this device
  271. </ul>
  272. <br>
  273. </ul>
  274. =end html
  275. =cut