forked from Supergiovane/node-red-contrib-knx-ultimate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknxUltimate.html
359 lines (321 loc) · 20.4 KB
/
knxUltimate.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
<script type="text/javascript">
RED.nodes.registerType('knxUltimate', {
category: 'input',
color: '#99ccff',
defaults: {
server: { type: "knxUltimate-config", required: true },
topic: { value: "" },
dpt: { value: "" },
initialread: { value: false },
notifyreadrequest: { value: false },
notifyresponse: { value: false },
notifywrite: { value: true },
notifyreadrequestalsorespondtobus: { value: false },
notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized: { value: "0" },
listenallga: { value: false },
name: { value: "" },
outputtype: { value: "write" },
outputRBE: { value: true },
inputRBE: { value: false }
},
inputs: 1,
outputs: 1,
align: "left",
icon: "knx.png",
label: function () {
return (this.outputRBE==true ? "|rbe| " : "") + (this.name || this.topic || "knx-ultimate") + (this.inputRBE==true ? " |rbe|" : "" )
},
oneditprepare: function () {
$.getJSON('knxUltimateDpts', (data) => {
data.forEach(dpt => {
$("#node-input-dpt").append($("<option></option>")
.attr("value", dpt.value)
.text(dpt.text))
});
$("#node-input-dpt").val(this.dpt)
})
// Add write and response as default for existing nodes like was default before
if (typeof this.notifywrite === 'undefined') {
this.notifywrite = true
this.notifyresponse = true
$("#node-input-notifywrite").prop("checked", true)
$("#node-input-notifyresponse").prop("checked", true)
}
// Add Write as default for existing clients output
if (typeof this.outputtype === 'undefined') {
this.outputtype = "write"
$("#node-input-outputtype").val("write")
}
$("#node-input-notifyreadrequest").on('change',function() {
if ($("#node-input-notifyreadrequest").is(":checked")) {
if ($("#node-input-listenallga").is(":checked")) {
}else{
$("#divnotifyreadrequestautoreact").show();
}
}else{
$("#divnotifyreadrequestautoreact").hide();
}
})
$("#node-input-listenallga").on('change',function() {
if ($("#node-input-listenallga").is(":checked")) {
$("#GAandDPT").hide()
$("#divOutputRBE").hide()
$("#node-input-outputRBE").prop('checked', false)
$("#divInputRBE").hide()
$("#node-input-inputRBE").prop('checked', false)
$("#divnotifyreadrequestautoreact").hide();
$("#helpallga").show();
if ($("#helpallga").html==""){
// There is a ETS csv file, show the init read option
$("#divNode-input-initialread").show()
}
else
{
// There isn't a ETS csv file, hide and deselect the init read option
$("#divNode-input-initialread").hide();
$("#node-input-initialread").prop('checked', false);
}
}else{
$("#GAandDPT").show()
$("#divOutputRBE").show()
$("#divInputRBE").show()
if ($("#node-input-notifyreadrequest").is(":checked")) {
$("#divnotifyreadrequestautoreact").show();
}else{
$("#divnotifyreadrequestautoreact").hide();
}
$("#helpallga").hide()
$("#divNode-input-initialread").show();
}
})
// Autocomplete suggestion with ETS csv File
$( "#node-input-topic" ).autocomplete({
minLength: 1,
source: function( request, response ) {
//$.getJSON("csv", request, function( data, status, xhr ) {
$.getJSON("knxUltimatecsv", (data) => {
response($.map(data, function (value, key) {
var sSearch = (value.ga + " (" + value.devicename+") DPT"+value.dpt).toUpperCase();
if (sSearch.indexOf(request.term.toUpperCase()) != -1) {
return {
label: value.ga + " # " + value.devicename+" # "+value.dpt, // Label for Display
value: value.ga // Value
}
} else {
return null;
}
}));
});
},select: function(event, ui) {
// Sets Datapoint and device name automatically
var sDevName=ui.item.label.split("#")[1].trim();
try {
sDevName=sDevName.substr(sDevName.indexOf(")")+1).trim();
} catch (error) {
}
$('#node-input-name').val(sDevName);
var optVal = $("#node-input-dpt option:contains('"+ui.item.label.split("#")[2].trim()+"')").attr('value');
// Select the option value
$("#node-input-dpt").val(optVal);
}
});
// Hide or show the GA and DPT fields if Notify on all Group Addresses is checked
if(this.server){
if (typeof RED.nodes.node(this.server).csv !== 'undefined' && RED.nodes.node(this.server).csv!="") {
$("#helpallga").html("");
// There is a ETS csv file, show the init read option
$("#divNode-input-initialread").show()
}else{
// 25/10/2019 Warn user that the node will node encode/decode datagram, if Listen All GA's if the config node doesn't contain the csv
$("#helpallga").html("<i> You haven't imported the ETS csv file. <br/> The node will work as blind transmitter/receiver. <a href=\"https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/2.-Node-Configuration\" target='_blank'>See the wiki about that</a>.</i>");
if ($("#node-input-listenallga").is(":checked")) {
// There isn't a ETS csv file, hide and deselect the init read option
$("#divNode-input-initialread").hide();
$("#node-input-initialread").prop('checked', false);
}else
{
$("#divNode-input-initialread").show()
}
}
}else{
$("#node-input-listenallga").prop("checked", false)
$("#GAandDPT").show()
$("#divOutputRBE").show()
$("#divInputRBE").show()
$("#helpallga").hide()
$("#divNode-input-initialread").show()
}
},
oneditsave: function(){
// 25/10/2019 Warn user that the node will node encode/decode datagram, if Listen All GA's if the config node doesn't contain the csv
if(this.server){
if (typeof RED.nodes.node(this.server).csv !== 'undefined' && RED.nodes.node(this.server).csv!="") {
}else{
// Notify the user
if($("#node-input-listenallga").is(":checked")){
var checkResult="Universal mode (listen to all Group Addresses) needs a valid ETS csv to be able to decode datatypes and output device names. Please paste the ETS csv in the config node. If you don't use ETS csv file, the node will work als blind transmitter/receiver and you need to pass in the input message, the datatype besides the value."
var myNotification= RED.notify(checkResult,
{
modal: true,
fixed: true,
type: 'error',
buttons: [
{
text: "OK",
click: function(e) {
myNotification.close();
}
}]
})
}
// $("#node-input-listenallga").prop("checked", false)
// $("#GAandDPT").show()
// $("#divOutputRBE").show()
// $("#divInputRBE").show()
$("#helpallga").show()
}
}else{
$("#node-input-listenallga").prop("checked", false)
$("#GAandDPT").show()
$("#divOutputRBE").show()
$("#divInputRBE").show()
$("#helpallga").hide()
}
}
})
</script>
<script type="text/x-red" data-template-name="knxUltimate">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-tag"></i> Gateway </label>
<input type="text" id="node-input-server">
</div>
<div id="GAandDPT">
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Group Address (topic)</label>
<input type="text" id="node-input-topic" placeholder="Ex: 1/1/1 or select 'Listen to all Groups'">
</div>
<div class="form-row">
<label for="node-input-dpt"><i class="fa fa-tasks"></i> Datapoint </label>
<select id="node-input-dpt"></select>
</div>
</div>
<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">
<input type="checkbox" id="node-input-listenallga" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-listenallga"> <i class="fa fa-th-list"></i> Universal mode (listen to all Group Addresses)</label>
<div id="helpallga">Some Content Here</div>
</div>
<br/ ><dt><i class="fa fa-code-fork"></i> OUTPUT (sends datagram to the KNX bus)</dt><br/ >
<div class="form-row">
<label for="node-input-outputtype"><i class="fa fa-rocket"></i> Output Type </label>
<select id="node-input-outputtype">
<option value="write">Write</option>
<option value="response">Response</option>
</select>
</div>
<div class="form-row" id="divOutputRBE">
<input type="checkbox" id="node-input-outputRBE" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-outputRBE"> <i class="fa fa-filter"></i> Send payload to KNX bus only if changed (RBE filter)</label>
</div>
<div class="form-row" id="divNode-input-initialread">
<input type="checkbox" id="node-input-initialread" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-initialread"> <i class="fa fa-question-circle-o"></i> Send a GrpValue read once on connection/reconnect</label>
</div>
<br/ ><dt><i class="fa fa-code-fork"></i> INPUT (listen to datagram from the KNX bus)</dt><br/ >
<!-- <div class="form-row" id="divAllInputsDeselected">
<label style="width:auto"><i class="fa fa-times-circle"></i> The node will not respond to telegrams coming from the KNX bus,<br />
<i class="fa fa-times-circle"></i> unless you tick some checks here below.</label>
</div> -->
<div class="form-row" id="divInputRBE">
<input type="checkbox" id="node-input-inputRBE" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-inputRBE"> <i class="fa fa-filter"></i> React only if payload from KNX Bus is changed (RBE filter)</label>
</div>
<div class="form-row">
<input type="checkbox" id="node-input-notifywrite" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-notifywrite"> <i class="fa fa-sign-in"></i> React to event GroupValue write </label>
</div>
<div class="form-row">
<input type="checkbox" id="node-input-notifyresponse" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-notifyresponse"> <i class="fa fa-sign-in"></i> React to event GroupValue response </label>
</div>
<div class="form-row">
<input type="checkbox" id="node-input-notifyreadrequest" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-notifyreadrequest"> <i class="fa fa-sign-in"></i> React to event GroupValue read </label>
</div>
<div id="divnotifyreadrequestautoreact">
<dd>
<div class="form-row" >
<input type="checkbox" id="node-input-notifyreadrequestalsorespondtobus" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width:auto" for="node-input-notifyreadrequestalsorespondtobus"> Auto send node value as response to the KNX Bus</label>
</div>
<div class="form-row">
<label style="width:auto"> If value is undefined, send</label>
<input style="width:auto"type="text" id="node-input-notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized" placeholder="Ex: 0 for false, 1 for true, otherwise any value">
</div>
</dd>
</div>
</script>
<script type="text/x-red" data-help-name="knxUltimate">
<p>
Knx-ultimate is a powerfull device node, all-in-one. It acts as input device as well as output device at the same time.<br />
Please see the <a href="https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki">WIKI for instructions.</a>.<br />
You can import your ETS csv file, containing all your group addresses and datapoint types and use it instead of manually create one node for each group address.<br />
Node's settings is divided in 3 parts: common settings, input settings (Node used as input device) and output settings (Node used as output device).
<a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>
</p>
<p>
<h3>COMMON SETTINGS</h3>
<dl class="message-properties">
<dt>Gateway</dt>
<dd> Selected KNX gateway. </dd>
<dt>Group Address (topic)
<span class="property-type">Example 0/0/1</span>
</dt>
<dd> KNX Group address to read/write to. It's not mandatory if you import the ETS csv file and select <i>Universal mode (listen to all Group Addresses)</i>. Please note that the Group Address will then transmitted to the flow as <code>msg.topic</code>. It can be overridden by <code>msg.knx.destination</code>.</dd>
<dt>Datapoint</dt>
<dd> KNX datapoint type (DPT). It's not mandatory if you import the ETS csv file and select <i>Universal mode (listen to all Group Addresses)</i>. It can be overridden by <code>msg.dpt</code>.</dd>
<dt>Universal mode (listen to all Group Addresses)</dt>
<dd> The node will react to all group addresses when used as INPUT, and will notify a message containing a payload correctly decoded using the datapoints specified in the ETS csv file. When used as OUTPUT, it automatically decodes the payload using the right datapoint specified in the ETS csv file.</dd>
<dd> Starting from Version 1.1.11, you can use <i>Universal mode (listen to all Group Addresses)</i> option without the need of an imported ETS CSV File. You need to pass a message to the node, containing datapoint type and a value. As soon as the node receives a telegram from KNX Bus, it will output a RAW value and beside that, it will try to decode the value without knowing the datapoint type.</dd>
</dl>
<h3>OUTPUT (sends datagram to the KNX bus)</h3>
<dl class="message-properties">
<dt>Output Type</dt>
<dd>Write: the node will send the payload to the KNX bus as a 'write' message (standard).<br />
Response: the node will send the payload to the KNX bus as a 'response' message (in case you wish to create your own 'response', in response to a read request).</dd>
<dt>Send payload to KNX bus only if changed (RBE filter)</dt>
<dd>The RBE (Report by Exception) filter, only passes on data if the payload has changed. The node writes to KNX bus only if the received msg.payload differs from the current value. For example, if the kitchen light is on (true) and you send again a msg.payload=true to the node, the value will not be written again to the bus. This is useful to avoid loops.</dd>
<dt>Send a GrpValue read once on connection/reconnect</dt>
<dd>On connection/reconnection, the node will send a 'read' request to the group address specified on the <b>Group Address</b> or, if <i>Universal mode (listen to all Group Addresses)</i> is selected and ETS cvs file was imported, on all group addresses specified on the ETS csv file.</dd>
</dl>
<h3>INPUT (listen to datagram from the KNX bus)</h3>
<dl class="message-properties">
<dt>React only if payload from KNX Bus is changed (RBE filter)</dt>
<dd>The RBE (Report by Exception) filter, only passes on data on the flow if the KNX Telegram coming from BUS has changed. The node starts a flow only if the received KNX Telegram differs from the current Payload. This is useful to avoid loops.</dd>
<dt>React to event GroupValue write</dt>
<dd>When checked, received writeRequests will be notified</dd>
<dt>React to event GroupValue response</dt>
<dd>When checked, received responses will be notified</dd>
<dt>React to event GroupValue read</dt>
<dd> When checked, received read requests will be notified, this can be used to create your own response with a <i>Output Type</i> set to 'Response'.
<strong>Attention:</strong> Messages for received read requests have a <code>msg.payload</code> and
<code>msg.knx.rawValue</code> with value <code>null</code>.<br/>
<dt>Auto send node value as response to the KNX Bus</dt>
<dd> Only enabled if "Universal mode (listen to all Group Addresses)" is not selected. It works in conjunction with <b>React to event GroupValue read</b>. When checked, whenever the node receives a read request from bus, it sends a response to the KNX Bus with the stored payload value.
If the value is unknown/not initialized, it sends a default value you've selected in the text box.
</dd>
</dd>
</dl>
</p>
<p>
<h3>MSG FORMAT</h3>
The Node Device accepts input and output messages.<br />
These messages can vary. <a href="https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/2.-Node-Configuration" target="_blank">See the wiki about that</a>.<br /><br />
</p>
<p>
The Node has a circular reference protection. If 2 nodes with same group address are link toghether, the protection avoids loops by stopping the message transmitted to the KNX BUS.
</p>
</script>