-
Notifications
You must be signed in to change notification settings - Fork 4
/
cul.html
224 lines (200 loc) · 8.92 KB
/
cul.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!--
CUL nodes for IBM's Node-Red
https://github.com/1stsetup/node-red-contrib-cul.git
(c) 2016, Michel Verbraak <[email protected]>
One may find full license text here: https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
You are free to:
Share - copy and redistribute the material in any medium or format
Adapt - remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
NonCommercial - You may not use the material for commercial purposes.
ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
No additional restrictions - You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
-->
<script type="text/x-red" data-template-name="cul-controller">
<div class="form-row">
<label for="node-config-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-config-input-serialport"><i class="icon-bookmark"></i> Serialport</label>
<input type="text" id="node-config-input-serialport">
</div>
<div class="form-row">
<label for="node-config-input-baudrate"><i class="icon-bookmark"></i> Baudrate</label>
<select id="node-config-input-baudrate">
<option value="300">300</option>
<option value="1200">1200</option>
<option value="2400">2400</option>
<option value="4800">4800</option>
<option value="9600">9600</option>
<option value="14400">14400</option>
<option value="19200">19200</option>
<option value="28800">28800</option>
<option value="38400">38400</option>
<option value="57600">57600</option>
<option value="115200">115200</option>
<option value="230400">230400</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-mode"><i class="icon-bookmark"></i> Mode</label>
<select id="node-config-input-mode">
<option value="SlowRF">SlowRF (FS20, HMS, FHT, EM,...)</option>
<option value="MORITZ">MORITZ (MAX! devices)</option>
<option value="AskSin">AskSin (HomeMatic devices)</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-parse"><i class="icon-bookmark"></i> Parse</label>
<input type="checkbox" id="node-config-input-parse">
</div>
<div class="form-row">
<label for="node-config-input-init"><i class="icon-bookmark"></i> init</label>
<input type="checkbox" id="node-config-input-init">
</div>
<div class="form-row">
<label for="node-config-input-coc"><i class="icon-bookmark"></i> COC</label>
<input type="checkbox" id="node-config-input-coc" onchange="COCChanged(this);" >
</div>
<div class="form-row">
<label for="node-config-input-scc"><i class="icon-bookmark"></i> SCC</label>
<input type="checkbox" id="node-config-input-scc" onchange="SCCChanged(this);" >
</div>
<div class="form-row">
<label for="node-config-input-rssi"><i class="icon-bookmark"></i> rssi</label>
<input type="checkbox" id="node-config-input-rssi">
</div>
<div class="form-row">
<label for="node-config-input-debug"><i class="icon-bookmark"></i> debug</label>
<input type="checkbox" id="node-config-input-debug">
</div>
</script>
<script type="text/x-red" data-template-name="cul-out">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-address"><i class="icon-tag"></i> Address</label>
<input type="text" id="node-input-address placeholder="Address" onchange="addressChanged(this)">
<span id="hexWarning"></span>
</div>
<div class="form-row">
<label for="node-input-controller"><i class="icon-bookmark"></i> Controller</label>
<input type="text" id="node-input-controller">
</div>
</script>
<script type="text/x-red" data-template-name="cul-in">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-controller"><i class="icon-bookmark"></i> Controller</label>
<input type="text" id="node-input-controller">
</div>
</script>
<script type="text/x-red" data-help-name="cul-out">
<p>Use this to <b>send</b> messages to a CUL device.<br/>
<b>msg.topic</b> must be:<br>
<ul>
<li>raw: payload will contain raw command to send to cul.</li>
<li>cmd: payload will contain array of predefined commands.</li>
</ul>
<BR>
<b>Example raw for FH20:</b><br>
msg = { "topic":"raw", "payload":"F6C480111" }<BR>
<BR>
<b>Example cmd for FH20:</b><br>
msg = { "topic":"cmd", "payload":[ "FS20", "2341 2131", "1112", "on"] }<BR>
<BR>
See <a href="https://www.npmjs.com/package/cul">https://www.npmjs.com/package/cul</a> for more info.
</p>
</script>
<script type="text/x-red" data-help-name="cul-in">
<p>Use this to <b>inject</b> messages from a CUL device on the bus<br/>
<b>msg.payload</b> will have the CUL message object.
</p>
</script>
<script type="text/javascript">
function COCChanged(obj) {
if (obj.checked) {
document.getElementById("node-config-input-baudrate").value = "38400";
document.getElementById("node-config-input-serialport").value = "/dev/ttyACM0";
document.getElementById("node-config-input-scc").checked = false;
}
}
function SCCChanged(obj) {
if (obj.checked) {
document.getElementById("node-config-input-baudrate").value = "38400";
document.getElementById("node-config-input-serialport").value = "/dev/ttyAMA0";
document.getElementById("node-config-input-coc").checked = false;
}
}
function addressChanged(obj) {
var upperCase = obj.value.match(/[A-F]/);
if (upperCase) {
obj.value = obj.value.toLowerCase();
}
var nonHex = obj.value.match(/[0-9a-f]+/);
if (!nonHex) {
document.getElementById("hexWarning").innerHTML = "Illegal characters. Only hex values [0-9a-f] allowed.";
}
}
RED.nodes.registerType('cul-controller', {
category: 'config',
defaults: {
name: {value: ""},
serialport: {value: "/dev/ttyAMA0", required: true},
baudrate: {value: 9600, required: true, validate: RED.validators.number()},
mode: {value: "SlowRF", required: true},
parse: {value: true, required: true},
init: {value: true, required: true},
coc: {value: false, required: true},
scc: {value: false, required: true},
rssi: {value: true, required: true},
debug: {value: false, required: true},
},
label: function () {
return (this.name || 'cul' ) + ":" + this.serialport + "@" + this.baudrate + "@" + this.mode;
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('cul-out', {
category: 'output',
color: '#ffffff',
defaults: {
name: {value: ""},
address: {value: "123456"},
controller: {value: "", type: "cul-controller"}
},
inputs: 1,
outputs: 0,
align: 'right',
label: function () {
return (this.groupaddr || this.name || "cul");
}
});
</script>
<script type="text/javascript">
RED.nodes.registerType('cul-in', {
category: 'input',
color: '#ffffff',
defaults: {
name: {value: ""},
controller: {value: "", type: "cul-controller"}
},
inputs: 0,
outputs: 1,
label: function () {
return (this.groupaddr || this.name || "cul");
}
});
</script>