-
Notifications
You must be signed in to change notification settings - Fork 5
/
button.html
515 lines (448 loc) · 28.2 KB
/
button.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<script type="text/javascript">
RED.nodes.registerType('button-output',{
category: 'hapcan',
color: '#C1C1C1',
defaults: {
gateway: {type:"hapcan-gateway", required: true},
name: {value:""},
group: {value: 1, required: true, validate: function(val){return (val > 0 && val < 256);} },
node: {value: 1, required: true, validate: function(val){return (val > 0 && val < 256);}},
leds: {value: [], required: true, validate: function(val){return val.length === 14}},
defaultAction: {value: 0x02, required: true, validate: function(val) {return (val>=-1 && val <0x03)}},
},
inputs:1,
outputs:0,
icon: "relay-output.png",
align: 'right',
label: function() {
return (this.name||"button output") + ' ('+this.node+','+this.group+')';
},
labelStyle: function() { return this.name?"node_label_italic":""; } ,
inputLabels: "button control message",
oneditprepare: async function() {
let config = this
var nodeOptions = '';
var groupOptions = '';
var devicesOptions = null
var gatewaySelect = $('#node-input-gateway')
var devicesSelect = $("#node-input-devices")
var nodeSelect = $("#node-input-node")
var groupSelect = $("#node-input-group")
var currentDevice = null
var deviceList = []
gatewaySelect.change(function()
{
devicesOptions = ''
var selectedGatewayId = gatewaySelect.children('option[selected]').first().val()
if(selectedGatewayId == null)
selectedGatewayId = gatewaySelect.children("option").first().val()
var gateway = RED.nodes.node(selectedGatewayId)
if(gateway != null )
{
deviceList = gateway.devices.filter((d) => d.applicationType === 1) //JSON.parse(await deviceListResponse.json())
deviceList.forEach( (device) => {
var selected = '';
if(Number(config.node) === device.node && Number(config.group) === device.group)
{
selected = 'selected="selected"'
currentDevice = device
}
devicesOptions += `<option ${selected} value="${device.id}">${device.description} (${device.node},${device.group})</option>`
})
}
devicesOptions += `<option ${currentDevice === null ? 'selected="selected"' : ''} value="0">(set node, group manually)</option>`
devicesSelect.empty().append(devicesOptions).trigger('change')
})
devicesSelect.on('change', function() {
if(Number(this.value) === 0)
{
nodeSelect.removeAttr('disabled')
groupSelect.removeAttr('disabled')
}
currentDevice = deviceList.find(v=>v.id === this.value)
if(currentDevice !== undefined) {
nodeSelect.find('option').removeProp('selected').filter(`[value=${currentDevice.node}]`).prop('selected', true).trigger('change')
groupSelect.find('option').removeProp('selected').filter(`[value=${currentDevice.group}]`).prop('selected', true).trigger('change')
nodeSelect.attr('disabled', 'disabled')
groupSelect.attr('disabled', 'disabled')
}
})
for(var i = 1; i < 256; i++)
{
var selectedNode = '';
if((Number(this.node) === i))
selectedNode = 'selected="selected"';
nodeOptions += '<option '+ selectedNode +' value="'+i+'">'+i+'</option>';
var selectedGroup = '';
if((Number(this.group) === i))
selectedGroup = 'selected="selected"';
groupOptions += '<option '+ selectedGroup +' value="'+i+'">'+i+'</option>';
}
nodeSelect.append(nodeOptions);
groupSelect.append(groupOptions);
if(this.leds.length === 14){
for(var i = 0; i < 14; i++){
if(this.leds[i].checked)
$(`#led${i+1}`).prop('checked', true);
$(`#node-input-led${i+1}name`).val(this.leds[i].name)
}
}
},
oneditsave: function(){
this.leds = [];
for(var i = 0; i < 14; i++){
var led = {checked: $(`#led${i+1}`).is(":checked") ? true : false,
name: $(`#node-input-led${i+1}name`).val()}
this.leds.push(led)
}
}
});
</script>
<script type="text/x-red" data-template-name="button-output">
<style>
.leds .property-name {
width: 40% !important;
}
</style>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Device name">
</div>
<div class="form-row">
<label for="node-input-gateway"><i class="fa fa-globe"></i> Gateway</label>
<input type="text" id="node-input-gateway" placeholder="Gateway">
</div>
<div class="form-row">
<label for="node-input-devices"><i class="fa fa-microchip"></i> Device</label>
<select id="node-input-devices"></select>
</div>
<div class="form-row">
<label for="node-input-node"><i class="fa fa-cube"></i> Node</label>
<select id="node-input-node"></select>
</div>
<div class="form-row">
<label for="node-input-group"><i class="fa fa-cubes"></i> Group</label>
<select id="node-input-group"></select>
</div>
<div class="form-row">
<label for="node-input-defaultAction"><i class="fa fa-play"></i> Default action</label>
<select id="node-input-defaultAction">
<option value="-1">Do nothing</option>
<option value="0">Turn OFF</option>
<option value="1">Turn ON</option>
<option selected="selected" value="2">Toggle</option>
</select>
</div>
<div class="leds">
<div class="form-row">
<label for="node-input-led1name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span>
LED 1</label>
<input style="width: 10%;" id="led1" type="checkbox" value="1">
<input class="property-name" type="text" id="node-input-led1name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led2name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span>
LED 2</label>
<input style="width: 10%;" id="led2" type="checkbox" value="2">
<input class="property-name" type="text" id="node-input-led2name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led3name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 3</label>
<input style="width: 10%;" id="led3" type="checkbox" value="4">
<input class="property-name" type="text" id="node-input-led3name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led4name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 4</label>
<input style="width: 10%;" id="led4" type="checkbox" value="8">
<input class="property-name" type="text" id="node-input-led4name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led5name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 5</label>
<input style="width: 10%;" id="led5" type="checkbox" value="16">
<input class="property-name" type="text" id="node-input-led5name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led6name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 6</label>
<input style="width: 10%;" id="led6" type="checkbox" value="32">
<input class="property-name" type="text" id="node-input-led6name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led7name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 7</label>
<input style="width: 10%;" id="led7" type="checkbox" value="64">
<input class="property-name" type="text" id="node-input-led7name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led8name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 8</label>
<input style="width: 10%;" id="led8" type="checkbox" value="128">
<input class="property-name" type="text" id="node-input-led8name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led9name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 9</label>
<input style="width: 10%;" id="led9" type="checkbox" value="256">
<input class="property-name" type="text" id="node-input-led9name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led10name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 10</label>
<input style="width: 10%;" id="led10" type="checkbox" value="512">
<input class="property-name" type="text" id="node-input-led10name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led11name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 11</label>
<input style="width: 10%;" id="led11" type="checkbox" value="1024">
<input class="property-name" type="text" id="node-input-led11name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led12name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 12</label>
<input style="width: 10%;" id="led12" type="checkbox" value="2048">
<input class="property-name" type="text" id="node-input-led12name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led13name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 13</label>
<input style="width: 10%;" id="led13" type="checkbox" value="4096">
<input class="property-name" type="text" id="node-input-led13name" placeholder="led name">
</div>
<div class="form-row">
<label for="node-input-led14name"><span class="fa-stack"><i class="fa fa-minus fa-stack-1x" style="transform: scale(2.0, 0.5)"></i><i class="fa fa-step-forward fa-stack-1x"></i><i class="fa fa-long-arrow-up fa-stack-1x" style="transform: translate(0px, -12px) scale(0.5) rotate(45deg)"></i><i style="transform: translate(5px, -10px) scale(0.5) rotate(45deg)" class="fa fa-long-arrow-up fa-stack-1x"></i></span> LED 14</label>
<input style="width: 10%;" id="led14" type="checkbox" value="8192">
<input class="property-name" type="text" id="node-input-led14name" placeholder="led name">
</div>
</div>
</script>
<script type="text/x-red" data-help-name="button-output">
<p>Allows controlling of the Hapcan Button UNIV-3.1.3 module.</p>
<p>The node allows you to control button's module LEDs. It uses the Ethernet gateway to communicate with Hapcan bus.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string | number | bool | any | object</span></dt>
<dd>Any input message will perform default action. If topic is set to <i>control</i> the payload will control the Button module.</dd>
<dt class="optional">topic <span class="property-type">string</span></dt>
<dd>Topic is optional. When a <i>control</i> value is provided it will overrides default action settings and allows controlling of the node directly.</dd>
</dl>
<h3>Details</h3>
<p>The default node behaviour on any input message is to execute the action specified in properties.
When <code>msg.topic</code> is set to <i>control</i> then input value will control node in several ways. In control mode the <code>msg.payload</code>
can be one of the following types:
</p>
<dl class="message-properties">
<dt>string</dt>
<dd>Value of <i>on</i>, <i>off</i> or <i>toggle</i> will control the default channel. Other strings are ignored. Case insensitive.</dd>
<dt>number</dt>
<dd>Hapcan's Button module instruction. 0(off), 1(on) or 2(toggle) will control the default leds. Other values are ignored.</dd>
<dt>boolean</dt>
<dd>Default leds will turn ON when value is true, otherwise it will turn OFF. This type is easy to use with UI switch control.</dd>
<dt>object</dt>
<dd>Gives an ability to override node default parameters. See details below.</dd>
</dl>
<h3>Full control object definition</h3>
<p>
Passing the <i>object</i> (JSON) in <code>msg.payload</code> allows to control Button module LEDs. Below are the possible properties list that can be specified.
If no property is specified the default node settings values will be used. Node will throw an error in case of invalid values.
</p>
<dl class="message-properties">
<dt>action <span class="property-type">string | number | bool</span></dt></dt>
<dd>String or number action representation. See <code>msg.payload</code> description above for details.</dd>
<dt>leds <span class="property-type">array[int,string]</span></dt>
<dd>Array of selected LEDs to perform the action. You can pass LED number (1-14) oraz LED names specified in node configuration.
For example:
<pre>
{
"action": "toogle",
"leds": [1,2 "red led", "power led"]
}
</pre>
</dd>
</dl>
<h3>References</h3>
<ul>
<li><a href="https://hapcan.com/devices/universal/univ_3/univ_3-1-3-x/index.htm">Hapcan button UNIV-3.1.3.x</a> - module firmware notes.</li>
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('button-input',{
category: 'hapcan',
color: '#D3D3D3',
defaults: {
gateway: {type:"hapcan-gateway", required: true},
name: {value:""},
group: {value: 1, required: true, validate: function(val){return (val >= 0 && val < 256);} },
node: {value: 1, required: true, validate: function(val){return (val >= 0 && val < 256);}},
channelFilter: {value: 1, required: true,validate: function(val){return (val > 0 && val <= 16384);}},
},
inputs:0,
outputs:1,
icon: "relay-output.png",
align: 'left',
label: function() {
return `${this.name||"button input"} (${Number(this.node) === 0 ? 'any' : this.node}, ${Number(this.group) === 0 ? 'any' : this.group})`;
},
labelStyle: function() { return this.name?"node_label_italic":""; } ,
oneditprepare: async function() {
let config = this
var nodeOptions = '';
var groupOptions = '';
var devicesOptions = null
var gatewaySelect = $('#node-input-gateway')
var devicesSelect = $("#node-input-devices")
var nodeSelect = $("#node-input-node")
var groupSelect = $("#node-input-group")
var currentDevice = null
var deviceList = []
gatewaySelect.change(function()
{
devicesOptions = ''
currentDevice = null
var selectedGatewayId = gatewaySelect.children('option[selected]').first().val()
if(selectedGatewayId == null)
selectedGatewayId = gatewaySelect.children("option").first().val()
var gateway = RED.nodes.node(selectedGatewayId)
if(gateway != null )
{
deviceList = gateway.devices.filter((d) => d.applicationType === 1) //JSON.parse(await deviceListResponse.json())
deviceList.forEach( (device) => {
var selected = '';
if(Number(config.node) === device.node && Number(config.group) === device.group)
{
selected = 'selected="selected"'
currentDevice = device
}
devicesOptions += `<option ${selected} value="${device.id}">${device.description} (${device.node},${device.group})</option>`
})
}
devicesOptions += `<option ${currentDevice === null ? 'selected="selected"' : ''} value="0">(set node, group manually)</option>`
devicesSelect.empty().append(devicesOptions).trigger('change')
})
devicesSelect.on('change', function() {
if(Number(this.value) === 0)
{
nodeSelect.removeAttr('disabled')
groupSelect.removeAttr('disabled')
}
currentDevice = deviceList.find(v=>v.id === this.value)
if(currentDevice !== undefined) {
nodeSelect.find('option').removeProp('selected').filter(`[value=${currentDevice.node}]`).prop('selected', true).trigger('change')
groupSelect.find('option').removeProp('selected').filter(`[value=${currentDevice.group}]`).prop('selected', true).trigger('change')
nodeSelect.attr('disabled', 'disabled')
groupSelect.attr('disabled', 'disabled')
}
})
for(var i = 0; i < 256; i++)
{
var selectedNode = '';
if((Number(this.node) === i))
selectedNode = 'selected="selected"';
let text = i === 0? 'any' : i
nodeOptions += `<option ${selectedNode} value="${i}">${text}</option>`
var selectedGroup = '';
if((Number(this.group) === i))
selectedGroup = 'selected="selected"';
groupOptions += `<option ${selectedGroup} value="${i}">${text}</option>`
}
nodeSelect.append(nodeOptions);
groupSelect.append(groupOptions);
var channelFilterOptionsBase = "";
var channelFilterOptionsExtended = "";
for (var i = 0; i < 14; i++ )
{
if( i === 6)
channelFilterOptionsBase += '<br>';
var checked = ((this.channelFilter & (1 << i)) !== 0) ? 'checked' : '';
var options = '<label style="width: 100%; display: block;"><input style="width: auto; height: auto; margin-right: 10px;" id="channel'+(i+1)+'" type="checkbox" value="'+(1<<i)+'" '+checked+'>'+(i+1)+'</label>';
if( i < 8 )
channelFilterOptionsBase += options;
else
channelFilterOptionsExtended += options;
}
$("#channel-filter-options-base").append(channelFilterOptionsBase);
$("#channel-filter-options-extended").append(channelFilterOptionsExtended);
},
oneditsave: function(){
this.channelFilter = 0;
for(var i = 0; i < 14; i++)
{
this.channelFilter |= $("#channel"+(i+1)).is(":checked") ? (1<<i) : 0;
}
}
});
</script>
<script type="text/x-red" data-template-name="button-input">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Device name">
</div>
<div class="form-row">
<label for="node-input-gateway"><i class="fa fa-globe"></i> Gateway</label>
<input type="text" id="node-input-gateway" placeholder="Gateway">
</div>
<div class="form-row">
<label for="node-input-devices"><i class="fa fa-microchip"></i> Device</label>
<select id="node-input-devices"></select>
</div>
<div class="form-row">
<label for="node-input-node"><i class="fa fa-cube"></i> Node</label>
<select id="node-input-node"></select>
</div>
<div class="form-row">
<label for="node-input-group"><i class="fa fa-cubes"></i> Group</label>
<select id="node-input-group"></select>
</div>
<div class="form-row">
<label for="node-input-channel" style="width: 150px;"><i class="fa fa-sign-out"></i> Channel filter</label><br>
<div>
<div id="channel-filter-options-base" style="float:left; width: 50%;">
<span style="opacity: 0.7; font-size: 12px;">Button 3.1.X base inputs</span><br>
</div>
<div id="channel-filter-options-extended" style="float:left; width: 50%;">
<span style="opacity: 0.7; font-size: 12px;">Button 3.1.3 extended inputs</span><br>
</div>
</div>
</div>
</script>
<script type="text/x-red" data-help-name="button-input">
<p>Receives Hapcan button frame from UNIV-3.1.X modules.</p>
<ul>
<li>8 channel DIN RAIL button UNIV-3.1.0</li>
<li>6 channel back box touch button with led UNIV-3.1.2</li>
<li>14 channel back box button with led UNIV-3.1.3</li>
</ul>
<p>The node emit button messages sent by button modules. It uses the Ethernet gateway to receive messages from Hapcan bus.</p>
<h3>Output</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd>Hapcan message object with button data.</dd>
<dt>topic <span class="property-type">string</span></dt>
<dd>Contains <i>Button message</i> string.</dd>
</dl>
<h3>Details</h3>
<p>The <code>msg.payload</code> contains:
</p>
<dl class="message-properties">
<dt>frame <span class="property-type">Buffer[15]</span></dt>
<dd>15 bytes buffer containing raw Hapcan's CAN frame.</dd>
<dt>frameType <span class="property-type">number</span></dt>
<dd>Hapcan frame type number (decimal)</dd>
<dt>isAnswer <span class="property-type">bool</span></dt>
<dd><i>True</i> if message is an answer for request.</dd>
<dt>node <span class="property-type">number</span></dt>
<dd>Sender module node number.</dd>
<dt>group <span class="property-type">number</span></dt>
<dd>Sender module group number.</dd>
<dt>state <span class="property-type">string</span></dt>
<dd>Channel's state, can be: OPEN, CLOSED, DISABLED, HELD_400ms, HELD_4s,
RELEASED_BEFORE_400ms, RELEASED_AFTER_400ms, RELEASED_AFTER_4s,
and additional HELD_1s, RELEASED_AFTER_1s values implement in <a href="https://github.com/Onixarts/Hapcanuino/tree/master/SubModules/HapcanButton">Hapcanuino submodule</a></dd>
<dt>led <span class="property-type">string</span></dt>
<dd>LED state in case of module support LED output. Possible values are: ON, OFF, DISABLED. If module does not
support LED output, the value is OFF.
</dd>
<dt>channel <span class="property-type">number</span></dt>
<dd>Button channel that has changed.</dd>
<dt>channelName <span class="property-type">string</span></dt>
<dd>Device's channel name that has changed.</dd>
<dt>deviceName <span class="property-type">string</span></dt>
<dd>Device's name that emits the message.</dd>
</dl>
<h3>References</h3>
<ul>
<li><a href="http://hapcan.com/devices/universal/univ_3/univ_3-1-x-x.htm">Hapcan buttons</a> - module firmware notes.</li>
</ul>
</script>