-
Notifications
You must be signed in to change notification settings - Fork 2
/
fibaroEventsDevice.html
72 lines (69 loc) · 2.9 KB
/
fibaroEventsDevice.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
<script type="text/x-red" data-template-name="fibaroXDevice">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-server"><i class="icon-tag"></i> HC2 Server</label>
<input type="text" id="node-input-server" placeholder="">
</div>
<div class="form-row">
<label for="node-input-devices"><i class="fa fa-tasks"></i> Devices</label>
<input type="text" id="node-input-devices" placeholder="Devices">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-mqtt" style="display:inline-block; width: auto; vertical-align:baseline;">
<label for="node-input-mqtt" style="width: 70%;"> Allow IN</label>
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="fibaroXDevice">
<p></p>
<p>Outputs an object called <b>msg</b> containing <b>msg.topic</b> and
<b>msg.payload</b>. msg.payload is a object.</p>
</script>
<!-- Finally, the node type is registered along with all of its properties -->
<!-- The example below shows a small subset of the properties that can be set-->
<script type="text/javascript">
RED.nodes.registerType('fibaroXDevice', {
category: 'FIBARO', // the palette category
defaults: { // defines the editable properties of the node
name: { value: "" }, // along with default values.
server: { type: "fibaro-server", required: true },
mqtt: { value: false },
devices: {
value: "",
validate: function (v) {
if (!v) return true;
try {
JSON.parse(`[${v}]`);
return true;
} catch (err) {
return false;
}
}
}
},
inputs: 0, // set the number of inputs - only 0 or 1
outputs: 2, // set the number of outputs - 0 to n
// set the icon (held in icons dir below where you save the node)
icon: "myicon.png", // saved in icons/myicon.png
paletteLabel: 'hc: events',
label: function () { // sets the default label contents
return this.name || "fibaroXDevice";
},
labelStyle: function () { // sets the class to apply to the label
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
},
oneditsave: function () {
var node = this;
if ($("#node-input-mqtt").is(':checked')) {
node.inputs = 1;
} else {
node.inputs = 0;
}
}
});
</script>