ramp-thermostat.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <script type="text/x-red" data-template-name="ramp-thermostat">
  2. <div class="form-row">
  3. <label for="node-input-profile"><i class="fa fa-line-chart"></i> Profile</label>
  4. <input type="text" id="node-input-profile">
  5. </div>
  6. <div class="form-row">
  7. <label for="node-input-hysteresisplus"><i class="fa fa-arrows-v"></i> Hysteresis [+]</label>
  8. <input type="text" id="node-input-hysteresisplus" style="width:50px"> (degrees)
  9. </div>
  10. <div class="form-row">
  11. <label for="node-input-hysteresisminus"><i class="fa fa-arrows-v"></i> Hysteresis [-]</label>
  12. <input type="text" id="node-input-hysteresisminus" style="width:50px"> (degrees)
  13. </div>
  14. <div class="form-row">
  15. <label for="node-input-hysteresisleft"><i class="fa fa-stop-circle"></i> Ramp Limit</label>
  16. <input type="text" id="node-input-ramplimit" style="width:50px"> (mins)
  17. </div>
  18. <div class="form-row">
  19. <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
  20. <input type="text" id="node-input-name" placeholder="Name">
  21. </div>
  22. <div class="form-tips"><span class="fa fa-arrows-v"> Hysteresis is used to prevent osciliation.
  23. The [+] value is added to the target and the [-] (absolute) value is
  24. subtracted from the target. Within this neutral zone no action accurs.<br/>
  25. </span>
  26. </div>
  27. <div class="form-tips">
  28. <span class="fa fa-stop-circle"> Ramp Limit defines the maximum time prior to a point to apply the
  29. gradient for calculating the thermostat value. Prior to this time, the thermostat will
  30. stay constant, thus avoiding need to add extra points.
  31. </span>
  32. </div>
  33. </script>
  34. <script type="text/x-red" data-help-name="ramp-thermostat">
  35. <p>A node that emulates a thermostat.</p>
  36. <p>The ramp-thermostat controls an actuator depending on the current input temperature and the target temperature.</p>
  37. <h3>Inputs</h3>
  38. <dl class="message-properties">
  39. <dt>payload
  40. <span class="property-type">number</span>
  41. </dt>
  42. <dd> current temperature</dd>
  43. <dt class="optional">topic <span class="property-type">string</span></dt>
  44. <dd> setCurrent (or undefined)</dd>
  45. </dl>
  46. <dl class="message-properties">
  47. <dt>payload
  48. <span class="property-type">number</span>
  49. </dt>
  50. <dd> target temperature</dd>
  51. <dt class="optional">topic <span class="property-type">string</span></dt>
  52. <dd> setTarget</dd>
  53. </dl>
  54. <dl class="message-properties">
  55. <dt>payload
  56. <span class="property-type">string</span>
  57. </dt>
  58. <dd> profile name</dd>
  59. <dt class="optional">topic <span class="property-type">string</span></dt>
  60. <dd> setProfile</dd>
  61. </dl>
  62. <dl class="message-properties">
  63. <dt>payload
  64. <span class="property-type">object</span>
  65. </dt>
  66. <dd> JSON e.g. {"name":"myGreatProfile","points":{"00:00":16.0,"08:00":20.0,
  67. "20:00":20.0,"24:00":16.0}}</dd>
  68. <dt class="optional">topic <span class="property-type">string</span></dt>
  69. <dd> setProfile</dd>
  70. </dl>
  71. <h3>Outputs</h3>
  72. <ol class="node-ports">
  73. <li>State
  74. <dl class="message-properties">
  75. <dt>payload <span class="property-type">boolean</span></dt>
  76. <dd>the state of the thermostat.</dd>
  77. </dl>
  78. </li>
  79. <li>Current Temperature
  80. <dl class="message-properties">
  81. <dt>payload <span class="property-type">number</span></dt>
  82. <dd>the current temperature.</dd>
  83. </dl>
  84. </li>
  85. <li>Target Temperature
  86. <dl class="message-properties">
  87. <dt>payload <span class="property-type">number</span></dt>
  88. <dd>the actual target temperature.</dd>
  89. </dl>
  90. </li>
  91. </ol>
  92. <h3>Details</h3>
  93. <p>The target temperature is defined by a profile that
  94. provides the value depending on the current time <code>00:00-24:00</code>.
  95. The profile consists of several points whose connections build a sequence of lines.
  96. The switching moment can be optimized by defining a gradient line like a <code>ramp</code>.</p>
  97. <p>The hysteresis is used to prevent osciliation. The `[+]` value is added to the target and the `[-]` (absolute) value is subtracted from the target. Within this neutral zone no action accurs.</p>
  98. <p>
  99. The ramp limit defines the maximum time prior to a point to apply the
  100. gradient for calculating the thermostat value. Prior to this time, the thermostat will
  101. stay constant, thus avoiding need to add extra points. <br/>
  102. For example, 2 points:<br/><code>06:00: 10 (degrees)</code><br/><code>14:00: 21 (degrees)</code><br/>
  103. with no ramp limit will gradually increase thermostat over the 8 hour period. Setting the ramp
  104. limit to 60 minutes will keep the thermostat at 10 degrees until <code>13:00</code> and then will
  105. increase only over the last
  106. hour. <br/>Set to <code>1440</code> or leave empty to disable this feature.
  107. </p>
  108. </script>
  109. <script type="text/javascript">
  110. RED.nodes.registerType('ramp-thermostat',{
  111. category: 'smart home',
  112. color: '#E9967A',
  113. defaults: {
  114. name: {value:""},
  115. profile: {value:"",type:"profile"},
  116. hysteresisplus: {value:0, validate:RED.validators.number()},
  117. hysteresisminus: {value:0, validate:RED.validators.number()},
  118. ramplimit: {value:"", validate:RED.validators.regex(/^\d*$/)}
  119. },
  120. inputs:1,
  121. outputs:3,
  122. outputLabels: ["state","current temperature","target temperature"],
  123. icon: "trigger.png",
  124. label: function() {
  125. return this.name||"ramp-thermostat";
  126. },
  127. paletteLabel: 'thermostat'
  128. });
  129. </script>
  130. <script type="text/x-red" data-template-name="profile">
  131. <div class="form-row">
  132. <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
  133. <input type="text" id="node-config-input-name">
  134. </div>
  135. <div>
  136. <label style="float:left; margin-bottom:10px"><i class="fa fa-dot-circle-o"></i> Points:</label>
  137. <label style="float:left;margin-left:45px;"> Time (hh:mm)&nbsp;&nbsp&nbsp;Temp (°)</label>
  138. </div>
  139. <div class="form-row">
  140. <label for="node-config-input-time1"><i class="fa fa-dot-circle-o"></i> #1</label>
  141. <input class="input-append-left" type="text" id="node-config-input-time1" style="width:50px">
  142. <input type="text" id="node-config-input-temp1" style="margin-left:45px; width:50px">
  143. </div>
  144. <div class="form-row">
  145. <label for="node-config-input-time2"><i class="fa fa-dot-circle-o"></i> #2</label>
  146. <input class="input-append-left" type="text" id="node-config-input-time2" style="width:50px">
  147. <input type="text" id="node-config-input-temp2" style="margin-left:45px; width:50px">
  148. </div>
  149. <div class="form-row">
  150. <label for="node-config-input-time3"><i class="fa fa-dot-circle-o"></i> #3</label>
  151. <input class="input-append-left" type="text" id="node-config-input-time3" style="width:50px">
  152. <input type="text" id="node-config-input-temp3" style="margin-left:45px; width:50px">
  153. </div>
  154. <div class="form-row">
  155. <label for="node-config-input-time4"><i class="fa fa-dot-circle-o"></i> #4</label>
  156. <input class="input-append-left" type="text" id="node-config-input-time4" style="width:50px">
  157. <input type="text" id="node-config-input-temp4" style="margin-left:45px; width:50px">
  158. </div>
  159. <div class="form-row">
  160. <label for="node-config-input-time5"><i class="fa fa-dot-circle-o"></i> #5</label>
  161. <input class="input-append-left" type="text" id="node-config-input-time5" style="width:50px">
  162. <input type="text" id="node-config-input-temp5" style="margin-left:45px; width:50px">
  163. </div>
  164. <div class="form-row">
  165. <label for="node-config-input-time6"><i class="fa fa-dot-circle-o"></i> #6</label>
  166. <input class="input-append-left" type="text" id="node-config-input-time6" style="width:50px">
  167. <input type="text" id="node-config-input-temp6" style="margin-left:45px; width:50px">
  168. </div>
  169. <div class="form-row">
  170. <label for="node-config-input-time7"><i class="fa fa-dot-circle-o"></i> #7</label>
  171. <input class="input-append-left" type="text" id="node-config-input-time7" style="width:50px">
  172. <input type="text" id="node-config-input-temp7" style="margin-left:45px; width:50px">
  173. </div>
  174. <div class="form-row">
  175. <label for="node-config-input-time8"><i class="fa fa-dot-circle-o"></i> #8</label>
  176. <input class="input-append-left" type="text" id="node-config-input-time8" style="width:50px">
  177. <input type="text" id="node-config-input-temp8" style="margin-left:45px; width:50px">
  178. </div>
  179. <div class="form-row">
  180. <label for="node-config-input-time9"><i class="fa fa-dot-circle-o"></i> #9</label>
  181. <input class="input-append-left" type="text" id="node-config-input-time9" style="width:50px">
  182. <input type="text" id="node-config-input-temp9" style="margin-left:45px; width:50px">
  183. </div>
  184. <div class="form-row">
  185. <label for="node-config-input-time10"><i class="fa fa-dot-circle-o"></i> #10</label>
  186. <input class="input-append-left" type="text" id="node-config-input-time10" style="width:50px">
  187. <input type="text" id="node-config-input-temp10" style="margin-left:45px; width:50px">
  188. </div>
  189. <div class="form-tips"><span>A Profile has at least 2 Points and should typically start at 00:00 and end at 24:00.</span>
  190. </div>
  191. </script>
  192. <script type="text/javascript">
  193. var time_re = /(^$)|(^(?:[01]\d|2[0-4]):[0-5]\d$)/;
  194. var temp_re = /^[+-]?\d*\.?\d+$|^$/;
  195. RED.nodes.registerType('profile',{
  196. category: 'config',
  197. defaults: {
  198. name: {value:'',required:true},
  199. time1: {value:'', validate:RED.validators.regex(time_re)},
  200. temp1: {value:'', validate:RED.validators.regex(temp_re)},
  201. time2: {value:'', validate:RED.validators.regex(time_re)},
  202. temp2: {value:'', validate:RED.validators.regex(temp_re)},
  203. time3: {value:'', validate:RED.validators.regex(time_re)},
  204. temp3: {value:'', validate:RED.validators.regex(temp_re)},
  205. time4: {value:'', validate:RED.validators.regex(time_re)},
  206. temp4: {value:'', validate:RED.validators.regex(temp_re)},
  207. time5: {value:'', validate:RED.validators.regex(time_re)},
  208. temp5: {value:'', validate:RED.validators.regex(temp_re)},
  209. time6: {value:'', validate:RED.validators.regex(time_re)},
  210. temp6: {value:'', validate:RED.validators.regex(temp_re)},
  211. time7: {value:'', validate:RED.validators.regex(time_re)},
  212. temp7: {value:'', validate:RED.validators.regex(temp_re)},
  213. time8: {value:'', validate:RED.validators.regex(time_re)},
  214. temp8: {value:'', validate:RED.validators.regex(temp_re)},
  215. time9: {value:'', validate:RED.validators.regex(time_re)},
  216. temp9: {value:'', validate:RED.validators.regex(temp_re)},
  217. time10: {value:'', validate:RED.validators.regex(time_re)},
  218. temp10: {value:'', validate:RED.validators.regex(temp_re)},
  219. },
  220. label: function() {
  221. return this.name;
  222. }
  223. });
  224. </script>