mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Added try/catch around duino board creation. Added customisable pol interval to heat miser node
This commit is contained in:
parent
3858b4275d
commit
d1d177669d
@ -23,8 +23,12 @@ function DuinoNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.pin = n.pin || "10";
|
||||
node = this;
|
||||
try {
|
||||
this.board = new duino.Board();
|
||||
|
||||
}
|
||||
catch {
|
||||
util.log("[duino] - Error establishing board connection!");
|
||||
}
|
||||
|
||||
this.on("input", function(message) {
|
||||
if (typeof(message.payload) == "string") {
|
||||
|
@ -27,6 +27,10 @@
|
||||
<label for="node-input-name"><i class="icon-tag"></i> PIN</label>
|
||||
<input type="text" id="node-input-pin" placeholder="1234">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Poll time (in minutes)</label>
|
||||
<input type="text" id="node-input-pollTime" placeholder="30">
|
||||
</div>
|
||||
<div class="form-tips">Expects a msg.payload with a JSON object that contains settings for the Heatmiser thermostat</div>
|
||||
</script>
|
||||
|
||||
|
@ -21,10 +21,11 @@ var util = require('util');
|
||||
|
||||
function HeatmiserNode(n) {
|
||||
// TODO - holiday and hot water cases when confirmed working
|
||||
var DEBUG = true;
|
||||
var DEBUG = false;
|
||||
RED.nodes.createNode(this,n);
|
||||
this.ip = n.ip || "192.168.0.1";
|
||||
this.pin = n.pin || "1234";
|
||||
this.pollTime = n.pollTime*60*1000 || 30*60*1000
|
||||
this.multiWriteFunc = undefined;
|
||||
node = this;
|
||||
|
||||
@ -40,7 +41,7 @@ function HeatmiserNode(n) {
|
||||
node.multiWriteFunc = undefined;
|
||||
return;
|
||||
}
|
||||
node.send(data.dcb);
|
||||
node.send({topic: "", payload:JSON.stringify(data.dcb)});
|
||||
});
|
||||
this.hm.on('error', function(data) {
|
||||
if (DEBUG) {
|
||||
@ -57,7 +58,7 @@ function HeatmiserNode(n) {
|
||||
|
||||
if (!this.currentStatus) {
|
||||
this.read();
|
||||
setInterval(this.read, 30000);
|
||||
setInterval(this.read, this.pollTime);
|
||||
}
|
||||
|
||||
this.write = function(dcb) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user