98_Heating_Control.pm 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. # $Id: 98_Heating_Control.pm 16005 2018-01-27 06:05:51Z igami $
  2. ##############################################################################
  3. #
  4. # 98_Heating_Control.pm
  5. # written by Dietmar Ortmann
  6. # Maintained by igami since 02-2018
  7. #
  8. # This file is part of fhem.
  9. #
  10. # Fhem is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation, either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # Fhem is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. ##############################################################################
  24. package main;
  25. use strict;
  26. use warnings;
  27. use POSIX;
  28. ########################################################################
  29. sub Heating_Control_Initialize($)
  30. {
  31. my ($hash) = @_;
  32. if(!$modules{WeekdayTimer}{LOADED} && -f "$attr{global}{modpath}/FHEM/98_WeekdayTimer.pm") {
  33. my $ret = CommandReload(undef, "98_WeekdayTimer");
  34. Log3 undef, 1, $ret if($ret);
  35. }
  36. # Consumer
  37. $hash->{SetFn} = "Heating_Control_Set";
  38. $hash->{AttrFn} = "Heating_Control_Attr";
  39. $hash->{DefFn} = "Heating_Control_Define";
  40. $hash->{UndefFn} = "Heating_Control_Undef";
  41. $hash->{GetFn} = "Heating_Control_Get";
  42. $hash->{UpdFn} = "Heating_Control_Update";
  43. $hash->{AttrList}= "disable:0,1 delayedExecutionCond windowSensor switchInThePast:0,1 commandTemplate ".
  44. $readingFnAttributes;
  45. }
  46. ################################################################################
  47. sub Heating_Control_Set($@) {
  48. my ($hash, @a) = @_;
  49. return "no set value specified" if(int(@a) < 2);
  50. return "Unknown argument $a[1], choose one of enable disable " if($a[1] eq "?");
  51. my $name = shift @a;
  52. my $v = join(" ", @a);
  53. Log3 $hash, 3, "[$name] set $name $v";
  54. if ($v eq "enable") {
  55. fhem("attr $name disable 0");
  56. } elsif ($v eq "disable") {
  57. fhem("attr $name disable 1");
  58. }
  59. return undef;
  60. }
  61. ########################################################################
  62. sub Heating_Control_Get($@) {
  63. return WeekdayTimer_Get($@);
  64. }
  65. ########################################################################
  66. sub Heating_Control_Define($$){
  67. my ($hash, $def) = @_;
  68. my $ret = WeekdayTimer_Define($hash, $def);
  69. return $ret;
  70. }
  71. ########################################################################
  72. sub Heating_Control_Undef($$){
  73. my ($hash, $arg) = @_;
  74. return WeekdayTimer_Undef($hash, $arg);
  75. }
  76. ########################################################################
  77. sub Heating_Control_Update($){
  78. my ($hash) = @_;
  79. return WeekdayTimer_Update($hash);
  80. }
  81. ################################################################################
  82. sub Heating_Control_SetTimerOfDay($) {
  83. my ($hash) = @_;
  84. return WeekdayTimer_SetTimerOfDay($hash);
  85. }
  86. ########################################################################
  87. sub Heating_Control_Attr($$$$) {
  88. my ($cmd, $name, $attrName, $attrVal) = @_;
  89. WeekdayTimer_Attr($cmd, $name, $attrName, $attrVal);
  90. return undef;
  91. }
  92. ########################################################################
  93. sub Heating_Control_SetTimer($) {
  94. my ($hash) = @_;
  95. WeekdayTimer_DeleteTimer($hash);
  96. WeekdayTimer_SetTimer($hash);
  97. }
  98. ########################################################################
  99. sub Heating_Control_SetTemp($) {
  100. my ($name) = @_;
  101. my $hash = $modules{Heating_Control}{defptr}{$name};
  102. if(defined $hash) {
  103. Heating_Control_SetTimer($hash);
  104. }
  105. }
  106. ########################################################################
  107. sub Heating_Control_SetAllTemps() { # {Heating_Control_SetAllTemps()}
  108. my @hcNamen = sort keys %{$modules{Heating_Control}{defptr}};
  109. foreach my $hcName ( @hcNamen ) {
  110. Heating_Control_SetTemp($hcName);
  111. }
  112. Log3 undef, 3, "Heating_Control_SetAllTemps() done on: ".join(" ",@hcNamen );
  113. }
  114. 1;
  115. =pod
  116. =item device
  117. =item summary sends heating commands to heating at defined times
  118. =item summary_DE sendet Temperaturwerte zu festgelegen Zeiten an eine Heizung
  119. =begin html
  120. <a name="Heating_Control"></a>
  121. <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  122. <h3>Heating Control</h3>
  123. <ul>
  124. <br>
  125. <a name="Heating_Controldefine"></a>
  126. <b>Define</b>
  127. <ul>
  128. <code>define &lt;name&gt; Heating_Control &lt;device&gt; [&lt;language&gt;] [<u>weekdays</u>] &lt;profile&gt; [&lt;command&gt;|&lt;condition&gt;]</code>
  129. <br><br>
  130. to set a weekly profile for &lt;device&gt;, eg. a heating sink.<br>
  131. You can define different switchingtimes for every day.<br>
  132. The new temperature is sent to the &lt;device&gt; automatically with <br><br>
  133. <code>set &lt;device&gt; (desired-temp|desiredTemperature) &lt;temp&gt;</code><br><br>
  134. Because of the fhem-type of structures, a structures of heating sinks is sent "desired-temp":
  135. Use an explicit command if you have structures of MAX heating thermostats.<br>
  136. If you have defined a &lt;condition&gt; and this condition is false if the switchingtime has reached, no command will executed.<br>
  137. A other case is to define an own perl command with &lt;command&gt;.
  138. <p>
  139. The following parameter are defined:
  140. <ul><b>device</b><br>
  141. The device to switch at the given time.
  142. </ul>
  143. <p>
  144. <ul><b>language</b><br>
  145. Specifies the language used for definition and profiles.
  146. de,en,fr are possible. The parameter is optional.
  147. </ul>
  148. <p>
  149. <ul><b>weekdays</b><br>
  150. Specifies the days for all timer in the <b>Heating_Control</b>.
  151. The parameter is optional. For details see the weekdays part in profile.
  152. </ul>
  153. <p>
  154. <ul><b>profile</b><br>
  155. Define the weekly profile. All timings are separated by space. A switchingtime is defined
  156. by the following example: <br><br>
  157. <ul><b>[&lt;weekdays&gt;|]&lt;time&gt;|&lt;parameter&gt;</b></ul><br>
  158. <u>weekdays:</u> optional, if not set every day of the week is used.<br>
  159. Otherwise you can define a day with its number or its shortname.<br>
  160. <ul>
  161. <li>0,su sunday</li>
  162. <li>1,mo monday</li>
  163. <li>2,tu tuesday</li>
  164. <li>3,we wednesday</li>
  165. <li>4 ...</li>
  166. <li>7,$we weekend ($we)</li>
  167. <li>8,!$we weekday (!$we)</li>
  168. </ul><br>
  169. It is possible to define $we or !$we in daylist to easily allow weekend an holiday. $we !$we are coded as 7 8, when using a numeric daylist.<br><br>
  170. <u>time:</u>define the time to switch, format: HH:MM:[SS](HH in 24 hour format) or a Perlfunction like {sunrise_abs()}. Within the {} you can use the variable $date(epoch) to get the exact switchingtimes of the week. Example: {sunrise_abs_dat($date)}<br><br>
  171. <u>parameter:</u>the temperature to be set, using a float with mask 99.9 or a sybolic value like <b>eco</b> or <b>comfort</b> - whatever your thermostat understands.
  172. The symbolic value can be added an additional parameter: dayTemp:16 night-temp:15. See examples <br><br>
  173. </ul>
  174. <p>
  175. <ul><b>command</b><br>
  176. If no condition is set, all the rest is interpreted as a command. Perl-code is setting up
  177. by the well-known Block with {}.<br>
  178. Note: if a command is defined only this command is executed. In case of executing
  179. a "set desired-temp" command, you must define the hole commandpart explicitly by yourself.<br>
  180. <!----------------------------------------------------------------------------- -->
  181. <!----------------------------------------------------------------------------- -->
  182. <!-- -------------------------------------------------------------------------- -->
  183. The following parameter are replaced:<br>
  184. <ol>
  185. <li>$NAME => the device to switch</li>
  186. <li>$EVENT => the new temperature</li>
  187. </ol>
  188. </ul>
  189. <p>
  190. <ul><b>condition</b><br>
  191. if a condition is defined you must declare this with () and a valid perl-code.<br>
  192. The returnvalue must be boolean.<br>
  193. The parameter $NAME and $EVENT will be interpreted.
  194. </ul>
  195. <p>
  196. <b>Examples:</b>
  197. <ul>
  198. <code>define HCB Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|eco</code><br>
  199. Mo-Fr are setting the temperature at 05:20 to 21&deg;C, and at 05:25 to <b>comfort</b>.
  200. Every day will be set the temperature at 17:20 to 21&deg;C and 17:25 to <b>eco</b>.<p>
  201. <code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Tu,Th-Fr|16:00|18.5 20:00|12
  202. {fhem("set dummy on"); fhem("set $NAME desired-temp $EVENT");}</code><br>
  203. At the given times and weekdays only(!) the command will be executed.<p>
  204. <code>define HCW Heating_Control WZ_Heizung Sa-Su,We|08:00|21 (ReadingsVal("WeAreThere", "state", "no") eq "yes")</code><br>
  205. The temperature is only set if the dummy variable WeAreThere is "yes".<p>
  206. <code>define HCW Heating_Control WZ_Heizung en Su-Fr|{sunrise_abs()}|21 Mo-Fr|{sunset_abs()}|16</code><br>
  207. The device is switched at sunrise/sunset. Language: english.<p>
  208. <code>define HCW Heating_Control WZ_Heizung en Mo-Fr|{myFunction}|night-temp:18 Mo-Fr|{myFunction()}|dayTemp:16</code><br>
  209. The is switched at time myFunction(). It is sent the Command "night-temp 18" and "dayTemp 16".<p>
  210. If you want to have set all Heating_Controls their current value (after a temperature lowering phase holidays)
  211. you can call the function <b>Heating_Control_SetTemp("HC-device")</b> or <b>Heating_Control_SetAllTemps()</b>.<br>
  212. This call can be automatically coupled to a dummy by a notify:<br>
  213. <code>define HeizStatus2 notify Heating:. * {Heating_Control_SetAllTemps()}</code>
  214. <br><p>
  215. Some definitions without comment:
  216. <code><pre>
  217. define hc Heating_Control HeizungKueche de 7|23:35|25 34|23:30|22 23:30|16 23:15|22 8|23:45|16
  218. define hc Heating_Control HeizungKueche de fr,$we|23:35|25 34|23:30|22 23:30|16 23:15|22 12|23:45|16
  219. define hc Heating_Control HeizungKueche de 20:35|25 34|14:30|22 21:30|16 21:15|22 12|23:00|16
  220. define hw Heating_Control HeizungKueche de mo-so, $we|{sunrise_abs_dat($date)}|18 mo-so, $we|{sunset_abs_dat($date)}|22
  221. define ht Heating_Control HeizungKueche de mo-so,!$we|{sunrise_abs_dat($date)}|18 mo-so,!$we|{sunset_abs_dat($date)}|22
  222. define hh Heating_Control HeizungKueche de {sunrise_abs_dat($date)}|19 {sunset_abs_dat($date)}|21
  223. define hx Heating_Control HeizungKueche de 22:35|25 23:00|16
  224. </code></pre>
  225. the list of days can be set globaly for the whole Heating_Control:<p>
  226. <code><pre>
  227. define HeizungWohnen_an_wt Heating_Control HeizungWohnen de !$we 09:00|19 (heizungAnAus("Ein"))
  228. define HeizungWohnen_an_we Heating_Control HeizungWohnen de $we 09:00|19 (heizungAnAus("Ein"))
  229. define HeizungWohnen_an_we Heating_Control HeizungWohnen de 78 09:00|19 (heizungAnAus("Ein"))
  230. define HeizungWohnen_an_we Heating_Control HeizungWohnen de 57 09:00|19 (heizungAnAus("Ein"))
  231. define HeizungWohnen_an_we Heating_Control HeizungWohnen de fr,$we 09:00|19 (heizungAnAus("Ein"))
  232. </code></pre>
  233. An example to be able to temporarily boost the temperature for one hour:
  234. <code><pre>
  235. define hc Heating_Control HeatingBath de !$we|05:00|{HC_WithBoost(23,"HeatingBath")} $we|07:00|{HC_WithBoost(23,"HeatingBath")} 23:00|{HC_WithBoost(20,"HeatingBath")}
  236. </code></pre>
  237. and using a "HeatingBath_Boost" dummy variable:
  238. <code><pre>
  239. define HeatingBath_Boost dummy
  240. attr HeatingBath_Boost setList state:0,23,24,25
  241. attr HeatingBath_Boost webCmd state
  242. define di_ResetBoostBath DOIF ([HeatingBath_Boost] > 0)
  243. ({Heating_Control_SetAllTemps()}, defmod di_ResetBoostBath_Reset at +01:00:00 set HeatingBath_Boost 0)
  244. DOELSE
  245. ({Heating_Control_SetAllTemps()})
  246. attr di_ResetBoostBath do always
  247. </code></pre>
  248. and the perl subroutine in 99_myUtils.pm (or the like)
  249. <code><pre>
  250. sub HC_BathWithBoost {
  251. my $numParams = @_;
  252. my ($degree, $boostPrefix) = @_;
  253. if ($numParams > 1)
  254. {
  255. my $boost = ReadingsVal($boostPrefix . "_Boost", "state", "0");
  256. return $boost if ($boost =~ m/^\d+$/) && ($boost > 0); # boost?
  257. }
  258. return $degree; # otherwise return given temperature
  259. }
  260. </code></pre>
  261. Now you can set "HeatingBath_Boost" in the web interface for a one-hour boost of 3 degrees in the bath.
  262. (you can trigger that using the PRESENCE function using your girlfriend's device... grin).
  263. Easy to extend this with a vacation timer using another dummy variable, here <code>VacationTemp</code>.<br>
  264. Then you can use the command
  265. <code>defmod defVacationEnd at 2016-12-30T00:00:00 set VacationTemp off, {Heating_Control_SetAllTemps()}</code>
  266. to stop the vacation temperature before you return in january 2017 and let the appartment heat up again.
  267. <code><pre>
  268. sub HC_BathWithBoost($) {
  269. my $vacation = ReadingsVal("VacationTemp", "state", "unfortunately not on vacation");
  270. return $vacation if $vacation =~ /^(\d+|eco)$/; # set vacation temperature if given
  271. my $numParams = @_;
  272. my ($degree, $boostPrefix) = @_;
  273. if ($numParams > 1)
  274. {
  275. my $boost = ReadingsVal($boostPrefix . "_Boost", "state", "0");
  276. return $boost if ($boost =~ m/^\d+$/) && ($boost > 0); # boost?
  277. }
  278. }
  279. </code></pre>
  280. Pray that the device does not restart during your vacation, as the <code>define defVacationEnd ... at </code> is volatile and will be lost at restart!
  281. </ul>
  282. </ul>
  283. <a name="Heating_Controlset"></a>
  284. <b>Set</b> <ul>N/A</ul><br>
  285. <a name="Heating_Controlget"></a>
  286. <b>Get</b> <ul>N/A</ul><br>
  287. <a name="Heating_ControlLogattr"></a>
  288. <b>Attributes</b>
  289. <ul>
  290. <li>delayedExecutionCond <br>
  291. defines a delay Function. When returning true, the switching of the device is delayed until the function retruns a false value. The behavior is just like a windowsensor.
  292. <br><br>
  293. <b>Example:</b>
  294. <pre>
  295. attr hc delayedExecutionCond isDelayed("%HEATING_CONTROL","%WEEKDAYTIMER","%TIME","%NAME","%EVENT")
  296. </pre>
  297. the parameters %HEATING_CONTROL(timer name) %TIME %NAME(device name) %EVENT are replaced at runtime by the correct value.
  298. <br><br>
  299. <b>Example of a function:</b>
  300. <pre>
  301. sub isDelayed($$$$$) {
  302. my($hc, $wdt, $tim, $nam, $event ) = @_;
  303. my $theSunIsStillshining = ...
  304. return ($tim eq "16:30" && $theSunIsStillshining) ;
  305. }
  306. </pre>
  307. </li>
  308. <li>switchInThePast<br>
  309. defines that the depending device will be switched in the past in definition and startup phase when the device is not recognized as a heating.
  310. Heatings are always switched in the past.
  311. </li>
  312. <li><a href="#disable">disable</a></li>
  313. <li><a href="#event-on-update-reading">event-on-update-reading</a></li>
  314. <li><a href="#event-on-change-reading">event-on-change-reading</a></li>
  315. <li><a href="#stateFormat">stateFormat</a></li>
  316. <li>windowSensor<br>Defines a list of window sensors. When one of its window state readings is <b>open</b> the aktual switch is delayed.</li> </ul><br>
  317. </ul>
  318. =end html
  319. =begin html_DE
  320. <a name="Heating_Control"></a>
  321. <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
  322. <h3>Heating Control</h3>
  323. <ul>
  324. <br>
  325. <a name="Heating_Controldefine"></a>
  326. <b>Define</b>
  327. <ul>
  328. <code>define &lt;name&gt; Heating_Control &lt;device&gt; [&lt;language&gt;] &lt;wochentage;] &lt;profile&gt; &lt;command&gt;|&lt;condition&gt;</code>
  329. <br><br>
  330. Bildet ein Wochenprofil f&uumlr ein &lt;device&gt;, zb. Heizk&oumlrper, ab.<br>
  331. Es k&oumlnnen f&uumlr jeden Tag unterschiedliche Schaltzeiten angegeben werden.<br>
  332. Ist das &lt;device&gt; ein Heizk&oumlrperthermostat (zb. FHT8b, MAX) so wird bei FHT8b/MAX die
  333. zu setzende Temperatur im &lt;profile&gt; automatisch mittels <br><br>
  334. <code>set &lt;device&gt; (desired-temp|desiredTemperature) &lt;temp&gt;</code> <br><br> gesendet.
  335. Struktuen von Heizk&oumlrperthermostaten bekommen aufgrund des fhem-Typs auch desired-temp gesendet:
  336. Nutze bitte explizite Kommandos wenn Strukturen von MAX Heizthermostaten gesteuert werden sollen.<br><br>
  337. Ist eine &lt;condition&gt; angegeben und ist zum Schaltpunkt der Ausdruck unwahr,
  338. so wird dieser Schaltpunkt nicht ausgef&uumlhrt.<br>
  339. Alternativ zur Automatik kann stattdessen eigener Perl-Code im &lt;command&gt; ausgef&uumlhrt werden.
  340. <p>
  341. Folgende Parameter sind im Define definiert:
  342. <ul><b>device</b><br>
  343. Name des zu schaltenden Device.
  344. </ul>
  345. <p>
  346. <ul><b>language</b><br>
  347. Spezifiziert die Sprache f&uumlr die Definition und die Anzeige der Profile in der Weboberfl&aumlche.
  348. Zurzeit sind de,en,fr definiert. Der Parameter ist optional.
  349. </ul>
  350. <p>
  351. <ul><b><u>wochentage</u></b><br>
  352. Spezifiziert die Tage f&uumlr alle Timer eines <b>Heating_Control</b>.
  353. Der Parameter ist optional. Bitte f&uumlr Details zur Definition siehe wochentage im part profile.
  354. </ul>
  355. <p>
  356. <ul><b>profile</b><br>
  357. Angabe des Wochenprofils. Die einzelnen Schaltzeiten sind durch Leerzeichen getrennt
  358. Die Angabe der Schaltzeiten ist nach folgendem Muster definiert:<br>
  359. <ul><b>[&lt;Wochentage&gt;|]&lt;Uhrzeit&gt;|&lt;Parameter&gt;</b></ul><br>
  360. <u>Wochentage:</u> optionale Angabe, falls nicht gesetzt wird der Schaltpunkt jeden Tag ausgef&uumlhrt.
  361. F&uumlr die Tage an denen dieser Schaltpunkt aktiv sein soll, ist jeder Tag mit seiner
  362. Tagesnummer (Mo=1, ..., So=0) oder Name des Tages (Mo, Di, ..., So) einzusetzen.<br><br>
  363. <ul>
  364. <li>0,so Sonntag</li>
  365. <li>1,mo Montag</li>
  366. <li>2,di Dienstag</li>
  367. <li>3,mi Mittwoch</li>
  368. <li>4 ...</li>
  369. <li>7,$we Wochenende ($we)</li>
  370. <li>8,!$we Wochentag (!$we)</li>
  371. </ul><br>
  372. Es ist m&oumlglich $we or !$we in der Tagesliste zu definieren.
  373. So ist es auf einfache Art m&oumlglich die Schaltzeitpunkte f&uumlr das Wochenende oder Wochetage zu definieren.
  374. $we und!$we werden als 7 bzw. 8 spezifiziert, wenn die numerische Variante der Tagesliste gew&aumlhlt wird.<br><br>
  375. <u>Uhrzeit:</u>Angabe der Uhrzeit zu der geschaltet werden soll, Format: HH:MM:[SS](HH im 24 Stunden Format) oder eine Perlfunction wie {sunrise_abs()}.
  376. In {} kannst du die Variable $date(epoch) nutzen, um die Schaltzeiten der Woche zu berechnen. Beispiel: {sunrise_abs_dat($date)}<br><br>
  377. <u>Parameter:</u>Angabe der zu setzenden Temperatur als Zahl mit Format 99.9 oder als symbolische Konstante <b>eco</b>
  378. or <b>comfort</b> - was immer das Heizk&oumlrperthermostat versteht.
  379. Symbolischen Werten kann ein zus&aumltzlicher Parameter angeh&aumlngt werden: dayTemp:16 night-temp:15. Unten folgen Beispiele<br><br>
  380. </ul>
  381. <p>
  382. <ul><b>command</b><br>
  383. Falls keine Condition in () angegeben wurde, so wird alles weitere als Command
  384. interpretiert. Perl-Code ist in {} zu setzen. <br>
  385. Wichtig: Falls ein Command definiert ist, so wird zu den definierten Schaltzeiten
  386. nur(!) das Command ausgef&uumlhrt. Falls ein desired-temp Befehl abgesetzt werde soll,
  387. so muss dies explizit angegeben werden.<br>
  388. Folgende Parameter werden ersetzt:<br>
  389. <ol>
  390. <li>$NAME => das zu schaltende Device</li>
  391. <li>$EVENT => die zu setzende Temperatur</li>
  392. </ol>
  393. </ul>
  394. <p>
  395. <ul><b>condition</b><br>
  396. Bei Angabe einer Condition ist diese in () zu setzen und mit validem Perl-Code zu versehen.<br>
  397. Der R&uumlckgabedatentyp der condition muss boolean sein.<br>
  398. Die Parameter $NAME und $EVENT werden interpretiert.
  399. </ul>
  400. <p>
  401. <b>Beispiele:</b>
  402. <ul>
  403. <code>define HCW Heating_Control Bad_Heizung 12345|05:20|21 12345|05:25|comfort 17:20|21 17:25|eco</code><br>
  404. Mo-Fr wird die Temperatur um 05:20Uhr auf 21&deg;C, und um 05:25Uhr auf <b>comfort</b> gesetzt.
  405. Jeden Tag wird die Temperatur um 17:20Uhr auf 21&deg;C und 17:25Uhr auf <b>eco</b> gesetzt.<p>
  406. <code>define HCW Heating_Control WZ_Heizung 07:00|16 Mo,Di,Mi|16:00|18.5 20:00|12
  407. {fhem("set dummy on"); fhem("set $NAME desired-temp $EVENT");}</code><br>
  408. Zu den definierten Schaltzeiten wird nur(!) der in {} angegebene Perl-Code ausgef&uumlhrt.<p>
  409. <code>define HCW Heating_Control WZ_Heizung Sa-So,Mi|08:00|21 (ReadingsVal("WeAreThere", "state", "no") eq "yes")</code><br>
  410. Die zu setzende Temperatur wird nur gesetzt, falls die Dummy Variable WeAreThere = "yes" ist.<p>
  411. <code>define HCW Heating_Control WZ_Heizung en Su-Fr|{sunrise_abs()}|21 Mo-Fr|{sunset_abs()}|16</code><br>
  412. Das Ger&aumlt wird bei Sonnenaufgang und Sonnenuntergang geschaltet. Sprache: Englisch.<p>
  413. <code>define HCW Heating_Control WZ_Heizung en Mo-Fr|{myFunction}|night-temp:18 Mo-Fr|{myFunction()}|dayTemp:16</code><br>
  414. Das Ger&aumlt wird bei myFunction() geschaltet. Es wird das Kommando "night-temp 18" bzw. "dayTemp 16" gesendet.<p>
  415. Wenn du beispielsweise nach einer Temperaturabsenkungsphase erreichen willst, dass alle Heating_Controls ihren aktuellen Wert
  416. einstellen sollen, kannst du die Funktion <b>Heating_Control_SetTemp("HC-device")</b> or <b>Heating_Control_SetAllTemps()</b> aufrufen.<p>
  417. Dieser Aufruf kann per notify automatisch an ein dummy gekoppelt werden:<br>
  418. <code>define HeizStatus2 notify Heizung:.* {Heating_Control_SetAllTemps()}</code>
  419. <br><p>
  420. Einige Definitionen ohne weitere Erkl&aumlrung:
  421. <code><pre>
  422. define hc Heating_Control HeizungKueche de 7|23:35|25 34|23:30|22 23:30|16 23:15|22 8|23:45|16
  423. define hc Heating_Control HeizungKueche de fr,$we|23:35|25 34|23:30|22 23:30|16 23:15|22 12|23:45|16
  424. define hc Heating_Control HeizungKueche de 20:35|25 34|14:30|22 21:30|16 21:15|22 12|23:00|16
  425. define hw Heating_Control HeizungKueche de mo-so, $we|{sunrise_abs_dat($date)}|18 mo-so, $we|{sunset_abs_dat($date)}|22
  426. define ht Heating_Control HeizungKueche de mo-so,!$we|{sunrise_abs_dat($date)}|18 mo-so,!$we|{sunset_abs_dat($date)}|22
  427. define hh Heating_Control HeizungKueche de {sunrise_abs_dat($date)}|19 {sunset_abs_dat($date)}|21
  428. define hx Heating_Control HeizungKueche de 22:35|25 23:00|16
  429. </code></pre>
  430. Die Tagesliste kann global f&uumlr das ganze Heating_Control angegeben werden:<p>
  431. <code><pre>
  432. define HeizungWohnen_an_wt Heating_Control HeizungWohnen de !$we 09:00|19 (heizungAnAus("Ein"))
  433. define HeizungWohnen_an_we Heating_Control HeizungWohnen de $we 09:00|19 (heizungAnAus("Ein"))
  434. define HeizungWohnen_an_we Heating_Control HeizungWohnen de 78 09:00|19 (heizungAnAus("Ein"))
  435. define HeizungWohnen_an_we Heating_Control HeizungWohnen de 57 09:00|19 (heizungAnAus("Ein"))
  436. define HeizungWohnen_an_we Heating_Control HeizungWohnen de fr,$we 09:00|19 (heizungAnAus("Ein"))
  437. </code></pre>
  438. es ist möglich den Parameter als Perlcode zu spezifizieren:<p>
  439. <code><pre>
  440. ... 7|23:35|{getParameter(13,"this")} 7|23:36|{getParameter(14,"that")}
  441. </code></pre>
  442. ein detailiertes Beispiel ist in Heating_Control(EN) beschrieben<p>
  443. </ul>
  444. </ul>
  445. <a name="Heating_Controlset"></a>
  446. <b>Set</b>
  447. <code><b><font size="+1">set &lt;name&gt; &lt;value&gt;</font></b></code>
  448. <br><br>
  449. where <code>value</code> is one of:<br>
  450. <pre>
  451. <b>enable</b> # enables the Heating_Control
  452. <b>disable</b> # disables the Heating_Control
  453. </pre>
  454. <b><font size="+1">Examples</font></b>:
  455. <ul>
  456. <code>set hc disable</code><br>
  457. <code>set hc enable</code><br>
  458. </ul>
  459. </ul>
  460. <a name="Heating_Controlget"></a>
  461. <b>Get</b> <ul>N/A</ul><br>
  462. <a name="Heating_ControlLogattr"></a>
  463. <b>Attributes</b>
  464. <ul>
  465. <li>delayedExecutionCond <br>
  466. definiert eine Veroegerungsfunktion. Wenn die Funktion wahr liefert, wird die Schaltung des Geraets solage verzoegert, bis die Funktion wieder falsch liefert. Das Verhalten entspricht einem Fensterkontakt.
  467. <br><br>
  468. <b>Beispiel:</b>
  469. <pre>
  470. attr wd delayedExecutionCond isDelayed("$HEATING_CONTROL","$WEEKDAYTIMER","$TIME","$NAME","$EVENT")
  471. </pre>
  472. Die Parameter $HEATING_CONTROL(timer Name) $TIME $NAME(device Name) $EVENT werden zur Laufzeit durch die echten Werte ersetzt.
  473. <br><br>
  474. <b>Beispielfunktion:</b>
  475. <pre>
  476. sub isDelayed($$$$$) {
  477. my($hc, $wdt, $tim, $nam, $event ) = @_;
  478. my $theSunIsStillshining = ...
  479. return ($tim eq "16:30" && $theSunIsStillshining) ;
  480. }
  481. </pre>
  482. </li>
  483. <li>switchInThePast<br>
  484. Definiert, dass ein abh&aumlngiges Ger&aumlt in der Start- oder Definitionsphase mit einem Wert aus der Vergangheit geschaltet wird auch wenn das Ger&aumlt nicht als Heizung erkannt wurde.
  485. Heizungen werden immer mit einem Wert aus der Vergangenheit geschaltet.
  486. </li>
  487. <li><a href="#disable">disable</a></li>
  488. <li><a href="#event-on-update-reading">event-on-update-reading</a></li>
  489. <li><a href="#event-on-change-reading">event-on-change-reading</a></li>
  490. <li><a href="#stateFormat">stateFormat</a></li>
  491. <li>windowSensor<br>Definiert eine Liste mit Fensterkontakten. Wenn das Reading window state eines Fensterkontakts <b>open</b> ist, wird der aktuelle Schaltvorgang verz&oumlgert.</li>
  492. </ul><br>
  493. =end html_DE
  494. =cut