iobroker.device-watcher 2.9.11 → 2.9.13
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/LICENSE +1 -1
- package/README.md +10 -1
- package/io-package.json +27 -27
- package/main.js +270 -221
- package/package.json +8 -8
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 ciddi89 <mail@christian-behrends.de>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -189,6 +189,15 @@ It's possible to select:
|
|
|
189
189
|
Placeholder for the next version (at the beginning of the line):
|
|
190
190
|
### **WORK IN PROGRESS**
|
|
191
191
|
-->
|
|
192
|
+
### 2.9.13 (2024-01-03)
|
|
193
|
+
|
|
194
|
+
- (ciddi89) Fixed: Issues from v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)
|
|
195
|
+
- (ciddi89) Fixed: High CPU usage at object and state changes [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)
|
|
196
|
+
|
|
197
|
+
### 2.9.12 (2024-01-02)
|
|
198
|
+
|
|
199
|
+
- (ciddi89) Fixed: Changed handling for state changes and subscriptions [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)
|
|
200
|
+
|
|
192
201
|
### 2.9.11 (2023-12-12)
|
|
193
202
|
|
|
194
203
|
- (ciddi89) Fixed: Fullybroswer >v3 use id not common name
|
|
@@ -522,7 +531,7 @@ It's possible to select:
|
|
|
522
531
|
|
|
523
532
|
MIT License
|
|
524
533
|
|
|
525
|
-
Copyright (c)
|
|
534
|
+
Copyright (c) 2024 Christian Behrends <mail@christian-behrends.de>
|
|
526
535
|
|
|
527
536
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
528
537
|
of this software and associated documentation files (the "Software"), to deal
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "device-watcher",
|
|
4
|
-
"version": "2.9.
|
|
4
|
+
"version": "2.9.13",
|
|
5
5
|
"news": {
|
|
6
|
+
"2.9.13": {
|
|
7
|
+
"en": "Fixed: Issues from v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nFixed: High CPU usage at object and state changes [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
8
|
+
"de": "Behoben: Fehler von v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nBehoben: Hohe CPU-Nutzung bei Objekt- und Zustandsänderungen [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
9
|
+
"ru": "Исправлено: Вопросы от v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nИсправлено: Высокое использование процессора на объектах и государственных изменениях [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
10
|
+
"pt": "Corrigido: Questões do v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nCorrigido: Uso de alta CPU em alterações de objeto e estado [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
11
|
+
"nl": "Quality over Quantity (QoQ) Releases Vertaling:\nQuality over Quantity (QoQ) Releases Vertaling:",
|
|
12
|
+
"fr": "Correction : Questions renvoyées à l ' adresse v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nFixed: High CPU use at object and state changes [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
13
|
+
"it": "Risolto: Problemi da v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nRisolto: alto uso della CPU a oggetto e cambiamenti di stato [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
14
|
+
"es": "Arreglado: Cuestiones de v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nFijo: Alto uso de la CPU en los cambios de objeto y estado [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
15
|
+
"pl": "Fixed: Issues from v2.9.12 #283(https:/github.com/ciddi89/ioBroker,device-watcher/issues/283) (ang.)\n(Użycie procesora) w obiektach i stanach zmienia liczbę #283 (https:/github.com/ciddi89/ioBroker,device-watcher/issues/283)",
|
|
16
|
+
"uk": "Виправлено: Випуски від v2.9.12 [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)\nВиправлено: Високий рівень використання процесора при об'єктах та змінах стану [#283] (https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
17
|
+
"zh-cn": "Fixed: Issues from v2.9.12[#283] (http://github.com/ciddi89/ioBroker.device-watcher/issues/283)\n九. 固定:在物体和州变化中使用高频单位[第283](http://github.com/ciddi89/ioBroker.device-watcher/issues/283)"
|
|
18
|
+
},
|
|
19
|
+
"2.9.12": {
|
|
20
|
+
"en": "Fixed: Changed handling for state changes and subscriptions [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
21
|
+
"de": "Behoben: Handhabung für Zustandsänderungen und Abonnements geändert [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
22
|
+
"ru": "Исправлено: Изменение обработки государственных изменений и подписок [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
23
|
+
"pt": "Corrigido: Manuseio alterado para alterações e assinaturas do Estado [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
24
|
+
"nl": "Gewijzigd voor staatsverandering en abonnementen",
|
|
25
|
+
"fr": "Correction : Traitement modifié pour les changements d ' état et les abonnements [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
26
|
+
"it": "Risolto: Modificato il trattamento per le modifiche dello stato e gli abbonamenti [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
27
|
+
"es": "Corregido: Modificación de la tramitación de los cambios y suscripciones estatales [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
28
|
+
"pl": "Fixed: Changed handling for state changes and subscriptions #283(https:/github.com/ciddi89/ioBroker.device-watcher/issues/283) (ang.)",
|
|
29
|
+
"uk": "Виправлено: Змінене поводження з державними змінами та підписками [#283](https://github.com/ciddi89/ioBroker.device-watcher/issues/283)",
|
|
30
|
+
"zh-cn": "固定:国家变化和订阅的改变(第283号)"
|
|
31
|
+
},
|
|
6
32
|
"2.9.11": {
|
|
7
33
|
"en": "Fixed: Fullybroswer >v3 use id not common name",
|
|
8
34
|
"de": "Behoben: Fullybroswer >v3 verwende den ID Namen",
|
|
@@ -67,32 +93,6 @@
|
|
|
67
93
|
"pl": "Wspieranie Wifilight\nFixed: Multiple messages, jeśli urządzenia Sonoff docierają do miejsca #244 (https:/github.com/ciddi89/ioBroker.device-watcher/issues/244)",
|
|
68
94
|
"uk": "Доданий: Підтримка Wifilight\nВиправлено: Кілька повідомлень, якщо пристрої Sonoff досягаються [#244](https://github.com/ciddi89/ioBroker.device-watcher/issues/244)",
|
|
69
95
|
"zh-cn": "增 编:支持光明\nFixed:Sonoff装置可达到[第244](http://github.com/ciddi89/ioBroker.device-watcher/issues/244)"
|
|
70
|
-
},
|
|
71
|
-
"2.9.6": {
|
|
72
|
-
"en": "Fixed: Admin jsonConfig schema\nChanged: Admin jsonConfig to json5\nAdded: Support for Tuya devices with online state\nOthers: cleaned up files",
|
|
73
|
-
"de": "Behoben: Admin jsonConfig Schema\nGeändert: Admin jsonConfig zu json5\nHinzugefügt: Unterstützung für Tuya-Geräte mit Online-Zustand\nAnderes: Dateien aufgeräumt",
|
|
74
|
-
"ru": "Исправлено: Admin jsonConfig schema\nИзменено: Admin jsonConfig в json5\nДобавлена: Поддержка устройств Tuya с онлайн состоянием\nДругое: очищенные файлы",
|
|
75
|
-
"pt": "Corrigido: Admin jsonConfig schema\nAlterado: Admin jsonConfig to json5\nAdicionado: Suporte para dispositivos Tuya com estado on-line\nOutros: limpe arquivos",
|
|
76
|
-
"nl": "Admin jsonConfig schema\nAdministratie JsonConfig aan Json5\nVersterking voor Tuya apparaten met online staat\nVertaling:",
|
|
77
|
-
"fr": "Correction : Admin jsonConfig schema\nChanged: Admin jsonConfig to json5\nAjouté: Support pour les appareils Tuya avec l'état en ligne\nAutre: nettoyer les fichiers",
|
|
78
|
-
"it": "Fisso: Schema Admin jsonConfig\nModificato: Admin jsonConfig a json5\nAggiunto: Supporto per dispositivi Tuya con stato online\nAltro: file ripuliti",
|
|
79
|
-
"es": "Arreglado: Amin jsonConfig schema\nCambios: Admin jsonConfig a json5\nAñadido: Soporte para dispositivos Tuya con estado en línea\nOtros: limpiar archivos",
|
|
80
|
-
"pl": "Admin jsonConfig schema\nZmiana: Admin jsonConfig to json5\nWstęp: Wsparcie dla urządzeń Tuya z internetowym państwem\nInne: czyste pliki plikowe",
|
|
81
|
-
"uk": "Виправлено: Admin jsonConfig schema\nЗмінено: Admin jsonConfig to json5\nДодано: Підтримка пристроїв Туя з онлайн-державою\nІнше: очищення файлів",
|
|
82
|
-
"zh-cn": "Fix: Admin json Config schema\n修改: Admin json Configg to json5\n增 编:在网上国家支持图亚装置\n其他:清洁档案"
|
|
83
|
-
},
|
|
84
|
-
"2.9.5": {
|
|
85
|
-
"en": "Added: if available use deviceName datapoint for sonoff devices\nFixed: Changed zwave to zwave2\nFixed: minor bugfixes\nAdded: FullyBrowser > v3",
|
|
86
|
-
"de": "Hinzugefügt: Wenn verfügbar benutze deviceName Datenpunkt für Sonoff Geräte\nBehoben: Zwave zu zwave2 geändert\nBehoben: kleinere Bugfixes\nHinzugefügt: FullyBrowser > V3",
|
|
87
|
-
"ru": "Добавлена: если доступно использование устройстваName datapoint для устройств sonoff\nИсправлено: Изменено zwave в zwave2\nИсправлено: незначительные багфиксы\nДобавлено: FullyBrowser > В3",
|
|
88
|
-
"pt": "Adicionado: se disponível use deviceName datapoint for sonoff devices\nCorrigido: Alterado zwave para zwave2\nCorrigido: pequenos bugfixes\nAdicionado: FullyBrowser > v3",
|
|
89
|
-
"nl": "Toegegeven:\nQuality over Quantity (QoQ) Releases Vertaling:\nQuality over Quantity (QoQ) Releases Vertaling:\nVertaling: Vertaling:",
|
|
90
|
-
"fr": "Ajouté: si le dispositif d'utilisation disponibleNom datapoint pour les appareils à sonoff\nFixé: Zwave changée en zwave2\nCorrection : corrections mineures\nAjouté: FullyBrowser phy v3",
|
|
91
|
-
"it": "Aggiunto: if available use deviceName datapoint for sonoff devices\nFisso: Cambiato zwave a zwave2\nRisolto: bugfix minori\nAggiunto: FullyBrowser > V",
|
|
92
|
-
"es": "Añadido: si está disponible el punto de datos del dispositivoName para dispositivos sonoff\nFijo: Cambio de onda de zwave2\nFijación: bugfixes menores\nAñadido: FullyBrowser v3",
|
|
93
|
-
"pl": "Addd: jeśli urządzenie użyte do transmisji danych\nFixed: Changed zwave to zwave2 (ang.)\nFixed: minor bugfixes\nAdded: FullyBrowser> (ang.). v3",
|
|
94
|
-
"uk": "Додано: якщо доступний пристрій useName для пристроїв sonoff\nВиправлено: Змінено zwave to zwave2\nВиправлено: незначні виправлення\nДоданий: FullyBrowser > в3",
|
|
95
|
-
"zh-cn": "增删:如果能用装置Name数据点用于子壳装置\n九. 固定:对兹瓦韦的改变\n固定:小额配件\n增 编:全页 评 注"
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"titleLang": {
|
package/main.js
CHANGED
|
@@ -79,6 +79,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
79
79
|
// Interval timer
|
|
80
80
|
this.refreshDataTimeout = null;
|
|
81
81
|
|
|
82
|
+
this.mainRunning = false;
|
|
83
|
+
|
|
82
84
|
this.on('ready', this.onReady.bind(this));
|
|
83
85
|
this.on('stateChange', this.onStateChange.bind(this));
|
|
84
86
|
this.on('objectChange', this.onObjectChange.bind(this));
|
|
@@ -332,12 +334,19 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
332
334
|
// The object was changed
|
|
333
335
|
//this.log.debug(`object ${id} changed: ${JSON.stringify(obj)}`);
|
|
334
336
|
|
|
335
|
-
if (id.startsWith('system.adapter.')) {
|
|
337
|
+
if (this.config.checkAdapterInstances && id.startsWith('system.adapter.')) {
|
|
336
338
|
//read new instance data and add it to the lists
|
|
337
339
|
await this.getInstanceData(id);
|
|
338
340
|
} else {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
+
if (Array.from(this.listAllDevicesRaw.values()).some((obj) => obj.mainSelector === id)) {
|
|
342
|
+
if (!this.mainRunning) {
|
|
343
|
+
await this.main();
|
|
344
|
+
} else {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
} else {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
341
350
|
}
|
|
342
351
|
} catch (error) {
|
|
343
352
|
this.log.error(`Issue at object change: ${error}`);
|
|
@@ -374,215 +383,27 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
374
383
|
async onStateChange(id, state) {
|
|
375
384
|
if (state) {
|
|
376
385
|
// this.log.debug(`State changed: ${id} changed ${state.val}`);
|
|
377
|
-
let batteryData;
|
|
378
|
-
let signalData;
|
|
379
|
-
let oldLowBatState;
|
|
380
|
-
let contactData;
|
|
381
|
-
let oldStatus;
|
|
382
|
-
let isLowBatValue;
|
|
383
|
-
let instanceStatusRaw;
|
|
384
|
-
let oldAdapterUpdatesCounts;
|
|
385
386
|
|
|
386
387
|
try {
|
|
387
388
|
/*=============================================
|
|
388
|
-
=
|
|
389
|
+
= Instances / Adapter =
|
|
389
390
|
=============================================*/
|
|
390
|
-
if (
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (this.config.checkSendAdapterUpdateMsg && this.countAdapterUpdates > oldAdapterUpdatesCounts) {
|
|
395
|
-
await this.sendStateNotifications('updateAdapter', null);
|
|
396
|
-
}
|
|
397
|
-
for (const instance of this.listInstanceRaw.values()) {
|
|
398
|
-
if (this.adapterUpdatesJsonRaw.has(instance.Adapter)) {
|
|
399
|
-
for (const adapter of this.adapterUpdatesJsonRaw.values()) {
|
|
400
|
-
instance.updateAvailable = adapter.newVersion;
|
|
401
|
-
}
|
|
402
|
-
} else {
|
|
403
|
-
instance.updateAvailable = ' - ';
|
|
404
|
-
}
|
|
391
|
+
if (this.config.checkAdapterInstances) {
|
|
392
|
+
// Adapter Update data
|
|
393
|
+
if (id.endsWith('updatesJson')) {
|
|
394
|
+
await this.renewAdapterUpdateData(id);
|
|
405
395
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
= Instances =
|
|
410
|
-
=============================================*/
|
|
411
|
-
for (const [instanceID, instanceData] of this.listInstanceRaw) {
|
|
412
|
-
const checkInstance = async (instanceID, instanceData) => {
|
|
413
|
-
if (!instanceData.checkIsRunning) {
|
|
414
|
-
instanceData.checkIsRunning = true;
|
|
415
|
-
instanceStatusRaw = await this.setInstanceStatus(instanceData.instanceMode, instanceData.schedule, instanceID);
|
|
416
|
-
instanceData.isAlive = instanceStatusRaw[0];
|
|
417
|
-
instanceData.isHealthy = instanceStatusRaw[1];
|
|
418
|
-
instanceData.status = instanceStatusRaw[2];
|
|
419
|
-
instanceData.checkIsRunning = false;
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
|
|
424
|
-
switch (id) {
|
|
425
|
-
case `system.adapter.${instanceID}.alive`:
|
|
426
|
-
if (state.val !== instanceData.isAlive) {
|
|
427
|
-
await checkInstance(instanceID, instanceData);
|
|
428
|
-
// send message when instance was deactivated
|
|
429
|
-
if (this.config.checkSendInstanceDeactivatedMsg && !instanceData.isAlive) {
|
|
430
|
-
if (this.blacklistInstancesNotify.includes(instanceID)) continue;
|
|
431
|
-
await this.sendStateNotifications('deactivatedInstance', instanceID);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
break;
|
|
436
|
-
case `system.adapter.${instanceID}.connected`:
|
|
437
|
-
if (state.val !== instanceData.isConnectedHost && instanceData.isAlive) {
|
|
438
|
-
await checkInstance(instanceID, instanceData);
|
|
439
|
-
// send message when instance has an error
|
|
440
|
-
if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
|
|
441
|
-
if (this.blacklistInstancesNotify.includes(instanceID)) continue;
|
|
442
|
-
await this.sendStateNotifications('errorInstance', instanceID);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
break;
|
|
446
|
-
case `${instanceID}.info.connection`:
|
|
447
|
-
if (state.val !== instanceData.isConnectedDevice && instanceData.isAlive) {
|
|
448
|
-
await checkInstance(instanceID, instanceData);
|
|
449
|
-
// send message when instance has an error
|
|
450
|
-
if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
|
|
451
|
-
if (this.blacklistInstancesNotify.includes(instanceID)) continue;
|
|
452
|
-
await this.sendStateNotifications('errorInstance', instanceID);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
break;
|
|
396
|
+
// Instanz data
|
|
397
|
+
if (Array.from(this.listInstanceRaw.values()).some((obj) => Object.values(obj).includes(id))) {
|
|
398
|
+
await this.renewInstanceData(id, state);
|
|
457
399
|
}
|
|
458
400
|
}
|
|
459
401
|
|
|
460
402
|
/*=============================================
|
|
461
403
|
= Devices =
|
|
462
404
|
=============================================*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
switch (id) {
|
|
466
|
-
// device connection
|
|
467
|
-
case deviceData.instanceDeviceConnectionDP:
|
|
468
|
-
if (state.val !== deviceData.instancedeviceConnected) {
|
|
469
|
-
deviceData.instancedeviceConnected = state.val;
|
|
470
|
-
}
|
|
471
|
-
break;
|
|
472
|
-
|
|
473
|
-
// device updates
|
|
474
|
-
case deviceData.UpdateDP:
|
|
475
|
-
if (state.val !== deviceData.Upgradable) {
|
|
476
|
-
deviceData.Upgradable = await this.checkDeviceUpdate(deviceData.adapterID, state.val);
|
|
477
|
-
if (deviceData.Upgradable === true) {
|
|
478
|
-
if (this.config.checkSendDeviceUpgrade && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
479
|
-
await this.sendStateNotifications('updateDevice', device);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
break;
|
|
484
|
-
|
|
485
|
-
// device signal
|
|
486
|
-
case deviceData.SignalStrengthDP:
|
|
487
|
-
signalData = await this.calculateSignalStrength(state, deviceData.adapterID);
|
|
488
|
-
deviceData.SignalStrength = signalData[0];
|
|
489
|
-
|
|
490
|
-
break;
|
|
491
|
-
|
|
492
|
-
// device battery
|
|
493
|
-
case deviceData.batteryDP:
|
|
494
|
-
if (deviceData.isBatteryDevice) {
|
|
495
|
-
oldLowBatState = deviceData.LowBat;
|
|
496
|
-
if (state.val === 0 && deviceData.BatteryRaw >= 5) continue;
|
|
497
|
-
batteryData = await this.getBatteryData(state.val, oldLowBatState, deviceData.faultReport, deviceData.adapterID);
|
|
498
|
-
|
|
499
|
-
deviceData.Battery = batteryData[0];
|
|
500
|
-
deviceData.BatteryRaw = batteryData[2];
|
|
501
|
-
deviceData.BatteryUnitRaw = batteryData[3];
|
|
502
|
-
if (deviceData.LowBatDP !== 'none') {
|
|
503
|
-
isLowBatValue = await this.getInitValue(deviceData.LowBatDP);
|
|
504
|
-
} else {
|
|
505
|
-
isLowBatValue = undefined;
|
|
506
|
-
}
|
|
507
|
-
deviceData.LowBat = await this.setLowbatIndicator(state.val, isLowBatValue, deviceData.faultReport, deviceData.adapterID);
|
|
508
|
-
|
|
509
|
-
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
510
|
-
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
511
|
-
await this.sendStateNotifications('lowBatDevice', device);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
|
|
517
|
-
// device low bat
|
|
518
|
-
case deviceData.LowBatDP:
|
|
519
|
-
if (deviceData.isBatteryDevice) {
|
|
520
|
-
oldLowBatState = deviceData.LowBat;
|
|
521
|
-
batteryData = await this.getBatteryData(deviceData.BatteryRaw, state.val, deviceData.faultReport, deviceData.adapterID);
|
|
522
|
-
deviceData.Battery = batteryData[0];
|
|
523
|
-
deviceData.BatteryRaw = batteryData[2];
|
|
524
|
-
deviceData.BatteryUnitRaw = batteryData[3];
|
|
525
|
-
deviceData.LowBat = await this.setLowbatIndicator(deviceData.BatteryRaw, state.val, deviceData.faultReport, deviceData.adapterID);
|
|
526
|
-
|
|
527
|
-
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
528
|
-
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
529
|
-
await this.sendStateNotifications('lowBatDevice', device);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
break;
|
|
534
|
-
|
|
535
|
-
//device error / fault reports
|
|
536
|
-
case deviceData.faultReportDP:
|
|
537
|
-
if (deviceData.isBatteryDevice) {
|
|
538
|
-
oldLowBatState = deviceData.LowBat;
|
|
539
|
-
batteryData = await this.getBatteryData(deviceData.BatteryRaw, oldLowBatState, state.val, deviceData.adapterID);
|
|
540
|
-
|
|
541
|
-
deviceData.Battery = batteryData[0];
|
|
542
|
-
deviceData.BatteryRaw = batteryData[2];
|
|
543
|
-
deviceData.BatteryUnitRaw = batteryData[3];
|
|
544
|
-
deviceData.LowBat = await this.setLowbatIndicator(deviceData.BatteryRaw, undefined, state.val, deviceData.adapterID);
|
|
545
|
-
|
|
546
|
-
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
547
|
-
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
548
|
-
await this.sendStateNotifications('lowBatDevice', device);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
break;
|
|
553
|
-
|
|
554
|
-
// device unreach
|
|
555
|
-
case deviceData.UnreachDP:
|
|
556
|
-
if (deviceData.UnreachState !== state.val) {
|
|
557
|
-
oldStatus = deviceData.Status;
|
|
558
|
-
deviceData.UnreachState = state.val;
|
|
559
|
-
contactData = await this.getOnlineState(
|
|
560
|
-
deviceData.timeSelector,
|
|
561
|
-
deviceData.adapterID,
|
|
562
|
-
deviceData.UnreachDP,
|
|
563
|
-
deviceData.SignalStrength,
|
|
564
|
-
deviceData.UnreachState,
|
|
565
|
-
deviceData.DeviceStateSelectorDP,
|
|
566
|
-
deviceData.rssiPeerSelectorDP,
|
|
567
|
-
);
|
|
568
|
-
if (contactData !== undefined) {
|
|
569
|
-
deviceData.LastContact = contactData[0];
|
|
570
|
-
deviceData.Status = contactData[1];
|
|
571
|
-
deviceData.SignalStrength = contactData[2];
|
|
572
|
-
}
|
|
573
|
-
if (this.config.checkSendOfflineMsg && oldStatus !== deviceData.Status && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
574
|
-
if (deviceData.instanceDeviceConnectionDP.val !== undefined) {
|
|
575
|
-
// check if the generally deviceData connected state is for a while true
|
|
576
|
-
if (await this.getTimestampConnectionDP(deviceData.instanceDeviceConnectionDP, 20000)) {
|
|
577
|
-
await this.sendStateNotifications('onlineStateDevice', device);
|
|
578
|
-
}
|
|
579
|
-
} else {
|
|
580
|
-
await this.sendStateNotifications('onlineStateDevice', device);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
405
|
+
if (Array.from(this.listAllDevicesRaw.values()).some((obj) => Object.values(obj).includes(id))) {
|
|
406
|
+
await this.renewDeviceData(id, state);
|
|
586
407
|
}
|
|
587
408
|
} catch (error) {
|
|
588
409
|
this.log.error(`Issue at state change: ${error}`);
|
|
@@ -686,6 +507,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
686
507
|
*/
|
|
687
508
|
async main() {
|
|
688
509
|
this.log.debug(`Function started: ${this.main.name}`);
|
|
510
|
+
this.mainRunning = true;
|
|
689
511
|
|
|
690
512
|
// cancel run if no adapter is selected
|
|
691
513
|
if (this.adapterSelected.length === 0) return;
|
|
@@ -720,7 +542,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
720
542
|
this.log.error(`[main - create and fill datapoints for each adapter] - ${error}`);
|
|
721
543
|
}
|
|
722
544
|
}
|
|
723
|
-
|
|
545
|
+
this.mainRunning = false;
|
|
724
546
|
this.log.debug(`Function finished: ${this.main.name}`);
|
|
725
547
|
} //<--End of main function
|
|
726
548
|
|
|
@@ -856,6 +678,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
856
678
|
/*---------- Start of loop ----------*/
|
|
857
679
|
for (const [id] of Object.entries(devices)) {
|
|
858
680
|
if (id.endsWith('.')) continue;
|
|
681
|
+
const mainSelector = id;
|
|
859
682
|
|
|
860
683
|
/*=============================================
|
|
861
684
|
= get Instanz =
|
|
@@ -864,9 +687,10 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
864
687
|
|
|
865
688
|
const instanceDeviceConnectionDP = `${instance}.info.connection`;
|
|
866
689
|
const instancedeviceConnected = await this.getInitValue(instanceDeviceConnectionDP);
|
|
867
|
-
this.subscribeForeignStates(instanceDeviceConnectionDP);
|
|
690
|
+
// this.subscribeForeignStates(instanceDeviceConnectionDP);
|
|
868
691
|
this.subscribeForeignObjects(`${this.selAdapter[i].Selektor}`);
|
|
869
|
-
|
|
692
|
+
// this.subscribeForeignObjects('*');
|
|
693
|
+
this.subscribeForeignStates('*');
|
|
870
694
|
/*=============================================
|
|
871
695
|
= Get device name =
|
|
872
696
|
=============================================*/
|
|
@@ -884,7 +708,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
884
708
|
const shortCurrDeviceString = currDeviceString.slice(0, currDeviceString.lastIndexOf('.') + 1 - 1);
|
|
885
709
|
|
|
886
710
|
// subscribe to object device path
|
|
887
|
-
this.
|
|
711
|
+
// this.subscribeForeignStates(currDeviceString);
|
|
888
712
|
|
|
889
713
|
/*=============================================
|
|
890
714
|
= Get signal strength =
|
|
@@ -911,7 +735,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
911
735
|
break;
|
|
912
736
|
}
|
|
913
737
|
//subscribe to states
|
|
914
|
-
this.subscribeForeignStates(deviceQualityDP);
|
|
738
|
+
// this.subscribeForeignStates(deviceQualityDP);
|
|
915
739
|
|
|
916
740
|
const signalData = await this.calculateSignalStrength(deviceQualityState, adapterID);
|
|
917
741
|
let linkQuality = signalData[0];
|
|
@@ -983,9 +807,9 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
983
807
|
faultReportingState = await this.getInitValue(faultReportingDP);
|
|
984
808
|
|
|
985
809
|
//subscribe to states
|
|
986
|
-
this.subscribeForeignStates(deviceBatteryStateDP);
|
|
987
|
-
this.subscribeForeignStates(isLowBatDP);
|
|
988
|
-
this.subscribeForeignStates(faultReportingDP);
|
|
810
|
+
// this.subscribeForeignStates(deviceBatteryStateDP);
|
|
811
|
+
// this.subscribeForeignStates(isLowBatDP);
|
|
812
|
+
// this.subscribeForeignStates(faultReportingDP);
|
|
989
813
|
|
|
990
814
|
const batteryData = await this.getBatteryData(deviceBatteryState, deviceLowBatState, faultReportingState, adapterID);
|
|
991
815
|
batteryHealth = batteryData[0];
|
|
@@ -1018,10 +842,10 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1018
842
|
}
|
|
1019
843
|
|
|
1020
844
|
// subscribe to states
|
|
1021
|
-
this.subscribeForeignStates(timeSelector);
|
|
1022
|
-
this.subscribeForeignStates(unreachDP);
|
|
1023
|
-
this.subscribeForeignStates(deviceStateSelectorDP);
|
|
1024
|
-
this.subscribeForeignStates(rssiPeerSelectorDP);
|
|
845
|
+
// this.subscribeForeignStates(timeSelector);
|
|
846
|
+
// this.subscribeForeignStates(unreachDP);
|
|
847
|
+
// this.subscribeForeignStates(deviceStateSelectorDP);
|
|
848
|
+
// this.subscribeForeignStates(rssiPeerSelectorDP);
|
|
1025
849
|
|
|
1026
850
|
const onlineState = await this.getOnlineState(timeSelector, adapterID, unreachDP, linkQuality, deviceUnreachState, deviceStateSelectorDP, rssiPeerSelectorDP);
|
|
1027
851
|
let deviceState;
|
|
@@ -1059,7 +883,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1059
883
|
}
|
|
1060
884
|
|
|
1061
885
|
// subscribe to states
|
|
1062
|
-
this.subscribeForeignStates(deviceUpdateDP);
|
|
886
|
+
// this.subscribeForeignStates(deviceUpdateDP);
|
|
887
|
+
this.subscribeForeignStates('*');
|
|
1063
888
|
}
|
|
1064
889
|
|
|
1065
890
|
/*=============================================
|
|
@@ -1068,6 +893,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1068
893
|
const setupList = () => {
|
|
1069
894
|
this.listAllDevicesRaw.set(currDeviceString, {
|
|
1070
895
|
Path: id,
|
|
896
|
+
mainSelector: mainSelector,
|
|
1071
897
|
instanceDeviceConnectionDP: instanceDeviceConnectionDP,
|
|
1072
898
|
instancedeviceConnected: instancedeviceConnected,
|
|
1073
899
|
instance: instance,
|
|
@@ -2043,6 +1869,149 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2043
1869
|
this.log.debug(`Function finished: ${this.writeDatapoints.name}`);
|
|
2044
1870
|
} //<--End of writing Datapoints
|
|
2045
1871
|
|
|
1872
|
+
/**
|
|
1873
|
+
* @param {string | string[]} id
|
|
1874
|
+
* @param {ioBroker.State} state
|
|
1875
|
+
*/
|
|
1876
|
+
async renewDeviceData(id, state) {
|
|
1877
|
+
let batteryData;
|
|
1878
|
+
let signalData;
|
|
1879
|
+
let oldLowBatState;
|
|
1880
|
+
let contactData;
|
|
1881
|
+
let oldStatus;
|
|
1882
|
+
let isLowBatValue;
|
|
1883
|
+
|
|
1884
|
+
const deviceID = id.slice(0, id.lastIndexOf('.') + 1 - 1);
|
|
1885
|
+
const deviceData = this.listAllDevicesRaw.get(deviceID);
|
|
1886
|
+
|
|
1887
|
+
if (deviceData) {
|
|
1888
|
+
// On statechange update available datapoint
|
|
1889
|
+
switch (id) {
|
|
1890
|
+
// device connection
|
|
1891
|
+
case deviceData.instanceDeviceConnectionDP:
|
|
1892
|
+
if (state.val !== deviceData.instancedeviceConnected) {
|
|
1893
|
+
deviceData.instancedeviceConnected = state.val;
|
|
1894
|
+
}
|
|
1895
|
+
break;
|
|
1896
|
+
|
|
1897
|
+
// device updates
|
|
1898
|
+
case deviceData.UpdateDP:
|
|
1899
|
+
if (state.val !== deviceData.Upgradable) {
|
|
1900
|
+
deviceData.Upgradable = await this.checkDeviceUpdate(deviceData.adapterID, state.val);
|
|
1901
|
+
if (deviceData.Upgradable === true) {
|
|
1902
|
+
if (this.config.checkSendDeviceUpgrade && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
1903
|
+
await this.sendStateNotifications('updateDevice', deviceID);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
break;
|
|
1908
|
+
|
|
1909
|
+
// device signal
|
|
1910
|
+
case deviceData.SignalStrengthDP:
|
|
1911
|
+
signalData = await this.calculateSignalStrength(state, deviceData.adapterID);
|
|
1912
|
+
deviceData.SignalStrength = signalData[0];
|
|
1913
|
+
|
|
1914
|
+
break;
|
|
1915
|
+
|
|
1916
|
+
// device battery
|
|
1917
|
+
case deviceData.batteryDP:
|
|
1918
|
+
if (deviceData.isBatteryDevice) {
|
|
1919
|
+
oldLowBatState = deviceData.LowBat;
|
|
1920
|
+
if (state.val === 0 && deviceData.BatteryRaw >= 5) return;
|
|
1921
|
+
batteryData = await this.getBatteryData(state.val, oldLowBatState, deviceData.faultReport, deviceData.adapterID);
|
|
1922
|
+
|
|
1923
|
+
deviceData.Battery = batteryData[0];
|
|
1924
|
+
deviceData.BatteryRaw = batteryData[2];
|
|
1925
|
+
deviceData.BatteryUnitRaw = batteryData[3];
|
|
1926
|
+
if (deviceData.LowBatDP !== 'none') {
|
|
1927
|
+
isLowBatValue = await this.getInitValue(deviceData.LowBatDP);
|
|
1928
|
+
} else {
|
|
1929
|
+
isLowBatValue = undefined;
|
|
1930
|
+
}
|
|
1931
|
+
deviceData.LowBat = await this.setLowbatIndicator(state.val, isLowBatValue, deviceData.faultReport, deviceData.adapterID);
|
|
1932
|
+
|
|
1933
|
+
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
1934
|
+
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
1935
|
+
await this.sendStateNotifications('lowBatDevice', deviceID);
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
break;
|
|
1940
|
+
|
|
1941
|
+
// device low bat
|
|
1942
|
+
case deviceData.LowBatDP:
|
|
1943
|
+
if (deviceData.isBatteryDevice) {
|
|
1944
|
+
oldLowBatState = deviceData.LowBat;
|
|
1945
|
+
batteryData = await this.getBatteryData(deviceData.BatteryRaw, state.val, deviceData.faultReport, deviceData.adapterID);
|
|
1946
|
+
deviceData.Battery = batteryData[0];
|
|
1947
|
+
deviceData.BatteryRaw = batteryData[2];
|
|
1948
|
+
deviceData.BatteryUnitRaw = batteryData[3];
|
|
1949
|
+
deviceData.LowBat = await this.setLowbatIndicator(deviceData.BatteryRaw, state.val, deviceData.faultReport, deviceData.adapterID);
|
|
1950
|
+
|
|
1951
|
+
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
1952
|
+
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
1953
|
+
await this.sendStateNotifications('lowBatDevice', deviceID);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
break;
|
|
1958
|
+
|
|
1959
|
+
//device error / fault reports
|
|
1960
|
+
case deviceData.faultReportDP:
|
|
1961
|
+
if (deviceData.isBatteryDevice) {
|
|
1962
|
+
oldLowBatState = deviceData.LowBat;
|
|
1963
|
+
batteryData = await this.getBatteryData(deviceData.BatteryRaw, oldLowBatState, state.val, deviceData.adapterID);
|
|
1964
|
+
|
|
1965
|
+
deviceData.Battery = batteryData[0];
|
|
1966
|
+
deviceData.BatteryRaw = batteryData[2];
|
|
1967
|
+
deviceData.BatteryUnitRaw = batteryData[3];
|
|
1968
|
+
deviceData.LowBat = await this.setLowbatIndicator(deviceData.BatteryRaw, undefined, state.val, deviceData.adapterID);
|
|
1969
|
+
|
|
1970
|
+
if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
|
|
1971
|
+
if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
1972
|
+
await this.sendStateNotifications('lowBatDevice', deviceID);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
break;
|
|
1977
|
+
|
|
1978
|
+
// device unreach
|
|
1979
|
+
case deviceData.UnreachDP:
|
|
1980
|
+
if (deviceData.instanceDeviceConnectionDP.val !== undefined) {
|
|
1981
|
+
// check if the generally deviceData connected state is for a while true
|
|
1982
|
+
if (deviceData.UnreachState !== state.val) {
|
|
1983
|
+
oldStatus = deviceData.Status;
|
|
1984
|
+
deviceData.UnreachState = state.val;
|
|
1985
|
+
contactData = await this.getOnlineState(
|
|
1986
|
+
deviceData.timeSelector,
|
|
1987
|
+
deviceData.adapterID,
|
|
1988
|
+
deviceData.UnreachDP,
|
|
1989
|
+
deviceData.SignalStrength,
|
|
1990
|
+
deviceData.UnreachState,
|
|
1991
|
+
deviceData.DeviceStateSelectorDP,
|
|
1992
|
+
deviceData.rssiPeerSelectorDP,
|
|
1993
|
+
);
|
|
1994
|
+
if (contactData !== undefined) {
|
|
1995
|
+
deviceData.LastContact = contactData[0];
|
|
1996
|
+
deviceData.Status = contactData[1];
|
|
1997
|
+
deviceData.SignalStrength = contactData[2];
|
|
1998
|
+
}
|
|
1999
|
+
if (this.config.checkSendOfflineMsg && oldStatus !== deviceData.Status && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
2000
|
+
if (deviceData.instanceDeviceConnectionDP.val !== undefined) {
|
|
2001
|
+
// check if the generally deviceData connected state is for a while true
|
|
2002
|
+
if (await this.getTimestampConnectionDP(deviceData.instanceDeviceConnectionDP, 20000)) {
|
|
2003
|
+
await this.sendStateNotifications('onlineStateDevice', deviceID);
|
|
2004
|
+
}
|
|
2005
|
+
} else {
|
|
2006
|
+
await this.sendStateNotifications('onlineStateDevice', deviceID);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
break;
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2046
2015
|
/**
|
|
2047
2016
|
* get all Instances at start
|
|
2048
2017
|
*/
|
|
@@ -2127,10 +2096,12 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2127
2096
|
}
|
|
2128
2097
|
|
|
2129
2098
|
//subscribe to statechanges
|
|
2130
|
-
this.subscribeForeignStates(id);
|
|
2131
|
-
this.subscribeForeignStates(instanceConnectedHostDP);
|
|
2132
|
-
this.subscribeForeignStates(instanceConnectedDeviceDP);
|
|
2099
|
+
// this.subscribeForeignStates(id);
|
|
2100
|
+
// this.subscribeForeignStates(instanceConnectedHostDP);
|
|
2101
|
+
// this.subscribeForeignStates(instanceConnectedDeviceDP);
|
|
2133
2102
|
this.subscribeForeignObjects(`system.adapter.*`);
|
|
2103
|
+
this.subscribeForeignStates('*');
|
|
2104
|
+
// this.subscribeForeignObjects('*');
|
|
2134
2105
|
|
|
2135
2106
|
// create raw list
|
|
2136
2107
|
this.listInstanceRaw.set(instanceID, {
|
|
@@ -2146,6 +2117,9 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2146
2117
|
isConnectedDevice: instanceConnectedDeviceVal,
|
|
2147
2118
|
status: instanceStatus,
|
|
2148
2119
|
checkIsRunning: false,
|
|
2120
|
+
aliveDP: `system.adapter.${instanceID}.alive`,
|
|
2121
|
+
hostConnectionDP: instanceConnectedHostDP,
|
|
2122
|
+
deviceConnectionDP: instanceConnectedDeviceDP,
|
|
2149
2123
|
});
|
|
2150
2124
|
}
|
|
2151
2125
|
await this.createInstanceList();
|
|
@@ -2176,9 +2150,9 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2176
2150
|
let connectedDeviceState = await this.getInitValue(`${instanceID}.info.connection`);
|
|
2177
2151
|
if (connectedDeviceState === undefined) connectedDeviceState = true;
|
|
2178
2152
|
|
|
2179
|
-
let isAlive =
|
|
2153
|
+
let isAlive = aliveState;
|
|
2180
2154
|
let isHealthy = false;
|
|
2181
|
-
let instanceStatusString = 'Instanz deaktiviert';
|
|
2155
|
+
let instanceStatusString = aliveState ? 'Instanz aktiviert' : 'Instanz deaktiviert';
|
|
2182
2156
|
|
|
2183
2157
|
if (!aliveState) {
|
|
2184
2158
|
isAlive = false;
|
|
@@ -2214,7 +2188,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2214
2188
|
|
|
2215
2189
|
let isAlive = false;
|
|
2216
2190
|
let isHealthy = false;
|
|
2217
|
-
let instanceStatusString = 'Instanz deaktiviert';
|
|
2191
|
+
let instanceStatusString = aliveState ? 'Instanz aktiviert' : 'Instanz deaktiviert';
|
|
2218
2192
|
|
|
2219
2193
|
if (aliveState) {
|
|
2220
2194
|
daemonIsAlive = await this.checkDaemonIsHealthy(instanceID);
|
|
@@ -2364,7 +2338,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2364
2338
|
const adapterUpdateListDP = `admin.*.info.updatesJson`;
|
|
2365
2339
|
|
|
2366
2340
|
// subscribe to datapoint
|
|
2367
|
-
this.subscribeForeignStates(adapterUpdateListDP);
|
|
2341
|
+
// this.subscribeForeignStates(adapterUpdateListDP);
|
|
2368
2342
|
|
|
2369
2343
|
await this.getAdapterUpdateData(adapterUpdateListDP);
|
|
2370
2344
|
|
|
@@ -2535,6 +2509,81 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2535
2509
|
await this.setStateChangedAsync(`adapterAndInstances.countInstancesError`, { val: this.countErrorInstance, ack: true });
|
|
2536
2510
|
}
|
|
2537
2511
|
|
|
2512
|
+
/**
|
|
2513
|
+
* @param {string} id
|
|
2514
|
+
*/
|
|
2515
|
+
async renewAdapterUpdateData(id) {
|
|
2516
|
+
const oldAdapterUpdatesCounts = this.countAdapterUpdates;
|
|
2517
|
+
await this.getAdapterUpdateData(id);
|
|
2518
|
+
await this.createAdapterUpdateList();
|
|
2519
|
+
if (this.config.checkSendAdapterUpdateMsg && this.countAdapterUpdates > oldAdapterUpdatesCounts) {
|
|
2520
|
+
await this.sendStateNotifications('updateAdapter', null);
|
|
2521
|
+
}
|
|
2522
|
+
this.listInstanceRaw.forEach((instance) => {
|
|
2523
|
+
const adapterUpdate = this.adapterUpdatesJsonRaw.get(instance.Adapter);
|
|
2524
|
+
instance.updateAvailable = adapterUpdate ? adapterUpdate.newVersion : ' - ';
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* call function on state change, renew data and send messages
|
|
2529
|
+
* @param {string} id
|
|
2530
|
+
* @param {ioBroker.State} state
|
|
2531
|
+
*/
|
|
2532
|
+
async renewInstanceData(id, state) {
|
|
2533
|
+
const instanceID = await this.getInstanceName(id);
|
|
2534
|
+
const instanceData = this.listInstanceRaw.get(instanceID);
|
|
2535
|
+
if (instanceData) {
|
|
2536
|
+
let instanceStatusRaw;
|
|
2537
|
+
|
|
2538
|
+
const checkInstance = async (instanceID, instanceData) => {
|
|
2539
|
+
if (!instanceData.checkIsRunning) {
|
|
2540
|
+
instanceData.checkIsRunning = true;
|
|
2541
|
+
instanceStatusRaw = await this.setInstanceStatus(instanceData.instanceMode, instanceData.schedule, instanceID);
|
|
2542
|
+
instanceData.isAlive = instanceStatusRaw[0];
|
|
2543
|
+
instanceData.isHealthy = instanceStatusRaw[1];
|
|
2544
|
+
instanceData.status = instanceStatusRaw[2];
|
|
2545
|
+
instanceData.checkIsRunning = false;
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
};
|
|
2549
|
+
|
|
2550
|
+
switch (id) {
|
|
2551
|
+
case `system.adapter.${instanceID}.alive`:
|
|
2552
|
+
if (state.val !== instanceData.isAlive) {
|
|
2553
|
+
await checkInstance(instanceID, instanceData);
|
|
2554
|
+
// send message when instance was deactivated
|
|
2555
|
+
if (this.config.checkSendInstanceDeactivatedMsg && !instanceData.isAlive) {
|
|
2556
|
+
if (this.blacklistInstancesNotify.includes(instanceID)) return;
|
|
2557
|
+
await this.sendStateNotifications('deactivatedInstance', instanceID);
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
break;
|
|
2561
|
+
|
|
2562
|
+
case `system.adapter.${instanceID}.connected`:
|
|
2563
|
+
if (state.val !== instanceData.isConnectedHost && instanceData.isAlive) {
|
|
2564
|
+
await checkInstance(instanceID, instanceData);
|
|
2565
|
+
// send message when instance has an error
|
|
2566
|
+
if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
|
|
2567
|
+
if (this.blacklistInstancesNotify.includes(instanceID)) return;
|
|
2568
|
+
await this.sendStateNotifications('errorInstance', instanceID);
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
break;
|
|
2572
|
+
|
|
2573
|
+
case `${instanceID}.info.connection`:
|
|
2574
|
+
if (state.val !== instanceData.isConnectedDevice && instanceData.isAlive) {
|
|
2575
|
+
await checkInstance(instanceID, instanceData);
|
|
2576
|
+
// send message when instance has an error
|
|
2577
|
+
if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
|
|
2578
|
+
if (this.blacklistInstancesNotify.includes(instanceID)) return;
|
|
2579
|
+
await this.sendStateNotifications('errorInstance', instanceID);
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2538
2587
|
/**
|
|
2539
2588
|
* create Datapoints for Instances
|
|
2540
2589
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.device-watcher",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.13",
|
|
4
4
|
"description": "Watchdog for devices",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Christian Behrends",
|
|
@@ -37,24 +37,24 @@
|
|
|
37
37
|
"@types/chai": "^4.3.11",
|
|
38
38
|
"@types/chai-as-promised": "^7.1.8",
|
|
39
39
|
"@types/mocha": "^10.0.6",
|
|
40
|
-
"@types/node": "^20.10.
|
|
41
|
-
"@types/node-schedule": "^2.1.
|
|
40
|
+
"@types/node": "^20.10.6",
|
|
41
|
+
"@types/node-schedule": "^2.1.5",
|
|
42
42
|
"@types/proxyquire": "^1.3.31",
|
|
43
43
|
"@types/sinon": "^17.0.2",
|
|
44
44
|
"@types/sinon-chai": "^3.2.12",
|
|
45
45
|
"chai": "^4.3.10",
|
|
46
46
|
"chai-as-promised": "^7.1.1",
|
|
47
47
|
"cron-parser": "^4.9.0",
|
|
48
|
-
"eslint": "^8.
|
|
49
|
-
"eslint-config-prettier": "^9.
|
|
50
|
-
"eslint-plugin-prettier": "^5.
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"eslint-config-prettier": "^9.1.0",
|
|
50
|
+
"eslint-plugin-prettier": "^5.1.2",
|
|
51
51
|
"mocha": "^10.2.0",
|
|
52
52
|
"node-schedule": "^2.1.1",
|
|
53
|
-
"prettier": "^3.1.
|
|
53
|
+
"prettier": "^3.1.1",
|
|
54
54
|
"proxyquire": "^2.1.3",
|
|
55
55
|
"sinon": "^17.0.1",
|
|
56
56
|
"sinon-chai": "^3.7.0",
|
|
57
|
-
"typescript": "~5.3.
|
|
57
|
+
"typescript": "~5.3.3"
|
|
58
58
|
},
|
|
59
59
|
"main": "main.js",
|
|
60
60
|
"files": [
|