Updated help files, standardised node convention

This commit is contained in:
Sean Bedford 2014-03-08 18:01:27 +00:00
parent 18b1190029
commit ac9d2424cf
2 changed files with 28 additions and 20 deletions

View File

@ -31,7 +31,15 @@
</script> </script>
<script type="text/x-red" data-help-name="heatmiser"> <script type="text/x-red" data-help-name="heatmiser">
<p>Heatmiser I/O node. Expects a msg.payload with a JSON object that contains settings for the Heatmiser thermostat</p> <p>Heatmiser I/O node.</p>
<p>INPUT - Expects a msg.payload with a JSON object that contains settings for the Heatmiser thermostat</p>
<p>msg.payload can currently be either a heating boost option, or a run mode, as below:</p>
<h3>Heating boost</h3>
<p><pre>{heating: {target: TARGET_TEMPERATURE, hold: MINUTES_TO_STAY_ON_FOR}}</pre></p>
<h3>Run mode</h3>
<p><pre>{runmode:"frost" OR "heating"}</pre></p>
<p>OUTPUT - Will read and send a status update every 30 seconds</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">

View File

@ -26,7 +26,7 @@ function HeatmiserNode(n) {
this.ip = n.ip || "192.168.0.1"; this.ip = n.ip || "192.168.0.1";
this.pin = n.pin || "1234"; this.pin = n.pin || "1234";
this.multiWriteFunc = undefined; this.multiWriteFunc = undefined;
that = this; node = this;
this.hm = new Heatmiser(this.ip, this.pin); this.hm = new Heatmiser(this.ip, this.pin);
@ -34,23 +34,23 @@ function HeatmiserNode(n) {
if (DEBUG) { if (DEBUG) {
util.log(JSON.stringify(data)); util.log(JSON.stringify(data));
} }
that.currentStatus = data.dcb; node.currentStatus = data.dcb;
if (that.multiWriteFunc) { if (node.multiWriteFunc) {
that.multiWriteFunc(); node.multiWriteFunc();
that.multiWriteFunc = undefined; node.multiWriteFunc = undefined;
return; return;
} }
that.send(data.dcb); node.send(data.dcb);
}); });
this.hm.on('error', function(data) { this.hm.on('error', function(data) {
if (DEBUG) { if (DEBUG) {
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
} }
that.send(data); node.send(data);
}); });
this.read = function() { this.read = function() {
that.hm.read_device(); node.hm.read_device();
}; };
if (!this.currentStatus) { if (!this.currentStatus) {
@ -59,7 +59,7 @@ function HeatmiserNode(n) {
} }
this.write = function(dcb) { this.write = function(dcb) {
that.hm.write_device(dcb); node.hm.write_device(dcb);
}; };
this.validateAndWrite = function(message) { this.validateAndWrite = function(message) {
@ -85,7 +85,7 @@ function HeatmiserNode(n) {
// return; // return;
// } // }
// var time = message.payload[key].time; // var time = message.payload[key].time;
// // Ensure that time is a date // // Ensure node time is a date
// if (typeof(time) == "string") { // if (typeof(time) == "string") {
// util.log("Typeof time was " +typeof(message.payload[key].time)); // util.log("Typeof time was " +typeof(message.payload[key].time));
// // message.payload[key].time = new Date(message.payload[key].time); // // message.payload[key].time = new Date(message.payload[key].time);
@ -128,13 +128,13 @@ function HeatmiserNode(n) {
(target <= 10.0) ? message.payload[key].target = 10.0 : message.payload[key].target = target; (target <= 10.0) ? message.payload[key].target = 10.0 : message.payload[key].target = target;
(hold <= 0) ? message.payload[key].hold = 0 : message.payload[key].hold = hold; (hold <= 0) ? message.payload[key].hold = 0 : message.payload[key].hold = hold;
// Ensure that runmode == heating first // Ensure node runmode == heating first
if (that.currentStatus.run_mode === "frost_protection") { if (node.currentStatus.run_mode === "frost_protection") {
// Use the multiWriteFunc as a callback in our success case // Use the multiWriteFunc as a callback in our success case
that.multiWriteFunc = function() { node.multiWriteFunc = function() {
that.write(message.payload); node.write(message.payload);
} }
that.write({"runmode" : "heating"}); node.write({"runmode" : "heating"});
// End the flow here to ensure no double-writing // End the flow here to ensure no double-writing
return; return;
} }
@ -144,7 +144,7 @@ function HeatmiserNode(n) {
if (DEBUG) { if (DEBUG) {
util.log("[100-heatmiser.js] Hit the default case"); util.log("[100-heatmiser.js] Hit the default case");
} }
that.read(); node.read();
} }
} }
// Valid set of key messages, construct DCB and write // Valid set of key messages, construct DCB and write
@ -152,7 +152,7 @@ function HeatmiserNode(n) {
if (DEBUG) { if (DEBUG) {
util.log("[100-heatmiser.js] Injecting " + JSON.stringify(dcb)); util.log("[100-heatmiser.js] Injecting " + JSON.stringify(dcb));
} }
that.write(dcb); node.write(dcb);
}; };
this.on("input", function(message) { this.on("input", function(message) {
@ -161,7 +161,7 @@ function HeatmiserNode(n) {
message.payload = JSON.parse(message.payload); message.payload = JSON.parse(message.payload);
} }
if (message.payload.read) { if (message.payload.read) {
that.hm.read_device(); node.hm.read_device();
} }
else if (message.payload) { else if (message.payload) {
// Compare message.payload data to confirm valid and send to thermostat // Compare message.payload data to confirm valid and send to thermostat
@ -174,7 +174,7 @@ function HeatmiserNode(n) {
} }
} }
} }
that.validateAndWrite(message); node.validateAndWrite(message);
} }
}); });
} }