iobroker.hm-rpc 4.3.0 → 4.3.2
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 +21 -12
- package/admin/jsonConfig.json +13 -1
- package/build/lib/lite.d.ts +44 -8
- package/build/lib/lite.js +97 -19
- package/build/lib/lite.js.map +1 -1
- package/build/lib/liteConnection.d.ts +7 -0
- package/build/lib/liteConnection.js +8 -0
- package/build/lib/liteConnection.js.map +1 -1
- package/build/lib/liteNames.d.ts +39 -6
- package/build/lib/liteNames.js +62 -15
- package/build/lib/liteNames.js.map +1 -1
- package/build/main.d.ts +19 -2
- package/build/main.js +102 -6
- package/build/main.js.map +1 -1
- package/io-package.json +27 -27
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liteNames.js","sourceRoot":"","sources":["../../src/lib/liteNames.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"liteNames.js","sourceRoot":"","sources":["../../src/lib/liteNames.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iCAAwG;AAuDxG;;GAEG;AACH,MAAa,SAAS;IAKlB;;;;;;OAMG;IACH,YACqB,OAAqB,EACrB,IAAgB,EAChB,KAAa,EACb,IAAY,EACZ,OAAyB,EAAE;QAJ3B,YAAO,GAAP,OAAO,CAAc;QACrB,SAAI,GAAJ,IAAI,CAAY;QAChB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAuB;QAdxC,UAAK,GAAG,KAAK,CAAC;IAenB,CAAC;IAEJ;;;;OAIG;IACH,QAAQ,CAAC,KAAK,GAAG,GAAG;QAChB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC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,CAAC;QACd,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAjOD,8BAiOC;AAED;;;;GAIG;AACH,SAAS,SAAS,CAAC,GAAoB;IACnC,MAAM,OAAO,GAAY,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC"}
|
package/build/main.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare class HomematicRpc extends Adapter {
|
|
|
32
32
|
private lite;
|
|
33
33
|
/** Names and rooms from the openccu-lite system, when switched on */
|
|
34
34
|
private liteNames;
|
|
35
|
+
/** The removal of the objects of devices the system no longer has, while it runs (it catches its own errors) */
|
|
36
|
+
private liteCleanup;
|
|
35
37
|
/** The pairing with an openccu-lite system, created with the first request of the admin */
|
|
36
38
|
private litePairing;
|
|
37
39
|
/** The language of ioBroker, for the names of rooms and functions and the pairing texts */
|
|
@@ -69,8 +71,9 @@ export declare class HomematicRpc extends Adapter {
|
|
|
69
71
|
private onReady;
|
|
70
72
|
/**
|
|
71
73
|
* Connects to the openccu-lite system: the requests through lite-rpc, the events from its stream, no callback
|
|
72
|
-
* server and no `init`. The device snapshot of the stream arrives as `newDevices`, which creates the new devices
|
|
73
|
-
*
|
|
74
|
+
* server and no `init`. The device snapshot of the stream arrives as `newDevices`, which creates the new devices;
|
|
75
|
+
* the stale ones are removed once the client is ready. The state of the connection follows the client's status
|
|
76
|
+
* instead of a PING.
|
|
74
77
|
*/
|
|
75
78
|
private startLite;
|
|
76
79
|
/**
|
|
@@ -80,6 +83,20 @@ export declare class HomematicRpc extends Adapter {
|
|
|
80
83
|
* @param state the client's status
|
|
81
84
|
*/
|
|
82
85
|
private onLiteStatus;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the system lists a device or channel address of this instance's interface. True while it has no device
|
|
88
|
+
* list for it (not connected yet, or the interface process is stopped): nothing is removed then either.
|
|
89
|
+
*
|
|
90
|
+
* @param address the device or channel address
|
|
91
|
+
*/
|
|
92
|
+
private liteKnows;
|
|
93
|
+
/**
|
|
94
|
+
* Removes the device and channel objects the system does not know any more (unless "Don't delete devices" is
|
|
95
|
+
* set): once the client is ready, at the start and after every reconnect, against the client's live picture of
|
|
96
|
+
* the devices. A `newDevices` is no ground for it on openccu-lite: the snapshot at connect carries the whole list,
|
|
97
|
+
* but a device paired later comes alone.
|
|
98
|
+
*/
|
|
99
|
+
private removeStaleLiteObjects;
|
|
83
100
|
/**
|
|
84
101
|
* Writes the values the system's state store holds into the states, through the event path: at connect, for
|
|
85
102
|
* the devices just created and after a resync, so a restart of ioBroker shows the current values before the
|
package/build/main.js
CHANGED
|
@@ -96,6 +96,8 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
96
96
|
EPAPER_TONE_INTERVAL: 'number',
|
|
97
97
|
EPAPER_TONE_REPETITIONS: 'number',
|
|
98
98
|
};
|
|
99
|
+
/** The removal of the objects of devices the system no longer has, while it runs (it catches its own errors) */
|
|
100
|
+
this.liteCleanup = Promise.resolve();
|
|
99
101
|
/** The language of ioBroker, for the names of rooms and functions and the pairing texts */
|
|
100
102
|
this.liteLanguage = 'en';
|
|
101
103
|
/** admin/icons sits next to build/ in the installed package */
|
|
@@ -377,8 +379,9 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
377
379
|
}
|
|
378
380
|
/**
|
|
379
381
|
* Connects to the openccu-lite system: the requests through lite-rpc, the events from its stream, no callback
|
|
380
|
-
* server and no `init`. The device snapshot of the stream arrives as `newDevices`, which creates the new devices
|
|
381
|
-
*
|
|
382
|
+
* server and no `init`. The device snapshot of the stream arrives as `newDevices`, which creates the new devices;
|
|
383
|
+
* the stale ones are removed once the client is ready. The state of the connection follows the client's status
|
|
384
|
+
* instead of a PING.
|
|
382
385
|
*/
|
|
383
386
|
async startLite() {
|
|
384
387
|
clientId = this.namespace;
|
|
@@ -414,7 +417,11 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
414
417
|
return;
|
|
415
418
|
}
|
|
416
419
|
if (this.config.liteNames !== false && this.lite.meta) {
|
|
417
|
-
this.liteNames = new liteNames_1.LiteNames(this, this.lite.meta, this.config.liteInterface, this.liteLanguage
|
|
420
|
+
this.liteNames = new liteNames_1.LiteNames(this, this.lite.meta, this.config.liteInterface, this.liteLanguage, {
|
|
421
|
+
// a pass waits for the removal of the devices the system no longer has, and skips them
|
|
422
|
+
settled: () => this.liteCleanup,
|
|
423
|
+
known: address => this.liteKnows(address),
|
|
424
|
+
});
|
|
418
425
|
// every change of the names, rooms and functions on the system, once the client's copy is in step again
|
|
419
426
|
// (right after a change applied in place, or once the snapshot is read again): a pass, debounced
|
|
420
427
|
this.lite.on('metaSettled', () => this.liteNames?.schedule());
|
|
@@ -431,6 +438,10 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
431
438
|
onLiteStatus(state) {
|
|
432
439
|
if (state === 'ready') {
|
|
433
440
|
this.updateConnection();
|
|
441
|
+
// one cleanup after the other; the names pass waits for it
|
|
442
|
+
this.liteCleanup = this.liteCleanup
|
|
443
|
+
.then(() => this.removeStaleLiteObjects())
|
|
444
|
+
.catch((e) => this.log.error(`Could not remove the objects of removed devices: ${e.message}`));
|
|
434
445
|
}
|
|
435
446
|
else if (connected) {
|
|
436
447
|
this.log.info(`Disconnected (${state})`);
|
|
@@ -438,6 +449,72 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
438
449
|
this.setStateAsync('info.connection', false, true).catch(e => this.log.error(`Cannot set state info.connection: ${e.message}`));
|
|
439
450
|
}
|
|
440
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Whether the system lists a device or channel address of this instance's interface. True while it has no device
|
|
454
|
+
* list for it (not connected yet, or the interface process is stopped): nothing is removed then either.
|
|
455
|
+
*
|
|
456
|
+
* @param address the device or channel address
|
|
457
|
+
*/
|
|
458
|
+
liteKnows(address) {
|
|
459
|
+
const devices = this.lite?.devices;
|
|
460
|
+
const iface = this.config.liteInterface;
|
|
461
|
+
if (!devices || !this.lite.interfaces.some(i => i.name === iface && i.running)) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
return devices.has(`${iface}.${address}`);
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Removes the device and channel objects the system does not know any more (unless "Don't delete devices" is
|
|
468
|
+
* set): once the client is ready, at the start and after every reconnect, against the client's live picture of
|
|
469
|
+
* the devices. A `newDevices` is no ground for it on openccu-lite: the snapshot at connect carries the whole list,
|
|
470
|
+
* but a device paired later comes alone.
|
|
471
|
+
*/
|
|
472
|
+
async removeStaleLiteObjects() {
|
|
473
|
+
const devices = this.lite?.devices;
|
|
474
|
+
if (!devices || this.config.dontDelete) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const iface = this.config.liteInterface;
|
|
478
|
+
if (!this.lite.interfaces.some(i => i.name === iface && i.running)) {
|
|
479
|
+
// a stopped interface process has no device list: its objects stay
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
if (![...devices.keys()].some(key => key.startsWith(`${iface}.`))) {
|
|
483
|
+
// an interface that lists no device at all - e.g. its process on the system was just restarted and has
|
|
484
|
+
// not loaded its devices yet - is no reason to delete every object: they stay until it lists some
|
|
485
|
+
this.log.debug(`${iface} lists no devices: no stale objects removed`);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
let objects;
|
|
489
|
+
try {
|
|
490
|
+
objects = {
|
|
491
|
+
...(await this.getForeignObjectsAsync(`${this.namespace}.*`, 'device')),
|
|
492
|
+
...(await this.getForeignObjectsAsync(`${this.namespace}.*`, 'channel')),
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
catch (e) {
|
|
496
|
+
this.log.error(`Cannot read the objects to remove the stale ones: ${e.message}`);
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
for (const obj of Object.values(objects)) {
|
|
500
|
+
const address = obj.native?.ADDRESS;
|
|
501
|
+
if (typeof address !== 'string' || devices.has(`${iface}.${address}`)) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
const id = obj._id.slice(this.namespace.length + 1);
|
|
505
|
+
if (!(await this.getObjectAsync(id))) {
|
|
506
|
+
// the channel of a device removed a moment ago
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
try {
|
|
510
|
+
await this.deleteObjectTree(id);
|
|
511
|
+
this.log.info(`obsolete ${obj.type} ${address} deleted`);
|
|
512
|
+
}
|
|
513
|
+
catch (e) {
|
|
514
|
+
this.log.error(`Could not delete obsolete ${obj.type} ${address}: ${e.message}`);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
441
518
|
/**
|
|
442
519
|
* Writes the values the system's state store holds into the states, through the event path: at connect, for
|
|
443
520
|
* the devices just created and after a resync, so a restart of ioBroker shows the current values before the
|
|
@@ -1269,7 +1346,7 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
1269
1346
|
this.log.info(`${this.config.type}rpc <- newDevices ${newDevices.length}`);
|
|
1270
1347
|
// for a HmIP-adapter (and virtual-devices) we have to filter out the devices that
|
|
1271
1348
|
// are already present if forceReinit is not set. The same for every interface of an openccu-lite
|
|
1272
|
-
// system, whose stream sends the whole device list at
|
|
1349
|
+
// system, whose stream sends the whole device list at connect
|
|
1273
1350
|
const filterKnown = this.lite
|
|
1274
1351
|
? !this.config.forceReInit
|
|
1275
1352
|
: this.config.forceReInit === false &&
|
|
@@ -1306,9 +1383,10 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
1306
1383
|
}
|
|
1307
1384
|
}
|
|
1308
1385
|
// if index is -1 than the newDevices doesn't have the
|
|
1309
|
-
// device with address val.ADDRESS anymore, thus we can delete it
|
|
1386
|
+
// device with address val.ADDRESS anymore, thus we can delete it. Not on openccu-lite:
|
|
1387
|
+
// a device paired later comes alone, the stale ones go when the client is ready
|
|
1310
1388
|
if (index === -1) {
|
|
1311
|
-
if (val.ADDRESS && !this.config.dontDelete) {
|
|
1389
|
+
if (val.ADDRESS && !this.config.dontDelete && !this.lite) {
|
|
1312
1390
|
if (val.ADDRESS.includes(':')) {
|
|
1313
1391
|
const address = val.ADDRESS.replace(':', '.').replace(tools.FORBIDDEN_CHARS, '_');
|
|
1314
1392
|
const parts = address.split('.');
|
|
@@ -1675,6 +1753,24 @@ class HomematicRpc extends adapter_core_1.Adapter {
|
|
|
1675
1753
|
}
|
|
1676
1754
|
params[key] = dpType.TYPE === 'FLOAT' ? { explicitDouble: value } : value;
|
|
1677
1755
|
}
|
|
1756
|
+
// #1557: HmIP-RGBW also wants LEVEL in the same putParamset, else MISSING_NON_OPTIONAL_PARAMETER
|
|
1757
|
+
const levelId = `${channelId}.LEVEL`;
|
|
1758
|
+
const levelType = this.dpTypes[levelId];
|
|
1759
|
+
if (levelType) {
|
|
1760
|
+
try {
|
|
1761
|
+
const state = await this.getForeignStateAsync(levelId);
|
|
1762
|
+
if (typeof state?.val === 'number') {
|
|
1763
|
+
let value = state.val;
|
|
1764
|
+
if (levelType.UNIT === '100%') {
|
|
1765
|
+
value = Math.round((value / 100) * 1_000) / 1_000;
|
|
1766
|
+
}
|
|
1767
|
+
params.LEVEL = levelType.TYPE === 'FLOAT' ? { explicitDouble: value } : value;
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
catch (e) {
|
|
1771
|
+
this.log.error(`Cannot read state ${levelId}: ${e.message}`);
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1678
1774
|
this.log.debug(`${this.config.type}rpc -> putParamset ${JSON.stringify([address, 'VALUES', params])}`);
|
|
1679
1775
|
try {
|
|
1680
1776
|
if (rpcClient && connected) {
|