diff --git a/98-ds18b20.html b/98-ds18b20.html index 34d437e..82f311d 100644 --- a/98-ds18b20.html +++ b/98-ds18b20.html @@ -5,9 +5,10 @@ defaults: { name: {value:""}, sensorid: {value:"", required:true}, - timer: {value:"1", required:true, validate:RED.validators.number()} + timer: {value:"1", required:true, validate:RED.validators.number()}, + repeat: {value: false} }, - inputs: 0, + inputs: 1, outputs: 1, icon: "thermometer.png", label: function() { @@ -37,7 +38,11 @@ -
+
+ + +
+
diff --git a/98-ds18b20.js b/98-ds18b20.js index 2b634b4..aa4e8ff 100644 --- a/98-ds18b20.js +++ b/98-ds18b20.js @@ -5,6 +5,7 @@ module.exports = function(RED) { function DS18B20Node(config) { RED.nodes.createNode(this, config); this.sensorid = config.sensorid; + this.repeat = config.repeat; // user input is in minutes, this is conversion to miliseconds this.timer = config.timer * 1000 * 60; var node = this; @@ -18,11 +19,15 @@ module.exports = function(RED) { }); } - node.tout = setInterval(readSensor, node.timer); - this.on("close", function() { clearInterval(this.tout); }); + + if (node.repeat) + node.tout = setInterval(readSensor, node.timer); + + this.on('input', readSensor); + } RED.nodes.registerType("ds18b20", DS18B20Node);