iobroker.device-watcher 2.10.1 → 2.10.3

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/main.js CHANGED
@@ -80,8 +80,12 @@ class DeviceWatcher extends utils.Adapter {
80
80
  // Interval timer
81
81
  this.refreshDataTimeout = null;
82
82
 
83
+ // Check if main function is running
83
84
  this.mainRunning = false;
84
85
 
86
+ // System anguage
87
+ this.userSystemLanguage;
88
+
85
89
  this.on('ready', this.onReady.bind(this));
86
90
  this.on('stateChange', this.onStateChange.bind(this));
87
91
  this.on('objectChange', this.onObjectChange.bind(this));
@@ -95,6 +99,13 @@ class DeviceWatcher extends utils.Adapter {
95
99
  async onReady() {
96
100
  this.log.debug(`Adapter ${adapterName} was started`);
97
101
 
102
+ // set user language
103
+ if (this.userSystemLanguage === undefined && this.userSystemLanguage === null) {
104
+ this.userSystemLanguage = 'de';
105
+ } else {
106
+ this.userSystemLanguage = this.language;
107
+ }
108
+
98
109
  this.configCreateInstanceList = this.config.checkAdapterInstances;
99
110
  this.configListOnlyBattery = this.config.listOnlyBattery;
100
111
  this.configCreateOwnFolder = this.config.createOwnFolder;
@@ -383,7 +394,7 @@ class DeviceWatcher extends utils.Adapter {
383
394
  */
384
395
  async onStateChange(id, state) {
385
396
  if (state) {
386
- // this.log.debug(`State changed: ${id} changed ${state.val}`);
397
+ this.log.debug(`State changed: ${id} changed ${state.val}`);
387
398
 
388
399
  try {
389
400
  /*=============================================
@@ -616,7 +627,7 @@ class DeviceWatcher extends utils.Adapter {
616
627
  this.log.error(`[createBlacklist] - ${error}`);
617
628
  }
618
629
  if (this.blacklistLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistLists}`);
619
- if (this.blacklistAdapterLists.length >= 1) this.log.info(`Found devices/services on blacklist for lists: ${this.blacklistAdapterLists}`);
630
+ if (this.blacklistAdapterLists.length >= 1) this.log.info(`Found devices/services on blacklist for own adapter lists: ${this.blacklistAdapterLists}`);
620
631
  if (this.blacklistNotify.length >= 1) this.log.info(`Found devices/services on blacklist for notifications: ${this.blacklistNotify}`);
621
632
  }
622
633
  }
@@ -1212,10 +1223,10 @@ class DeviceWatcher extends utils.Adapter {
1212
1223
 
1213
1224
  lastContactString = `${this.formatDate(new Date(selector), 'hh:mm')}`;
1214
1225
  if (Math.round(lastContact) > 100) {
1215
- lastContactString = `${Math.round(lastContact / 60)} ${translations.hours[this.language]}`;
1226
+ lastContactString = `${Math.round(lastContact / 60)} ${translations.hours[this.userSystemLanguage]}`;
1216
1227
  }
1217
1228
  if (Math.round(lastContact / 60) > 48) {
1218
- lastContactString = `${Math.round(lastContact / 60 / 24)} ${translations.days[this.language]}`;
1229
+ lastContactString = `${Math.round(lastContact / 60 / 24)} ${translations.days[this.userSystemLanguage]}`;
1219
1230
  }
1220
1231
  return lastContactString;
1221
1232
  }
@@ -1425,7 +1436,7 @@ class DeviceWatcher extends utils.Adapter {
1425
1436
  deviceData.linkQuality = contactData[2];
1426
1437
  }
1427
1438
  if (this.config.checkSendOfflineMsg && oldContactState !== deviceData.Status && !this.blacklistNotify.includes(deviceData.Path)) {
1428
- await this.sendStateNotifications('onlineStateDevice', device);
1439
+ await this.sendStateNotifications('Devices', 'onlineStateDevice', device);
1429
1440
  }
1430
1441
  }
1431
1442
  }
@@ -1548,56 +1559,56 @@ class DeviceWatcher extends utils.Adapter {
1548
1559
 
1549
1560
  // List with all devices
1550
1561
  this.listAllDevices.push({
1551
- [translations.Device[this.language]]: device.Device,
1552
- [translations.Adapter[this.language]]: device.Adapter,
1553
- [translations.Battery[this.language]]: device.Battery,
1554
- [translations.Signal_strength[this.language]]: device.SignalStrength,
1555
- [translations.Last_Contact[this.language]]: device.LastContact,
1556
- [translations.Status[this.language]]: device.Status,
1562
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1563
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1564
+ [translations.Battery[this.userSystemLanguage]]: device.Battery,
1565
+ [translations.Signal_strength[this.userSystemLanguage]]: device.SignalStrength,
1566
+ [translations.Last_Contact[this.userSystemLanguage]]: device.LastContact,
1567
+ [translations.Status[this.userSystemLanguage]]: device.Status,
1557
1568
  });
1558
1569
 
1559
1570
  // LinkQuality lists
1560
1571
  if (device.SignalStrength != ' - ') {
1561
1572
  this.linkQualityDevices.push({
1562
- [translations.Device[this.language]]: device.Device,
1563
- [translations.Adapter[this.language]]: device.Adapter,
1564
- [translations.Signal_strength[this.language]]: device.SignalStrength,
1573
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1574
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1575
+ [translations.Signal_strength[this.userSystemLanguage]]: device.SignalStrength,
1565
1576
  });
1566
1577
  }
1567
1578
 
1568
1579
  // Battery lists
1569
1580
  if (device.isBatteryDevice) {
1570
1581
  this.batteryPowered.push({
1571
- [translations.Device[this.language]]: device.Device,
1572
- [translations.Adapter[this.language]]: device.Adapter,
1573
- [translations.Battery[this.language]]: device.Battery,
1574
- [translations.Status[this.language]]: device.Status,
1582
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1583
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1584
+ [translations.Battery[this.userSystemLanguage]]: device.Battery,
1585
+ [translations.Status[this.userSystemLanguage]]: device.Status,
1575
1586
  });
1576
1587
  }
1577
1588
 
1578
1589
  // Low Bat lists
1579
1590
  if (device.LowBat && device.Status !== 'Offline') {
1580
1591
  this.batteryLowPowered.push({
1581
- [translations.Device[this.language]]: device.Device,
1582
- [translations.Adapter[this.language]]: device.Adapter,
1583
- [translations.Battery[this.language]]: device.Battery,
1592
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1593
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1594
+ [translations.Battery[this.userSystemLanguage]]: device.Battery,
1584
1595
  });
1585
1596
  }
1586
1597
 
1587
1598
  // Offline List
1588
1599
  if (device.Status === 'Offline') {
1589
1600
  this.offlineDevices.push({
1590
- [translations.Device[this.language]]: device.Device,
1591
- [translations.Adapter[this.language]]: device.Adapter,
1592
- [translations.Last_Contact[this.language]]: device.LastContact,
1601
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1602
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1603
+ [translations.Last_Contact[this.userSystemLanguage]]: device.LastContact,
1593
1604
  });
1594
1605
  }
1595
1606
 
1596
1607
  // Device update List
1597
1608
  if (device.Upgradable === true || device.Upgradable === 1) {
1598
1609
  this.upgradableList.push({
1599
- [translations.Device[this.language]]: device.Device,
1600
- [translations.Adapter[this.language]]: device.Adapter,
1610
+ [translations.Device[this.userSystemLanguage]]: device.Device,
1611
+ [translations.Adapter[this.userSystemLanguage]]: device.Adapter,
1601
1612
  });
1602
1613
  }
1603
1614
  }
@@ -1652,12 +1663,12 @@ class DeviceWatcher extends utils.Adapter {
1652
1663
  // if no device is count, write the JSON List with default value
1653
1664
  this.listAllDevices = [
1654
1665
  {
1655
- [translations.Device[this.language]]: '--none--',
1656
- [translations.Adapter[this.language]]: '',
1657
- [translations.Battery[this.language]]: '',
1658
- [translations.Signal_strength[this.language]]: '',
1659
- [translations.Last_Contact[this.language]]: '',
1660
- [translations.Status[this.language]]: '',
1666
+ [translations.Device[this.userSystemLanguage]]: '--none--',
1667
+ [translations.Adapter[this.userSystemLanguage]]: '',
1668
+ [translations.Battery[this.userSystemLanguage]]: '',
1669
+ [translations.Signal_strength[this.userSystemLanguage]]: '',
1670
+ [translations.Last_Contact[this.userSystemLanguage]]: '',
1671
+ [translations.Status[this.userSystemLanguage]]: '',
1661
1672
  },
1662
1673
  ];
1663
1674
  this.listAllDevicesUserRaw = [
@@ -1685,9 +1696,9 @@ class DeviceWatcher extends utils.Adapter {
1685
1696
  // if no device is count, write the JSON List with default value
1686
1697
  this.linkQualityDevices = [
1687
1698
  {
1688
- [translations.Device[this.language]]: '--none--',
1689
- [translations.Adapter[this.language]]: '',
1690
- [translations.Signal_strength[this.language]]: '',
1699
+ [translations.Device[this.userSystemLanguage]]: '--none--',
1700
+ [translations.Adapter[this.userSystemLanguage]]: '',
1701
+ [translations.Signal_strength[this.userSystemLanguage]]: '',
1691
1702
  },
1692
1703
  ];
1693
1704
  }
@@ -1702,9 +1713,9 @@ class DeviceWatcher extends utils.Adapter {
1702
1713
  // if no device is count, write the JSON List with default value
1703
1714
  this.offlineDevices = [
1704
1715
  {
1705
- [translations.Device[this.language]]: '--none--',
1706
- [translations.Adapter[this.language]]: '',
1707
- [translations.Last_Contact[this.language]]: '',
1716
+ [translations.Device[this.userSystemLanguage]]: '--none--',
1717
+ [translations.Adapter[this.userSystemLanguage]]: '',
1718
+ [translations.Last_Contact[this.userSystemLanguage]]: '',
1708
1719
  },
1709
1720
  ];
1710
1721
  }
@@ -1719,9 +1730,9 @@ class DeviceWatcher extends utils.Adapter {
1719
1730
  // if no device is count, write the JSON List with default value
1720
1731
  this.upgradableList = [
1721
1732
  {
1722
- [translations.Device[this.language]]: '--none--',
1723
- [translations.Adapter[this.language]]: '',
1724
- [translations.Last_Contact[this.language]]: '',
1733
+ [translations.Device[this.userSystemLanguage]]: '--none--',
1734
+ [translations.Adapter[this.userSystemLanguage]]: '',
1735
+ [translations.Last_Contact[this.userSystemLanguage]]: '',
1725
1736
  },
1726
1737
  ];
1727
1738
  }
@@ -1734,7 +1745,9 @@ class DeviceWatcher extends utils.Adapter {
1734
1745
  // List battery powered
1735
1746
  if (this.batteryPoweredCount === 0) {
1736
1747
  // if no device is count, write the JSON List with default value
1737
- this.batteryPowered = [{ [translations.Device[this.language]]: '--none--', [translations.Adapter[this.language]]: '', [translations.Battery[this.language]]: '' }];
1748
+ this.batteryPowered = [
1749
+ { [translations.Device[this.userSystemLanguage]]: '--none--', [translations.Adapter[this.userSystemLanguage]]: '', [translations.Battery[this.userSystemLanguage]]: '' },
1750
+ ];
1738
1751
  }
1739
1752
  //write JSON list
1740
1753
  await this.setStateChangedAsync(`devices.${dpSubFolder}batteryList`, {
@@ -1745,7 +1758,9 @@ class DeviceWatcher extends utils.Adapter {
1745
1758
  // list battery low powered
1746
1759
  if (this.lowBatteryPoweredCount === 0) {
1747
1760
  // if no device is count, write the JSON List with default value
1748
- this.batteryLowPowered = [{ [translations.Device[this.language]]: '--none--', [translations.Adapter[this.language]]: '', [translations.Battery[this.language]]: '' }];
1761
+ this.batteryLowPowered = [
1762
+ { [translations.Device[this.userSystemLanguage]]: '--none--', [translations.Adapter[this.userSystemLanguage]]: '', [translations.Battery[this.userSystemLanguage]]: '' },
1763
+ ];
1749
1764
  }
1750
1765
  //write JSON list
1751
1766
  await this.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryList`, {
@@ -1797,7 +1812,7 @@ class DeviceWatcher extends utils.Adapter {
1797
1812
  ack: true,
1798
1813
  });
1799
1814
  await this.setStateChangedAsync(`devices.${dpSubFolder}offlineListHTML`, {
1800
- val: await this.createListHTML('offlineList', this.offlineDevicesRaw, this.offlineDevicesCount, null),
1815
+ val: await this.createListHTML('offlineList', this.offlineDevices, this.offlineDevicesCount, null),
1801
1816
  ack: true,
1802
1817
  });
1803
1818
  await this.setStateChangedAsync(`devices.${dpSubFolder}batteryListHTML`, {
@@ -1810,23 +1825,23 @@ class DeviceWatcher extends utils.Adapter {
1810
1825
  });
1811
1826
  if (this.config.checkAdapterInstances) {
1812
1827
  await this.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`, {
1813
- val: await this.createListHTMLInstances('allInstancesList', this.listInstanceRaw, this.countAllInstances),
1828
+ val: await this.createListHTMLInstances('allInstancesList', this.listAllInstances, this.countAllInstances),
1814
1829
  ack: true,
1815
1830
  });
1816
1831
  await this.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`, {
1817
- val: await this.createListHTMLInstances('allActiveInstancesList', this.listInstanceRaw, this.countAllActiveInstances),
1832
+ val: await this.createListHTMLInstances('allActiveInstancesList', this.listAllActiveInstances, this.countAllActiveInstances),
1818
1833
  ack: true,
1819
1834
  });
1820
1835
  await this.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`, {
1821
- val: await this.createListHTMLInstances('errorInstanceList', this.listErrorInstanceRaw, this.countErrorInstance),
1836
+ val: await this.createListHTMLInstances('errorInstanceList', this.listErrorInstance, this.countErrorInstance),
1822
1837
  ack: true,
1823
1838
  });
1824
1839
  await this.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`, {
1825
- val: await this.createListHTMLInstances('deactivatedInstanceList', this.listInstanceRaw, this.countDeactivatedInstances),
1840
+ val: await this.createListHTMLInstances('deactivatedInstanceList', this.listDeactivatedInstances, this.countDeactivatedInstances),
1826
1841
  ack: true,
1827
1842
  });
1828
1843
  await this.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`, {
1829
- val: await this.createListHTMLInstances('updateAdapterList', this.listInstanceRaw, this.countAdapterUpdates),
1844
+ val: await this.createListHTMLInstances('updateAdapterList', this.listAdapterUpdates, this.countAdapterUpdates),
1830
1845
  ack: true,
1831
1846
  });
1832
1847
  }
@@ -1872,7 +1887,7 @@ class DeviceWatcher extends utils.Adapter {
1872
1887
  deviceData.Upgradable = await this.checkDeviceUpdate(deviceData.adapterID, state.val);
1873
1888
  if (deviceData.Upgradable === true) {
1874
1889
  if (this.config.checkSendDeviceUpgrade && !this.blacklistNotify.includes(deviceData.Path)) {
1875
- await this.sendStateNotifications('updateDevice', deviceID);
1890
+ await this.sendStateNotifications('Devices', 'updateDevice', deviceID);
1876
1891
  }
1877
1892
  }
1878
1893
  }
@@ -1904,7 +1919,7 @@ class DeviceWatcher extends utils.Adapter {
1904
1919
 
1905
1920
  if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
1906
1921
  if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
1907
- await this.sendStateNotifications('lowBatDevice', deviceID);
1922
+ await this.sendStateNotifications('Devices', 'lowBatDevice', deviceID);
1908
1923
  }
1909
1924
  }
1910
1925
  }
@@ -1922,7 +1937,7 @@ class DeviceWatcher extends utils.Adapter {
1922
1937
 
1923
1938
  if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
1924
1939
  if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
1925
- await this.sendStateNotifications('lowBatDevice', deviceID);
1940
+ await this.sendStateNotifications('Devices', 'lowBatDevice', deviceID);
1926
1941
  }
1927
1942
  }
1928
1943
  }
@@ -1941,7 +1956,7 @@ class DeviceWatcher extends utils.Adapter {
1941
1956
 
1942
1957
  if (deviceData.LowBat && oldLowBatState !== deviceData.LowBat) {
1943
1958
  if (this.config.checkSendBatteryMsg && !this.blacklistNotify.includes(deviceData.Path)) {
1944
- await this.sendStateNotifications('lowBatDevice', deviceID);
1959
+ await this.sendStateNotifications('Devices', 'lowBatDevice', deviceID);
1945
1960
  }
1946
1961
  }
1947
1962
  }
@@ -1972,10 +1987,10 @@ class DeviceWatcher extends utils.Adapter {
1972
1987
  if (deviceData.instanceDeviceConnectionDP.val !== undefined) {
1973
1988
  // check if the generally deviceData connected state is for a while true
1974
1989
  if (await this.getTimestampConnectionDP(deviceData.instanceDeviceConnectionDP, 20000)) {
1975
- await this.sendStateNotifications('onlineStateDevice', deviceID);
1990
+ await this.sendStateNotifications('Devices', 'onlineStateDevice', deviceID);
1976
1991
  }
1977
1992
  } else {
1978
- await this.sendStateNotifications('onlineStateDevice', deviceID);
1993
+ await this.sendStateNotifications('Devices', 'onlineStateDevice', deviceID);
1979
1994
  }
1980
1995
  }
1981
1996
  }
@@ -2126,16 +2141,16 @@ class DeviceWatcher extends utils.Adapter {
2126
2141
  }
2127
2142
 
2128
2143
  let isHealthy = false;
2129
- let instanceStatusString = translations.instance_deactivated[this.language];
2144
+ let instanceStatusString = translations.instance_deactivated[this.userSystemLanguage];
2130
2145
 
2131
2146
  if (isAlive) {
2132
2147
  if (connectedHostState && connectedDeviceState) {
2133
2148
  isHealthy = true;
2134
- instanceStatusString = translations.instance_okay[this.language];
2149
+ instanceStatusString = translations.instance_okay[this.userSystemLanguage];
2135
2150
  } else if (!connectedHostState) {
2136
- instanceStatusString = translations.not_connected_host[this.language];
2151
+ instanceStatusString = translations.not_connected_host[this.userSystemLanguage];
2137
2152
  } else if (!connectedDeviceState) {
2138
- instanceStatusString = translations.not_connected_device[this.language];
2153
+ instanceStatusString = translations.not_connected_device[this.userSystemLanguage];
2139
2154
  }
2140
2155
  }
2141
2156
 
@@ -2151,7 +2166,7 @@ class DeviceWatcher extends utils.Adapter {
2151
2166
  let isAlive = await this.getInitValue(`system.adapter.${instanceID}.alive`);
2152
2167
  let daemonIsAlive;
2153
2168
  let isHealthy = false;
2154
- let instanceStatusString = isAlive ? translations.instance_activated[this.language] : translations.instance_deactivated[this.language];
2169
+ let instanceStatusString = isAlive ? translations.instance_activated[this.userSystemLanguage] : translations.instance_deactivated[this.userSystemLanguage];
2155
2170
 
2156
2171
  if (isAlive) {
2157
2172
  daemonIsAlive = await this.checkDaemonIsHealthy(instanceID);
@@ -2178,7 +2193,7 @@ class DeviceWatcher extends utils.Adapter {
2178
2193
  let diff;
2179
2194
  let isAlive = false;
2180
2195
  let isHealthy = false;
2181
- let instanceStatusString = translations.instance_deactivated[this.language];
2196
+ let instanceStatusString = translations.instance_deactivated[this.userSystemLanguage];
2182
2197
  const isAliveSchedule = await this.getForeignStateAsync(`system.adapter.${instanceID}.alive`);
2183
2198
 
2184
2199
  if (isAliveSchedule) {
@@ -2191,7 +2206,7 @@ class DeviceWatcher extends utils.Adapter {
2191
2206
  // if 5 minutes difference exceeded, instance is not alive
2192
2207
  isAlive = true;
2193
2208
  isHealthy = true;
2194
- instanceStatusString = translations.instance_okay[this.language];
2209
+ instanceStatusString = translations.instance_okay[this.userSystemLanguage];
2195
2210
  }
2196
2211
  }
2197
2212
  }
@@ -2249,7 +2264,7 @@ class DeviceWatcher extends utils.Adapter {
2249
2264
 
2250
2265
  let isAlive = false;
2251
2266
  let isHealthy = false;
2252
- let instanceStatusString = translations.instance_deactivated[this.language];
2267
+ let instanceStatusString = translations.instance_deactivated[this.userSystemLanguage];
2253
2268
 
2254
2269
  switch (instanceMode) {
2255
2270
  case 'schedule':
@@ -2324,9 +2339,9 @@ class DeviceWatcher extends utils.Adapter {
2324
2339
 
2325
2340
  for (const [adapter, updateData] of this.adapterUpdatesJsonRaw) {
2326
2341
  this.listAdapterUpdates.push({
2327
- [translations.Adapter[this.language]]: adapter,
2328
- 'Available Version': updateData.newVersion,
2329
- 'Installed Version': updateData.oldVersion,
2342
+ [translations.Adapter[this.userSystemLanguage]]: adapter,
2343
+ [translations.Available_Version[this.userSystemLanguage]]: updateData.newVersion,
2344
+ [translations.Installed_Version[this.userSystemLanguage]]: updateData.oldVersion,
2330
2345
  });
2331
2346
  }
2332
2347
  this.countAdapterUpdates = this.listAdapterUpdates.length;
@@ -2340,9 +2355,14 @@ class DeviceWatcher extends utils.Adapter {
2340
2355
  // Write Datapoints for counts
2341
2356
  await this.setStateChangedAsync(`adapterAndInstances.countAdapterUpdates`, { val: this.countAdapterUpdates, ack: true });
2342
2357
 
2343
- // list deactivated instances
2344
2358
  if (this.countAdapterUpdates === 0) {
2345
- this.listAdapterUpdates = [{ [translations.Adapter[this.language]]: '--none--', 'Available Version': '', 'Installed Version': '' }];
2359
+ this.listAdapterUpdates = [
2360
+ {
2361
+ [translations.Adapter[this.userSystemLanguage]]: '--none--',
2362
+ [translations.Available_Version[this.userSystemLanguage]]: '',
2363
+ [translations.Installed_Version[this.userSystemLanguage]]: '',
2364
+ },
2365
+ ];
2346
2366
  }
2347
2367
  await this.setStateChangedAsync(`adapterAndInstances.listAdapterUpdates`, { val: JSON.stringify(this.listAdapterUpdates), ack: true });
2348
2368
  }
@@ -2371,40 +2391,40 @@ class DeviceWatcher extends utils.Adapter {
2371
2391
  if (this.blacklistInstancesLists.includes(instance)) continue;
2372
2392
  // all instances
2373
2393
  this.listAllInstances.push({
2374
- [translations.Adapter[this.language]]: instanceData.Adapter,
2375
- [translations.Instance[this.language]]: instance,
2376
- [translations.Mode[this.language]]: instanceData.instanceMode,
2377
- [translations.Schedule[this.language]]: instanceData.schedule,
2378
- [translations.Version[this.language]]: instanceData.adapterVersion,
2379
- [translations.Updateable[this.language]]: instanceData.updateAvailable,
2380
- [translations.Status[this.language]]: instanceData.status,
2394
+ [translations.Adapter[this.userSystemLanguage]]: instanceData.Adapter,
2395
+ [translations.Instance[this.userSystemLanguage]]: instance,
2396
+ [translations.Mode[this.userSystemLanguage]]: instanceData.instanceMode,
2397
+ [translations.Schedule[this.userSystemLanguage]]: instanceData.schedule,
2398
+ [translations.Version[this.userSystemLanguage]]: instanceData.adapterVersion,
2399
+ [translations.Updateable[this.userSystemLanguage]]: instanceData.updateAvailable,
2400
+ [translations.Status[this.userSystemLanguage]]: instanceData.status,
2381
2401
  });
2382
2402
 
2383
2403
  if (!instanceData.isAlive) {
2384
2404
  // list with deactivated instances
2385
2405
  this.listDeactivatedInstances.push({
2386
- [translations.Adapter[this.language]]: instanceData.Adapter,
2387
- [translations.Instance[this.language]]: instance,
2388
- [translations.Status[this.language]]: instanceData.status,
2406
+ [translations.Adapter[this.userSystemLanguage]]: instanceData.Adapter,
2407
+ [translations.Instance[this.userSystemLanguage]]: instance,
2408
+ [translations.Status[this.userSystemLanguage]]: instanceData.status,
2389
2409
  });
2390
2410
  } else {
2391
2411
  // list with active instances
2392
2412
  this.listAllActiveInstances.push({
2393
- [translations.Adapter[this.language]]: instanceData.Adapter,
2394
- [translations.Instance[this.language]]: instance,
2395
- [translations.Mode[this.language]]: instanceData.instanceMode,
2396
- [translations.Schedule[this.language]]: instanceData.schedule,
2397
- [translations.Status[this.language]]: instanceData.status,
2413
+ [translations.Adapter[this.userSystemLanguage]]: instanceData.Adapter,
2414
+ [translations.Instance[this.userSystemLanguage]]: instance,
2415
+ [translations.Mode[this.userSystemLanguage]]: instanceData.instanceMode,
2416
+ [translations.Schedule[this.userSystemLanguage]]: instanceData.schedule,
2417
+ [translations.Status[this.userSystemLanguage]]: instanceData.status,
2398
2418
  });
2399
2419
  }
2400
2420
 
2401
2421
  // list with error instances
2402
2422
  if (instanceData.isAlive && !instanceData.isHealthy) {
2403
2423
  this.listErrorInstance.push({
2404
- [translations.Adapter[this.language]]: instanceData.Adapter,
2405
- [translations.Instance[this.language]]: instance,
2406
- [translations.Mode[this.language]]: instanceData.instanceMode,
2407
- [translations.Status[this.language]]: instanceData.status,
2424
+ [translations.Adapter[this.userSystemLanguage]]: instanceData.Adapter,
2425
+ [translations.Instance[this.userSystemLanguage]]: instance,
2426
+ [translations.Mode[this.userSystemLanguage]]: instanceData.instanceMode,
2427
+ [translations.Status[this.userSystemLanguage]]: instanceData.status,
2408
2428
  });
2409
2429
  }
2410
2430
  }
@@ -2441,7 +2461,12 @@ class DeviceWatcher extends utils.Adapter {
2441
2461
  // list deactivated instances
2442
2462
  if (this.countDeactivatedInstances === 0) {
2443
2463
  this.listDeactivatedInstances = [
2444
- { [translations.Adapter[this.language]]: '--none--', [translations.Instance[this.language]]: '', [translations.Version[this.language]]: '', [translations.Status[this.language]]: '' },
2464
+ {
2465
+ [translations.Adapter[this.userSystemLanguage]]: '--none--',
2466
+ [translations.Instance[this.userSystemLanguage]]: '',
2467
+ [translations.Version[this.userSystemLanguage]]: '',
2468
+ [translations.Status[this.userSystemLanguage]]: '',
2469
+ },
2445
2470
  ];
2446
2471
  }
2447
2472
  await this.setStateChangedAsync(`adapterAndInstances.listDeactivatedInstances`, { val: JSON.stringify(this.listDeactivatedInstances), ack: true });
@@ -2450,7 +2475,12 @@ class DeviceWatcher extends utils.Adapter {
2450
2475
  // list error instances
2451
2476
  if (this.countErrorInstance === 0) {
2452
2477
  this.listErrorInstance = [
2453
- { [translations.Adapter[this.language]]: '--none--', [translations.Instance[this.language]]: '', [translations.Mode[this.language]]: '', [translations.Status[this.language]]: '' },
2478
+ {
2479
+ [translations.Adapter[this.userSystemLanguage]]: '--none--',
2480
+ [translations.Instance[this.userSystemLanguage]]: '',
2481
+ [translations.Mode[this.userSystemLanguage]]: '',
2482
+ [translations.Status[this.userSystemLanguage]]: '',
2483
+ },
2454
2484
  ];
2455
2485
  }
2456
2486
  await this.setStateChangedAsync(`adapterAndInstances.listInstancesError`, { val: JSON.stringify(this.listErrorInstance), ack: true });
@@ -2469,7 +2499,7 @@ class DeviceWatcher extends utils.Adapter {
2469
2499
 
2470
2500
  // Check and send update notification if required
2471
2501
  if (this.config.checkSendAdapterUpdateMsg && this.countAdapterUpdates > previousAdapterUpdatesCount) {
2472
- await this.sendStateNotifications('updateAdapter', null);
2502
+ await this.sendStateNotifications('AdapterUpdates', 'updateAdapter', null);
2473
2503
  }
2474
2504
 
2475
2505
  // Update instances with available adapter updates
@@ -2512,7 +2542,7 @@ class DeviceWatcher extends utils.Adapter {
2512
2542
  // send message when instance was deactivated
2513
2543
  if (this.config.checkSendInstanceDeactivatedMsg && !instanceData.isAlive) {
2514
2544
  if (this.blacklistInstancesNotify.includes(instanceID)) return;
2515
- await this.sendStateNotifications('deactivatedInstance', instanceID);
2545
+ await this.sendStateNotifications('Instances', 'deactivatedInstance', instanceID);
2516
2546
  }
2517
2547
  }
2518
2548
  break;
@@ -2523,7 +2553,7 @@ class DeviceWatcher extends utils.Adapter {
2523
2553
  // send message when instance has an error
2524
2554
  if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
2525
2555
  if (this.blacklistInstancesNotify.includes(instanceID)) return;
2526
- await this.sendStateNotifications('errorInstance', instanceID);
2556
+ await this.sendStateNotifications('Instances', 'errorInstance', instanceID);
2527
2557
  }
2528
2558
  }
2529
2559
  break;
@@ -2534,7 +2564,7 @@ class DeviceWatcher extends utils.Adapter {
2534
2564
  // send message when instance has an error
2535
2565
  if (this.config.checkSendInstanceFailedMsg && !instanceData.isHealthy && instanceData.isAlive) {
2536
2566
  if (this.blacklistInstancesNotify.includes(instanceID)) return;
2537
- await this.sendStateNotifications('errorInstance', instanceID);
2567
+ await this.sendStateNotifications('Instances', 'errorInstance', instanceID);
2538
2568
  }
2539
2569
  }
2540
2570
  break;
@@ -3022,17 +3052,26 @@ class DeviceWatcher extends utils.Adapter {
3022
3052
  /*---------- Notifications ----------*/
3023
3053
  /**
3024
3054
  * Notifications on state changes
3055
+ * @param {string} mainType
3025
3056
  * @param {string} type
3026
3057
  * @param {object} id
3027
3058
  */
3028
- async sendStateNotifications(type, id) {
3059
+ async sendStateNotifications(mainType, type, id) {
3029
3060
  if (isUnloaded) return;
3030
-
3031
- let objectData = this.listAllDevicesRaw.get(id);
3032
- const adapterName = this.config.showAdapterNameinMsg ? `${objectData.Adapter}: ` : '';
3061
+ let objectData;
3062
+ let adapterName;
3033
3063
  let list = '';
3034
3064
  let message = '';
3035
3065
 
3066
+ if (id !== null) {
3067
+ if (mainType === 'Devices') {
3068
+ objectData = this.listAllDevicesRaw.get(id);
3069
+ adapterName = this.config.showAdapterNameinMsg ? `${objectData.Adapter}: ` : '';
3070
+ } else if (mainType === 'Instances') {
3071
+ objectData = this.listInstanceRaw.get(id);
3072
+ }
3073
+ }
3074
+
3036
3075
  const setMessage = async (message) => {
3037
3076
  this.log.info(message);
3038
3077
  await this.setStateAsync('lastNotification', message, true);
@@ -3041,40 +3080,45 @@ class DeviceWatcher extends utils.Adapter {
3041
3080
 
3042
3081
  switch (type) {
3043
3082
  case 'lowBatDevice':
3044
- message = `${translations.Device_low_bat_detected[this.language]}: \n${adapterName} ${objectData.Device} (${objectData.Battery})`;
3083
+ message = `${translations.Device_low_bat_detected[this.userSystemLanguage]}: \n${adapterName} ${objectData.Device} (${objectData.Battery})`;
3045
3084
  await setMessage(message);
3046
3085
  break;
3047
3086
 
3048
3087
  case 'onlineStateDevice':
3049
3088
  switch (objectData.Status) {
3050
3089
  case 'Online':
3051
- message = `${translations.Device_available_again[this.language]}: \n${adapterName} ${objectData.Device} (${objectData.LastContact})`;
3090
+ message = `${translations.Device_available_again[this.userSystemLanguage]}: \n${adapterName} ${objectData.Device} (${objectData.LastContact})`;
3052
3091
  break;
3053
3092
 
3054
3093
  case 'Offline':
3055
- message = `${translations.Device_not_reachable[this.language]}: \n${adapterName} ${objectData.Device} (${objectData.LastContact})`;
3094
+ message = `${translations.Device_not_reachable[this.userSystemLanguage]}: \n${adapterName} ${objectData.Device} (${objectData.LastContact})`;
3056
3095
  break;
3057
3096
  }
3058
3097
  await setMessage(message);
3059
3098
  break;
3060
3099
 
3061
3100
  case 'updateDevice':
3062
- message = `${translations.Device_new_updates[this.language]}: \n${adapterName} ${objectData.Device}`;
3101
+ message = `${translations.Device_new_updates[this.userSystemLanguage]}: \n${adapterName} ${objectData.Device}`;
3063
3102
  await setMessage(message);
3064
3103
  break;
3065
3104
 
3066
3105
  case 'updateAdapter':
3067
3106
  if (this.countAdapterUpdates === 0) return;
3068
3107
 
3069
- list = objectData.map((id) => `${id.Adapter}: v${id['Available Version']}`).join('\n');
3070
- message = `${translations.Adapter_new_updates[this.language]}: ${list}`;
3108
+ objectData = this.listAdapterUpdates;
3109
+ list = '';
3110
+
3111
+ for (const id of objectData) {
3112
+ list = `${list}\n${id[translations.Adapter[this.userSystemLanguage]]}: v${id[translations.Available_Version[this.userSystemLanguage]]}`;
3113
+ }
3114
+
3115
+ message = `${translations.Adapter_new_updates[this.userSystemLanguage]}: ${list}`;
3071
3116
  await setMessage(message);
3072
3117
  break;
3073
3118
 
3074
3119
  case 'errorInstance':
3075
3120
  case 'deactivatedInstance':
3076
- objectData = this.listInstanceRaw.get(id);
3077
- message = `${translations.Instance_Watchdog[this.language]}:\n${id}: ${objectData.status}`;
3121
+ message = `${translations.Instance_Watchdog[this.userSystemLanguage]}:\n${id}: ${objectData.status}`;
3078
3122
  await setMessage(message);
3079
3123
  break;
3080
3124
  }
@@ -3107,8 +3151,8 @@ class DeviceWatcher extends utils.Adapter {
3107
3151
 
3108
3152
  const processInstanceList = (instanceList, property) => {
3109
3153
  for (const id of instanceList) {
3110
- if (this.blacklistInstancesNotify.includes(id[translations['Instance'][this.language]])) continue;
3111
- list += `\n${id[translations['Instance'][this.language]]}${property ? `: ${id[property]}` : ''}`;
3154
+ if (this.blacklistInstancesNotify.includes(id[translations['Instance'][this.userSystemLanguage]])) continue;
3155
+ list += `\n${id[translations['Instance'][this.userSystemLanguage]]}${property ? `: ${id[property]}` : ''}`;
3112
3156
  }
3113
3157
  };
3114
3158
 
@@ -3117,13 +3161,13 @@ class DeviceWatcher extends utils.Adapter {
3117
3161
 
3118
3162
  switch (checkDays.length) {
3119
3163
  case 1:
3120
- message = `${translations.Weekly_overview[this.language]} ${translations[messageType][this.language]}: ${list}`;
3164
+ message = `${translations.Weekly_overview[this.userSystemLanguage]} ${translations[messageType][this.userSystemLanguage]}: ${list}`;
3121
3165
  break;
3122
3166
  case 7:
3123
- message = `${translations.Daily_overview[this.language]} ${translations[messageType][this.language]}: ${list}`;
3167
+ message = `${translations.Daily_overview[this.userSystemLanguage]} ${translations[messageType][this.userSystemLanguage]}: ${list}`;
3124
3168
  break;
3125
3169
  default:
3126
- message = `${translations.Overview_of[this.language]} ${translations[messageType][this.language]}: ${list}`;
3170
+ message = `${translations.Overview_of[this.userSystemLanguage]} ${translations[messageType][this.userSystemLanguage]}: ${list}`;
3127
3171
  break;
3128
3172
  }
3129
3173
 
@@ -3189,9 +3233,10 @@ class DeviceWatcher extends utils.Adapter {
3189
3233
  this.log.debug(`Number of selected days for daily adapter update message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
3190
3234
 
3191
3235
  schedule.scheduleJob(`4 ${this.config.checkSendAdapterUpdateTime.split(':').reverse().join(' ')} * * ${checkDays.join(',')}`, async () => {
3192
- processDeviceList(this.listAdapterUpdates, translations.Adapter[this.language], translations.Available_Version[this.language]);
3193
-
3194
- await processNotification(list, 'available_adapter_update');
3236
+ for (const id of this.listAdapterUpdates) {
3237
+ list = `${list}\n${id[translations.Adapter[this.userSystemLanguage]]}: v${id[translations.Available_Version[this.userSystemLanguage]]}`;
3238
+ }
3239
+ await processNotification(list, 'available_adapter_updates');
3195
3240
  });
3196
3241
  break;
3197
3242
 
@@ -3248,14 +3293,14 @@ class DeviceWatcher extends utils.Adapter {
3248
3293
  return a.localeCompare(b);
3249
3294
  });
3250
3295
  html = `<center>
3251
- <b>${[translations.Link_quality_devices[this.language]]}:<font> ${deviceCount}</b><small></small></font>
3296
+ <b>${[translations.Link_quality_devices[this.userSystemLanguage]]}:<font> ${deviceCount}</b><small></small></font>
3252
3297
  <p></p>
3253
3298
  </center>
3254
3299
  <table width=100%>
3255
3300
  <tr>
3256
- <th align=left>${[translations.Device[this.language]]}</th>
3257
- <th align=center width=120>${[translations.Adapter[this.language]]}</th>
3258
- <th align=right>${[translations.Signal_strength[this.language]]}</th>
3301
+ <th align=left>${[translations.Device[this.userSystemLanguage]]}</th>
3302
+ <th align=center width=120>${[translations.Adapter[this.userSystemLanguage]]}</th>
3303
+ <th align=right>${[translations.Signal_strength[this.userSystemLanguage]]}</th>
3259
3304
  </tr>
3260
3305
  <tr>
3261
3306
  <td colspan="5"><hr></td>
@@ -3263,9 +3308,9 @@ class DeviceWatcher extends utils.Adapter {
3263
3308
 
3264
3309
  for (const device of devices) {
3265
3310
  html += `<tr>
3266
- <td><font>${device[translations.Device[this.language]]}</font></td>
3267
- <td align=center><font>${device[translations.Adapter[this.language]]}</font></td>
3268
- <td align=right><font>${device[translations.Signal_strength[this.language]]}</font></td>
3311
+ <td><font>${device[translations.Device[this.userSystemLanguage]]}</font></td>
3312
+ <td align=center><font>${device[translations.Adapter[this.userSystemLanguage]]}</font></td>
3313
+ <td align=right><font>${device[translations.Signal_strength[this.userSystemLanguage]]}</font></td>
3269
3314
  </tr>`;
3270
3315
  }
3271
3316
 
@@ -3279,14 +3324,14 @@ class DeviceWatcher extends utils.Adapter {
3279
3324
  return a.localeCompare(b);
3280
3325
  });
3281
3326
  html = `<center>
3282
- <b>${[translations.offline_devices[this.language]]}: <font color=${deviceCount === 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
3327
+ <b>${[translations.offline_devices[this.userSystemLanguage]]}: <font color=${deviceCount === 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
3283
3328
  <p></p>
3284
3329
  </center>
3285
3330
  <table width=100%>
3286
3331
  <tr>
3287
- <th align=left>${[translations.Device[this.language]]}</th>
3288
- <th align=center width=120>${[translations.Adapter[this.language]]}</th>
3289
- <th align=center>${[translations.Last_Contact[this.language]]}</th>
3332
+ <th align=left>${[translations.Device[this.userSystemLanguage]]}</th>
3333
+ <th align=center width=120>${[translations.Adapter[this.userSystemLanguage]]}</th>
3334
+ <th align=center>${[translations.Last_Contact[this.userSystemLanguage]]}</th>
3290
3335
  </tr>
3291
3336
  <tr>
3292
3337
  <td colspan="5"><hr></td>
@@ -3294,9 +3339,9 @@ class DeviceWatcher extends utils.Adapter {
3294
3339
 
3295
3340
  for (const device of devices) {
3296
3341
  html += `<tr>
3297
- <td><font>${device.Device}</font></td>
3298
- <td align=center><font>${device.Adapter}</font></td>
3299
- <td align=center><font color=orange>${device.LastContact}</font></td>
3342
+ <td><font>${device[translations.Device[this.userSystemLanguage]]}</font></td>
3343
+ <td align=center><font>${device[translations.Adapter[this.userSystemLanguage]]}</font></td>
3344
+ <td align=center><font color=orange>${device[translations.Last_Contact[this.userSystemLanguage]]}</font></td>
3300
3345
  </tr>`;
3301
3346
  }
3302
3347
 
@@ -3310,28 +3355,28 @@ class DeviceWatcher extends utils.Adapter {
3310
3355
  return a.localeCompare(b);
3311
3356
  });
3312
3357
  html = `<center>
3313
- <b>${isLowBatteryList === true ? `${[translations.low[this.language]]} ` : ''}${[translations.battery_devices[this.language]]}:
3358
+ <b>${isLowBatteryList === true ? `${[translations.low[this.userSystemLanguage]]} ` : ''}${[translations.battery_devices[this.userSystemLanguage]]}:
3314
3359
  <font color=${isLowBatteryList === true ? (deviceCount > 0 ? 'orange' : '#3bcf0e') : ''}>${deviceCount}</b></font>
3315
3360
  <p></p>
3316
3361
  </center>
3317
3362
  <table width=100%>
3318
3363
  <tr>
3319
- <th align=left>${[translations.Device[this.language]]}</th>
3320
- <th align=center width=120>${[translations.Adapter[this.language]]}</th>
3321
- <th align=${isLowBatteryList ? 'center' : 'right'}>${[translations.Battery[this.language]]}</th>
3364
+ <th align=left>${[translations.Device[this.userSystemLanguage]]}</th>
3365
+ <th align=center width=120>${[translations.Adapter[this.userSystemLanguage]]}</th>
3366
+ <th align=${isLowBatteryList ? 'center' : 'right'}>${[translations.Battery[this.userSystemLanguage]]}</th>
3322
3367
  </tr>
3323
3368
  <tr>
3324
3369
  <td colspan="5"><hr></td>
3325
3370
  </tr>`;
3326
3371
  for (const device of devices) {
3327
3372
  html += `<tr>
3328
- <td><font>${device[translations.Device[this.language]]}</font></td>
3329
- <td align=center><font>${device[translations.Adapter[this.language]]}</font></td>`;
3373
+ <td><font>${device[translations.Device[this.userSystemLanguage]]}</font></td>
3374
+ <td align=center><font>${device[translations.Adapter[this.userSystemLanguage]]}</font></td>`;
3330
3375
 
3331
3376
  if (isLowBatteryList) {
3332
- html += `<td align=center><font color=orange>${device[translations.Battery[this.language]]}</font></td>`;
3377
+ html += `<td align=center><font color=orange>${device[translations.Battery[this.userSystemLanguage]]}</font></td>`;
3333
3378
  } else {
3334
- html += `<td align=right><font color=#3bcf0e>${device[translations.Battery[this.language]]}</font></td>`;
3379
+ html += `<td align=right><font color=#3bcf0e>${device[translations.Battery[this.userSystemLanguage]]}</font></td>`;
3335
3380
  }
3336
3381
  html += `</tr>`;
3337
3382
  }
@@ -3351,25 +3396,30 @@ class DeviceWatcher extends utils.Adapter {
3351
3396
  let html;
3352
3397
  switch (type) {
3353
3398
  case 'allInstancesList':
3399
+ instances = instances.sort((a, b) => {
3400
+ a = a.Instance || '';
3401
+ b = b.Instance || '';
3402
+ return a.localeCompare(b);
3403
+ });
3354
3404
  html = `<center>
3355
- <b>${[translations.All_Instances[this.language]]}:<font> ${instancesCount}</b><small></small></font>
3405
+ <b>${[translations.All_Instances[this.userSystemLanguage]]}:<font> ${instancesCount}</b><small></small></font>
3356
3406
  <p></p>
3357
3407
  </center>
3358
3408
  <table width=100%>
3359
3409
  <tr>
3360
- <th align=left>${[translations.Adapter[this.language]]}</th>
3361
- <th align=center>${[translations.Instance[this.language]]}</th>
3362
- <th align=center width=180>${[translations.Status[this.language]]}</th>
3410
+ <th align=left>${[translations.Adapter[this.userSystemLanguage]]}</th>
3411
+ <th align=center>${[translations.Instance[this.userSystemLanguage]]}</th>
3412
+ <th align=center width=180>${[translations.Status[this.userSystemLanguage]]}</th>
3363
3413
  </tr>
3364
3414
  <tr>
3365
3415
  <td colspan="5"><hr></td>
3366
3416
  </tr>`;
3367
3417
 
3368
- for (const [instance, instanceData] of instances) {
3418
+ for (const instanceData of instances) {
3369
3419
  html += `<tr>
3370
- <td><font>${instanceData.Adapter}</font></td>
3371
- <td align=center><font>${instance}</font></td>
3372
- <td align=center><font>${instanceData.status}</font></td>
3420
+ <td><font>${instanceData[translations.Adapter[this.userSystemLanguage]]}</font></td>
3421
+ <td align=center><font>${instanceData[translations.Instance[this.userSystemLanguage]]}</font></td>
3422
+ <td align=center><font>${instanceData[translations.Status[this.userSystemLanguage]]}</font></td>
3373
3423
  </tr>`;
3374
3424
  }
3375
3425
 
@@ -3377,53 +3427,61 @@ class DeviceWatcher extends utils.Adapter {
3377
3427
  break;
3378
3428
 
3379
3429
  case 'allActiveInstancesList':
3430
+ instances = instances.sort((a, b) => {
3431
+ a = a.Instance || '';
3432
+ b = b.Instances || '';
3433
+ return a.localeCompare(b);
3434
+ });
3380
3435
  html = `<center>
3381
- <b>${[translations.Active_Instances[this.language]]}: <font> ${instancesCount}</b><small></small></font>
3436
+ <b>${[translations.Active_Instances[this.userSystemLanguage]]}: <font> ${instancesCount}</b><small></small></font>
3382
3437
  <p></p>
3383
3438
  </center>
3384
3439
  <table width=100%>
3385
3440
  <tr>
3386
- <th align=left>${[translations.Adapter[this.language]]}</th>
3387
- <th align=center>${[translations.Instance[this.language]]}</th>
3388
- <th align=center width=180>${[translations.Status[this.language]]}</th>
3441
+ <th align=left>${[translations.Adapter[this.userSystemLanguage]]}</th>
3442
+ <th align=center>${[translations.Instance[this.userSystemLanguage]]}</th>
3443
+ <th align=center width=180>${[translations.Status[this.userSystemLanguage]]}</th>
3389
3444
  </tr>
3390
3445
  <tr>
3391
3446
  <td colspan="5"><hr></td>
3392
3447
  </tr>`;
3393
3448
 
3394
- for (const [instance, instanceData] of instances) {
3395
- if (instanceData.isAlive) {
3396
- html += `<tr>
3397
- <td><font>${instanceData.Adapter}</font></td>
3398
- <td align=center><font>${instance}</font></td>
3399
- <td align=center><font color=orange>${instanceData.status}</font></td>
3449
+ for (const instanceData of instances) {
3450
+ html += `<tr>
3451
+ <td><font>${instanceData[translations.Adapter[this.userSystemLanguage]]}</font></td>
3452
+ <td align=center><font>${instanceData[translations.Instance[this.userSystemLanguage]]}</font></td>
3453
+ <td align=center><font color=orange>${instanceData[translations.Status[this.userSystemLanguage]]}</font></td>
3400
3454
  </tr>`;
3401
- }
3402
3455
  }
3403
3456
 
3404
3457
  html += '</table>';
3405
3458
  break;
3406
3459
 
3407
3460
  case 'errorInstanceList':
3461
+ instances = instances.sort((a, b) => {
3462
+ a = a.Instance || '';
3463
+ b = b.Instances || '';
3464
+ return a.localeCompare(b);
3465
+ });
3408
3466
  html = `<center>
3409
- <b>${[translations.Error_Instances[this.language]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3467
+ <b>${[translations.Error_Instances[this.userSystemLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3410
3468
  <p></p>
3411
3469
  </center>
3412
3470
  <table width=100%>
3413
3471
  <tr>
3414
- <th align=left>${[translations.Adapter[this.language]]}</th>
3415
- <th align=center>${[translations.Instance[this.language]]}</th>
3416
- <th align=center width=180>${[translations.Status[this.language]]}</th>
3472
+ <th align=left>${[translations.Adapter[this.userSystemLanguage]]}</th>
3473
+ <th align=center>${[translations.Instance[this.userSystemLanguage]]}</th>
3474
+ <th align=center width=180>${[translations.Status[this.userSystemLanguage]]}</th>
3417
3475
  </tr>
3418
3476
  <tr>
3419
3477
  <td colspan="5"><hr></td>
3420
3478
  </tr>`;
3421
3479
 
3422
- for (const instance of instances) {
3480
+ for (const instanceData of instances) {
3423
3481
  html += `<tr>
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>
3482
+ <td><font>${instanceData[translations.Adapter[this.userSystemLanguage]]}</font></td>
3483
+ <td align=center><font>${instanceData[translations.Instance[this.userSystemLanguage]]}</font></td>
3484
+ <td align=center><font color=orange>${instanceData[translations.Status[this.userSystemLanguage]]}</font></td>
3427
3485
  </tr>`;
3428
3486
  }
3429
3487
 
@@ -3431,26 +3489,31 @@ class DeviceWatcher extends utils.Adapter {
3431
3489
  break;
3432
3490
 
3433
3491
  case 'deactivatedInstanceList':
3492
+ instances = instances.sort((a, b) => {
3493
+ a = a.Instance || '';
3494
+ b = b.Instances || '';
3495
+ return a.localeCompare(b);
3496
+ });
3434
3497
  html = `<center>
3435
- <b>${[translations.Deactivated_Instances[this.language]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3498
+ <b>${[translations.Deactivated_Instances[this.userSystemLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3436
3499
  <p></p>
3437
3500
  </center>
3438
3501
  <table width=100%>
3439
3502
  <tr>
3440
- <th align=left>${[translations.Adapter[this.language]]}</th>
3441
- <th align=center>${[translations.Instance[this.language]]}</th>
3442
- <th align=center width=180>${[translations.Status[this.language]]}</th>
3503
+ <th align=left>${[translations.Adapter[this.userSystemLanguage]]}</th>
3504
+ <th align=center>${[translations.Instance[this.userSystemLanguage]]}</th>
3505
+ <th align=center width=180>${[translations.Status[this.userSystemLanguage]]}</th>
3443
3506
  </tr>
3444
3507
  <tr>
3445
3508
  <td colspan="5"><hr></td>
3446
3509
  </tr>`;
3447
3510
 
3448
- for (const [instance, instanceData] of instances) {
3511
+ for (const instanceData of instances) {
3449
3512
  if (!instanceData.isAlive) {
3450
3513
  html += `<tr>
3451
- <td><font>${instanceData.Adapter}</font></td>
3452
- <td align=center><font>${instance}</font></td>
3453
- <td align=center><font color=orange>${instanceData.status}</font></td>
3514
+ <td><font>${instanceData[translations.Adapter[this.userSystemLanguage]]}</font></td>
3515
+ <td align=center><font>${instanceData[translations.Instance[this.userSystemLanguage]]}</font></td>
3516
+ <td align=center><font color=orange>${instanceData[translations.Status[this.userSystemLanguage]]}</font></td>
3454
3517
  </tr>`;
3455
3518
  }
3456
3519
  }
@@ -3460,14 +3523,14 @@ class DeviceWatcher extends utils.Adapter {
3460
3523
 
3461
3524
  case 'updateAdapterList':
3462
3525
  html = `<center>
3463
- <b>${[translations.Updatable_adapters[this.language]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3526
+ <b>${[translations.Updatable_adapters[this.userSystemLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
3464
3527
  <p></p>
3465
3528
  </center>
3466
3529
  <table width=100%>
3467
3530
  <tr>
3468
- <th align=left>${[translations.Adapter[this.language]]}</th>
3469
- <th align=center>${[translations.Installed_Version[this.language]]}</th>
3470
- <th align=center>${[translations.Available_Version[this.language]]}</th>
3531
+ <th align=left>${[translations.Adapter[this.userSystemLanguage]]}</th>
3532
+ <th align=center>${[translations.Installed_Version[this.userSystemLanguage]]}</th>
3533
+ <th align=center>${[translations.Available_Version[this.userSystemLanguage]]}</th>
3471
3534
  </tr>
3472
3535
  <tr>
3473
3536
  <td colspan="5"><hr></td>
@@ -3476,9 +3539,9 @@ class DeviceWatcher extends utils.Adapter {
3476
3539
  for (const instanceData of instances.values()) {
3477
3540
  if (instanceData.updateAvailable !== ' - ') {
3478
3541
  html += `<tr>
3479
- <td><font>${instanceData.Adapter}</font></td>
3480
- <td align=center><font>${instanceData.adapterVersion}</font></td>
3481
- <td align=center><font color=orange>${instanceData.updateAvailable}</font></td>
3542
+ <td><font>${instanceData[translations.Adapter[this.userSystemLanguage]]}</font></td>
3543
+ <td align=center><font>${instanceData[translations.Installed_Version[this.userSystemLanguage]]}</font></td>
3544
+ <td align=center><font color=orange>${instanceData[translations.Available_Version[this.userSystemLanguage]]}</font></td>
3482
3545
  </tr>`;
3483
3546
  }
3484
3547
  }