iobroker.device-watcher 2.0.3 → 2.1.0
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 +14 -2
- package/io-package.json +27 -17
- package/lib/arrApart.js +30 -1
- package/main.js +186 -37
- package/package.json +10 -11
- package/admin/i18n/de/translations.json +0 -82
- package/admin/i18n/en/translations.json +0 -82
- package/admin/i18n/es/translations.json +0 -82
- package/admin/i18n/fr/translations.json +0 -82
- package/admin/i18n/it/translations.json +0 -82
- package/admin/i18n/nl/translations.json +0 -82
- package/admin/i18n/pl/translations.json +0 -82
- package/admin/i18n/pt/translations.json +0 -82
- package/admin/i18n/ru/translations.json +0 -82
- package/admin/i18n/uk/translations.json +0 -82
- package/admin/i18n/zh-cn/translations.json +0 -82
- package/admin/index_m.html +0 -56
- package/admin/jsonConfig.json +0 -1359
- package/admin/style.css +0 -32
- package/admin/words.js +0 -91
package/main.js
CHANGED
|
@@ -33,6 +33,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
33
33
|
this.blacklistNotify = [];
|
|
34
34
|
this.arrDev = [];
|
|
35
35
|
this.adapterSelected = [];
|
|
36
|
+
this.upgradableList = [];
|
|
36
37
|
|
|
37
38
|
// raw arrays
|
|
38
39
|
this.listAllDevicesRaw = [];
|
|
@@ -43,6 +44,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
43
44
|
this.offlineDevicesCountRaw = 0;
|
|
44
45
|
this.offlineDevicesCountRawOld = 0;
|
|
45
46
|
this.lowBatteryPoweredCountRaw = 0;
|
|
47
|
+
this.upgradableDevicesCountRawOld = 0;
|
|
46
48
|
|
|
47
49
|
// counts
|
|
48
50
|
this.offlineDevicesCount = 0;
|
|
@@ -74,6 +76,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
74
76
|
|
|
75
77
|
this.supAdapter = {
|
|
76
78
|
alexa2: this.config.alexa2Devices,
|
|
79
|
+
apcups: this.config.apcupsDevices,
|
|
77
80
|
ble: this.config.bleDevices,
|
|
78
81
|
deconz: this.config.deconzDevices,
|
|
79
82
|
enocean: this.config.enoceanDevices,
|
|
@@ -94,6 +97,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
94
97
|
mihome: this.config.mihomeDevices,
|
|
95
98
|
mihomeGW: this.config.mihomeDevices,
|
|
96
99
|
mihomeVacuum: this.config.mihomeVacuumDevices,
|
|
100
|
+
mqttClientZigbee2Mqtt: this.config.mqttClientZigbee2MqttDevices,
|
|
101
|
+
mqttNuki: this.config.mqttNukiDevices,
|
|
97
102
|
netatmo: this.config.netatmoDevices,
|
|
98
103
|
nukiExt: this.config.nukiExtDevices,
|
|
99
104
|
nut: this.config.nutDevices,
|
|
@@ -117,6 +122,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
117
122
|
|
|
118
123
|
this.maxMinutes = {
|
|
119
124
|
alexa2: this.config.alexa2MaxMinutes,
|
|
125
|
+
apcups: this.config.apcupsMaxMinutes,
|
|
120
126
|
ble: this.config.bleMaxMinutes,
|
|
121
127
|
deconz: this.config.deconzMaxMinutes,
|
|
122
128
|
enocean: this.config.enoceanMaxMinutes,
|
|
@@ -137,6 +143,8 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
137
143
|
mihome: this.config.mihomeMaxMinutes,
|
|
138
144
|
mihomeGW: this.config.mihomeMaxMinutes,
|
|
139
145
|
mihomeVacuum: this.config.mihomeVacuumMaxMinutes,
|
|
146
|
+
mqttClientZigbee2Mqtt: this.config.mqttClientZigbee2MqttMaxMinutes,
|
|
147
|
+
mqttNuki: this.config.mqttNukiMaxMinutes,
|
|
140
148
|
netatmo: this.config.netatmoMaxMinutes,
|
|
141
149
|
nukiExt: this.config.nukiextendMaxMinutes,
|
|
142
150
|
nut: this.config.nutMaxMinutes,
|
|
@@ -212,6 +220,12 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
212
220
|
// update data in interval
|
|
213
221
|
await this.refreshData();
|
|
214
222
|
|
|
223
|
+
// trigger update notification on state change
|
|
224
|
+
/*
|
|
225
|
+
if (this.config.checkSendAdapterUpdateNotify) {
|
|
226
|
+
this.subscribeForeignStatesAsync(`admin.*.info.updatesJson`);
|
|
227
|
+
}*/
|
|
228
|
+
|
|
215
229
|
// send overview for low battery devices
|
|
216
230
|
if (this.config.checkSendBatteryMsg) await this.sendBatteryNotifyShedule();
|
|
217
231
|
|
|
@@ -229,12 +243,10 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
229
243
|
* @param {ioBroker.State | null | undefined} state
|
|
230
244
|
*/
|
|
231
245
|
onStateChange(id, state) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.log.
|
|
235
|
-
|
|
236
|
-
// The state was deleted
|
|
237
|
-
this.log.warn(`state ${id} deleted`);
|
|
246
|
+
// Admin JSON for Adapter updates
|
|
247
|
+
if (id && state) {
|
|
248
|
+
this.log.debug(`State changed: ${id} changed ${state.val}`);
|
|
249
|
+
//this.sendAdapterUpdatesNotification(id, state);
|
|
238
250
|
}
|
|
239
251
|
}
|
|
240
252
|
|
|
@@ -433,6 +445,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
433
445
|
case 'switchbotBle':
|
|
434
446
|
case 'esphome':
|
|
435
447
|
case 'fullybrowser':
|
|
448
|
+
case 'apcups':
|
|
436
449
|
deviceName = await this.getInitValue(currDeviceString + this.arrDev[i].id);
|
|
437
450
|
break;
|
|
438
451
|
|
|
@@ -524,6 +537,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
524
537
|
this.offlineDevices = [];
|
|
525
538
|
this.batteryLowPoweredRaw = [];
|
|
526
539
|
this.offlineDevicesRaw = [];
|
|
540
|
+
this.upgradableList = [];
|
|
527
541
|
|
|
528
542
|
for (const device of this.listAllDevicesRaw) {
|
|
529
543
|
/*---------- fill raw lists ----------*/
|
|
@@ -590,6 +604,14 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
590
604
|
'Last contact': device['Last contact'],
|
|
591
605
|
});
|
|
592
606
|
}
|
|
607
|
+
|
|
608
|
+
// Device update List
|
|
609
|
+
if (device['Upgradable']) {
|
|
610
|
+
this.upgradableList.push({
|
|
611
|
+
Device: device['Device'],
|
|
612
|
+
Adapter: device['Adapter'],
|
|
613
|
+
});
|
|
614
|
+
}
|
|
593
615
|
}
|
|
594
616
|
}
|
|
595
617
|
}
|
|
@@ -650,6 +672,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
650
672
|
=============================================*/
|
|
651
673
|
let deviceQualityState;
|
|
652
674
|
let linkQuality;
|
|
675
|
+
let mqttNukiValue;
|
|
653
676
|
|
|
654
677
|
switch (adapterID) {
|
|
655
678
|
case 'mihomeVacuum':
|
|
@@ -707,6 +730,15 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
707
730
|
case 'nukiExt':
|
|
708
731
|
linkQuality = ' - ';
|
|
709
732
|
break;
|
|
733
|
+
case 'mqttNuki':
|
|
734
|
+
linkQuality = deviceQualityState.val;
|
|
735
|
+
mqttNukiValue = parseInt(linkQuality);
|
|
736
|
+
if (this.config.trueState) {
|
|
737
|
+
linkQuality = deviceQualityState.val;
|
|
738
|
+
} else if (mqttNukiValue < 0) {
|
|
739
|
+
linkQuality = Math.min(Math.max(2 * (mqttNukiValue + 100), 0), 100) + '%';
|
|
740
|
+
// If Quality State is an value between 0-255 (zigbee) calculate in percent:
|
|
741
|
+
}
|
|
710
742
|
}
|
|
711
743
|
break;
|
|
712
744
|
}
|
|
@@ -739,7 +771,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
739
771
|
deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
|
|
740
772
|
}
|
|
741
773
|
|
|
742
|
-
if (
|
|
774
|
+
if (deviceBatteryState === undefined && shortDeviceBatteryState === undefined) {
|
|
743
775
|
if (deviceLowBatState !== undefined) {
|
|
744
776
|
switch (this.arrDev[i].isLowBat || this.arrDev[i].isLowBat2) {
|
|
745
777
|
case 'none':
|
|
@@ -771,6 +803,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
771
803
|
|
|
772
804
|
case 'hueExt':
|
|
773
805
|
case 'mihomeVacuum':
|
|
806
|
+
case 'mqttNuki':
|
|
774
807
|
if (shortDeviceBatteryState) {
|
|
775
808
|
batteryHealth = shortDeviceBatteryState + '%';
|
|
776
809
|
isBatteryDevice = true;
|
|
@@ -830,7 +863,6 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
830
863
|
const deviceUnreachState = await this.getInitValue(currDeviceString + this.arrDev[i].reach);
|
|
831
864
|
const lastDeviceUnreachStateChange = deviceUnreachSelector != undefined ? await this.getTimestamp(deviceUnreachSelector.lc) : await this.getTimestamp(deviceMainSelector.ts);
|
|
832
865
|
const shortDeviceUnreachState = await this.getForeignStateAsync(shortCurrDeviceString + this.arrDev[i].reach);
|
|
833
|
-
|
|
834
866
|
// If there is no contact since user sets minutes add device in offline list
|
|
835
867
|
// calculate to days after 48 hours
|
|
836
868
|
switch (this.arrDev[i].reach) {
|
|
@@ -884,37 +916,33 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
884
916
|
linkQuality = '0%'; // set linkQuality to nothing
|
|
885
917
|
}
|
|
886
918
|
break;
|
|
919
|
+
case 'apcups':
|
|
920
|
+
case 'hue':
|
|
921
|
+
case 'hueExt':
|
|
887
922
|
case 'ping':
|
|
888
923
|
case 'deconz':
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
deviceState = 'Offline'; //set online state to offline
|
|
892
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
893
|
-
}
|
|
894
|
-
} else if (lastDeviceUnreachStateChange > this.maxMinutes[adapterID] && !deviceUnreachState) {
|
|
895
|
-
deviceState = 'Offline'; //set online state to offline
|
|
896
|
-
linkQuality = '0%'; // set linkQuality to nothing
|
|
897
|
-
}
|
|
898
|
-
break;
|
|
924
|
+
case 'shelly':
|
|
925
|
+
case 'sonoff':
|
|
899
926
|
case 'unifi':
|
|
927
|
+
case 'zigbee':
|
|
928
|
+
case 'zigbee2MQTT':
|
|
900
929
|
if (this.maxMinutes[adapterID] <= 0) {
|
|
901
|
-
if (deviceUnreachState
|
|
930
|
+
if (!deviceUnreachState) {
|
|
902
931
|
deviceState = 'Offline'; //set online state to offline
|
|
903
932
|
linkQuality = '0%'; // set linkQuality to nothing
|
|
904
933
|
}
|
|
905
|
-
} else if (
|
|
934
|
+
} else if (!deviceUnreachState && lastDeviceUnreachStateChange > this.maxMinutes[adapterID]) {
|
|
906
935
|
deviceState = 'Offline'; //set online state to offline
|
|
907
936
|
linkQuality = '0%'; // set linkQuality to nothing
|
|
908
937
|
}
|
|
909
938
|
break;
|
|
910
|
-
case '
|
|
911
|
-
case 'sonoff':
|
|
939
|
+
case 'mqttClientZigbee2Mqtt':
|
|
912
940
|
if (this.maxMinutes[adapterID] <= 0) {
|
|
913
|
-
if (
|
|
941
|
+
if (deviceUnreachState !== 'online') {
|
|
914
942
|
deviceState = 'Offline'; //set online state to offline
|
|
915
943
|
linkQuality = '0%'; // set linkQuality to nothing
|
|
916
944
|
}
|
|
917
|
-
} else if (
|
|
945
|
+
} else if (deviceUnreachState !== 'online' && lastDeviceUnreachStateChange > this.maxMinutes[adapterID]) {
|
|
918
946
|
deviceState = 'Offline'; //set online state to offline
|
|
919
947
|
linkQuality = '0%'; // set linkQuality to nothing
|
|
920
948
|
}
|
|
@@ -970,6 +998,20 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
970
998
|
this.errorReporting('[getLastContact]', error);
|
|
971
999
|
}
|
|
972
1000
|
}
|
|
1001
|
+
/*=============================================
|
|
1002
|
+
= Get update data =
|
|
1003
|
+
=============================================*/
|
|
1004
|
+
let deviceUpdateSelector;
|
|
1005
|
+
let isUpgradable;
|
|
1006
|
+
|
|
1007
|
+
if (this.config.checkSendDeviceUpgrade) {
|
|
1008
|
+
deviceUpdateSelector = await this.getInitValue(currDeviceString + this.arrDev[i].upgrade);
|
|
1009
|
+
if (deviceUpdateSelector) {
|
|
1010
|
+
isUpgradable = true;
|
|
1011
|
+
} else {
|
|
1012
|
+
isUpgradable = false;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
973
1015
|
|
|
974
1016
|
/*=============================================
|
|
975
1017
|
= Fill Raw Lists =
|
|
@@ -988,6 +1030,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
988
1030
|
'Signal strength': linkQuality,
|
|
989
1031
|
'Last contact': lastContactString,
|
|
990
1032
|
Status: deviceState,
|
|
1033
|
+
Upgradable: isUpgradable,
|
|
991
1034
|
});
|
|
992
1035
|
}
|
|
993
1036
|
} else {
|
|
@@ -1002,6 +1045,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1002
1045
|
'Signal strength': linkQuality,
|
|
1003
1046
|
'Last contact': lastContactString,
|
|
1004
1047
|
Status: deviceState,
|
|
1048
|
+
Upgradable: isUpgradable,
|
|
1005
1049
|
});
|
|
1006
1050
|
}
|
|
1007
1051
|
} else {
|
|
@@ -1058,6 +1102,9 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1058
1102
|
// send message if new devices are offline
|
|
1059
1103
|
if (this.config.checkSendOfflineMsg) await this.sendOfflineNotifications();
|
|
1060
1104
|
|
|
1105
|
+
// send overview of upgradable devices
|
|
1106
|
+
if (this.config.checkSendDeviceUpgrade) await this.sendDeviceUpdatesNotification();
|
|
1107
|
+
|
|
1061
1108
|
await this.writeDatapoints(); // fill the datapoints
|
|
1062
1109
|
} catch (error) {
|
|
1063
1110
|
this.errorReporting('[createDataOfAllAdapter]', error);
|
|
@@ -1190,6 +1237,26 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1190
1237
|
} catch (error) {
|
|
1191
1238
|
this.errorReporting('[sendNotification Lovelace]', error);
|
|
1192
1239
|
}
|
|
1240
|
+
|
|
1241
|
+
// Synochat Notification
|
|
1242
|
+
try {
|
|
1243
|
+
if (this.config.instanceSynochat) {
|
|
1244
|
+
//first check if instance is living
|
|
1245
|
+
const synochatAliveState = await this.getInitValue('system.adapter.' + this.config.instanceSynochat + '.alive');
|
|
1246
|
+
|
|
1247
|
+
if (!synochatAliveState) {
|
|
1248
|
+
this.log.warn('Synochat instance is not running. Message could not be sent. Please check your instance configuration.');
|
|
1249
|
+
} else {
|
|
1250
|
+
if (this.config.channelSynochat !== undefined) {
|
|
1251
|
+
await this.setForeignStateAsync(`${this.config.instanceSynochat}.${this.config.channelSynochat}.message`, text);
|
|
1252
|
+
} else {
|
|
1253
|
+
this.log.warn('Synochat channel is not set. Message could not be sent. Please check your instance configuration.');
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
} catch (error) {
|
|
1258
|
+
this.errorReporting('[sendNotification Synochat]', error);
|
|
1259
|
+
}
|
|
1193
1260
|
} // <-- End of sendNotification function
|
|
1194
1261
|
|
|
1195
1262
|
/**
|
|
@@ -1225,14 +1292,19 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1225
1292
|
|
|
1226
1293
|
for (const id of this.batteryLowPoweredRaw) {
|
|
1227
1294
|
if (!this.blacklistNotify.includes(id['Path'])) {
|
|
1228
|
-
|
|
1295
|
+
if (!this.config.showAdapterNameinMsg) {
|
|
1296
|
+
deviceList = `${deviceList}\n${id['Device']} (${id['Battery']})`;
|
|
1297
|
+
} else {
|
|
1298
|
+
// Add adaptername if checkbox is checked true in options by user
|
|
1299
|
+
deviceList = `${deviceList}\n${id['Adapter']}: ${id['Device']} (${id['Battery']})`;
|
|
1300
|
+
}
|
|
1229
1301
|
}
|
|
1230
1302
|
}
|
|
1231
1303
|
if (deviceList.length > 0) {
|
|
1232
1304
|
this.log.info(`Niedrige Batteriezustände: ${deviceList}`);
|
|
1233
1305
|
this.setStateAsync('lastNotification', `Niedrige Batteriezustände: ${deviceList}`, true);
|
|
1234
1306
|
|
|
1235
|
-
this.sendNotification(`
|
|
1307
|
+
this.sendNotification(`Niedrige Batteriezustände: ${deviceList}`);
|
|
1236
1308
|
}
|
|
1237
1309
|
} catch (error) {
|
|
1238
1310
|
this.errorReporting('[sendBatteryNotifyShedule]', error);
|
|
@@ -1253,13 +1325,17 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1253
1325
|
|
|
1254
1326
|
for (const id of this.offlineDevicesRaw) {
|
|
1255
1327
|
if (!this.blacklistNotify.includes(id['Path'])) {
|
|
1256
|
-
|
|
1328
|
+
if (!this.config.showAdapterNameinMsg) {
|
|
1329
|
+
deviceList = `${deviceList}\n${id['Device']} (${id['Last contact']})`;
|
|
1330
|
+
} else {
|
|
1331
|
+
deviceList = `${deviceList}\n${id['Adapter']}: ${id['Device']} (${id['Last contact']})`;
|
|
1332
|
+
}
|
|
1257
1333
|
}
|
|
1258
1334
|
}
|
|
1259
1335
|
if (deviceList.length !== this.offlineDevicesCountRawOld) {
|
|
1260
|
-
if (deviceList.length
|
|
1336
|
+
if (deviceList.length === 0) {
|
|
1261
1337
|
msg = 'Alle Geräte sind Online.';
|
|
1262
|
-
} else if (deviceList.length
|
|
1338
|
+
} else if (deviceList.length === 1) {
|
|
1263
1339
|
// make singular if it is only one device
|
|
1264
1340
|
msg = 'Folgendes Gerät ist seit einiger Zeit nicht erreichbar: \n';
|
|
1265
1341
|
} else if (deviceList.length >= 2) {
|
|
@@ -1311,7 +1387,11 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1311
1387
|
|
|
1312
1388
|
for (const id of this.offlineDevicesRaw) {
|
|
1313
1389
|
if (!this.blacklistNotify.includes(id['Path'])) {
|
|
1314
|
-
|
|
1390
|
+
if (!this.config.showAdapterNameinMsg) {
|
|
1391
|
+
deviceList = `${deviceList}\n${id['Device']} (${id['Last contact']})`;
|
|
1392
|
+
} else {
|
|
1393
|
+
deviceList = `${deviceList}\n${id['Adapter']}: ${id['Device']} (${id['Last contact']})`;
|
|
1394
|
+
}
|
|
1315
1395
|
}
|
|
1316
1396
|
}
|
|
1317
1397
|
|
|
@@ -1328,6 +1408,75 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1328
1408
|
}
|
|
1329
1409
|
} //<--End of daily offline notification
|
|
1330
1410
|
|
|
1411
|
+
/**
|
|
1412
|
+
* check if adapter updates are available and send notification
|
|
1413
|
+
* @param {string} id
|
|
1414
|
+
* @param {ioBroker.State | null | undefined} state
|
|
1415
|
+
*/
|
|
1416
|
+
/*
|
|
1417
|
+
async sendAdapterUpdatesNotification(id, state) {
|
|
1418
|
+
this.log.debug(`Start the function: ${this.sendAdapterUpdatesNotification.name}`);
|
|
1419
|
+
|
|
1420
|
+
try {
|
|
1421
|
+
if (state && state !== undefined) {
|
|
1422
|
+
const list = await this.parseData(state.val);
|
|
1423
|
+
let msg = '';
|
|
1424
|
+
let adapterList = '';
|
|
1425
|
+
|
|
1426
|
+
for (const [id] of Object.entries(list)) {
|
|
1427
|
+
adapterList = `${adapterList}\n${this.capitalize(id)} - Version: ${list[id].availableVersion}`;
|
|
1428
|
+
}
|
|
1429
|
+
if (adapterList.length !== 0) {
|
|
1430
|
+
msg = `Neue Adapter Updates vorhanden: \n`;
|
|
1431
|
+
|
|
1432
|
+
this.log.info(msg + adapterList);
|
|
1433
|
+
await this.setStateAsync('lastNotification', msg + adapterList, true);
|
|
1434
|
+
await this.sendNotification(msg + adapterList);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
} catch (error) {
|
|
1438
|
+
this.errorReporting('[sendAdapterUpdatesNotification]', error);
|
|
1439
|
+
}
|
|
1440
|
+
this.log.debug(`Finished the function: ${this.sendAdapterUpdatesNotification.name}`);
|
|
1441
|
+
}*/
|
|
1442
|
+
|
|
1443
|
+
/**
|
|
1444
|
+
* check if device updates are available and send notification
|
|
1445
|
+
**/
|
|
1446
|
+
async sendDeviceUpdatesNotification() {
|
|
1447
|
+
this.log.debug(`Start the function: ${this.sendDeviceUpdatesNotification.name}`);
|
|
1448
|
+
|
|
1449
|
+
try {
|
|
1450
|
+
let msg = '';
|
|
1451
|
+
let deviceList = '';
|
|
1452
|
+
|
|
1453
|
+
for (const id of this.upgradableList) {
|
|
1454
|
+
if (!this.blacklistNotify.includes(id['Path'])) {
|
|
1455
|
+
if (!this.config.showAdapterNameinMsg) {
|
|
1456
|
+
deviceList = `${deviceList}\n${id['Device']}`;
|
|
1457
|
+
} else {
|
|
1458
|
+
deviceList = `${deviceList}\n${id['Adapter']}: ${id['Device']}`;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
if (deviceList.length !== this.upgradableDevicesCountRawOld) {
|
|
1463
|
+
if (deviceList.length >= 1) {
|
|
1464
|
+
msg = `Neue Geräte Updates vorhanden: \n`;
|
|
1465
|
+
|
|
1466
|
+
this.log.info(msg + deviceList);
|
|
1467
|
+
this.upgradableDevicesCountRawOld = deviceList.length;
|
|
1468
|
+
await this.setStateAsync('lastNotification', msg + deviceList, true);
|
|
1469
|
+
await this.sendNotification(msg + deviceList);
|
|
1470
|
+
} else {
|
|
1471
|
+
this.upgradableDevicesCountRawOld = deviceList.length;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
} catch (error) {
|
|
1475
|
+
this.errorReporting('[sendDeviceUpdatesNotification]', error);
|
|
1476
|
+
}
|
|
1477
|
+
this.log.debug(`Finished the function: ${this.sendDeviceUpdatesNotification.name}`);
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1331
1480
|
/**
|
|
1332
1481
|
* reset arrays and counts
|
|
1333
1482
|
*/
|
|
@@ -1381,13 +1530,13 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1381
1530
|
await this.setStateAsync(`${dpSubFolder}batteryCount`, { val: this.batteryPoweredCount, ack: true });
|
|
1382
1531
|
await this.setStateAsync(`${dpSubFolder}lowBatteryCount`, { val: this.lowBatteryPoweredCount, ack: true });
|
|
1383
1532
|
|
|
1384
|
-
if (this.deviceCounter
|
|
1533
|
+
if (this.deviceCounter === 0) {
|
|
1385
1534
|
// if no device is count, write the JSON List with default value
|
|
1386
1535
|
this.listAllDevices = [{ Device: '--none--', Adapter: '', Battery: '', 'Last contact': '', 'Signal strength': '' }];
|
|
1387
1536
|
}
|
|
1388
1537
|
await this.setStateAsync(`${dpSubFolder}listAll`, { val: JSON.stringify(this.listAllDevices), ack: true });
|
|
1389
1538
|
|
|
1390
|
-
if (this.linkQualityCount
|
|
1539
|
+
if (this.linkQualityCount === 0) {
|
|
1391
1540
|
// if no device is count, write the JSON List with default value
|
|
1392
1541
|
this.linkQualityDevices = [{ Device: '--none--', Adapter: '', 'Signal strength': '' }];
|
|
1393
1542
|
}
|
|
@@ -1403,7 +1552,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1403
1552
|
ack: true,
|
|
1404
1553
|
});
|
|
1405
1554
|
|
|
1406
|
-
if (this.offlineDevicesCount
|
|
1555
|
+
if (this.offlineDevicesCount === 0) {
|
|
1407
1556
|
// if no device is count, write the JSON List with default value
|
|
1408
1557
|
this.offlineDevices = [{ Device: '--none--', Adapter: '', 'Last contact': '' }];
|
|
1409
1558
|
}
|
|
@@ -1419,7 +1568,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1419
1568
|
ack: true,
|
|
1420
1569
|
});
|
|
1421
1570
|
|
|
1422
|
-
if (this.batteryPoweredCount
|
|
1571
|
+
if (this.batteryPoweredCount === 0) {
|
|
1423
1572
|
// if no device is count, write the JSON List with default value
|
|
1424
1573
|
this.batteryPowered = [{ Device: '--none--', Adapter: '', Battery: '' }];
|
|
1425
1574
|
}
|
|
@@ -1435,7 +1584,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1435
1584
|
ack: true,
|
|
1436
1585
|
});
|
|
1437
1586
|
|
|
1438
|
-
if (this.lowBatteryPoweredCount
|
|
1587
|
+
if (this.lowBatteryPoweredCount === 0) {
|
|
1439
1588
|
// if no device is count, write the JSON List with default value
|
|
1440
1589
|
this.batteryLowPowered = [{ Device: '--none--', Adapter: '', Battery: '' }];
|
|
1441
1590
|
}
|
|
@@ -1507,7 +1656,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1507
1656
|
return a.localeCompare(b);
|
|
1508
1657
|
});
|
|
1509
1658
|
let html = `<center>
|
|
1510
|
-
<b>Offline Devices: <font color=${deviceCount
|
|
1659
|
+
<b>Offline Devices: <font color=${deviceCount === 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
|
|
1511
1660
|
<p></p>
|
|
1512
1661
|
</center>
|
|
1513
1662
|
<table width=100%>
|
|
@@ -1544,7 +1693,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1544
1693
|
return a.localeCompare(b);
|
|
1545
1694
|
});
|
|
1546
1695
|
let html = `<center>
|
|
1547
|
-
<b>${isLowBatteryList
|
|
1696
|
+
<b>${isLowBatteryList === true ? 'Schwache ' : ''}Batterie Devices: <font color=${isLowBatteryList === true ? (deviceCount > 0 ? 'orange' : '#3bcf0e') : ''}>${deviceCount}</b></font>
|
|
1548
1697
|
<p></p>
|
|
1549
1698
|
</center>
|
|
1550
1699
|
<table width=100%>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.device-watcher",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Watchdog for devices",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Christian Behrends",
|
|
@@ -30,30 +30,29 @@
|
|
|
30
30
|
"@alcalzone/release-script-plugin-license": "^3.5.9",
|
|
31
31
|
"@iobroker/adapter-dev": "^1.2.0",
|
|
32
32
|
"@iobroker/testing": "^4.1.0",
|
|
33
|
-
"@types/chai": "^4.3.
|
|
33
|
+
"@types/chai": "^4.3.4",
|
|
34
34
|
"@types/chai-as-promised": "^7.1.5",
|
|
35
|
-
"@types/mocha": "^10.0.
|
|
36
|
-
"@types/node": "^18.11.
|
|
35
|
+
"@types/mocha": "^10.0.1",
|
|
36
|
+
"@types/node": "^18.11.10",
|
|
37
37
|
"@types/node-schedule": "^2.1.0",
|
|
38
38
|
"@types/proxyquire": "^1.3.28",
|
|
39
39
|
"@types/sinon": "^10.0.13",
|
|
40
|
-
"@types/sinon-chai": "^3.2.
|
|
41
|
-
"chai": "^4.3.
|
|
40
|
+
"@types/sinon-chai": "^3.2.9",
|
|
41
|
+
"chai": "^4.3.7",
|
|
42
42
|
"chai-as-promised": "^7.1.1",
|
|
43
|
-
"eslint": "^8.
|
|
43
|
+
"eslint": "^8.28.0",
|
|
44
44
|
"eslint-config-prettier": "^8.5.0",
|
|
45
45
|
"eslint-plugin-prettier": "^4.2.1",
|
|
46
46
|
"mocha": "^10.1.0",
|
|
47
47
|
"node-schedule": "^2.1.0",
|
|
48
|
-
"prettier": "^2.
|
|
48
|
+
"prettier": "^2.8.0",
|
|
49
49
|
"proxyquire": "^2.1.3",
|
|
50
|
-
"sinon": "^
|
|
50
|
+
"sinon": "^15.0.0",
|
|
51
51
|
"sinon-chai": "^3.7.0",
|
|
52
|
-
"typescript": "~4.
|
|
52
|
+
"typescript": "~4.9.3"
|
|
53
53
|
},
|
|
54
54
|
"main": "main.js",
|
|
55
55
|
"files": [
|
|
56
|
-
"admin{,/!(src)/**}/!(tsconfig|tsconfig.*).json",
|
|
57
56
|
"admin{,/!(src)/**}/*.{html,css,png,svg,jpg,js}",
|
|
58
57
|
"lib/",
|
|
59
58
|
"www/",
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Add own notes, name, etc": "Fügen Sie eigene Notizen, Namen usw. hinzu",
|
|
3
|
-
"Battery message": "Batteriemeldung",
|
|
4
|
-
"Choose devices to watch": "Wählen Sie Geräte zum Ansehen aus",
|
|
5
|
-
"Choose if only devices with batteries should be listed or all devices": "Wählen Sie, ob nur Geräte mit Batterien aufgelistet werden sollen oder alle Geräte",
|
|
6
|
-
"Choose the Time:": "Wählen Sie die Zeit:",
|
|
7
|
-
"Choose the day(s) where you want to get the message of low battery:": "Wählen Sie den/die Tag(e), an dem/denen Sie die Meldung über schwache Batterie erhalten möchten:",
|
|
8
|
-
"Choose the day(s) where you want to get the overview of offline devices:": "Wählen Sie die Tage aus, an denen Sie die Übersicht über Offline-Geräte erhalten möchten:",
|
|
9
|
-
"Choose the priority": "Wählen Sie die Priorität",
|
|
10
|
-
"Choose which devices should be excluded": "Wählen Sie aus, welche Geräte ausgeschlossen werden sollen",
|
|
11
|
-
"Choose your Chat-ID": "Wählen Sie Ihre Chat-ID",
|
|
12
|
-
"Choose your device": "Wählen Sie Ihr Gerät",
|
|
13
|
-
"Choose your email address": "Wählen Sie Ihre E-Mail-Adresse",
|
|
14
|
-
"Choose your notification services": "Wählen Sie Ihre Benachrichtigungsdienste",
|
|
15
|
-
"Choose your recipient": "Wählen Sie Ihren Empfänger",
|
|
16
|
-
"Choose your subject for the Email": "Wählen Sie Ihren Betreff für die E-Mail",
|
|
17
|
-
"Choose your title for Pushmessage": "Wählen Sie Ihren Titel für die Push-Nachricht",
|
|
18
|
-
"Common Notification Settings": "Allgemeine Benachrichtigungseinstellungen",
|
|
19
|
-
"Create additionally HTML lists": "Erstellen Sie zusätzlich HTML-Listen",
|
|
20
|
-
"Create own folders for each adapter": "Erstellen Sie für jeden Adapter eigene Ordner",
|
|
21
|
-
"Create the lists also in HTML": "Erstellen Sie die Listen auch in HTML",
|
|
22
|
-
"Daily overview of offline devices": "Tägliche Übersicht über Offline-Geräte",
|
|
23
|
-
"Device-ID (optional)": "Geräte-ID (optional)",
|
|
24
|
-
"Email Instance": "E-Mail-Instanz",
|
|
25
|
-
"Fri": "Fr",
|
|
26
|
-
"From how much min % would you get a message": "Ab wie viel min % würden Sie eine Nachricht bekommen",
|
|
27
|
-
"Get a message with an overview all offline devices": "Erhalten Sie eine Nachricht mit einer Übersicht aller Offline-Geräte",
|
|
28
|
-
"Get daily an overview with all offline devices": "Verschaffen Sie sich täglich einen Überblick mit allen Offline-Geräten",
|
|
29
|
-
"Get message if an device has low battery": "Erhalten Sie eine Nachricht, wenn der Akku eines Geräts schwach ist",
|
|
30
|
-
"Get message if an device is not reachable": "Erhalten Sie eine Nachricht, wenn ein Gerät nicht erreichbar ist",
|
|
31
|
-
"Here you can choose your notification service, you can use more than one service, but you can also leave all blank, then only the datapoint lastNotification will be filled.": "Hier können Sie Ihren Benachrichtigungsdienst auswählen, Sie können mehr als einen Dienst verwenden, Sie können aber auch alle leer lassen, dann wird nur der Datenpunkt lastNotification gefüllt.",
|
|
32
|
-
"Here you can define the offline times of each adapter. If you want to use the data points of the devices (online, available, reachable etc.) directly to determine the status, enter ' 0 '.": "Hier können Sie die Offline-Zeiten jedes Adapters definieren. Wenn Sie die Datenpunkte der Geräte (online, verfügbar, erreichbar etc.) direkt zur Statusermittlung nutzen möchten, geben Sie '0' ein.",
|
|
33
|
-
"Here you can define the offline times of each adapter. If you want to use the data points of the devices (online, available, reachable etc.) directly to determine the status, enter '-1'.": "Hier können Sie die Offline-Zeiten jedes Adapters definieren. Wenn Sie die Datenpunkte der Geräte (online, verfügbar, erreichbar etc.) direkt zur Statusermittlung verwenden möchten, geben Sie '-1' ein.",
|
|
34
|
-
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Hier können Sie das Aktualisierungsintervall der Datenpunkte/Listen festlegen. Aus Performance-Gründen wird davon abgeraten, einen zu niedrigen Poll-Wert zu wählen. Weniger als zwei Sekunden sind nicht wählbar.",
|
|
35
|
-
"High Priority": "Hohe Priorität",
|
|
36
|
-
"If you like to have for every Adapter an own folder with own data": "Wenn Sie möchten, haben Sie für jeden Adapter einen eigenen Ordner mit eigenen Daten",
|
|
37
|
-
"Ignor in lists": "In Listen ignorieren",
|
|
38
|
-
"Ignor in notifications": "In Benachrichtigungen ignorieren",
|
|
39
|
-
"Jarvis Instance": "Jarvis-Instanz",
|
|
40
|
-
"List only devices with batteries": "Nur Geräte mit Batterien auflisten",
|
|
41
|
-
"Lovelace Instance": "Lovelace-Instanz",
|
|
42
|
-
"Lovelace Notification": "Lovelace-Benachrichtigung",
|
|
43
|
-
"Mon": "Mo",
|
|
44
|
-
"Notification Service": "Benachrichtigungsdienst",
|
|
45
|
-
"Notifications": "Benachrichtigungen",
|
|
46
|
-
"Offline Time": "Offline-Zeit",
|
|
47
|
-
"Offline message": "Offline-Nachricht",
|
|
48
|
-
"Offline time of Devices": "Offlinezeit von Geräten",
|
|
49
|
-
"Other Settings": "Andere Einstellungen",
|
|
50
|
-
"Overview of offline devices": "Übersicht der Offline-Geräte",
|
|
51
|
-
"Please choose": "Bitte auswählen",
|
|
52
|
-
"Please choose the Whatsapp instance": "Bitte wählen Sie die WhatsApp-Instanz aus",
|
|
53
|
-
"Please choose the email instance": "Bitte wählen Sie die E-Mail-Instanz aus",
|
|
54
|
-
"Please choose the jarvis instance": "Bitte wählen Sie die jarvis-Instanz aus",
|
|
55
|
-
"Please choose the lovelace instance": "Bitte wählen Sie die Lovelace-Instanz aus",
|
|
56
|
-
"Please choose the pushover instance": "Bitte wählen Sie die Pushover-Instanz aus",
|
|
57
|
-
"Please choose the telegram instance": "Bitte wählen Sie die Telegramminstanz aus",
|
|
58
|
-
"Pushover Instance": "Pushover-Instanz",
|
|
59
|
-
"Recipient (optional)": "Empfänger (optional)",
|
|
60
|
-
"Sat": "Sa",
|
|
61
|
-
"Send batterie message": "Batterienachricht senden",
|
|
62
|
-
"Send offline message": "Offline-Nachricht senden",
|
|
63
|
-
"Send to (optional)": "Senden an (optional)",
|
|
64
|
-
"Subject (optional)": "Betreff (optional)",
|
|
65
|
-
"Sun": "Sonne",
|
|
66
|
-
"Telegram Instance": "Telegram-Instanz",
|
|
67
|
-
"Thu": "Do",
|
|
68
|
-
"Title (optional)": "Titel (optional)",
|
|
69
|
-
"True State": "Wahrer Zustand",
|
|
70
|
-
"Tue": "Di",
|
|
71
|
-
"Update-Interval": "Updateintervall",
|
|
72
|
-
"Use the true state from quality state": "Verwenden Sie den wahren Zustand aus dem Qualitätszustand",
|
|
73
|
-
"Use the true value of the signal strength, or it is converted to %": "Verwenden Sie den wahren Wert der Signalstärke oder konvertieren Sie ihn in %",
|
|
74
|
-
"Wed": "Heiraten",
|
|
75
|
-
"Whatsapp Instance": "WhatsApp-Instanz",
|
|
76
|
-
"With confirmation": "Mit Bestätigung",
|
|
77
|
-
"device-watcher adapter settings": "Adaptereinstellungen für Device-Watcher",
|
|
78
|
-
"in minutes": "in Minuten",
|
|
79
|
-
"in percent": "in Prozent",
|
|
80
|
-
"option1": "Option 1",
|
|
81
|
-
"option2": "Option 2"
|
|
82
|
-
}
|