iobroker.openknx 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -45
- package/admin/index_m.html +8 -2
- package/io-package.json +2 -2
- package/lib/knx/.gitignore +2 -0
- package/lib/knx/.npmignore +2 -0
- package/lib/knx/README-API.md +18 -0
- package/lib/knx/index.d.ts +27 -5
- package/lib/knx/package-lock.json +236 -341
- package/lib/knx/package.json +38 -57
- package/lib/knx/src/Connection.js +41 -1
- package/lib/knx/src/Datapoint.js +4 -11
- package/lib/knx/src/FSM.js +2 -2
- package/lib/knx/test/dptlib/test-dpt.js +23 -1
- package/lib/knx/typescript-sample/.gitignore +1 -0
- package/lib/knx/typescript-sample/.npmignore +1 -0
- package/main.js +63 -30
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -31,10 +31,6 @@ IP of your KNX IP gateway.
|
|
|
31
31
|
### Port
|
|
32
32
|
this is normally port 3671 of the KNX IP gateway.
|
|
33
33
|
|
|
34
|
-
### phys. KNX Adress
|
|
35
|
-
Fill in physical address of the KNX IP gateway in the format 1/1/1.
|
|
36
|
-
Two level group addresses can be transformed manually if needed.
|
|
37
|
-
|
|
38
34
|
### Local IPv4 network interface
|
|
39
35
|
The interface that is connected to the KNX IP gateway.
|
|
40
36
|
|
|
@@ -42,7 +38,9 @@ The interface that is connected to the KNX IP gateway.
|
|
|
42
38
|
Searches via a standardized protocol all available KNX IP Gateways on the given network interface.
|
|
43
39
|
|
|
44
40
|
### Frames delay [ms]
|
|
45
|
-
This settings protects the KNX bus from data flooding by limiting data frames to a certain rate.
|
|
41
|
+
This settings protects the KNX bus from data flooding by limiting data frames to a certain rate.
|
|
42
|
+
Not sent frames are delay until the delay time since last send on bus is elapsed. If more send requests are waiting, send order is random.
|
|
43
|
+
If you experience disconnects from your KNX IP Gateway in the log then increase this number.
|
|
46
44
|
|
|
47
45
|
### Add only new Objects
|
|
48
46
|
If checked, the import will skip overwriting existing communication objects.
|
|
@@ -147,36 +145,38 @@ IoBroker state roles (https://github.com/ioBroker/ioBroker/blob/master/doc/STATE
|
|
|
147
145
|
|
|
148
146
|
Autoread is set to false where it is clear from the DPT that this is a trigger signal. This applies to scene numbers.
|
|
149
147
|
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"_id": "path.and.name.to.object", // derieved from the KNX structure
|
|
152
151
|
"type": "state",
|
|
153
|
-
"common": { //values here can be interpreted by iobroker
|
|
154
|
-
"desc": "Basetype: 1-bit value, Subtype: switch", //informative, from dpt
|
|
155
|
-
"name": "Aussen Melder Licht schalten", //informative description from ets export
|
|
156
|
-
"read": true, //default set, if false incoming bus values are not updating the object
|
|
157
|
-
"role": state,
|
|
158
|
-
"type": "boolean", //boolean, number, string, object, derieved from dpt
|
|
159
|
-
"unit": "", //derived from dpt
|
|
160
|
-
"write": true //default true, if set change on object is triggering knx write, succ. write sets then ack flag to true
|
|
152
|
+
"common": { // values here can be interpreted by iobroker
|
|
153
|
+
"desc": "Basetype: 1-bit value, Subtype: switch", // informative, from dpt
|
|
154
|
+
"name": "Aussen Melder Licht schalten", // informative description from ets export
|
|
155
|
+
"read": true, // default set, if false incoming bus values are not updating the object
|
|
156
|
+
"role": "state", // default state, derieved from DPT
|
|
157
|
+
"type": "boolean", // boolean, number, string, object, derieved from dpt
|
|
158
|
+
"unit": "", // derived from dpt
|
|
159
|
+
"write": true // default true, if set change on object is triggering knx write, succ. write sets then ack flag to true
|
|
161
160
|
},
|
|
162
|
-
"native": { //values here can be interpreted by openknx adapter
|
|
163
|
-
"address": "0/1/2", //knx group address
|
|
164
|
-
"answer_groupValueResponse": false, //default false, if set to true adapter responds with value on GroupValue_Read
|
|
165
|
-
"autoread": true, //default true for non trigger signals , adapter sends a GroupValue_read on start to sync its states
|
|
166
|
-
"bitlength": 1, //size ob knx data, derived from dpt
|
|
167
|
-
"dpt": "DPT1.001", //DPT
|
|
168
|
-
"encoding": { //informative
|
|
161
|
+
"native": { // values here can be interpreted by openknx adapter
|
|
162
|
+
"address": "0/1/2", // knx group address
|
|
163
|
+
"answer_groupValueResponse": false, // default false, if set to true adapter responds with value on GroupValue_Read
|
|
164
|
+
"autoread": true, // default true for non trigger signals , adapter sends a GroupValue_read on start to sync its states
|
|
165
|
+
"bitlength": 1, // size ob knx data, derived from dpt
|
|
166
|
+
"dpt": "DPT1.001", // DPT
|
|
167
|
+
"encoding": { // informative
|
|
169
168
|
"0": "Off",
|
|
170
169
|
"1": "On"
|
|
171
170
|
},
|
|
172
|
-
"force_encoding": "", //informative
|
|
173
|
-
"signedness": "", //informative
|
|
174
|
-
"valuetype": "basic" //composite means set via a specific javascript object
|
|
171
|
+
"force_encoding": "", // informative
|
|
172
|
+
"signedness": "", // informative
|
|
173
|
+
"valuetype": "basic" // composite means set via a specific javascript object
|
|
175
174
|
},
|
|
176
175
|
"from": "system.adapter.openknx.0",
|
|
177
176
|
"user": "system.user.admin",
|
|
178
177
|
"ts": 1638913951639
|
|
179
|
-
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
180
|
|
|
181
181
|
# Adapter communication Interface Description
|
|
182
182
|
Handeled DPTs are: 1-21,232,237,238
|
|
@@ -186,27 +186,31 @@ Where number datatype is used please note that interface values can be scaled.
|
|
|
186
186
|
### API call
|
|
187
187
|
IoBroker defines States as communication interface.
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
@param {
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
@param {boolean} [ack]
|
|
203
|
-
@param {object} [options]
|
|
204
|
-
@param {ioBroker.SetStateCallback} [callback]
|
|
189
|
+
```javascript
|
|
190
|
+
setState(
|
|
191
|
+
'', // @param {string} id of the object with path
|
|
192
|
+
{ // @param {object|string|number|boolean} state simple value or object with attribues.
|
|
193
|
+
val: value,
|
|
194
|
+
ack: true|false, // optional, should be false by convention
|
|
195
|
+
ts: timestampMS, // optional, default - now
|
|
196
|
+
q: qualityAsNumber, // optional, set it to value 0x10 to trigger a bus read to this object, given StateValue is ignored
|
|
197
|
+
from: origin, // optional, default - this adapter
|
|
198
|
+
c: comment, // optional, set it to value GroupValue_Read to trigger a bus read to this object, given StateValue is ignored
|
|
199
|
+
expire: expireInSeconds // optional, default - 0
|
|
200
|
+
lc: timestampMS // optional, default - calculated value
|
|
201
|
+
},
|
|
202
|
+
false, // @param {boolean} [ack] optional, should be false by convention
|
|
203
|
+
{}, // @param {object} [options] optional, user context
|
|
204
|
+
(err, id) => {} // @param {ioBroker.SetStateCallback} [callback] optional, return error and id
|
|
205
|
+
);
|
|
206
|
+
```
|
|
205
207
|
|
|
206
208
|
example to trigger a GroupValue_Read:
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
```javascript
|
|
211
|
+
setState(myState, {val: false, ack: false, c:'GroupValue_Read'});
|
|
212
|
+
setState(myState, {val: false, ack: false, q:0x10});
|
|
213
|
+
```
|
|
210
214
|
|
|
211
215
|
GroupValue_Read comment does not work for javascript adapter. Use qualityAsNumber value 0x10 instead.
|
|
212
216
|
|
|
@@ -306,8 +310,14 @@ Data is sent to Iobroker Sentry server hosted in Germany. If you have allowed io
|
|
|
306
310
|
- only IPv4 supported
|
|
307
311
|
|
|
308
312
|
## Changelog
|
|
313
|
+
## 0.2.5 (2022-06-22)
|
|
314
|
+
* feature: option remove existing KNX objects that are not in import file
|
|
315
|
+
|
|
316
|
+
## 0.2.4 (2022-05-27)
|
|
317
|
+
* feature: cleanly disconnect on shutdown, upgrade to knx lib 2.5.2
|
|
318
|
+
|
|
309
319
|
### 0.2.2 (2022-05-26)
|
|
310
|
-
* feature: writing to bus l_data.con creates a ack on the iobroker object if successful (the knx conf flag unset)
|
|
320
|
+
* feature: writing to bus l_data.con creates a ack on the iobroker object if successful (the knx conf flag unset) #133
|
|
311
321
|
* bugfix: remove manual Physical KNX address dialog, use 0.0.0 instead
|
|
312
322
|
* bugfix: remove error log when answering to GroupValueRead: #183
|
|
313
323
|
* bugfix: improve warning logs on intended and unintended disconnects
|
package/admin/index_m.html
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
this.getIsAdapterAlive(function (isAlive) {
|
|
65
65
|
if (isAlive && !window.isProcessingRequest) {
|
|
66
66
|
$("#onlyAddNewObjects").removeClass("disabled");
|
|
67
|
+
$("#removeUnusedObjects").removeClass("disabled");
|
|
67
68
|
$("#setAckOnWrite").removeClass("disabled");
|
|
68
69
|
$(".file-field .btn").removeClass("disabled");
|
|
69
70
|
$(".file-field .file-path").prop("disabled", false);
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
if (settings.gwipport === undefined) settings.gwipport = 3671;
|
|
80
81
|
if (settings.minimumDelay === undefined) settings.minimumDelay = 50;
|
|
81
82
|
if (settings.onlyAddNewObjects === undefined) settings.onlyAddNewObjects = false;
|
|
83
|
+
if (settings.removeUnusedObjects === undefined) settings.removeUnusedObjects = false;
|
|
82
84
|
if (settings.localInterface === undefined) settings.localInterface = "";
|
|
83
85
|
if (settings.setAckOnWrite === undefined) settings.setAckOnWrite = false;
|
|
84
86
|
|
|
@@ -218,7 +220,7 @@
|
|
|
218
220
|
$("#etsFile").change(processXmlFile);
|
|
219
221
|
showToast(null, _("Import started..."), null, 3000);
|
|
220
222
|
$("#progress").show();
|
|
221
|
-
sendTo(null, "import", { xml: event.target.result, onlyAddNewObjects: $("#onlyAddNewObjects").prop("checked") }, function (result) {
|
|
223
|
+
sendTo(null, "import", { xml: event.target.result, onlyAddNewObjects: $("#onlyAddNewObjects").prop("checked"), removeUnusedObjects: $("#removeUnusedObjects").prop("checked") }, function (result) {
|
|
222
224
|
$("#progress").hide();
|
|
223
225
|
if (!result || result.error) {
|
|
224
226
|
let message = "Unknown error"
|
|
@@ -372,7 +374,11 @@
|
|
|
372
374
|
<div class="row">
|
|
373
375
|
<div class="col s12 input-field">
|
|
374
376
|
<input class="value" id="onlyAddNewObjects" type="checkbox" />
|
|
375
|
-
<label class="translate" for="onlyAddNewObjects">
|
|
377
|
+
<label class="translate" for="onlyAddNewObjects">store only additionally found GAs</label>
|
|
378
|
+
</div>
|
|
379
|
+
<div class="col s12 input-field">
|
|
380
|
+
<input class="value" id="removeUnusedObjects" type="checkbox" />
|
|
381
|
+
<label class="translate" for="removeUnusedObjects">remove existing KNX objects that are not in import file</label>
|
|
376
382
|
</div>
|
|
377
383
|
|
|
378
384
|
<div class="col s12 m12 l6 file-field input-field">
|
package/io-package.json
CHANGED
package/lib/knx/README-API.md
CHANGED
|
@@ -136,3 +136,21 @@ connection.writeRaw('1/0/0', Buffer.from('01', 'hex'), 1)
|
|
|
136
136
|
// Write raw buffer to a groupaddress with dpt 9 (e.g temperature 18.4 °C = Buffer<0730>) without bitlength
|
|
137
137
|
connection.writeRaw('1/0/0', Buffer.from('0730', 'hex'))
|
|
138
138
|
```
|
|
139
|
+
|
|
140
|
+
### Disconnect
|
|
141
|
+
|
|
142
|
+
In order to cleanly disconnect, you must send the Disconnect-Request and give the KNX-IP-Stack enough time to receive the Disconnect-Response back from the IP Gateway. Most IP-Gateways will have a timeout and clean stale connection up, even if you do not disconect cleanly, but depending on the limits on the number of parallel active connections, this will limit your ability to re-connect until the timeout has passed.
|
|
143
|
+
|
|
144
|
+
For NodeJS cleaning up when the script exits, this requires something like [async-exit-hook](https://www.npmjs.com/package/async-exit-hook):
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const exitHook = require('async-exit-hook');
|
|
148
|
+
|
|
149
|
+
exitHook(cb => {
|
|
150
|
+
console.log('Disconnecting from KNX…');
|
|
151
|
+
connection.Disconnect(() => {
|
|
152
|
+
console.log('Disconnected from KNX');
|
|
153
|
+
cb();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
```
|
package/lib/knx/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ type ConnectionSpec = {
|
|
|
17
17
|
debug?: boolean,
|
|
18
18
|
manualConnect?: true,
|
|
19
19
|
minimumDelay?: number,
|
|
20
|
-
handlers
|
|
20
|
+
handlers?: HandlersSpec,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
type KnxDeviceAddress = string
|
|
@@ -42,17 +42,39 @@ interface DatapointEvent {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
declare module 'knx' {
|
|
45
|
-
|
|
45
|
+
type MachinaEventsCallback = (...args: any[]) => void
|
|
46
|
+
|
|
47
|
+
interface MachinaEventsReturn {
|
|
48
|
+
eventName: string
|
|
49
|
+
callback: MachinaEventsCallback
|
|
50
|
+
off: () => void
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class MachinaEvents {
|
|
54
|
+
emit(eventName: string): void
|
|
55
|
+
on(eventName: string, callback: MachinaEventsCallback): MachinaEventsReturn
|
|
56
|
+
off(eventName?: string, callback?: MachinaEventsCallback): void
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface MachinaEventsReturn {
|
|
60
|
+
eventName: string
|
|
61
|
+
callback: MachinaEventsCallback
|
|
62
|
+
off: () => void
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface IConnection extends MachinaEvents {
|
|
46
66
|
debug: boolean
|
|
47
|
-
|
|
67
|
+
Connect(): void
|
|
68
|
+
Disconnect(cb?: Function): void
|
|
48
69
|
read( ga: KnxGroupAddress, cb?: (value: Buffer) => void ): void
|
|
49
70
|
write( ga: KnxGroupAddress, value: Buffer, dpt: DPT, cb?: () => void): void
|
|
50
71
|
}
|
|
51
72
|
|
|
52
|
-
export class Connection extends
|
|
73
|
+
export class Connection extends MachinaEvents implements IConnection {
|
|
53
74
|
public debug: boolean
|
|
54
75
|
constructor( conf: ConnectionSpec )
|
|
55
|
-
|
|
76
|
+
Connect(): void
|
|
77
|
+
Disconnect(cb?: Function): void
|
|
56
78
|
read( ga: KnxGroupAddress, cb?: (value: Buffer) => void ): void
|
|
57
79
|
write( ga: KnxGroupAddress, value: Buffer, dpt: DPT, cb?: () => void): void
|
|
58
80
|
writeRaw( ga: KnxGroupAddress, value: Buffer, bitlength?: number, cb?: () => void): void
|