ramp-thermostat.html 12 KB

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