-
Notifications
You must be signed in to change notification settings - Fork 16
/
rmu.html
executable file
·78 lines (74 loc) · 2.83 KB
/
rmu.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script type="text/javascript">
RED.nodes.registerType('nibe-rmu',{
category: 'input',
color: '#e32222',
defaults: {
server: {value:"", type:"nibe-config"},
name: {value:""},
system: {value:"s1"},
sensor: {value:""},
},
inputs:1,
outputs:2,
inputLabels: ["Update"],
outputLabels: ["RMU40","Data"],
icon: "inject.svg",
label: function() {
return this.name||"NibePi RMU40";
},
oneditprepare: function() {
$.getJSON('/config', function(data) {
let system = $("#node-input-system").val();
$("#node-input-sensor").val(data.rmu[`sensor_${system}`]);
$('#node-input-system').change(() => {
system = $("#node-input-system").val();
$("#node-input-sensor").val(data.rmu[`sensor_${system}`]);
});
})
},
oneditsave: function() {
let node = this;
$.getJSON('/config', function(data) {
let system = $("#node-input-system").val();
data.home['sensor_'+system] = $("#node-input-sensor").val();
let out = {data:node,config:data};
$.ajax({
contentType: 'application/json',
data: JSON.stringify(out),
dataType: 'json',
success: function(data){
app.log("device control succeeded");
},
error: function(){
app.log("Device control failed");
},
processData: false,
type: 'POST',
url: "config/"+node.id
});
})
}
});
</script>
<script type="text/x-red" data-template-name="nibe-rmu">
<div class="form-row">
<label for="node-input-system"><i class="icon-bookmark"></i> System</label>
<select id="node-input-system">
<option value="s1">System 1</option>
<option value="s2">System 2</option>
<!-- <option value="s3">System 3</option> -->
<!-- <option value="s4">System 4</option> -->
<!-- <option value="s5">System 5</option> -->
<!-- <option value="s6">System 6</option> -->
<!-- <option value="s7">System 7</option> -->
<!-- <option value="s8">System 8</option> -->
</select>
</div>
<div class="form-row">
<label for="node-input-server"><i class="icon-tag"></i> Server</label>
<input type="text" id="node-input-server" placeholder="Server">
</div>
</script>
<script type="text/x-red" data-help-name="nibe-rmu">
<p>RMU40 node for NibePi</p>
</script>