Browse Source

moved ramp_max to editable field named hysterialeft

Shane Weaver 6 years ago
parent
commit
cf03cc712b
3 changed files with 42 additions and 27 deletions
  1. 19 18
      package.json
  2. 19 5
      ramp-thermostat/ramp-thermostat.html
  3. 4 4
      ramp-thermostat/ramp-thermostat.js

+ 19 - 18
package.json

@@ -1,26 +1,27 @@
 {
-    "name"         : "node-red-contrib-ramp-thermostat",
-    "version"      : "0.4.0",
-    "description"  : "A Node-RED node that emulates a thermostat",
-    "dependencies": {
-    },
-    "keywords": [ 
-      "node-red",
-      "thermostat",
-      "profile",
-      "heating control",
-      "tmeperature control",
-      "energy saving",
-      "multtple heating zones",
-      "single room temperature control"
+    "name": "node-red-contrib-ramp-thermostat",
+    "version": "0.5.0",
+    "description": "A Node-RED node that emulates a thermostat",
+    "dependencies": {},
+    "keywords": [
+        "node-red",
+        "thermostat",
+        "profile",
+        "heating control",
+        "tmeperature control",
+        "energy saving",
+        "multtple heating zones",
+        "single room temperature control"
     ],
     "author": "cflurin",
+    "contributors": [
+        "drweaver"
+    ],
     "repository": {
-      "type": "git",
-      "url": "https://github.com/cflurin/node-red-contrib-ramp-thermostat.git"
+        "type": "git",
+        "url": "https://github.com/cflurin/node-red-contrib-ramp-thermostat.git"
     },
-    
-    "node-red"     : {
+    "node-red": {
         "nodes": {
             "ramp-thermostat": "ramp-thermostat/ramp-thermostat.js"
         }

+ 19 - 5
ramp-thermostat/ramp-thermostat.html

@@ -5,17 +5,30 @@
     </div>
     <div class="form-row">
         <label for="node-input-hysteresisplus"><i class="fa fa-arrows-v"></i> Hysteresis [+]</label>
-        <input type="text" id="node-input-hysteresisplus" style="width:50px">
+        <input type="text" id="node-input-hysteresisplus" style="width:50px"> (degrees)
     </div>
     <div class="form-row">
         <label for="node-input-hysteresisminus"><i class="fa fa-arrows-v"></i> Hysteresis [-]</label>
-        <input type="text" id="node-input-hysteresisminus" style="width:50px">
+        <input type="text" id="node-input-hysteresisminus" style="width:50px"> (degrees)
     </div>
+    <div class="form-row">
+        <label for="node-input-hysteresisleft"><i class="fa fa-arrows-h"></i> Hysteresis</label>
+        <input type="text" id="node-input-hysteresisleft" style="width:50px"> (mins)
+    </div>    
     <div class="form-row">
         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
-        <input type="text" id="node-input-name" placeholder="Name">
+        <input type="text" id="node-input-name" placeholder="Name"> 
+    </div>
+    <div class="form-tips"><span class="fa fa-arrows-v"> 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.<br/>
+    </span>
     </div>
-    <div class="form-tips"><span>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.</span>
+    <div class="form-tips">
+    <span class="fa fa-arrows-h"> Hysteresis defines the maximum time prior to a point to apply the 
+        gradient for calculating the thermostat value. Above this time, the thermostat will
+        stay constant, thus avoiding need to add extra points.
+    </span>
     </div>
 </script>
 
@@ -94,7 +107,8 @@
             name: {value:""},
             profile: {value:"",type:"profile"},
             hysteresisplus: {value:0, validate:RED.validators.number()},
-            hysteresisminus: {value:0, validate:RED.validators.number()}
+            hysteresisminus: {value:0, validate:RED.validators.number()},
+            hysteresisleft: {value:60, validate:RED.validators.number()}
         },
         inputs:1,
         outputs:3,

+ 4 - 4
ramp-thermostat/ramp-thermostat.js

@@ -28,6 +28,7 @@ module.exports = function(RED) {
     
     this.h_plus = Math.abs(parseFloat(config.hysteresisplus)) || 0;
     this.h_minus = Math.abs(parseFloat(config.hysteresisminus)) || 0;
+    this.h_left = Math.abs(parseInt(config.hysteresisleft)) || 1440;
     
     // experimental
     //this.profile = globalContext.get(node_name);
@@ -178,16 +179,15 @@ module.exports = function(RED) {
       point_target = profile.points[k].t;
       
       if (current_mins < point_mins) {
-        const ramp_max = 60;
 
-        if( point_mins - current_mins > ramp_max ) {
+        if( point_mins - current_mins > this.h_left ) {
           // Not yet in window to start ramping thermostat, stay constant
           target = pre_target;
           break;
         }
 
-        if( point_mins - pre_mins > ramp_max && point_mins - current_mins < ramp_max ) {
-          pre_mins = point_mins - ramp_max;
+        if( point_mins - pre_mins > this.h_left && point_mins - current_mins <= this.h_left ) {
+          pre_mins = point_mins - this.h_left;
         }
 
         gradient = (point_target - pre_target) / (point_mins - pre_mins);