iobroker.device-watcher 2.10.0 → 2.10.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.
@@ -581,6 +581,71 @@ const translations = {
581
581
  uk: 'Пристрої акумулятора',
582
582
  'zh-cn': '电池设备',
583
583
  },
584
+ instance_activated: {
585
+ en: 'Instance activated',
586
+ de: 'Instanz aktiviert',
587
+ ru: 'Активируется',
588
+ pt: 'Processo activado',
589
+ nl: 'Instantie geactiveerd',
590
+ fr: 'Instance activée',
591
+ it: 'Attivazione',
592
+ es: 'Instalación activada',
593
+ pl: 'Uruchamiony osąd',
594
+ uk: 'Інструкції активовані',
595
+ 'zh-cn': '实例激活',
596
+ },
597
+ instance_deactivated: {
598
+ en: 'Instance deactivated',
599
+ de: 'Instanz deaktiviert',
600
+ ru: 'Экземпляр деактивирован',
601
+ pt: 'Instância desativada',
602
+ nl: 'Instantie gedeactiveerd',
603
+ fr: 'Instance désactivée',
604
+ it: 'Istanza disattivata',
605
+ es: 'Instancia desactivada',
606
+ pl: 'Instancja dezaktywowana',
607
+ uk: 'Екземпляр деактивовано',
608
+ 'zh-cn': '实例已停用',
609
+ },
610
+ instance_okay: {
611
+ en: 'Instance okay',
612
+ de: 'Instanz okay',
613
+ ru: 'Экземпляр в норме',
614
+ pt: 'Instância OK',
615
+ nl: 'Instantie OK',
616
+ fr: 'Instance OK',
617
+ it: 'Istanza OK',
618
+ es: 'Instancia OK',
619
+ pl: 'Instancja OK',
620
+ uk: 'Екземпляр в нормі',
621
+ 'zh-cn': '实例正常',
622
+ },
623
+ not_connected_host: {
624
+ en: 'Not connected to host',
625
+ de: 'Nicht mit Host verbunden',
626
+ ru: 'Не подключен к хосту',
627
+ pt: 'Não conectado ao host',
628
+ nl: 'Niet verbonden met host',
629
+ fr: 'Pas connecté au hôte',
630
+ it: 'Non connesso al host',
631
+ es: 'No conectado al host',
632
+ pl: 'Nie podłączony do hosta',
633
+ uk: "Не під'єднаний до хоста",
634
+ 'zh-cn': '未连接到主机',
635
+ },
636
+ not_connected_device: {
637
+ en: 'Not connected to device or service',
638
+ de: 'Nicht mit Gerät oder Service verbunden',
639
+ ru: 'Не подключен к устройству или сервису',
640
+ pt: 'Não conectado ao dispositivo ou serviço',
641
+ nl: 'Niet verbonden met apparaat of dienst',
642
+ fr: 'Non connecté à un appareil ou à un service',
643
+ it: 'Non collegato al dispositivo o al servizio',
644
+ es: 'No conectado al dispositivo o servicio',
645
+ pl: 'Niepodłączone do urządzenia lub usługi',
646
+ uk: 'Не підключено до пристрою або сервісу',
647
+ 'zh-cn': '未连接到设备或服务',
648
+ },
584
649
  };
585
650
 
586
651
  module.exports = translations;
package/main.js CHANGED
@@ -299,22 +299,22 @@ class DeviceWatcher extends utils.Adapter {
299
299
  await this.refreshData();
300
300
 
301
301
  // send overview for low battery devices
302
- if (this.config.checkSendBatteryMsgDaily) this.sendScheduleNotifications('lowBatteryDevices');
302
+ if (this.config.checkSendBatteryMsgDaily) await this.sendScheduleNotifications('lowBatteryDevices');
303
303
 
304
304
  // send overview of offline devices
305
- if (this.config.checkSendOfflineMsgDaily) this.sendScheduleNotifications('offlineDevices');
305
+ if (this.config.checkSendOfflineMsgDaily) await this.sendScheduleNotifications('offlineDevices');
306
306
 
307
307
  // send overview of upgradeable devices
308
- if (this.config.checkSendUpgradeMsgDaily) this.sendScheduleNotifications('updateDevices');
308
+ if (this.config.checkSendUpgradeMsgDaily) await this.sendScheduleNotifications('updateDevices');
309
309
 
310
310
  // send overview of updatable adapters
311
- if (this.config.checkSendAdapterUpdateMsgDaily) this.sendScheduleNotifications('updateAdapter');
311
+ if (this.config.checkSendAdapterUpdateMsgDaily) await this.sendScheduleNotifications('updateAdapter');
312
312
 
313
313
  // send overview of deactivated instances
314
- if (this.config.checkSendInstanceDeactivatedDaily) this.sendScheduleNotifications('deactivatedInstance');
314
+ if (this.config.checkSendInstanceDeactivatedDaily) await this.sendScheduleNotifications('deactivatedInstance');
315
315
 
316
316
  // send overview of instances with error
317
- if (this.config.checkSendInstanceFailedDaily) this.sendScheduleNotifications('errorInstance');
317
+ if (this.config.checkSendInstanceFailedDaily) await this.sendScheduleNotifications('errorInstance');
318
318
  } catch (error) {
319
319
  this.log.error(`[onReady] - ${error}`);
320
320
  this.terminate ? this.terminate(15) : process.exit(15);
@@ -583,9 +583,9 @@ class DeviceWatcher extends utils.Adapter {
583
583
  this.refreshDataTimeout = null;
584
584
  }
585
585
 
586
- this.refreshDataTimeout = this.setTimeout(() => {
586
+ this.refreshDataTimeout = this.setTimeout(async () => {
587
587
  this.log.debug('Updating Data');
588
- this.refreshData();
588
+ await this.refreshData();
589
589
  }, nextTimeout);
590
590
  } // <-- refreshData end
591
591
 
@@ -1210,14 +1210,13 @@ class DeviceWatcher extends utils.Adapter {
1210
1210
  const lastContact = this.getTimestamp(selector);
1211
1211
  let lastContactString;
1212
1212
 
1213
+ lastContactString = `${this.formatDate(new Date(selector), 'hh:mm')}`;
1213
1214
  if (Math.round(lastContact) > 100) {
1214
- lastContactString = `${Math.round(lastContact / 60 / 24)} ${translations.days[this.language]}`;
1215
- } else if (Math.round(lastContact) > 48) {
1216
1215
  lastContactString = `${Math.round(lastContact / 60)} ${translations.hours[this.language]}`;
1217
- } else {
1218
- lastContactString = `${this.formatDate(new Date(selector), 'hh:mm')}`;
1219
1216
  }
1220
-
1217
+ if (Math.round(lastContact / 60) > 48) {
1218
+ lastContactString = `${Math.round(lastContact / 60 / 24)} ${translations.days[this.language]}`;
1219
+ }
1221
1220
  return lastContactString;
1222
1221
  }
1223
1222
 
@@ -1240,63 +1239,83 @@ class DeviceWatcher extends utils.Adapter {
1240
1239
  const deviceUnreachSelector = await this.getForeignStateAsync(unreachDP);
1241
1240
  const deviceStateSelector = await this.getForeignStateAsync(deviceStateSelectorDP); // for hmrpc devices
1242
1241
  const rssiPeerSelector = await this.getForeignStateAsync(rssiPeerSelectorDP);
1243
- const lastDeviceUnreachStateChange = deviceUnreachSelector !== undefined ? this.getTimestamp(deviceUnreachSelector.lc) : this.getTimestamp(timeSelector.ts);
1244
-
1245
- // If there is no contact since the user sets minutes, add the device to the offline list and calculate to days after 48 hours
1242
+ const lastDeviceUnreachStateChange = deviceUnreachSelector != undefined ? this.getTimestamp(deviceUnreachSelector.lc) : this.getTimestamp(timeSelector.ts);
1243
+ // If there is no contact since user sets minutes add device in offline list
1244
+ // calculate to days after 48 hours
1246
1245
  switch (unreachDP) {
1247
1246
  case 'none':
1248
- if (deviceTimeSelector) {
1249
- lastContactString = await this.getLastContact(deviceTimeSelector.ts);
1250
- }
1247
+ if (deviceTimeSelector) lastContactString = await this.getLastContact(deviceTimeSelector.ts);
1251
1248
  break;
1252
1249
 
1253
1250
  default:
1254
- // State changed
1251
+ //State changed
1255
1252
  if (adapterID === 'hmrpc') {
1256
1253
  if (linkQuality !== ' - ' && deviceTimeSelector) {
1257
- lastContactString = deviceUnreachState === 1 ? await this.getLastContact(deviceTimeSelector.lc) : await this.getLastContact(deviceTimeSelector.ts);
1254
+ if (deviceUnreachState === 1) {
1255
+ lastContactString = await this.getLastContact(deviceTimeSelector.lc);
1256
+ } else {
1257
+ lastContactString = await this.getLastContact(deviceTimeSelector.ts);
1258
+ }
1258
1259
  } else {
1259
1260
  if (deviceStateSelector) {
1260
- // Because old hm devices don't send rssi states
1261
+ // because old hm devices don't send rssi states
1261
1262
  lastContactString = await this.getLastContact(deviceStateSelector.ts);
1262
1263
  } else if (rssiPeerSelector) {
1263
- // Because old hm sensors don't send rssi/state values
1264
+ // because old hm sensors don't send rssi/state values
1264
1265
  lastContactString = await this.getLastContact(rssiPeerSelector.ts);
1265
1266
  }
1266
1267
  }
1267
1268
  } else {
1268
1269
  if ((!deviceUnreachState || deviceUnreachState === 0) && deviceTimeSelector) {
1269
1270
  lastContactString = await this.getLastContact(deviceTimeSelector.lc);
1270
- } else if (deviceTimeSelector) {
1271
- lastContactString = await this.getLastContact(deviceTimeSelector.ts);
1271
+ } else {
1272
+ if (deviceTimeSelector) lastContactString = await this.getLastContact(deviceTimeSelector.ts);
1272
1273
  }
1273
1274
  break;
1274
1275
  }
1275
1276
  }
1276
1277
 
1277
1278
  /*=============================================
1278
- = Set Online Status =
1279
- =============================================*/
1279
+ = Set Online Status =
1280
+ =============================================*/
1280
1281
  let lastContact;
1281
-
1282
1282
  if (deviceTimeSelector) lastContact = this.getTimestamp(deviceTimeSelector.ts);
1283
1283
 
1284
1284
  if (this.configMaxMinutes !== undefined) {
1285
- let setOfflineState = false;
1286
-
1287
1285
  switch (adapterID) {
1288
1286
  case 'hmrpc':
1289
- setOfflineState =
1290
- (this.configMaxMinutes[adapterID] <= 0 && deviceUnreachState === 1) || (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState === 1);
1287
+ if (this.configMaxMinutes[adapterID] <= 0) {
1288
+ if (deviceUnreachState === 1) {
1289
+ deviceState = 'Offline'; //set online state to offline
1290
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1291
+ }
1292
+ } else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState === 1) {
1293
+ deviceState = 'Offline'; //set online state to offline
1294
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1295
+ }
1291
1296
  break;
1292
1297
  case 'proxmox':
1293
- setOfflineState =
1294
- (this.configMaxMinutes[adapterID] <= 0 && deviceUnreachState !== 'running' && deviceUnreachState !== 'online') ||
1295
- (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState !== 'running' && deviceUnreachState !== 'online');
1298
+ if (this.configMaxMinutes[adapterID] <= 0) {
1299
+ if (deviceUnreachState !== 'running' && deviceUnreachState !== 'online') {
1300
+ deviceState = 'Offline'; //set online state to offline
1301
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1302
+ }
1303
+ } else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState !== 'running' && deviceUnreachState !== 'online') {
1304
+ deviceState = 'Offline'; //set online state to offline
1305
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1306
+ }
1296
1307
  break;
1297
1308
  case 'hmiP':
1298
1309
  case 'maxcube':
1299
- setOfflineState = (this.configMaxMinutes[adapterID] <= 0 && deviceUnreachState) || (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState);
1310
+ if (this.configMaxMinutes[adapterID] <= 0) {
1311
+ if (deviceUnreachState) {
1312
+ deviceState = 'Offline'; //set online state to offline
1313
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1314
+ }
1315
+ } else if (lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID] && deviceUnreachState) {
1316
+ deviceState = 'Offline'; //set online state to offline
1317
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1318
+ }
1300
1319
  break;
1301
1320
  case 'apcups':
1302
1321
  case 'hue':
@@ -1309,36 +1328,74 @@ class DeviceWatcher extends utils.Adapter {
1309
1328
  case 'unifi':
1310
1329
  case 'zigbee':
1311
1330
  case 'zigbee2MQTT':
1312
- setOfflineState = (this.configMaxMinutes[adapterID] <= 0 && !deviceUnreachState) || (!deviceUnreachState && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]);
1331
+ if (this.configMaxMinutes[adapterID] <= 0) {
1332
+ if (!deviceUnreachState) {
1333
+ deviceState = 'Offline'; //set online state to offline
1334
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1335
+ }
1336
+ } else if (!deviceUnreachState && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
1337
+ deviceState = 'Offline'; //set online state to offline
1338
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1339
+ }
1313
1340
  break;
1314
1341
  case 'mqttClientZigbee2Mqtt':
1315
- setOfflineState =
1316
- (this.configMaxMinutes[adapterID] <= 0 && deviceUnreachState !== 'online') ||
1317
- (deviceUnreachState !== 'online' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]);
1342
+ if (this.configMaxMinutes[adapterID] <= 0) {
1343
+ if (deviceUnreachState !== 'online') {
1344
+ deviceState = 'Offline'; //set online state to offline
1345
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1346
+ }
1347
+ } else if (deviceUnreachState !== 'online' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
1348
+ deviceState = 'Offline'; //set online state to offline
1349
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1350
+ }
1318
1351
  break;
1319
1352
  case 'mihome':
1320
1353
  if (deviceUnreachState !== undefined) {
1321
- setOfflineState = (this.configMaxMinutes[adapterID] <= 0 && !deviceUnreachState) || (lastContact && lastContact > this.configMaxMinutes[adapterID]);
1354
+ if (this.configMaxMinutes[adapterID] <= 0) {
1355
+ if (!deviceUnreachState) {
1356
+ deviceState = 'Offline'; //set online state to offline
1357
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1358
+ }
1359
+ } else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
1360
+ deviceState = 'Offline'; //set online state to offline
1361
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1362
+ }
1322
1363
  } else {
1323
- setOfflineState = (this.config.mihomeMaxMinutes <= 0 && this.configMaxMinutes[adapterID] <= 0) || (lastContact && lastContact > this.configMaxMinutes[adapterID]);
1364
+ if (this.config.mihomeMaxMinutes <= 0) {
1365
+ if (this.configMaxMinutes[adapterID] <= 0) {
1366
+ deviceState = 'Offline'; //set online state to offline
1367
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1368
+ }
1369
+ } else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
1370
+ deviceState = 'Offline'; //set online state to offline
1371
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1372
+ }
1324
1373
  }
1325
1374
  break;
1326
1375
  case 'smartgarden':
1327
- setOfflineState =
1328
- (this.configMaxMinutes[adapterID] <= 0 && deviceUnreachState === 'OFFLINE') ||
1329
- (deviceUnreachState === 'OFFLINE' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]);
1376
+ if (this.configMaxMinutes[adapterID] <= 0) {
1377
+ if (deviceUnreachState === 'OFFLINE') {
1378
+ deviceState = 'Offline'; //set online state to offline
1379
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1380
+ }
1381
+ } else if (deviceUnreachState === 'OFFLINE' && lastDeviceUnreachStateChange > this.configMaxMinutes[adapterID]) {
1382
+ deviceState = 'Offline'; //set online state to offline
1383
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1384
+ }
1330
1385
  break;
1331
1386
  default:
1332
- setOfflineState = (this.configMaxMinutes[adapterID] <= 0 && !deviceUnreachState) || (lastContact && lastContact > this.configMaxMinutes[adapterID]);
1387
+ if (this.configMaxMinutes[adapterID] <= 0) {
1388
+ if (!deviceUnreachState) {
1389
+ deviceState = 'Offline'; //set online state to offline
1390
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1391
+ }
1392
+ } else if (lastContact && lastContact > this.configMaxMinutes[adapterID]) {
1393
+ deviceState = 'Offline'; //set online state to offline
1394
+ if (linkQuality !== ' - ') linkQuality = '0%'; // set linkQuality to nothing
1395
+ }
1333
1396
  break;
1334
1397
  }
1335
-
1336
- if (setOfflineState) {
1337
- deviceState = 'Offline';
1338
- if (linkQuality !== ' - ' && !this.config.showLastSignal) linkQuality = '0%';
1339
- }
1340
1398
  }
1341
-
1342
1399
  return [lastContactString, deviceState, linkQuality];
1343
1400
  } catch (error) {
1344
1401
  this.log.error(`[getLastContact] - ${error}`);
@@ -1473,20 +1530,20 @@ class DeviceWatcher extends utils.Adapter {
1473
1530
  async theLists(device) {
1474
1531
  // Raw List with all devices for user
1475
1532
  this.listAllDevicesUserRaw.push({
1476
- [translations.Device[this.language]]: device.Device,
1477
- [translations.Adapter[this.language]]: device.Adapter,
1478
- [translations.Instance[this.language]]: device.instance,
1479
- [translations.Instance_connected[this.language]]: device.instancedeviceConnected,
1480
- [translations.isBatteryDevice[this.language]]: device.isBatteryDevice,
1481
- [translations.Battery[this.language]]: device.Battery,
1482
- [translations.BatteryRaw[this.language]]: device.BatteryRaw,
1483
- [translations.BatteryUnitRaw[this.language]]: device.BatteryUnitRaw,
1484
- [translations.isLowBat[this.language]]: device.LowBat,
1485
- [translations.Signal_strength[this.language]]: device.SignalStrength,
1486
- [translations.Signal_strength_Raw[this.language]]: device.SignalStrengthRaw,
1487
- [translations.Last_Contact[this.language]]: device.LastContact,
1488
- [translations.Update_Available[this.language]]: device.Upgradable,
1489
- [translations.Status[this.language]]: device.Status,
1533
+ Device: device.Device,
1534
+ Adapter: device.Adapter,
1535
+ Instance: device.instance,
1536
+ 'Instance connected': device.instancedeviceConnected,
1537
+ isBatteryDevice: device.isBatteryDevice,
1538
+ Battery: device.Battery,
1539
+ BatteryRaw: device.BatteryRaw,
1540
+ BatteryUnitRaw: device.BatteryUnitRaw,
1541
+ isLowBat: device.LowBat,
1542
+ 'Signal strength': device.SignalStrength,
1543
+ 'Signal strength Raw': device.SignalStrengthRaw,
1544
+ 'Last contact': device.LastContact,
1545
+ 'Update Available': device.Upgradable,
1546
+ Status: device.Status,
1490
1547
  });
1491
1548
 
1492
1549
  // List with all devices
@@ -1605,18 +1662,18 @@ class DeviceWatcher extends utils.Adapter {
1605
1662
  ];
1606
1663
  this.listAllDevicesUserRaw = [
1607
1664
  {
1608
- [translations.Device[this.language]]: '--none--',
1609
- [translations.Adapter[this.language]]: '',
1610
- [translations.Instance[this.language]]: '',
1611
- [translations.Instance_connected[this.language]]: '',
1612
- [translations.isBatteryDevice[this.language]]: '',
1613
- [translations.Battery[this.language]]: '',
1614
- [translations.BatteryRaw[this.language]]: '',
1615
- [translations.isLowBat[this.language]]: '',
1616
- [translations.Signal_strength[this.language]]: '',
1617
- [translations.Last_Contact[this.language]]: '',
1618
- [translations.Update_Available[this.language]]: '',
1619
- [translations.Status[this.language]]: '',
1665
+ Device: '--none--',
1666
+ Adapter: '',
1667
+ Instance: '',
1668
+ 'Instance connected': '',
1669
+ isBatteryDevice: '',
1670
+ Battery: '',
1671
+ BatteryRaw: '',
1672
+ isLowBat: '',
1673
+ 'Signal strength': '',
1674
+ 'Last contact': '',
1675
+ UpdateAvailable: '',
1676
+ Status: '',
1620
1677
  },
1621
1678
  ];
1622
1679
  }
@@ -2069,16 +2126,16 @@ class DeviceWatcher extends utils.Adapter {
2069
2126
  }
2070
2127
 
2071
2128
  let isHealthy = false;
2072
- let instanceStatusString = 'Instanz deaktiviert';
2129
+ let instanceStatusString = translations.instance_deactivated[this.language];
2073
2130
 
2074
2131
  if (isAlive) {
2075
2132
  if (connectedHostState && connectedDeviceState) {
2076
2133
  isHealthy = true;
2077
- instanceStatusString = 'Instanz okay';
2134
+ instanceStatusString = translations.instance_okay[this.language];
2078
2135
  } else if (!connectedHostState) {
2079
- instanceStatusString = 'Nicht verbunden mit Host';
2136
+ instanceStatusString = translations.not_connected_host[this.language];
2080
2137
  } else if (!connectedDeviceState) {
2081
- instanceStatusString = 'Nicht verbunden mit Gerät oder Dienst';
2138
+ instanceStatusString = translations.not_connected_device[this.language];
2082
2139
  }
2083
2140
  }
2084
2141
 
@@ -2094,7 +2151,7 @@ class DeviceWatcher extends utils.Adapter {
2094
2151
  let isAlive = await this.getInitValue(`system.adapter.${instanceID}.alive`);
2095
2152
  let daemonIsAlive;
2096
2153
  let isHealthy = false;
2097
- let instanceStatusString = isAlive ? 'Instanz aktiviert' : 'Instanz deaktiviert';
2154
+ let instanceStatusString = isAlive ? translations.instance_activated[this.language] : translations.instance_deactivated[this.language];
2098
2155
 
2099
2156
  if (isAlive) {
2100
2157
  daemonIsAlive = await this.checkDaemonIsHealthy(instanceID);
@@ -2121,7 +2178,7 @@ class DeviceWatcher extends utils.Adapter {
2121
2178
  let diff;
2122
2179
  let isAlive = false;
2123
2180
  let isHealthy = false;
2124
- let instanceStatusString = 'Instanz deaktiviert';
2181
+ let instanceStatusString = translations.instance_deactivated[this.language];
2125
2182
  const isAliveSchedule = await this.getForeignStateAsync(`system.adapter.${instanceID}.alive`);
2126
2183
 
2127
2184
  if (isAliveSchedule) {
@@ -2134,7 +2191,7 @@ class DeviceWatcher extends utils.Adapter {
2134
2191
  // if 5 minutes difference exceeded, instance is not alive
2135
2192
  isAlive = true;
2136
2193
  isHealthy = true;
2137
- instanceStatusString = 'Instanz okay';
2194
+ instanceStatusString = translations.instance_okay[this.language];
2138
2195
  }
2139
2196
  }
2140
2197
  }
@@ -2192,7 +2249,7 @@ class DeviceWatcher extends utils.Adapter {
2192
2249
 
2193
2250
  let isAlive = false;
2194
2251
  let isHealthy = false;
2195
- let instanceStatusString = 'Instanz deaktiviert';
2252
+ let instanceStatusString = translations.instance_deactivated[this.language];
2196
2253
 
2197
2254
  switch (instanceMode) {
2198
2255
  case 'schedule':
@@ -2985,7 +3042,7 @@ class DeviceWatcher extends utils.Adapter {
2985
3042
  switch (type) {
2986
3043
  case 'lowBatDevice':
2987
3044
  message = `${translations.Device_low_bat_detected[this.language]}: \n${adapterName} ${objectData.Device} (${objectData.Battery})`;
2988
- setMessage(message);
3045
+ await setMessage(message);
2989
3046
  break;
2990
3047
 
2991
3048
  case 'onlineStateDevice':
@@ -2998,12 +3055,12 @@ class DeviceWatcher extends utils.Adapter {
2998
3055
  message = `${translations.Device_not_reachable[this.language]}: \n${adapterName} ${objectData.Device} (${objectData.LastContact})`;
2999
3056
  break;
3000
3057
  }
3001
- setMessage(message);
3058
+ await setMessage(message);
3002
3059
  break;
3003
3060
 
3004
3061
  case 'updateDevice':
3005
3062
  message = `${translations.Device_new_updates[this.language]}: \n${adapterName} ${objectData.Device}`;
3006
- setMessage(message);
3063
+ await setMessage(message);
3007
3064
  break;
3008
3065
 
3009
3066
  case 'updateAdapter':
@@ -3011,14 +3068,14 @@ class DeviceWatcher extends utils.Adapter {
3011
3068
 
3012
3069
  list = objectData.map((id) => `${id.Adapter}: v${id['Available Version']}`).join('\n');
3013
3070
  message = `${translations.Adapter_new_updates[this.language]}: ${list}`;
3014
- setMessage(message);
3071
+ await setMessage(message);
3015
3072
  break;
3016
3073
 
3017
3074
  case 'errorInstance':
3018
3075
  case 'deactivatedInstance':
3019
3076
  objectData = this.listInstanceRaw.get(id);
3020
3077
  message = `${translations.Instance_Watchdog[this.language]}:\n${id}: ${objectData.status}`;
3021
- setMessage(message);
3078
+ await setMessage(message);
3022
3079
  break;
3023
3080
  }
3024
3081
  }
@@ -3055,7 +3112,7 @@ class DeviceWatcher extends utils.Adapter {
3055
3112
  }
3056
3113
  };
3057
3114
 
3058
- const processNotification = (list, messageType) => {
3115
+ const processNotification = async (list, messageType) => {
3059
3116
  if (list.length === 0) return;
3060
3117
 
3061
3118
  switch (checkDays.length) {
@@ -3070,7 +3127,7 @@ class DeviceWatcher extends utils.Adapter {
3070
3127
  break;
3071
3128
  }
3072
3129
 
3073
- setMessage(message);
3130
+ await setMessage(message);
3074
3131
  };
3075
3132
 
3076
3133
  switch (type) {
@@ -3083,10 +3140,10 @@ class DeviceWatcher extends utils.Adapter {
3083
3140
  }
3084
3141
  this.log.debug(`Number of selected days for daily low battery devices message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3085
3142
 
3086
- schedule.scheduleJob(`1 ${this.config.checkSendBatteryTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3143
+ schedule.scheduleJob(`1 ${this.config.checkSendBatteryTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3087
3144
  processDeviceList(this.batteryLowPoweredRaw, 'Device', 'Battery');
3088
3145
 
3089
- processNotification(list, 'devices_low_bat');
3146
+ await processNotification(list, 'devices_low_bat');
3090
3147
  });
3091
3148
  break;
3092
3149
 
@@ -3099,10 +3156,10 @@ class DeviceWatcher extends utils.Adapter {
3099
3156
  }
3100
3157
  this.log.debug(`Number of selected days for daily offline devices message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3101
3158
 
3102
- schedule.scheduleJob(`2 ${this.config.checkSendOfflineTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3159
+ schedule.scheduleJob(`2 ${this.config.checkSendOfflineTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3103
3160
  processDeviceList(this.offlineDevicesRaw, `Device`, 'LastContact');
3104
3161
 
3105
- processNotification(list, 'offline_devices');
3162
+ await processNotification(list, 'offline_devices');
3106
3163
  });
3107
3164
  break;
3108
3165
 
@@ -3115,10 +3172,10 @@ class DeviceWatcher extends utils.Adapter {
3115
3172
  }
3116
3173
  this.log.debug(`Number of selected days for daily updatable devices message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3117
3174
 
3118
- schedule.scheduleJob(`3 ${this.config.checkSendUpgradeTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3175
+ schedule.scheduleJob(`3 ${this.config.checkSendUpgradeTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3119
3176
  processDeviceList(this.upgradableDevicesRaw, 'Device');
3120
3177
 
3121
- processNotification(list, 'available_updatable_devices');
3178
+ await processNotification(list, 'available_updatable_devices');
3122
3179
  });
3123
3180
  break;
3124
3181
 
@@ -3131,10 +3188,10 @@ class DeviceWatcher extends utils.Adapter {
3131
3188
  }
3132
3189
  this.log.debug(`Number of selected days for daily adapter update message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3133
3190
 
3134
- schedule.scheduleJob(`4 ${this.config.checkSendAdapterUpdateTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3191
+ schedule.scheduleJob(`4 ${this.config.checkSendAdapterUpdateTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3135
3192
  processDeviceList(this.listAdapterUpdates, translations.Adapter[this.language], translations.Available_Version[this.language]);
3136
3193
 
3137
- processNotification(list, 'available_adapter_update');
3194
+ await processNotification(list, 'available_adapter_update');
3138
3195
  });
3139
3196
  break;
3140
3197
 
@@ -3147,10 +3204,10 @@ class DeviceWatcher extends utils.Adapter {
3147
3204
  }
3148
3205
  this.log.debug(`Number of selected days for daily instance error message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3149
3206
 
3150
- schedule.scheduleJob(`5 ${this.config.checkSendInstanceFailedTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3207
+ schedule.scheduleJob(`5 ${this.config.checkSendInstanceFailedTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3151
3208
  processInstanceList(this.listErrorInstanceRaw, 'Status');
3152
3209
 
3153
- processNotification(list, 'error_instances_msg');
3210
+ await processNotification(list, 'error_instances_msg');
3154
3211
  });
3155
3212
  break;
3156
3213
 
@@ -3163,10 +3220,10 @@ class DeviceWatcher extends utils.Adapter {
3163
3220
  }
3164
3221
  this.log.debug(`Number of selected days for daily instance deactivated message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3165
3222
 
3166
- schedule.scheduleJob(`5 ${this.config.checkSendInstanceDeactivatedTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, () => {
3223
+ schedule.scheduleJob(`5 ${this.config.checkSendInstanceDeactivatedTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3167
3224
  processInstanceList(this.listDeactivatedInstances);
3168
3225
 
3169
- processNotification(list, 'deactivated_instances_msg');
3226
+ await processNotification(list, 'deactivated_instances_msg');
3170
3227
  });
3171
3228
  break;
3172
3229
  }
@@ -3362,11 +3419,11 @@ class DeviceWatcher extends utils.Adapter {
3362
3419
  <td colspan="5"><hr></td>
3363
3420
  </tr>`;
3364
3421
 
3365
- for (const [instance, instanceData] of instances) {
3422
+ for (const instance of instances) {
3366
3423
  html += `<tr>
3367
- <td><font>${instanceData.Adapter}</font></td>
3368
- <td align=center><font>${instance}</font></td>
3369
- <td align=center><font color=orange>${instanceData.status}</font></td>
3424
+ <td><font>${instance.Adapter}</font></td>
3425
+ <td align=center><font>${instance.Instance}</font></td>
3426
+ <td align=center><font color=orange>${instance.Status}</font></td>
3370
3427
  </tr>`;
3371
3428
  }
3372
3429
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.device-watcher",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "Watchdog for devices",
5
5
  "author": {
6
6
  "name": "Christian Behrends",
@@ -42,6 +42,8 @@
42
42
  "@types/proxyquire": "^1.3.31",
43
43
  "@types/sinon": "^17.0.2",
44
44
  "@types/sinon-chai": "^3.2.12",
45
+ "@typescript-eslint/eslint-plugin": "^6.18.1",
46
+ "@typescript-eslint/parser": "^6.18.1",
45
47
  "chai": "^4.3.10",
46
48
  "chai-as-promised": "^7.1.1",
47
49
  "cron-parser": "^4.9.0",