iobroker.device-watcher 2.8.5 → 2.9.1
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 +10 -0
- package/admin/jsonConfig.json +38 -0
- package/io-package.json +851 -827
- package/lib/arrApart.js +25 -0
- package/main.js +159 -88
- package/package.json +1 -1
package/lib/arrApart.js
CHANGED
|
@@ -183,6 +183,7 @@ const arrApart = {
|
|
|
183
183
|
battery: 'none',
|
|
184
184
|
reach: '.unreach',
|
|
185
185
|
isLowBat: '.lowBat',
|
|
186
|
+
upgrade: '.info.updateState',
|
|
186
187
|
},
|
|
187
188
|
hmrpc: {
|
|
188
189
|
Selektor: 'hm-rpc.*.RSSI_PEER',
|
|
@@ -212,6 +213,18 @@ const arrApart = {
|
|
|
212
213
|
id: '.name',
|
|
213
214
|
upgrade: 'none',
|
|
214
215
|
},
|
|
216
|
+
homekitController: {
|
|
217
|
+
Selektor: 'homekit-controller.*.connected',
|
|
218
|
+
timeSelector: '.lastDiscovered',
|
|
219
|
+
adapterID: 'homekitController',
|
|
220
|
+
adapter: 'Homekit Controller',
|
|
221
|
+
rssiState: 'none',
|
|
222
|
+
battery: 'none',
|
|
223
|
+
reach: '.connected',
|
|
224
|
+
isLowBat: 'none',
|
|
225
|
+
id: 'none',
|
|
226
|
+
upgrade: 'none',
|
|
227
|
+
},
|
|
215
228
|
hs100: {
|
|
216
229
|
Selektor: 'hs100.*.last_update',
|
|
217
230
|
timeSelector: '.last_update',
|
|
@@ -525,6 +538,18 @@ const arrApart = {
|
|
|
525
538
|
id: 'none',
|
|
526
539
|
upgrade: '.upgradable',
|
|
527
540
|
},
|
|
541
|
+
viessmann: {
|
|
542
|
+
Selektor: 'viessmann.*.info.connection',
|
|
543
|
+
timeSelector: '.lastPoll',
|
|
544
|
+
adapterID: 'viessmann',
|
|
545
|
+
adapter: 'Viessmann',
|
|
546
|
+
rssiState: 'none',
|
|
547
|
+
battery: 'none',
|
|
548
|
+
reach: '.connection',
|
|
549
|
+
isLowBat: 'none',
|
|
550
|
+
id: 'none',
|
|
551
|
+
upgrade: 'none',
|
|
552
|
+
},
|
|
528
553
|
wled: {
|
|
529
554
|
Selektor: 'wled.*._online',
|
|
530
555
|
timeSelector: '._online',
|
package/main.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/* jshint -W097 */
|
|
2
|
-
/* jshint strict: false */
|
|
3
|
-
/* jslint node: true */
|
|
4
|
-
|
|
5
1
|
'use strict';
|
|
6
2
|
|
|
7
3
|
const utils = require('@iobroker/adapter-core');
|
|
@@ -10,9 +6,6 @@ const schedule = require('node-schedule');
|
|
|
10
6
|
const arrApart = require('./lib/arrApart.js'); // list of supported adapters
|
|
11
7
|
const cronParser = require('cron-parser');
|
|
12
8
|
|
|
13
|
-
// Sentry error reporting, disable when testing code!
|
|
14
|
-
const enableSendSentry = true;
|
|
15
|
-
|
|
16
9
|
// indicator if the adapter is running or not (for intervall/shedule)
|
|
17
10
|
let isUnloaded = false;
|
|
18
11
|
|
|
@@ -122,6 +115,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
122
115
|
hmiP: this.config.hmiPDevices,
|
|
123
116
|
hmrpc: this.config.hmrpcDevices,
|
|
124
117
|
homeconnect: this.config.homeconnectDevices,
|
|
118
|
+
homekitController: this.config.homekitControllerDevices,
|
|
125
119
|
hs100: this.config.hs100Devices,
|
|
126
120
|
hue: this.config.hueDevices,
|
|
127
121
|
hueExt: this.config.hueExtDevices,
|
|
@@ -153,6 +147,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
153
147
|
tapo: this.config.tapoDevices,
|
|
154
148
|
tradfri: this.config.tradfriDevices,
|
|
155
149
|
unifi: this.config.unifiDevices,
|
|
150
|
+
viessmann: this.config.viessmannDevices,
|
|
156
151
|
wled: this.config.wledDevices,
|
|
157
152
|
yeelight: this.config.yeelightDevices,
|
|
158
153
|
zigbee: this.config.zigbeeDevices,
|
|
@@ -178,6 +173,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
178
173
|
hmiP: this.config.hmiPMaxMinutes,
|
|
179
174
|
hmrpc: this.config.hmrpcMaxMinutes,
|
|
180
175
|
homeconnect: this.config.homeconnectMaxMinutes,
|
|
176
|
+
homekitController: this.config.homekitControllerMaxMinutes,
|
|
181
177
|
hs100: this.config.hs100MaxMinutes,
|
|
182
178
|
hue: this.config.hueMaxMinutes,
|
|
183
179
|
hueExt: this.config.hueextMaxMinutes,
|
|
@@ -209,6 +205,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
209
205
|
tapo: this.config.tapoMaxMinutes,
|
|
210
206
|
tradfri: this.config.tradfriMaxMinutes,
|
|
211
207
|
unifi: this.config.unifiMaxMinutes,
|
|
208
|
+
viessmann: this.config.viessmannMaxMinutes,
|
|
212
209
|
wled: this.config.wledMaxMinutes,
|
|
213
210
|
yeelight: this.config.yeelightMaxMinutes,
|
|
214
211
|
zigbee: this.config.zigbeeMaxMinutes,
|
|
@@ -260,7 +257,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
260
257
|
}
|
|
261
258
|
}
|
|
262
259
|
} catch (error) {
|
|
263
|
-
this.
|
|
260
|
+
this.log.error(`[onReady - create and fill datapoints for each adapter] - ${error}`);
|
|
264
261
|
}
|
|
265
262
|
}
|
|
266
263
|
|
|
@@ -310,7 +307,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
310
307
|
// send overview of instances with error
|
|
311
308
|
if (this.config.checkSendInstanceFailedDaily) this.sendScheduleNotifications('errorInstance');
|
|
312
309
|
} catch (error) {
|
|
313
|
-
this.
|
|
310
|
+
this.log.error(`[onReady] - ${error}`);
|
|
314
311
|
this.terminate ? this.terminate(15) : process.exit(15);
|
|
315
312
|
}
|
|
316
313
|
} // <-- onReady end
|
|
@@ -447,8 +444,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
447
444
|
// device updates
|
|
448
445
|
case deviceData.UpdateDP:
|
|
449
446
|
if (state.val !== deviceData.Upgradable) {
|
|
450
|
-
deviceData.Upgradable = state.val;
|
|
451
|
-
if (
|
|
447
|
+
deviceData.Upgradable = await this.checkDeviceUpdate(deviceData.adapterID, state.val);
|
|
448
|
+
if (deviceData.Upgradable === true) {
|
|
452
449
|
if (this.config.checkSendDeviceUpgrade && !this.blacklistNotify.includes(deviceData.Path)) {
|
|
453
450
|
await this.sendStateNotifications('updateDevice', device);
|
|
454
451
|
}
|
|
@@ -597,7 +594,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
597
594
|
});
|
|
598
595
|
this.sendTo(obj.from, obj.command, sortDevices, obj.callback);
|
|
599
596
|
} catch (error) {
|
|
600
|
-
this.
|
|
597
|
+
this.log.error(`[onMessage - deviceList for blacklisttable] - ${error}`);
|
|
601
598
|
}
|
|
602
599
|
}
|
|
603
600
|
break;
|
|
@@ -622,7 +619,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
622
619
|
});
|
|
623
620
|
this.sendTo(obj.from, obj.command, sortInstances, obj.callback);
|
|
624
621
|
} catch (error) {
|
|
625
|
-
this.
|
|
622
|
+
this.log.error(`[onMessage - instanceList] - ${error}`);
|
|
626
623
|
}
|
|
627
624
|
}
|
|
628
625
|
break;
|
|
@@ -646,7 +643,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
646
643
|
});
|
|
647
644
|
this.sendTo(obj.from, obj.command, sortInstances, obj.callback);
|
|
648
645
|
} catch (error) {
|
|
649
|
-
this.
|
|
646
|
+
this.log.error(`[onMessage - instanceList] - ${error}`);
|
|
650
647
|
}
|
|
651
648
|
}
|
|
652
649
|
break;
|
|
@@ -668,7 +665,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
668
665
|
await this.writeDatapoints(); // fill the datapoints
|
|
669
666
|
this.log.debug(`Created and filled data for all adapters`);
|
|
670
667
|
} catch (error) {
|
|
671
|
-
this.
|
|
668
|
+
this.log.error(`[main - create data of all adapter] - ${error}`);
|
|
672
669
|
}
|
|
673
670
|
|
|
674
671
|
// fill datapoints for each adapter if selected
|
|
@@ -686,7 +683,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
686
683
|
}
|
|
687
684
|
}
|
|
688
685
|
} catch (error) {
|
|
689
|
-
this.
|
|
686
|
+
this.log.error(`[main - create and fill datapoints for each adapter] - ${error}`);
|
|
690
687
|
}
|
|
691
688
|
}
|
|
692
689
|
|
|
@@ -759,7 +756,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
759
756
|
this.blacklistNotify.push(blacklistParse.path);
|
|
760
757
|
}
|
|
761
758
|
} catch (error) {
|
|
762
|
-
this.
|
|
759
|
+
this.log.error(`[createBlacklist] - ${error}`);
|
|
763
760
|
}
|
|
764
761
|
if (this.blacklistLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistLists}`);
|
|
765
762
|
if (this.blacklistAdapterLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistAdapterLists}`);
|
|
@@ -782,7 +779,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
782
779
|
this.blacklistInstancesNotify.push(blacklistParse.instanceID);
|
|
783
780
|
}
|
|
784
781
|
} catch (error) {
|
|
785
|
-
this.
|
|
782
|
+
this.log.error(`[createBlacklist] - ${error}`);
|
|
786
783
|
}
|
|
787
784
|
}
|
|
788
785
|
if (this.blacklistInstancesLists.length >= 1) this.log.info(`Found instances items on blacklist for lists: ${this.blacklistInstancesLists}`);
|
|
@@ -807,7 +804,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
807
804
|
errorTime: userTimeListInstances[i].errorTime,
|
|
808
805
|
});
|
|
809
806
|
} catch (error) {
|
|
810
|
-
this.
|
|
807
|
+
this.log.error(`[createTimeListInstances] - ${error}`);
|
|
811
808
|
}
|
|
812
809
|
}
|
|
813
810
|
if (this.userTimeInstancesList.size >= 1) this.log.info(`Found instances items on lists for timesettings: ${Array.from(this.userTimeInstancesList.keys())}`);
|
|
@@ -1001,18 +998,24 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1001
998
|
/*=============================================
|
|
1002
999
|
= Get update data =
|
|
1003
1000
|
=============================================*/
|
|
1004
|
-
const deviceUpdateDP = currDeviceString + this.selAdapter[i].upgrade;
|
|
1005
1001
|
let isUpgradable;
|
|
1002
|
+
let deviceUpdateDP;
|
|
1006
1003
|
|
|
1007
1004
|
if (this.config.checkSendDeviceUpgrade) {
|
|
1008
|
-
|
|
1005
|
+
deviceUpdateDP = currDeviceString + this.selAdapter[i].upgrade;
|
|
1006
|
+
let deviceUpdateSelector = await this.getInitValue(deviceUpdateDP);
|
|
1007
|
+
if (deviceUpdateSelector === undefined) {
|
|
1008
|
+
deviceUpdateDP = shortCurrDeviceString + this.selAdapter[i].upgrade;
|
|
1009
|
+
deviceUpdateSelector = await this.getInitValue(deviceUpdateDP);
|
|
1010
|
+
if (deviceUpdateSelector === undefined) {
|
|
1011
|
+
const shortShortCurrDeviceString = shortCurrDeviceString.slice(0, shortCurrDeviceString.lastIndexOf('.') + 1 - 1);
|
|
1012
|
+
deviceUpdateDP = shortShortCurrDeviceString + this.selAdapter[i].upgrade;
|
|
1013
|
+
deviceUpdateSelector = await this.getInitValue(deviceUpdateDP);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1009
1016
|
|
|
1010
1017
|
if (deviceUpdateSelector !== undefined) {
|
|
1011
|
-
|
|
1012
|
-
isUpgradable = true;
|
|
1013
|
-
} else if (!deviceUpdateSelector) {
|
|
1014
|
-
isUpgradable = false;
|
|
1015
|
-
}
|
|
1018
|
+
isUpgradable = await this.checkDeviceUpdate(adapterID, deviceUpdateSelector);
|
|
1016
1019
|
} else {
|
|
1017
1020
|
isUpgradable = ' - ';
|
|
1018
1021
|
}
|
|
@@ -1067,7 +1070,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1067
1070
|
}
|
|
1068
1071
|
} // <-- end of loop
|
|
1069
1072
|
} catch (error) {
|
|
1070
|
-
this.
|
|
1073
|
+
this.log.error(`[createData - create data of devices] - ${error}`);
|
|
1071
1074
|
}
|
|
1072
1075
|
} // <-- end of createData
|
|
1073
1076
|
|
|
@@ -1107,6 +1110,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1107
1110
|
case 'wled':
|
|
1108
1111
|
case 'mqttNuki':
|
|
1109
1112
|
case 'loqedSmartLock':
|
|
1113
|
+
case 'viessmann':
|
|
1114
|
+
case 'homekitController':
|
|
1110
1115
|
if (shortDeviceObject && typeof shortDeviceObject === 'object') {
|
|
1111
1116
|
deviceName = shortDeviceObject.common.name;
|
|
1112
1117
|
}
|
|
@@ -1162,7 +1167,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1162
1167
|
}
|
|
1163
1168
|
return deviceName;
|
|
1164
1169
|
} catch (error) {
|
|
1165
|
-
this.
|
|
1170
|
+
this.log.error(`[getDeviceName] - ${error}`);
|
|
1166
1171
|
}
|
|
1167
1172
|
}
|
|
1168
1173
|
|
|
@@ -1441,21 +1446,21 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1441
1446
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1442
1447
|
if (deviceUnreachState === 1) {
|
|
1443
1448
|
deviceState = 'Offline'; //set online state to offline
|
|
1444
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1449
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1445
1450
|
}
|
|
1446
1451
|
} else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState === 1) {
|
|
1447
1452
|
deviceState = 'Offline'; //set online state to offline
|
|
1448
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1453
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1449
1454
|
}
|
|
1450
1455
|
break;
|
|
1451
1456
|
case 'proxmox':
|
|
1452
1457
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1453
1458
|
if (deviceUnreachState !== 'running' && deviceUnreachState !== 'online') {
|
|
1454
|
-
deviceState = 'Offline'; //set online state to offline
|
|
1459
|
+
if (linkQuality !== ' - ') deviceState = 'Offline'; //set online state to offline
|
|
1455
1460
|
}
|
|
1456
1461
|
} else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState !== 'running' && deviceUnreachState !== 'online') {
|
|
1457
1462
|
deviceState = 'Offline'; //set online state to offline
|
|
1458
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1463
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1459
1464
|
}
|
|
1460
1465
|
break;
|
|
1461
1466
|
case 'hmiP':
|
|
@@ -1463,11 +1468,11 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1463
1468
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1464
1469
|
if (deviceUnreachState) {
|
|
1465
1470
|
deviceState = 'Offline'; //set online state to offline
|
|
1466
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1471
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1467
1472
|
}
|
|
1468
1473
|
} else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState) {
|
|
1469
1474
|
deviceState = 'Offline'; //set online state to offline
|
|
1470
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1475
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1471
1476
|
}
|
|
1472
1477
|
break;
|
|
1473
1478
|
case 'apcups':
|
|
@@ -1483,22 +1488,22 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1483
1488
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1484
1489
|
if (!deviceUnreachState) {
|
|
1485
1490
|
deviceState = 'Offline'; //set online state to offline
|
|
1486
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1491
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1487
1492
|
}
|
|
1488
1493
|
} else if (!deviceUnreachState && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
|
|
1489
1494
|
deviceState = 'Offline'; //set online state to offline
|
|
1490
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1495
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1491
1496
|
}
|
|
1492
1497
|
break;
|
|
1493
1498
|
case 'mqttClientZigbee2Mqtt':
|
|
1494
1499
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1495
1500
|
if (deviceUnreachState !== 'online') {
|
|
1496
1501
|
deviceState = 'Offline'; //set online state to offline
|
|
1497
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1502
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1498
1503
|
}
|
|
1499
1504
|
} else if (deviceUnreachState !== 'online' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
|
|
1500
1505
|
deviceState = 'Offline'; //set online state to offline
|
|
1501
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1506
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1502
1507
|
}
|
|
1503
1508
|
break;
|
|
1504
1509
|
case 'mihome':
|
|
@@ -1506,21 +1511,21 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1506
1511
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1507
1512
|
if (!deviceUnreachState) {
|
|
1508
1513
|
deviceState = 'Offline'; //set online state to offline
|
|
1509
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1514
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1510
1515
|
}
|
|
1511
1516
|
} else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
|
|
1512
1517
|
deviceState = 'Offline'; //set online state to offline
|
|
1513
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1518
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1514
1519
|
}
|
|
1515
1520
|
} else {
|
|
1516
1521
|
if (this.config.mihomeMaxMinutes <= 0) {
|
|
1517
1522
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1518
1523
|
deviceState = 'Offline'; //set online state to offline
|
|
1519
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1524
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1520
1525
|
}
|
|
1521
1526
|
} else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
|
|
1522
1527
|
deviceState = 'Offline'; //set online state to offline
|
|
1523
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1528
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1524
1529
|
}
|
|
1525
1530
|
}
|
|
1526
1531
|
break;
|
|
@@ -1528,29 +1533,29 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1528
1533
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1529
1534
|
if (deviceUnreachState === 'OFFLINE') {
|
|
1530
1535
|
deviceState = 'Offline'; //set online state to offline
|
|
1531
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1536
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1532
1537
|
}
|
|
1533
1538
|
} else if (deviceUnreachState === 'OFFLINE' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
|
|
1534
1539
|
deviceState = 'Offline'; //set online state to offline
|
|
1535
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1540
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1536
1541
|
}
|
|
1537
1542
|
break;
|
|
1538
1543
|
default:
|
|
1539
1544
|
if (this.configMaxMinutes[adapterID] <= 0) {
|
|
1540
1545
|
if (!deviceUnreachState) {
|
|
1541
1546
|
deviceState = 'Offline'; //set online state to offline
|
|
1542
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1547
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1543
1548
|
}
|
|
1544
1549
|
} else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
|
|
1545
1550
|
deviceState = 'Offline'; //set online state to offline
|
|
1546
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
1551
|
+
if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
|
|
1547
1552
|
}
|
|
1548
1553
|
break;
|
|
1549
1554
|
}
|
|
1550
1555
|
}
|
|
1551
1556
|
return [lastContactString, deviceState, linkQuality];
|
|
1552
1557
|
} catch (error) {
|
|
1553
|
-
this.
|
|
1558
|
+
this.log.error(`[getLastContact] - ${error}`);
|
|
1554
1559
|
}
|
|
1555
1560
|
}
|
|
1556
1561
|
|
|
@@ -1583,8 +1588,35 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1583
1588
|
}
|
|
1584
1589
|
}
|
|
1585
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* @param {any} adapterID
|
|
1593
|
+
* @param {string | number | boolean | null} deviceUpdateSelector
|
|
1594
|
+
*/
|
|
1595
|
+
async checkDeviceUpdate(adapterID, deviceUpdateSelector) {
|
|
1596
|
+
let isUpgradable;
|
|
1597
|
+
|
|
1598
|
+
switch (adapterID) {
|
|
1599
|
+
case 'hmiP':
|
|
1600
|
+
if (deviceUpdateSelector === 'UPDATE_AVAILABLE') {
|
|
1601
|
+
isUpgradable = true;
|
|
1602
|
+
} else {
|
|
1603
|
+
isUpgradable = false;
|
|
1604
|
+
}
|
|
1605
|
+
break;
|
|
1606
|
+
default:
|
|
1607
|
+
if (deviceUpdateSelector) {
|
|
1608
|
+
isUpgradable = true;
|
|
1609
|
+
} else if (!deviceUpdateSelector) {
|
|
1610
|
+
isUpgradable = false;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
return isUpgradable;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1586
1617
|
/**
|
|
1587
1618
|
* Create Lists
|
|
1619
|
+
* @param {string | undefined} [adptName]
|
|
1588
1620
|
*/
|
|
1589
1621
|
async createLists(adptName) {
|
|
1590
1622
|
this.linkQualityDevices = [];
|
|
@@ -1961,7 +1993,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1961
1993
|
const lastCheck = this.formatDate(new Date(), 'DD.MM.YYYY') + ' - ' + this.formatDate(new Date(), 'hh:mm:ss');
|
|
1962
1994
|
await this.setStateChangedAsync('lastCheck', lastCheck, true);
|
|
1963
1995
|
} catch (error) {
|
|
1964
|
-
this.
|
|
1996
|
+
this.log.error(`[writeDatapoints] - ${error}`);
|
|
1965
1997
|
}
|
|
1966
1998
|
this.log.debug(`Function finished: ${this.writeDatapoints.name}`);
|
|
1967
1999
|
} //<--End of writing Datapoints
|
|
@@ -1974,7 +2006,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1974
2006
|
const allInstances = `system.adapter.*`;
|
|
1975
2007
|
await this.getInstanceData(allInstances);
|
|
1976
2008
|
} catch (error) {
|
|
1977
|
-
this.
|
|
2009
|
+
this.log.error(`[getInstance] - ${error}`);
|
|
1978
2010
|
}
|
|
1979
2011
|
}
|
|
1980
2012
|
|
|
@@ -2074,7 +2106,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2074
2106
|
await this.createInstanceList();
|
|
2075
2107
|
await this.writeInstanceDPs();
|
|
2076
2108
|
} catch (error) {
|
|
2077
|
-
this.
|
|
2109
|
+
this.log.error(`[getInstanceData] - ${error}`);
|
|
2078
2110
|
}
|
|
2079
2111
|
}
|
|
2080
2112
|
|
|
@@ -2765,7 +2797,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2765
2797
|
});
|
|
2766
2798
|
}
|
|
2767
2799
|
} catch (error) {
|
|
2768
|
-
this.
|
|
2800
|
+
this.log.error(`[sendNotification Pushover] - ${error}`);
|
|
2769
2801
|
}
|
|
2770
2802
|
}
|
|
2771
2803
|
|
|
@@ -2785,7 +2817,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2785
2817
|
});
|
|
2786
2818
|
}
|
|
2787
2819
|
} catch (error) {
|
|
2788
|
-
this.
|
|
2820
|
+
this.log.error(`[sendNotification Telegram] - ${error}`);
|
|
2789
2821
|
}
|
|
2790
2822
|
}
|
|
2791
2823
|
|
|
@@ -2804,7 +2836,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2804
2836
|
});
|
|
2805
2837
|
}
|
|
2806
2838
|
} catch (error) {
|
|
2807
|
-
this.
|
|
2839
|
+
this.log.error(`[sendNotification Whatsapp] - ${error}`);
|
|
2808
2840
|
}
|
|
2809
2841
|
}
|
|
2810
2842
|
|
|
@@ -2823,7 +2855,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2823
2855
|
});
|
|
2824
2856
|
}
|
|
2825
2857
|
} catch (error) {
|
|
2826
|
-
this.
|
|
2858
|
+
this.log.error(`[sendNotification Matrix] - ${error}`);
|
|
2827
2859
|
}
|
|
2828
2860
|
}
|
|
2829
2861
|
|
|
@@ -2842,7 +2874,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2842
2874
|
});
|
|
2843
2875
|
}
|
|
2844
2876
|
} catch (error) {
|
|
2845
|
-
this.
|
|
2877
|
+
this.log.error(`[sendNotification Signal] - ${error}`);
|
|
2846
2878
|
}
|
|
2847
2879
|
}
|
|
2848
2880
|
|
|
@@ -2862,7 +2894,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2862
2894
|
});
|
|
2863
2895
|
}
|
|
2864
2896
|
} catch (error) {
|
|
2865
|
-
this.
|
|
2897
|
+
this.log.error(`[sendNotification eMail] - ${error}`);
|
|
2866
2898
|
}
|
|
2867
2899
|
}
|
|
2868
2900
|
|
|
@@ -2882,7 +2914,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2882
2914
|
);
|
|
2883
2915
|
}
|
|
2884
2916
|
} catch (error) {
|
|
2885
|
-
this.
|
|
2917
|
+
this.log.error(`[sendNotification Jarvis] - ${error}`);
|
|
2886
2918
|
}
|
|
2887
2919
|
}
|
|
2888
2920
|
|
|
@@ -2902,7 +2934,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2902
2934
|
);
|
|
2903
2935
|
}
|
|
2904
2936
|
} catch (error) {
|
|
2905
|
-
this.
|
|
2937
|
+
this.log.error(`[sendNotification Lovelace] - ${error}`);
|
|
2906
2938
|
}
|
|
2907
2939
|
}
|
|
2908
2940
|
|
|
@@ -2922,7 +2954,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2922
2954
|
}
|
|
2923
2955
|
}
|
|
2924
2956
|
} catch (error) {
|
|
2925
|
-
this.
|
|
2957
|
+
this.log.error(`[sendNotification Synochat] - ${error}`);
|
|
2926
2958
|
}
|
|
2927
2959
|
}
|
|
2928
2960
|
} // <-- End of sendNotification function
|
|
@@ -3057,10 +3089,22 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
3057
3089
|
}
|
|
3058
3090
|
}
|
|
3059
3091
|
if (list.length === 0) return;
|
|
3060
|
-
|
|
3092
|
+
|
|
3093
|
+
switch (checkDays.length) {
|
|
3094
|
+
case 1:
|
|
3095
|
+
message = `Wöchentliche Übersicht über Geräte mit niedrigen Batteriezuständen: ${list}`;
|
|
3096
|
+
break;
|
|
3097
|
+
case 7:
|
|
3098
|
+
message = `Tägliche Übersicht über Geräte mit niedrigen Batteriezuständen: ${list}`;
|
|
3099
|
+
break;
|
|
3100
|
+
default:
|
|
3101
|
+
message = `Übersicht über Geräte mit niedrigen Batteriezuständen: ${list}`;
|
|
3102
|
+
break;
|
|
3103
|
+
}
|
|
3061
3104
|
setMessage(message);
|
|
3062
3105
|
});
|
|
3063
3106
|
break;
|
|
3107
|
+
|
|
3064
3108
|
case 'offlineDevices':
|
|
3065
3109
|
// push the selected days in list
|
|
3066
3110
|
if (this.config.checkOfflineMonday) checkDays.push(1);
|
|
@@ -3093,10 +3137,22 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
3093
3137
|
}
|
|
3094
3138
|
|
|
3095
3139
|
if (list.length === 0) return;
|
|
3096
|
-
|
|
3140
|
+
|
|
3141
|
+
switch (checkDays.length) {
|
|
3142
|
+
case 1:
|
|
3143
|
+
message = `Wöchentliche Übersicht über offline Geräte: ${list}`;
|
|
3144
|
+
break;
|
|
3145
|
+
case 7:
|
|
3146
|
+
message = `Tägliche Übersicht über offline Geräte: ${list}`;
|
|
3147
|
+
break;
|
|
3148
|
+
default:
|
|
3149
|
+
message = `Übersicht über offline Geräte: ${list}`;
|
|
3150
|
+
break;
|
|
3151
|
+
}
|
|
3097
3152
|
setMessage(message);
|
|
3098
3153
|
});
|
|
3099
3154
|
break;
|
|
3155
|
+
|
|
3100
3156
|
case 'updateDevices':
|
|
3101
3157
|
// push the selected days in list
|
|
3102
3158
|
if (this.config.checkUpgradeMonday) checkDays.push(1);
|
|
@@ -3128,10 +3184,22 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
3128
3184
|
}
|
|
3129
3185
|
}
|
|
3130
3186
|
if (list.length === 0) return;
|
|
3131
|
-
|
|
3187
|
+
|
|
3188
|
+
switch (checkDays.length) {
|
|
3189
|
+
case 1:
|
|
3190
|
+
message = `Wöchentliche Übersicht über verfügbare Geräte Updates: ${list}`;
|
|
3191
|
+
break;
|
|
3192
|
+
case 7:
|
|
3193
|
+
message = `Tägliche Übersicht über verfügbare Geräte Updates: ${list}`;
|
|
3194
|
+
break;
|
|
3195
|
+
default:
|
|
3196
|
+
message = `Übersicht über verfügbare Geräte Updates: ${list}`;
|
|
3197
|
+
break;
|
|
3198
|
+
}
|
|
3132
3199
|
setMessage(message);
|
|
3133
3200
|
});
|
|
3134
3201
|
break;
|
|
3202
|
+
|
|
3135
3203
|
case 'updateAdapter':
|
|
3136
3204
|
// push the selected days in list
|
|
3137
3205
|
if (this.config.checkAdapterUpdateMonday) checkDays.push(1);
|
|
@@ -3158,10 +3226,22 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
3158
3226
|
list = `${list}\n${id.Adapter}: v${id['Available Version']}`;
|
|
3159
3227
|
}
|
|
3160
3228
|
if (list.length === 0) return;
|
|
3161
|
-
|
|
3229
|
+
|
|
3230
|
+
switch (checkDays.length) {
|
|
3231
|
+
case 1:
|
|
3232
|
+
message = `Wöchentliche Übersicht über verfügbare Adapter Updates: ${list}`;
|
|
3233
|
+
break;
|
|
3234
|
+
case 7:
|
|
3235
|
+
message = `Tägliche Übersicht über verfügbare Adapter Updates: ${list}`;
|
|
3236
|
+
break;
|
|
3237
|
+
default:
|
|
3238
|
+
message = `Übersicht über verfügbare Adapter Updates: ${list}`;
|
|
3239
|
+
break;
|
|
3240
|
+
}
|
|
3162
3241
|
setMessage(message);
|
|
3163
3242
|
});
|
|
3164
3243
|
break;
|
|
3244
|
+
|
|
3165
3245
|
case 'errorInstance':
|
|
3166
3246
|
// push the selected days in list
|
|
3167
3247
|
if (this.config.checkFailedInstancesMonday) checkDays.push(1);
|
|
@@ -3212,13 +3292,24 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
3212
3292
|
cron = '5 ' + time[1] + ' ' + time[0] + ' * * ' + checkDays;
|
|
3213
3293
|
schedule.scheduleJob(cron, () => {
|
|
3214
3294
|
list = '';
|
|
3215
|
-
|
|
3216
3295
|
for (const id of this.listDeactivatedInstances) {
|
|
3217
|
-
if (this.blacklistInstancesNotify.includes(id)) continue;
|
|
3218
|
-
list = `${list}\n${id}`;
|
|
3296
|
+
if (this.blacklistInstancesNotify.includes(id.Instance)) continue;
|
|
3297
|
+
list = `${list}\n${id.Instance}`;
|
|
3219
3298
|
}
|
|
3299
|
+
|
|
3220
3300
|
if (list.length === 0) return;
|
|
3221
|
-
|
|
3301
|
+
|
|
3302
|
+
switch (checkDays.length) {
|
|
3303
|
+
case 1:
|
|
3304
|
+
message = `Wöchentliche Übersicht über deaktivierte Instanzen: ${list}`;
|
|
3305
|
+
break;
|
|
3306
|
+
case 7:
|
|
3307
|
+
message = `Tägliche Übersicht über deaktivierte Instanzen: ${list}`;
|
|
3308
|
+
break;
|
|
3309
|
+
default:
|
|
3310
|
+
message = `Übersicht über deaktivierte Instanzen: ${list}`;
|
|
3311
|
+
break;
|
|
3312
|
+
}
|
|
3222
3313
|
setMessage(message);
|
|
3223
3314
|
});
|
|
3224
3315
|
break;
|
|
@@ -4256,30 +4347,10 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
4256
4347
|
const previous = interval.prev();
|
|
4257
4348
|
return Math.floor(Date.now() - previous.getTime()); // in ms
|
|
4258
4349
|
} catch (error) {
|
|
4259
|
-
this.log.
|
|
4260
|
-
return;
|
|
4350
|
+
this.log.error(`[getPreviousCronRun] - ${error}`);
|
|
4261
4351
|
}
|
|
4262
4352
|
}
|
|
4263
4353
|
|
|
4264
|
-
/**
|
|
4265
|
-
* @param {string} codePart - Message Prefix
|
|
4266
|
-
* @param {object} error - Sentry message
|
|
4267
|
-
*/
|
|
4268
|
-
errorReporting(codePart, error) {
|
|
4269
|
-
const msg = `[${codePart}] error: ${error.message}`;
|
|
4270
|
-
if (enableSendSentry) {
|
|
4271
|
-
if (this.supportsFeature && this.supportsFeature('PLUGINS')) {
|
|
4272
|
-
const sentryInstance = this.getPluginInstance('sentry');
|
|
4273
|
-
if (sentryInstance) {
|
|
4274
|
-
this.log.warn(`Error catched and sent to Sentry, error: ${msg}`);
|
|
4275
|
-
sentryInstance.getSentryObject().captureException(msg);
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
} else {
|
|
4279
|
-
this.log.error(`Sentry disabled, error catched : ${msg}`);
|
|
4280
|
-
}
|
|
4281
|
-
} // <-- end of errorReporting
|
|
4282
|
-
|
|
4283
4354
|
/**
|
|
4284
4355
|
* @param {() => void} callback
|
|
4285
4356
|
*/
|