Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions 98-ds18b20.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -37,7 +38,11 @@
<select type="text" id="node-input-sensorid">
</select>
</div>
<div class="form-row">
<div class="form-row">
<label for="node-input-name"><i class="icon-ok"></i>Allow sensing interval/repetion</label>
<input type="checkbox" id="node-input-repeat">
</div>
<div class="form-row">
<label for="node-input-timer"><i class="fa fa-repeat"></i> Interval (min)</label>
<input type="text" id="node-input-timer" placeholder="1">
</div>
Expand Down
9 changes: 7 additions & 2 deletions 98-ds18b20.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down