-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path98-ds18b20.html
52 lines (50 loc) · 1.81 KB
/
98-ds18b20.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<script type="text/javascript">
RED.nodes.registerType('ds18b20',{
category: 'Raspberry Pi',
color: "#C7E9C0",
defaults: {
name: {value:""},
sensorid: {value:"", required:true},
timer: {value:"1", required:true, validate:RED.validators.number()}
},
inputs: 0,
outputs: 1,
icon: "thermometer.png",
label: function() {
return this.name || this.sensorid || "ds18b20";
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
var configuredSensorId = this.sensorid;
$.getJSON('/sensors/1wire/',function(data) {
$.each(data, function( index, value ) {
var isSelected = configuredSensorId === value;
$("#node-input-sensorid").append(
new Option(value, value, isSelected, isSelected));
});
});
}
});
</script>
<script type="text/x-red" data-template-name="ds18b20">
<div class="form-row">
<label for="node-input-sensorid">
<i class="fa fa-ellipsis-v"></i> Sensor ID
</label>
<select type="text" id="node-input-sensorid">
</select>
</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>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name/topic</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/x-red" data-help-name="ds18b20">
<p>Read a temperature value from a DS18B20 sensor</p>
</script>