iobroker.device-watcher 2.0.1 → 2.0.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
@@ -16,7 +16,6 @@ const enableSendSentry = true;
16
16
  let isUnloaded = false;
17
17
 
18
18
  class DeviceWatcher extends utils.Adapter {
19
-
20
19
  constructor(options) {
21
20
  super({
22
21
  ...options,
@@ -30,12 +29,21 @@ class DeviceWatcher extends utils.Adapter {
30
29
  this.batteryPowered = [];
31
30
  this.batteryLowPowered = [];
32
31
  this.listAllDevices = [];
33
- this.listAllDevicesRaw = [];
34
32
  this.blacklistLists = [];
35
33
  this.blacklistNotify = [];
36
34
  this.arrDev = [];
37
35
  this.adapterSelected = [];
38
36
 
37
+ // raw arrays
38
+ this.listAllDevicesRaw = [];
39
+ this.batteryLowPoweredRaw = [];
40
+ this.offlineDevicesRaw = [];
41
+
42
+ // raw counts
43
+ this.offlineDevicesCountRaw = 0;
44
+ this.offlineDevicesCountRawOld = 0;
45
+ this.lowBatteryPoweredCountRaw = 0;
46
+
39
47
  // counts
40
48
  this.offlineDevicesCount = 0;
41
49
  this.deviceCounter = 0;
@@ -51,9 +59,11 @@ class DeviceWatcher extends utils.Adapter {
51
59
  // this.on('objectChange', this.onObjectChange.bind(this));
52
60
  this.on('message', this.onMessage.bind(this));
53
61
  this.on('unload', this.onUnload.bind(this));
54
-
55
62
  }
56
63
 
64
+ /**
65
+ * onReady
66
+ */
57
67
  async onReady() {
58
68
  this.log.debug(`Adapter ${adapterName} was started`);
59
69
 
@@ -69,9 +79,10 @@ class DeviceWatcher extends utils.Adapter {
69
79
  enocean: this.config.enoceanDevices,
70
80
  esphome: this.config.esphomeDevices,
71
81
  fritzdect: this.config.fritzdectDevices,
82
+ fullybrowser: this.config.fullybrowserDevices,
72
83
  ham: this.config.hamDevices,
73
84
  harmony: this.config.harmonyDevices,
74
- hmiP : this.config.hmiPDevices,
85
+ hmiP: this.config.hmiPDevices,
75
86
  hmrpc: this.config.hmrpcDevices,
76
87
  hs100: this.config.hs100Devices,
77
88
  hue: this.config.hueDevices,
@@ -91,8 +102,10 @@ class DeviceWatcher extends utils.Adapter {
91
102
  shelly: this.config.shellyDevices,
92
103
  sonoff: this.config.sonoffDevices,
93
104
  sonos: this.config.sonosDevices,
105
+ sureflap: this.config.sureflapDevices,
94
106
  switchbotBle: this.config.switchbotBleDevices,
95
107
  tado: this.config.tadoDevices,
108
+ tapo: this.config.tapoDevices,
96
109
  tradfri: this.config.tradfriDevices,
97
110
  unifi: this.config.unifiDevices,
98
111
  wled: this.config.wledDevices,
@@ -109,9 +122,10 @@ class DeviceWatcher extends utils.Adapter {
109
122
  enocean: this.config.enoceanMaxMinutes,
110
123
  esphome: this.config.esphomeMaxMinutes,
111
124
  fritzdect: this.config.fritzdectMaxMinutes,
125
+ fullybrowser: this.config.fullybrowserMaxMinutes,
112
126
  ham: this.config.hamMaxMinutes,
113
127
  harmony: this.config.harmonyMaxMinutes,
114
- hmiP : this.config.hmiPMaxMinutes,
128
+ hmiP: this.config.hmiPMaxMinutes,
115
129
  hmrpc: this.config.hmrpcMaxMinutes,
116
130
  hs100: this.config.hs100MaxMinutes,
117
131
  hue: this.config.hueMaxMinutes,
@@ -131,8 +145,10 @@ class DeviceWatcher extends utils.Adapter {
131
145
  shelly: this.config.shellyMaxMinutes,
132
146
  sonoff: this.config.sonoffMaxMinutes,
133
147
  sonos: this.config.sonosMaxMinutes,
148
+ sureflap: this.config.sureflapMaxMinutes,
134
149
  switchbotBle: this.config.switchbotMaxMinutes,
135
150
  tado: this.config.tadoMaxMinutes,
151
+ tapo: this.config.tapoMaxMinutes,
136
152
  tradfri: this.config.tradfriMaxMinutes,
137
153
  unifi: this.config.unifiMaxMinutes,
138
154
  wled: this.config.wledMaxMinutes,
@@ -158,7 +174,7 @@ class DeviceWatcher extends utils.Adapter {
158
174
  // show list in debug log
159
175
  this.log.debug(JSON.stringify(this.arrDev));
160
176
 
161
- this.log.info(`Number of selected adapters: ${this.adapterSelected.length}. Loading data from: ${(this.adapterSelected).join(', ')} ...`);
177
+ this.log.info(`Number of selected adapters: ${this.adapterSelected.length}. Loading data from: ${this.adapterSelected.join(', ')} ...`);
162
178
  } else {
163
179
  this.log.warn(`No adapter selected. Please check the instance configuration!`);
164
180
  return; // cancel run if no adapter is selected
@@ -175,8 +191,7 @@ class DeviceWatcher extends utils.Adapter {
175
191
  try {
176
192
  for (const [id] of Object.entries(arrApart)) {
177
193
  if (!isUnloaded) {
178
- if ((this.supAdapter !== undefined) && (this.supAdapter[id])) {
179
-
194
+ if (this.supAdapter !== undefined && this.supAdapter[id]) {
180
195
  if (this.config.createOwnFolder) {
181
196
  await this.createDPsForEachAdapter(id);
182
197
  if (this.config.createHtmlList) await this.createHtmlListDatapoints(id);
@@ -202,7 +217,6 @@ class DeviceWatcher extends utils.Adapter {
202
217
 
203
218
  // send overview of offline devices
204
219
  if (this.config.checkSendOfflineMsgDaily) await this.sendOfflineNotificationsShedule();
205
-
206
220
  } catch (error) {
207
221
  this.errorReporting('[onReady]', error);
208
222
  this.terminate ? this.terminate(15) : process.exit(15);
@@ -210,10 +224,10 @@ class DeviceWatcher extends utils.Adapter {
210
224
  } // <-- onReady end
211
225
 
212
226
  /**
213
- * Is called if a subscribed state changes
214
- * @param {string} id
215
- * @param {ioBroker.State | null | undefined} state
216
- */
227
+ * Is called if a subscribed state changes
228
+ * @param {string} id
229
+ * @param {ioBroker.State | null | undefined} state
230
+ */
217
231
  onStateChange(id, state) {
218
232
  if (state) {
219
233
  // The state was changed
@@ -225,8 +239,8 @@ class DeviceWatcher extends utils.Adapter {
225
239
  }
226
240
 
227
241
  /**
228
- * @param {ioBroker.Message} obj
229
- */
242
+ * @param {ioBroker.Message} obj
243
+ */
230
244
  onMessage(obj) {
231
245
  const devices = [];
232
246
  let myCount = 0;
@@ -234,28 +248,33 @@ class DeviceWatcher extends utils.Adapter {
234
248
 
235
249
  switch (obj.command) {
236
250
  case 'devicesList':
237
- if(obj.message){
238
- try{
251
+ if (obj.message) {
252
+ try {
239
253
  result = this.listAllDevicesRaw;
240
- for(const element in result){
254
+ for (const element in result) {
241
255
  const label = 'Device: ' + result[element].Device + ' - Adapter: ' + result[element].Adapter;
242
- const myValueObject = {deviceName: result[element].Device, adapter: result[element].Adapter, path: result[element].Path};
243
- devices[myCount] = {label: label,value: JSON.stringify(myValueObject)};
244
- myCount ++;
256
+ const myValueObject = {
257
+ deviceName: result[element].Device,
258
+ adapter: result[element].Adapter,
259
+ path: result[element].Path,
260
+ };
261
+ devices[myCount] = { label: label, value: JSON.stringify(myValueObject) };
262
+ myCount++;
245
263
  }
246
264
  this.sendTo(obj.from, obj.command, devices, obj.callback);
247
- }
248
- catch(error){
265
+ } catch (error) {
249
266
  this.sendTo(obj.from, obj.command, obj.callback);
250
267
  }
251
- }
252
- else{
268
+ } else {
253
269
  this.sendTo(obj.from, obj.command, obj.callback);
254
270
  }
255
271
  break;
256
272
  }
257
273
  }
258
274
 
275
+ /**
276
+ * refresh data with interval
277
+ */
259
278
  async refreshData() {
260
279
  const nextTimeout = this.config.updateinterval * 1000;
261
280
 
@@ -276,9 +295,11 @@ class DeviceWatcher extends utils.Adapter {
276
295
  } else {
277
296
  return; // cancel run if unloaded was called.
278
297
  }
279
-
280
298
  } // <-- refreshData end
281
299
 
300
+ /**
301
+ * main function
302
+ */
282
303
  async main() {
283
304
  this.log.debug(`Function started: ${this.main.name}`);
284
305
 
@@ -286,7 +307,7 @@ class DeviceWatcher extends utils.Adapter {
286
307
  try {
287
308
  for (const [id] of Object.entries(arrApart)) {
288
309
  if (!isUnloaded) {
289
- if ((this.supAdapter !== undefined) && (this.supAdapter[id])) {
310
+ if (this.supAdapter !== undefined && this.supAdapter[id]) {
290
311
  if (this.config.createOwnFolder) {
291
312
  await this.createDataForEachAdapter(id);
292
313
  this.log.debug(`Created and filled data for ${await this.capitalize(id)}`);
@@ -312,13 +333,12 @@ class DeviceWatcher extends utils.Adapter {
312
333
  this.log.debug(`Function finished: ${this.main.name}`);
313
334
  } //<--End of main function
314
335
 
315
-
316
336
  /**
317
- * @param {string} sentence - Word which should be capitalize
337
+ * @param {string} id - id which should be capitalize
318
338
  */
319
- async capitalize(sentence) {
339
+ capitalize(id) {
320
340
  //make the first letter uppercase
321
- return sentence && sentence[0].toUpperCase() + sentence.slice(1);
341
+ return id && id[0].toUpperCase() + id.slice(1);
322
342
  }
323
343
 
324
344
  /**
@@ -326,7 +346,7 @@ class DeviceWatcher extends utils.Adapter {
326
346
  */
327
347
  async getTimestamp(dpValue) {
328
348
  const time = new Date();
329
- return dpValue = Math.round((time.getTime() - dpValue) / 1000 / 60);
349
+ return (dpValue = Math.round((time.getTime() - dpValue) / 1000 / 60));
330
350
  }
331
351
 
332
352
  /**
@@ -347,6 +367,19 @@ class DeviceWatcher extends utils.Adapter {
347
367
  if (stateVal) return stateVal.val;
348
368
  }
349
369
 
370
+ /**
371
+ * @param {object} data - object
372
+ */
373
+ async parseData(data) {
374
+ if (!data) return {};
375
+ if (typeof data === 'object') return data;
376
+ if (typeof data === 'string') return JSON.parse(data);
377
+ return {};
378
+ }
379
+
380
+ /**
381
+ * create blacklist
382
+ */
350
383
  async createBlacklist() {
351
384
  this.log.debug(`Function started: ${this.createBlacklist.name}`);
352
385
 
@@ -354,14 +387,18 @@ class DeviceWatcher extends utils.Adapter {
354
387
  const myBlacklist = this.config.tableBlacklist;
355
388
 
356
389
  for (const i in myBlacklist) {
357
- const blacklistParse = JSON.parse(myBlacklist[i].devices);
358
- // push devices in list to ignor device in lists
359
- if (myBlacklist[i].checkIgnorLists) {
360
- this.blacklistLists.push(blacklistParse.path);
361
- }
362
- // push devices in list to ignor device in notifications
363
- if (myBlacklist[i].checkIgnorNotify) {
364
- this.blacklistNotify.push(blacklistParse.deviceName);
390
+ try {
391
+ const blacklistParse = await this.parseData(myBlacklist[i].devices);
392
+ // push devices in list to ignor device in lists
393
+ if (myBlacklist[i].checkIgnorLists) {
394
+ this.blacklistLists.push(blacklistParse.path);
395
+ }
396
+ // push devices in list to ignor device in notifications
397
+ if (myBlacklist[i].checkIgnorNotify) {
398
+ this.blacklistNotify.push(blacklistParse.path);
399
+ }
400
+ } catch (error) {
401
+ this.errorReporting('[createBlacklist]', error);
365
402
  }
366
403
  }
367
404
 
@@ -379,71 +416,101 @@ class DeviceWatcher extends utils.Adapter {
379
416
  * @param {object} i - each Device
380
417
  */
381
418
  async getDeviceName(id, i) {
382
- const currDeviceString = id.slice(0, (id.lastIndexOf('.') + 1) - 1);
383
- const shortCurrDeviceString = currDeviceString.slice(0, (currDeviceString.lastIndexOf('.') + 1) - 1);
384
- const shortshortCurrDeviceString = shortCurrDeviceString.slice(0, (shortCurrDeviceString.lastIndexOf('.') + 1) - 1);
385
-
386
- // Get device name
387
- const deviceObject = await this.getForeignObjectAsync(currDeviceString);
388
- const shortDeviceObject = await this.getForeignObjectAsync(shortCurrDeviceString);
389
- const shortshortDeviceObject = await this.getForeignObjectAsync(shortshortCurrDeviceString);
390
- let deviceName;
391
-
392
- // Get ID with currDeviceString from datapoint
393
- switch (this.arrDev[i].adapter) {
394
- // Get ID for Switchbot and ESPHome Devices
395
- case 'switchbotBle':
396
- case 'esphome':
397
- deviceName = await this.getInitValue(currDeviceString + this.arrDev[i].id);
398
- break;
419
+ const currDeviceString = id.slice(0, id.lastIndexOf('.') + 1 - 1);
420
+ const shortCurrDeviceString = currDeviceString.slice(0, currDeviceString.lastIndexOf('.') + 1 - 1);
421
+ const shortshortCurrDeviceString = shortCurrDeviceString.slice(0, shortCurrDeviceString.lastIndexOf('.') + 1 - 1);
399
422
 
400
- // Get ID with short currDeviceString from objectjson
401
- case 'hue-extended':
402
- case 'hmrpc':
403
- case 'nuki-extended':
404
- case 'wled':
405
- if (shortDeviceObject && typeof shortDeviceObject === 'object') {
406
- deviceName = shortDeviceObject.common.name;
407
- }
408
- break;
409
-
410
- // Get ID with short short currDeviceString from objectjson (HMiP Devices)
411
- case 'hmiP':
412
- if (shortshortDeviceObject && typeof shortshortDeviceObject === 'object') {
413
- deviceName = shortshortDeviceObject.common.name;
414
- }
415
- break;
423
+ try {
424
+ // Get device name
425
+ const deviceObject = await this.getForeignObjectAsync(currDeviceString);
426
+ const shortDeviceObject = await this.getForeignObjectAsync(shortCurrDeviceString);
427
+ const shortshortDeviceObject = await this.getForeignObjectAsync(shortshortCurrDeviceString);
428
+ let deviceName;
429
+
430
+ // Get ID with currDeviceString from datapoint
431
+ switch (this.arrDev[i].adapterID) {
432
+ // Get ID for Switchbot and ESPHome Devices
433
+ case 'switchbotBle':
434
+ case 'esphome':
435
+ case 'fullybrowser':
436
+ deviceName = await this.getInitValue(currDeviceString + this.arrDev[i].id);
437
+ break;
438
+
439
+ // Get ID with short currDeviceString from objectjson
440
+ case 'hueExt':
441
+ case 'hmrpc':
442
+ case 'nukiExt':
443
+ case 'wled':
444
+ if (shortDeviceObject && typeof shortDeviceObject === 'object') {
445
+ deviceName = shortDeviceObject.common.name;
446
+ }
447
+ break;
416
448
 
417
- // Get ID with short currDeviceString from datapoint
418
- case 'mihomeVacuum':
419
- case 'roomba':
420
- deviceName = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].id);
421
- break;
449
+ // Get ID with short short currDeviceString from objectjson (HMiP Devices)
450
+ case 'hmiP':
451
+ if (shortshortDeviceObject && typeof shortshortDeviceObject === 'object') {
452
+ deviceName = shortshortDeviceObject.common.name;
453
+ }
454
+ break;
455
+
456
+ // Get ID with short currDeviceString from datapoint
457
+ case 'mihomeVacuum':
458
+ case 'roomba':
459
+ deviceName = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].id);
460
+ break;
461
+
462
+ //Get ID of foldername
463
+ case 'tado':
464
+ deviceName = currDeviceString.slice(currDeviceString.lastIndexOf('.') + 1);
465
+ break;
466
+
467
+ // Format Device name
468
+ case 'sureflap':
469
+ if (deviceObject && typeof deviceObject === 'object') {
470
+ deviceName = deviceObject.common.name
471
+ // @ts-ignore FIXME: fix syntax error
472
+ .replace(/'/g, '')
473
+ .replace(/\(\d+\)/g, '')
474
+ .trim()
475
+ .replace('Hub', 'Hub -')
476
+ .replace('Device', 'Device -');
477
+ }
478
+ break;
422
479
 
423
- //Get ID of foldername
424
- case 'tado':
425
- deviceName = currDeviceString.slice(currDeviceString.lastIndexOf('.') + 1);
426
- break;
480
+ //Get ID of foldername
481
+ case 'yeelight':
482
+ deviceName = shortCurrDeviceString.slice(shortCurrDeviceString.lastIndexOf('.') + 1);
483
+ break;
427
484
 
428
- //Get ID of foldername
429
- case 'yeelight-2':
430
- deviceName = shortCurrDeviceString.slice(shortCurrDeviceString.lastIndexOf('.') + 1);
431
- break;
432
-
433
- // Get ID with main selektor from objectjson
434
- default:
435
- if (deviceObject && typeof deviceObject === 'object') {
436
- if (deviceObject.common.name['de'] != undefined) {
437
- deviceName = deviceObject.common.name['de'];
438
- } else if (deviceObject.common.name['en'] != undefined) {
439
- deviceName = deviceObject.common.name['en'];
440
- } else {
485
+ // Get ID with main selektor from objectjson
486
+ default:
487
+ if (deviceObject && typeof deviceObject === 'object') {
441
488
  deviceName = deviceObject.common.name;
442
489
  }
443
- }
444
- break;
490
+ break;
491
+ }
492
+ return deviceName;
493
+ } catch (error) {
494
+ this.errorReporting('[getDeviceName]', error);
445
495
  }
446
- return deviceName;
496
+ }
497
+
498
+ /**
499
+ * get Last Contact
500
+ * @param {object} selector - Selector
501
+ */
502
+ async getLastContact(selector) {
503
+ const lastContact = await this.getTimestamp(selector);
504
+ let lastContactString;
505
+
506
+ lastContactString = this.formatDate(new Date(selector), 'hh:mm') + ' Uhr';
507
+ if (Math.round(lastContact) > 100) {
508
+ lastContactString = Math.round(lastContact / 60) + ' Stunden';
509
+ }
510
+ if (Math.round(lastContact / 60) > 48) {
511
+ lastContactString = Math.round(lastContact / 60 / 24) + ' Tagen';
512
+ }
513
+ return lastContactString;
447
514
  }
448
515
 
449
516
  /**
@@ -455,59 +522,73 @@ class DeviceWatcher extends utils.Adapter {
455
522
  this.batteryLowPowered = [];
456
523
  this.listAllDevices = [];
457
524
  this.offlineDevices = [];
525
+ this.batteryLowPoweredRaw = [];
526
+ this.offlineDevicesRaw = [];
458
527
 
459
528
  for (const device of this.listAllDevicesRaw) {
529
+ /*---------- fill raw lists ----------*/
530
+ // low bat list
531
+ if (device['LowBat'] && device['Status'] !== 'Offline') {
532
+ this.batteryLowPoweredRaw.push({
533
+ Path: device['Path'],
534
+ Device: device['Device'],
535
+ Adapter: device['Adapter'],
536
+ Battery: device['Battery'],
537
+ });
538
+ }
539
+ // offline raw list
540
+ if (device['Status'] === 'Offline') {
541
+ this.offlineDevicesRaw.push({
542
+ Path: device['Path'],
543
+ Device: device['Device'],
544
+ Adapter: device['Adapter'],
545
+ 'Last contact': device['Last contact'],
546
+ });
547
+ }
548
+
549
+ /*---------- fill user lists ----------*/
460
550
  if (!this.blacklistLists.includes(device['Path'])) {
461
- this.listAllDevices.push(
462
- {
463
- 'Device': device['Device'],
464
- 'Adapter': device['Adapter'],
465
- 'Battery': device['Battery'],
466
- 'Signal strength': device['Signal strength'],
467
- 'Last contact': device['Last contact'],
468
- 'Status': device['Status']
469
- }
470
- );
551
+ this.listAllDevices.push({
552
+ Device: device['Device'],
553
+ Adapter: device['Adapter'],
554
+ Battery: device['Battery'],
555
+ 'Signal strength': device['Signal strength'],
556
+ 'Last contact': device['Last contact'],
557
+ Status: device['Status'],
558
+ });
471
559
  // LinkQuality lists
472
560
  if (device['Signal strength'] != ' - ') {
473
- this.linkQualityDevices.push(
474
- {
475
- 'Device': device['Device'],
476
- 'Adapter': device['Adapter'],
477
- 'Signal strength': device['Signal strength']
478
- }
479
- );
561
+ this.linkQualityDevices.push({
562
+ Device: device['Device'],
563
+ Adapter: device['Adapter'],
564
+ 'Signal strength': device['Signal strength'],
565
+ });
480
566
  }
481
567
  // Battery lists
482
- if (device['Battery'] != ' - ') {
483
- this.batteryPowered.push(
484
- {
485
- 'Device': device['Device'],
486
- 'Adapter': device['Adapter'],
487
- 'Battery': device['Battery']
488
- }
489
- );
568
+ if (device['isBatteryDevice']) {
569
+ this.batteryPowered.push({
570
+ Device: device['Device'],
571
+ Adapter: device['Adapter'],
572
+ Battery: device['Battery'],
573
+ Status: device['Status'],
574
+ });
490
575
  }
491
576
  // Low Bat lists
492
- if (device['LowBat']) {
493
- this.batteryLowPowered.push(
494
- {
495
- 'Device': device['Device'],
496
- 'Adapter': device['Adapter'],
497
- 'Battery': device['Battery']
498
- }
499
- );
577
+ if (device['LowBat'] && device['Status'] !== 'Offline') {
578
+ this.batteryLowPowered.push({
579
+ Device: device['Device'],
580
+ Adapter: device['Adapter'],
581
+ Battery: device['Battery'],
582
+ });
500
583
  }
501
584
 
502
585
  // Offline List
503
586
  if (device['Status'] === 'Offline') {
504
- this.offlineDevices.push(
505
- {
506
- 'Device': device['Device'],
507
- 'Adapter': device['Adapter'],
508
- 'Last contact': device['Last contact']
509
- }
510
- );
587
+ this.offlineDevices.push({
588
+ Device: device['Device'],
589
+ Adapter: device['Adapter'],
590
+ 'Last contact': device['Last contact'],
591
+ });
511
592
  }
512
593
  }
513
594
  }
@@ -531,6 +612,11 @@ class DeviceWatcher extends utils.Adapter {
531
612
 
532
613
  // Count how many devices are exists
533
614
  this.deviceCounter = this.listAllDevices.length;
615
+
616
+ // raws
617
+
618
+ // Count how many devcies are offline
619
+ this.offlineDevicesCountRaw = this.offlineDevicesRaw.length;
534
620
  }
535
621
 
536
622
  /**
@@ -538,23 +624,26 @@ class DeviceWatcher extends utils.Adapter {
538
624
  */
539
625
  async createData(i) {
540
626
  const devices = await this.getForeignStatesAsync(this.arrDev[i].Selektor);
541
- const adapterID = this.arrDev[i].adapter;
627
+ const adapterID = this.arrDev[i].adapterID;
542
628
 
543
629
  /*---------- Start of loop ----------*/
544
630
  for (const [id] of Object.entries(devices)) {
545
631
  if (!isUnloaded) {
546
-
547
632
  /*=============================================
548
633
  = Get device name =
549
634
  =============================================*/
550
635
  const deviceName = await this.getDeviceName(id, i);
551
636
 
637
+ /*=============================================
638
+ = Get adapter name =
639
+ =============================================*/
640
+ const adapter = this.arrDev[i].adapter;
552
641
 
553
642
  /*=============================================
554
643
  = Get path to datapoints =
555
644
  =============================================*/
556
- const currDeviceString = id.slice(0, (id.lastIndexOf('.') + 1) - 1);
557
- const shortCurrDeviceString = currDeviceString.slice(0, (currDeviceString.lastIndexOf('.') + 1) - 1);
645
+ const currDeviceString = id.slice(0, id.lastIndexOf('.') + 1 - 1);
646
+ const shortCurrDeviceString = currDeviceString.slice(0, currDeviceString.lastIndexOf('.') + 1 - 1);
558
647
 
559
648
  /*=============================================
560
649
  = Get signal strength =
@@ -601,8 +690,8 @@ class DeviceWatcher extends utils.Adapter {
601
690
  } else if (deviceQualityState.val < 0) {
602
691
  linkQuality = Math.min(Math.max(2 * (deviceQualityState.val + 100), 0), 100) + '%';
603
692
  // If Quality State is an value between 0-255 (zigbee) calculate in percent:
604
- } else if ((deviceQualityState.val) >= 0) {
605
- linkQuality = parseFloat((100 / 255 * deviceQualityState.val).toFixed(0)) + '%';
693
+ } else if (deviceQualityState.val >= 0) {
694
+ linkQuality = parseFloat(((100 / 255) * deviceQualityState.val).toFixed(0)) + '%';
606
695
  }
607
696
  break;
608
697
  }
@@ -615,7 +704,7 @@ class DeviceWatcher extends utils.Adapter {
615
704
  // for Netatmo devices
616
705
  linkQuality = deviceQualityState.val;
617
706
  break;
618
- case 'nuki-extended':
707
+ case 'nukiExt':
619
708
  linkQuality = ' - ';
620
709
  break;
621
710
  }
@@ -630,11 +719,19 @@ class DeviceWatcher extends utils.Adapter {
630
719
  =============================================*/
631
720
  let batteryHealth;
632
721
  let lowBatIndicator;
722
+ let isBatteryDevice;
633
723
 
634
724
  // Get battery states
635
- const deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery);
636
- const shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery);
637
- const shortDeviceBatteryState2 = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery2);
725
+ let deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery);
726
+ if (deviceBatteryState === undefined) {
727
+ deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery2);
728
+ }
729
+
730
+ // Get battery states with short path
731
+ let shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery);
732
+ if (shortDeviceBatteryState === undefined) {
733
+ shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery2);
734
+ }
638
735
 
639
736
  // Get low bat states
640
737
  let deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat);
@@ -642,17 +739,19 @@ class DeviceWatcher extends utils.Adapter {
642
739
  deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
643
740
  }
644
741
 
645
- if ((!deviceBatteryState) && (!shortDeviceBatteryState) && (!shortDeviceBatteryState2)) {
742
+ if (!deviceBatteryState && !shortDeviceBatteryState) {
646
743
  if (deviceLowBatState !== undefined) {
647
744
  switch (this.arrDev[i].isLowBat || this.arrDev[i].isLowBat2) {
648
745
  case 'none':
649
746
  batteryHealth = ' - ';
650
747
  break;
651
748
  default:
652
- if ((deviceLowBatState === false) || (deviceLowBatState === 'NORMAL') || (deviceLowBatState === 1)) {
749
+ if (deviceLowBatState === false || deviceLowBatState === 'NORMAL' || deviceLowBatState === 1) {
653
750
  batteryHealth = 'ok';
751
+ isBatteryDevice = true;
654
752
  } else {
655
753
  batteryHealth = 'low';
754
+ isBatteryDevice = true;
656
755
  }
657
756
  break;
658
757
  }
@@ -662,145 +761,106 @@ class DeviceWatcher extends utils.Adapter {
662
761
  } else {
663
762
  switch (adapterID) {
664
763
  case 'hmrpc':
665
- if (deviceBatteryState === 0) {
764
+ if (deviceBatteryState === 0 || (deviceBatteryState && deviceBatteryState >= 6)) {
666
765
  batteryHealth = ' - ';
667
766
  } else {
668
767
  batteryHealth = deviceBatteryState + 'V';
768
+ isBatteryDevice = true;
669
769
  }
670
770
  break;
671
771
 
672
- case 'hue-extended':
673
- if (shortDeviceBatteryState) {
674
- batteryHealth = shortDeviceBatteryState + '%';
675
- }
676
- break;
772
+ case 'hueExt':
677
773
  case 'mihomeVacuum':
678
774
  if (shortDeviceBatteryState) {
679
775
  batteryHealth = shortDeviceBatteryState + '%';
680
- } else if (shortDeviceBatteryState2) {
681
- batteryHealth = shortDeviceBatteryState2 + '%';
776
+ isBatteryDevice = true;
682
777
  }
683
778
  break;
779
+
684
780
  default:
685
- batteryHealth = (deviceBatteryState) + '%';
781
+ batteryHealth = deviceBatteryState + '%';
782
+ isBatteryDevice = true;
686
783
  }
687
784
  }
688
785
 
689
786
  /*=============================================
690
787
  = Set Lowbat indicator =
691
788
  =============================================*/
692
- switch (adapterID) {
693
- case 'hmrpc': // there are differnt low bat states between hm and hmIp devices
694
- if (deviceLowBatState) {
789
+ switch (typeof deviceLowBatState) {
790
+ case 'number':
791
+ if (deviceLowBatState === 0) {
695
792
  lowBatIndicator = true;
696
793
  }
697
794
  break;
698
- case 'tado': // there is an string as indicator
699
- if (deviceLowBatState != 'NORMAL') {
795
+
796
+ case 'string':
797
+ if (deviceLowBatState !== 'NORMAL') {
798
+ // Tado devices
700
799
  lowBatIndicator = true;
701
800
  }
702
801
  break;
703
802
 
704
- default: // for all other devices with low bat states
705
- if ((deviceLowBatState === true) || (deviceLowBatState === 0)) {
803
+ case 'boolean':
804
+ if (deviceLowBatState) {
706
805
  lowBatIndicator = true;
707
- } else if (deviceBatteryState && (deviceBatteryState < this.config.minWarnBatterie)) { // if the battery state is under the set limit
806
+ }
807
+ break;
808
+
809
+ default: // if the battery state is under the set limit
810
+ if (deviceBatteryState && deviceBatteryState < this.config.minWarnBatterie) {
708
811
  lowBatIndicator = true;
709
812
  }
813
+ break;
710
814
  }
711
815
 
712
816
  /*=============================================
713
817
  = Get last contact of device =
714
818
  =============================================*/
715
819
  let lastContactString;
716
- let lastDeviceUnreachStateChange;
717
820
  let deviceState = 'Online';
718
821
 
719
822
  const deviceMainSelector = await this.getForeignStateAsync(id);
823
+ const deviceUnreachSelector = await this.getForeignStateAsync(currDeviceString + this.arrDev[i].reach);
720
824
  const deviceStateSelector = await this.getForeignStateAsync(shortCurrDeviceString + this.arrDev[i].stateValue); // for hmrpc devices
721
825
  const rssiPeerSelector = await this.getForeignStateAsync(currDeviceString + this.arrDev[i].rssiPeerState);
722
826
 
723
827
  if (deviceMainSelector) {
724
828
  try {
725
829
  const lastContact = await this.getTimestamp(deviceMainSelector.ts);
726
- const lastStateChange = await this.getTimestamp(deviceMainSelector.lc);
727
830
  const deviceUnreachState = await this.getInitValue(currDeviceString + this.arrDev[i].reach);
728
- const deviceUnreachSelector = await this.getForeignStateAsync(currDeviceString + this.arrDev[i].reach);
729
- if (deviceUnreachSelector) {lastDeviceUnreachStateChange = await this.getTimestamp(deviceUnreachSelector.lc);}
831
+ const lastDeviceUnreachStateChange = deviceUnreachSelector != undefined ? await this.getTimestamp(deviceUnreachSelector.lc) : await this.getTimestamp(deviceMainSelector.ts);
730
832
  const shortDeviceUnreachState = await this.getForeignStateAsync(shortCurrDeviceString + this.arrDev[i].reach);
731
833
 
732
- const getLastContact = async () => {
733
- lastContactString = this.formatDate(new Date((deviceMainSelector.ts)), 'hh:mm') + ' Uhr';
734
- if (Math.round(lastContact) > 100) {
735
- lastContactString = Math.round(lastContact / 60) + ' Stunden';
736
- }
737
- if (Math.round(lastContact / 60) > 48) {
738
- lastContactString = Math.round(lastContact / 60 / 24) + ' Tagen';
739
- }
740
- return lastContactString;
741
- };
742
-
743
- const getLastStateChange = async () => {
744
- lastContactString = this.formatDate(new Date((deviceMainSelector.lc)), 'hh:mm') + ' Uhr';
745
- if (Math.round(lastStateChange) > 100) {
746
- lastContactString = Math.round(lastStateChange / 60) + ' Stunden';
747
- }
748
- if (Math.round(lastStateChange / 60) > 48) {
749
- lastContactString = Math.round(lastStateChange / 60 / 24) + ' Tagen';
750
- }
751
- return lastContactString;
752
- };
753
-
754
834
  // If there is no contact since user sets minutes add device in offline list
755
835
  // calculate to days after 48 hours
756
836
  switch (this.arrDev[i].reach) {
757
837
  case 'none':
758
- await getLastContact();
838
+ lastContactString = await this.getLastContact(deviceMainSelector.ts);
759
839
  break;
760
840
 
761
841
  default:
762
842
  //State changed
763
- if (adapterID === 'hmrpc') {
764
- if (linkQuality != ' - ') {
843
+ if (adapterID === 'hmrpc') {
844
+ if (linkQuality !== ' - ') {
765
845
  if (deviceUnreachState) {
766
- await getLastStateChange();
846
+ lastContactString = await this.getLastContact(deviceMainSelector.lc);
767
847
  } else {
768
- await getLastContact();
848
+ lastContactString = await this.getLastContact(deviceMainSelector.ts);
769
849
  }
770
850
  } else {
771
- if (deviceStateSelector) { // because old hm devices don't send rssi states
772
- const lastContactOfState = await this.getTimestamp(deviceStateSelector.ts);
773
- const getLastContactOfState = async () => {
774
- lastContactString = this.formatDate(new Date((deviceStateSelector.ts)), 'hh:mm') + ' Uhr';
775
- if (Math.round(lastContactOfState) > 100) {
776
- lastContactString = Math.round(lastContactOfState / 60) + ' Stunden';
777
- }
778
- if (Math.round(lastContactOfState / 60) > 48) {
779
- lastContactString = Math.round(lastContactOfState / 60 / 24) + ' Tagen';
780
- }
781
- return lastContactString;
782
- };
783
- await getLastContactOfState();
784
- } else if (rssiPeerSelector) { // because old hm sensors don't send rssi/state values
785
- const lastContactOfState = await this.getTimestamp(rssiPeerSelector.ts);
786
- const getLastContactOfState = async () => {
787
- lastContactString = this.formatDate(new Date((rssiPeerSelector.ts)), 'hh:mm') + ' Uhr';
788
- if (Math.round(lastContactOfState) > 100) {
789
- lastContactString = Math.round(lastContactOfState / 60) + ' Stunden';
790
- }
791
- if (Math.round(lastContactOfState / 60) > 48) {
792
- lastContactString = Math.round(lastContactOfState / 60 / 24) + ' Tagen';
793
- }
794
- return lastContactString;
795
- };
796
- await getLastContactOfState();
851
+ if (deviceStateSelector) {
852
+ // because old hm devices don't send rssi states
853
+ lastContactString = await this.getLastContact(deviceStateSelector.ts);
854
+ } else if (rssiPeerSelector) {
855
+ // because old hm sensors don't send rssi/state values
856
+ lastContactString = await this.getLastContact(rssiPeerSelector.ts);
797
857
  }
798
858
  }
799
859
  } else {
800
860
  if (!deviceUnreachState) {
801
- await getLastStateChange();
861
+ lastContactString = await this.getLastContact(deviceMainSelector.lc);
802
862
  } else {
803
- await getLastContact();
863
+ lastContactString = await this.getLastContact(deviceMainSelector.ts);
804
864
  }
805
865
  break;
806
866
  }
@@ -809,115 +869,102 @@ class DeviceWatcher extends utils.Adapter {
809
869
  /*=============================================
810
870
  = Set Online Status =
811
871
  =============================================*/
812
- switch (adapterID) {
813
- case 'hmrpc':
814
- case 'hmiP':
815
- case 'maxcube':
816
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
817
- if (deviceUnreachState) {
872
+ if (this.maxMinutes !== undefined) {
873
+ switch (adapterID) {
874
+ case 'hmrpc':
875
+ case 'hmiP':
876
+ case 'maxcube':
877
+ if (this.maxMinutes[adapterID] <= 0) {
878
+ if (deviceUnreachState) {
879
+ deviceState = 'Offline'; //set online state to offline
880
+ linkQuality = '0%'; // set linkQuality to nothing
881
+ }
882
+ } else if (lastDeviceUnreachStateChange > this.maxMinutes[adapterID] && deviceUnreachState) {
818
883
  deviceState = 'Offline'; //set online state to offline
819
884
  linkQuality = '0%'; // set linkQuality to nothing
820
- batteryHealth = ' - '; // set batteryhelth to nothing
821
885
  }
822
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
823
- deviceState = 'Offline'; //set online state to offline
824
- linkQuality = '0%'; // set linkQuality to nothing
825
- batteryHealth = ' - '; // set batteryhelth to nothing
826
- }
827
- break;
828
- case 'ping':
829
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
830
- if (!deviceUnreachState) {
886
+ break;
887
+ case 'ping':
888
+ case 'deconz':
889
+ if (this.maxMinutes[adapterID] <= 0) {
890
+ if (!deviceUnreachState) {
891
+ deviceState = 'Offline'; //set online state to offline
892
+ linkQuality = '0%'; // set linkQuality to nothing
893
+ }
894
+ } else if (lastDeviceUnreachStateChange > this.maxMinutes[adapterID] && !deviceUnreachState) {
831
895
  deviceState = 'Offline'; //set online state to offline
832
896
  linkQuality = '0%'; // set linkQuality to nothing
833
- batteryHealth = ' - '; // set batteryhelth to nothing
834
897
  }
835
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID]) && (!deviceUnreachState)) {
836
- deviceState = 'Offline'; //set online state to offline
837
- linkQuality = '0%'; // set linkQuality to nothing
838
- batteryHealth = ' - '; // set batteryhelth to nothing
839
- }
840
- break;
841
- case 'unifi':
842
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
843
- if (deviceUnreachState === 0) {
898
+ break;
899
+ case 'unifi':
900
+ if (this.maxMinutes[adapterID] <= 0) {
901
+ if (deviceUnreachState === 0) {
902
+ deviceState = 'Offline'; //set online state to offline
903
+ linkQuality = '0%'; // set linkQuality to nothing
904
+ }
905
+ } else if (this.maxMinutes !== undefined && lastContact > this.maxMinutes[adapterID]) {
844
906
  deviceState = 'Offline'; //set online state to offline
845
907
  linkQuality = '0%'; // set linkQuality to nothing
846
- batteryHealth = ' - '; // set batteryhelth to nothing
847
908
  }
848
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
849
- deviceState = 'Offline'; //set online state to offline
850
- linkQuality = '0%'; // set linkQuality to nothing
851
- batteryHealth = ' - '; // set batteryhelth to nothing
852
- }
853
- break;
854
- case 'shelly':
855
- case 'sonoff':
856
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
857
- if (!deviceUnreachState) {
909
+ break;
910
+ case 'shelly':
911
+ case 'sonoff':
912
+ if (this.maxMinutes[adapterID] <= 0) {
913
+ if (!deviceUnreachState) {
914
+ deviceState = 'Offline'; //set online state to offline
915
+ linkQuality = '0%'; // set linkQuality to nothing
916
+ }
917
+ } else if (!deviceUnreachState && lastDeviceUnreachStateChange > this.maxMinutes[adapterID]) {
858
918
  deviceState = 'Offline'; //set online state to offline
859
919
  linkQuality = '0%'; // set linkQuality to nothing
860
- batteryHealth = ' - '; // set batteryhelth to nothing
861
920
  }
862
- } else if ((!deviceUnreachState) && (typeof lastDeviceUnreachStateChange !== 'undefined') && (this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
863
- deviceState = 'Offline'; //set online state to offline
864
- linkQuality = '0%'; // set linkQuality to nothing
865
- batteryHealth = ' - '; // set batteryhelth to nothing
866
- }
867
- break;
868
- case 'mihomeVacuum':
869
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
870
- if (!shortDeviceUnreachState) {
921
+ break;
922
+ case 'mihomeVacuum':
923
+ if (this.maxMinutes[adapterID] <= 0) {
924
+ if (!shortDeviceUnreachState) {
925
+ deviceState = 'Offline'; //set online state to offline
926
+ linkQuality = '0%'; // set linkQuality to nothing
927
+ }
928
+ } else if (lastContact > this.maxMinutes[adapterID]) {
871
929
  deviceState = 'Offline'; //set online state to offline
872
930
  linkQuality = '0%'; // set linkQuality to nothing
873
- batteryHealth = ' - '; // set batteryhelth to nothing
874
931
  }
875
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
876
- deviceState = 'Offline'; //set online state to offline
877
- linkQuality = '0%'; // set linkQuality to nothing
878
- batteryHealth = ' - '; // set batteryhelth to nothing
879
- }
880
- break;
881
- case 'miHome':
882
- if (this.arrDev[i].battery === 'none') {
883
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
884
- if (!deviceUnreachState) {
932
+ break;
933
+ case 'mihome':
934
+ if (this.arrDev[i].battery === 'none') {
935
+ if (this.maxMinutes[adapterID] <= 0) {
936
+ if (!deviceUnreachState) {
937
+ deviceState = 'Offline'; //set online state to offline
938
+ linkQuality = '0%'; // set linkQuality to nothing
939
+ }
940
+ } else if (lastContact > this.maxMinutes[adapterID]) {
941
+ deviceState = 'Offline'; //set online state to offline
942
+ linkQuality = '0%'; // set linkQuality to nothing
943
+ }
944
+ } else {
945
+ if (this.config.mihomeMaxMinutes <= 0) {
946
+ if (this.maxMinutes[adapterID] <= 0) {
947
+ deviceState = 'Offline'; //set online state to offline
948
+ linkQuality = '0%'; // set linkQuality to nothing
949
+ }
950
+ } else if (lastContact > this.maxMinutes[adapterID]) {
885
951
  deviceState = 'Offline'; //set online state to offline
886
952
  linkQuality = '0%'; // set linkQuality to nothing
887
- batteryHealth = ' - '; // set batteryhelth to nothing
888
953
  }
889
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
890
- deviceState = 'Offline'; //set online state to offline
891
- linkQuality = '0%'; // set linkQuality to nothing
892
- batteryHealth = ' - '; // set batteryhelth to nothing
893
954
  }
894
- } else {
895
- if (this.config.mihomeMaxMinutes === -1) {
896
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
955
+ break;
956
+ default:
957
+ if (this.maxMinutes[adapterID] <= 0) {
958
+ if (!deviceUnreachState) {
897
959
  deviceState = 'Offline'; //set online state to offline
898
960
  linkQuality = '0%'; // set linkQuality to nothing
899
- batteryHealth = ' - '; // set batteryhelth to nothing
900
961
  }
901
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
962
+ } else if (lastContact > this.maxMinutes[adapterID]) {
902
963
  deviceState = 'Offline'; //set online state to offline
903
964
  linkQuality = '0%'; // set linkQuality to nothing
904
- batteryHealth = ' - '; // set batteryhelth to nothing
905
- }
906
- }
907
- break;
908
- default:
909
- if ((this.maxMinutes !== undefined) && (this.maxMinutes[adapterID] === -1)) {
910
- if (!deviceUnreachState) {
911
- deviceState = 'Offline'; //set online state to offline
912
- linkQuality = '0%'; // set linkQuality to nothing
913
- batteryHealth = ' - '; // set batteryhelth to nothing
914
965
  }
915
- } else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
916
- deviceState = 'Offline'; //set online state to offline
917
- linkQuality = '0%'; // set linkQuality to nothing
918
- batteryHealth = ' - '; // set batteryhelth to nothing
919
- }
920
- break;
966
+ break;
967
+ }
921
968
  }
922
969
  } catch (error) {
923
970
  this.errorReporting('[getLastContact]', error);
@@ -930,34 +977,32 @@ class DeviceWatcher extends utils.Adapter {
930
977
 
931
978
  /* Add only devices with battery in the rawlist */
932
979
  if (this.listOnlyBattery) {
933
- if (deviceBatteryState || shortDeviceBatteryState) {
934
- this.listAllDevicesRaw.push(
935
- {
936
- 'Path': id,
937
- 'Device': deviceName,
938
- 'Adapter': await this.capitalize(adapterID),
939
- 'Battery': batteryHealth,
940
- 'LowBat': lowBatIndicator,
941
- 'Signal strength': linkQuality,
942
- 'Last contact': lastContactString,
943
- 'Status': deviceState
944
- }
945
- );
980
+ if (isBatteryDevice) {
981
+ this.listAllDevicesRaw.push({
982
+ Path: id,
983
+ Device: deviceName,
984
+ Adapter: adapter,
985
+ isBatteryDevice: isBatteryDevice,
986
+ Battery: batteryHealth,
987
+ LowBat: lowBatIndicator,
988
+ 'Signal strength': linkQuality,
989
+ 'Last contact': lastContactString,
990
+ Status: deviceState,
991
+ });
946
992
  }
947
993
  } else {
948
994
  /* Add all devices */
949
- this.listAllDevicesRaw.push(
950
- {
951
- 'Path': id,
952
- 'Device': deviceName,
953
- 'Adapter': await this.capitalize(adapterID),
954
- 'Battery': batteryHealth,
955
- 'LowBat': lowBatIndicator,
956
- 'Signal strength': linkQuality,
957
- 'Last contact': lastContactString,
958
- 'Status': deviceState
959
- }
960
- );
995
+ this.listAllDevicesRaw.push({
996
+ Path: id,
997
+ Device: deviceName,
998
+ Adapter: adapter,
999
+ isBatteryDevice: isBatteryDevice,
1000
+ Battery: batteryHealth,
1001
+ LowBat: lowBatIndicator,
1002
+ 'Signal strength': linkQuality,
1003
+ 'Last contact': lastContactString,
1004
+ Status: deviceState,
1005
+ });
961
1006
  }
962
1007
  } else {
963
1008
  /* cancel run if unloaded was called. */
@@ -968,7 +1013,6 @@ class DeviceWatcher extends utils.Adapter {
968
1013
  await this.countDevices();
969
1014
  } // <-- end of createData
970
1015
 
971
-
972
1016
  /**
973
1017
  * @param {string} adptName - Adapter name
974
1018
  */
@@ -980,14 +1024,13 @@ class DeviceWatcher extends utils.Adapter {
980
1024
 
981
1025
  try {
982
1026
  for (let i = 0; i < this.arrDev.length; i++) {
983
-
984
- if (this.arrDev[i].adapter.includes(adptName)) { // list device only if selected adapter matched with device
1027
+ if (this.arrDev[i].adapterID.includes(adptName)) {
1028
+ // list device only if selected adapter matched with device
985
1029
  await this.createData(i);
986
1030
  }
987
1031
  }
988
1032
 
989
1033
  await this.writeDatapoints(adptName); // fill the datapoints
990
-
991
1034
  } catch (error) {
992
1035
  this.errorReporting('[createDataForEachAdapter]', error);
993
1036
  }
@@ -995,8 +1038,10 @@ class DeviceWatcher extends utils.Adapter {
995
1038
  this.log.debug(`Function finished: ${this.createDataForEachAdapter.name}`);
996
1039
  } // <-- end of createDataForEachAdapter
997
1040
 
1041
+ /**
1042
+ * create Data of all selected adapter in one list
1043
+ */
998
1044
  async createDataOfAllAdapter() {
999
- // create Data of all selected adapter in one list
1000
1045
  this.log.debug(`Function started: ${this.createDataOfAllAdapter.name}`);
1001
1046
 
1002
1047
  try {
@@ -1014,7 +1059,6 @@ class DeviceWatcher extends utils.Adapter {
1014
1059
  if (this.config.checkSendOfflineMsg) await this.sendOfflineNotifications();
1015
1060
 
1016
1061
  await this.writeDatapoints(); // fill the datapoints
1017
-
1018
1062
  } catch (error) {
1019
1063
  this.errorReporting('[createDataOfAllAdapter]', error);
1020
1064
  }
@@ -1022,13 +1066,11 @@ class DeviceWatcher extends utils.Adapter {
1022
1066
  this.log.debug(`Function finished: ${this.createDataOfAllAdapter.name}`);
1023
1067
  } // <-- end of createDataOfAllAdapter
1024
1068
 
1025
-
1026
1069
  /**
1027
1070
  * Notification service
1028
1071
  * @param {string} text - Text which should be send
1029
1072
  */
1030
1073
  async sendNotification(text) {
1031
-
1032
1074
  // Pushover
1033
1075
  try {
1034
1076
  if (this.config.instancePushover) {
@@ -1042,7 +1084,7 @@ class DeviceWatcher extends utils.Adapter {
1042
1084
  message: text,
1043
1085
  title: this.config.titlePushover,
1044
1086
  device: this.config.devicePushover,
1045
- priority: this.config.prioPushover
1087
+ priority: this.config.prioPushover,
1046
1088
  });
1047
1089
  }
1048
1090
  }
@@ -1062,7 +1104,7 @@ class DeviceWatcher extends utils.Adapter {
1062
1104
  await this.sendToAsync(this.config.instanceTelegram, 'send', {
1063
1105
  text: text,
1064
1106
  user: this.config.deviceTelegram,
1065
- chatId: this.config.chatIdTelegram
1107
+ chatId: this.config.chatIdTelegram,
1066
1108
  });
1067
1109
  }
1068
1110
  }
@@ -1081,7 +1123,7 @@ class DeviceWatcher extends utils.Adapter {
1081
1123
  } else {
1082
1124
  await this.sendToAsync(this.config.instanceWhatsapp, 'send', {
1083
1125
  text: text,
1084
- phone: this.config.phoneWhatsapp
1126
+ phone: this.config.phoneWhatsapp,
1085
1127
  });
1086
1128
  }
1087
1129
  }
@@ -1101,7 +1143,7 @@ class DeviceWatcher extends utils.Adapter {
1101
1143
  await this.sendToAsync(this.config.instanceEmail, 'send', {
1102
1144
  sendTo: this.config.sendToEmail,
1103
1145
  text: text,
1104
- subject: this.config.subjectEmail
1146
+ subject: this.config.subjectEmail,
1105
1147
  });
1106
1148
  }
1107
1149
  }
@@ -1119,7 +1161,10 @@ class DeviceWatcher extends utils.Adapter {
1119
1161
  this.log.warn('Jarvis instance is not running. Message could not be sent. Please check your instance configuration.');
1120
1162
  } else {
1121
1163
  const jsonText = JSON.stringify(text);
1122
- await this.setForeignStateAsync(`${this.config.instanceJarvis}.addNotification`, '{"title":"' + this.config.titleJarvis + ' (' + this.formatDate(new Date(), 'DD.MM.YYYY - hh:mm:ss') + ')","message": ' + jsonText + ',"display": "drawer"}');
1164
+ await this.setForeignStateAsync(
1165
+ `${this.config.instanceJarvis}.addNotification`,
1166
+ '{"title":"' + this.config.titleJarvis + ' (' + this.formatDate(new Date(), 'DD.MM.YYYY - hh:mm:ss') + ')","message": ' + jsonText + ',"display": "drawer"}',
1167
+ );
1123
1168
  }
1124
1169
  }
1125
1170
  } catch (error) {
@@ -1136,7 +1181,10 @@ class DeviceWatcher extends utils.Adapter {
1136
1181
  this.log.warn('Lovelace instance is not running. Message could not be sent. Please check your instance configuration.');
1137
1182
  } else {
1138
1183
  const jsonText = JSON.stringify(text);
1139
- await this.setForeignStateAsync(`${this.config.instanceLovelace}.notifications.add`, '{"message":' + jsonText + ', "title":"' + this.config.titleLovelace + ' (' + this.formatDate(new Date(), 'DD.MM.YYYY - hh:mm:ss') + ')"}');
1184
+ await this.setForeignStateAsync(
1185
+ `${this.config.instanceLovelace}.notifications.add`,
1186
+ '{"message":' + jsonText + ', "title":"' + this.config.titleLovelace + ' (' + this.formatDate(new Date(), 'DD.MM.YYYY - hh:mm:ss') + ')"}',
1187
+ );
1140
1188
  }
1141
1189
  }
1142
1190
  } catch (error) {
@@ -1144,10 +1192,11 @@ class DeviceWatcher extends utils.Adapter {
1144
1192
  }
1145
1193
  } // <-- End of sendNotification function
1146
1194
 
1195
+ /**
1196
+ * send shedule message for low battery devices
1197
+ */
1147
1198
  async sendBatteryNotifyShedule() {
1148
- // send message for low battery devices
1149
-
1150
- const time = (this.config.checkSendBatteryTime).split(':');
1199
+ const time = this.config.checkSendBatteryTime.split(':');
1151
1200
 
1152
1201
  const checkDays = []; // list of selected days
1153
1202
 
@@ -1160,8 +1209,9 @@ class DeviceWatcher extends utils.Adapter {
1160
1209
  if (this.config.checkSaturday) checkDays.push(6);
1161
1210
  if (this.config.checkSunday) checkDays.push(0);
1162
1211
 
1163
- if (checkDays.length >= 1) { // check if an day is selected
1164
- this.log.debug(`Number of selected days for daily battery message: ${checkDays.length}. Send Message on: ${(checkDays).join(', ')} ...`);
1212
+ if (checkDays.length >= 1) {
1213
+ // check if an day is selected
1214
+ this.log.debug(`Number of selected days for daily battery message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
1165
1215
  } else {
1166
1216
  this.log.warn(`No days selected for daily battery message. Please check the instance configuration!`);
1167
1217
  return; // cancel function if no day is selected
@@ -1173,20 +1223,17 @@ class DeviceWatcher extends utils.Adapter {
1173
1223
  try {
1174
1224
  let deviceList = '';
1175
1225
 
1176
- for (const id of this.batteryLowPowered) {
1177
- if (!this.blacklistNotify.includes(id['Device'])) {
1226
+ for (const id of this.batteryLowPoweredRaw) {
1227
+ if (!this.blacklistNotify.includes(id['Path'])) {
1178
1228
  deviceList = `${deviceList}\n${id['Device']} (${id['Battery']})`;
1179
1229
  }
1180
1230
  }
1181
-
1182
- if ((this.lowBatteryPoweredCount > 0) && (deviceList.length > 0)) {
1231
+ if (deviceList.length > 0) {
1183
1232
  this.log.info(`Niedrige Batteriezustände: ${deviceList}`);
1184
1233
  this.setStateAsync('lastNotification', `Niedrige Batteriezustände: ${deviceList}`, true);
1185
1234
 
1186
1235
  this.sendNotification(`Niedriege Batteriezustände: ${deviceList}`);
1187
-
1188
1236
  }
1189
-
1190
1237
  } catch (error) {
1191
1238
  this.errorReporting('[sendBatteryNotifyShedule]', error);
1192
1239
  }
@@ -1194,48 +1241,48 @@ class DeviceWatcher extends utils.Adapter {
1194
1241
  }
1195
1242
  } //<--End of battery notification
1196
1243
 
1244
+ /**
1245
+ * send message if an device is offline
1246
+ */
1197
1247
  async sendOfflineNotifications() {
1198
- // send message if an device is offline
1199
-
1200
1248
  this.log.debug(`Start the function: ${this.sendOfflineNotifications.name}`);
1201
1249
 
1202
1250
  try {
1203
1251
  let msg = '';
1204
1252
  let deviceList = '';
1205
- const offlineDevicesCountOld = await this.getOwnInitValue('offlineCount');
1206
1253
 
1207
- if ((this.offlineDevicesCount !== offlineDevicesCountOld)) {
1208
-
1209
- for (const id of this.offlineDevices) {
1210
- if (!this.blacklistNotify.includes(id['Device'])) {
1211
- deviceList = `${deviceList}\n${id['Device']} (${id['Last contact']})`;
1212
- }
1254
+ for (const id of this.offlineDevicesRaw) {
1255
+ if (!this.blacklistNotify.includes(id['Path'])) {
1256
+ deviceList = `${deviceList}\n${id['Device']} (${id['Last contact']})`;
1213
1257
  }
1214
- if (deviceList.length > 0) {
1215
- if (deviceList.length == 0) {
1216
- msg = 'Alle Geräte sind Online.';
1217
- } else if (deviceList.length == 1) { // make singular if it is only one device
1218
- msg = 'Folgendes Gerät ist seit einiger Zeit nicht erreichbar: \n';
1219
- } else if (deviceList.length >= 2) { //make plural if it is more than one device
1220
- msg = `Folgende Geräte sind seit einiger Zeit nicht erreichbar: \n`;
1221
- }
1222
-
1223
- this.log.info(msg + deviceList);
1224
- await this.setStateAsync('lastNotification', msg + deviceList, true);
1225
- await this.sendNotification(msg + deviceList);
1258
+ }
1259
+ if (deviceList.length !== this.offlineDevicesCountRawOld) {
1260
+ if (deviceList.length == 0) {
1261
+ msg = 'Alle Geräte sind Online.';
1262
+ } else if (deviceList.length == 1) {
1263
+ // make singular if it is only one device
1264
+ msg = 'Folgendes Gerät ist seit einiger Zeit nicht erreichbar: \n';
1265
+ } else if (deviceList.length >= 2) {
1266
+ //make plural if it is more than one device
1267
+ msg = `Folgende Geräte sind seit einiger Zeit nicht erreichbar: \n`;
1226
1268
  }
1227
1269
 
1270
+ this.log.info(msg + deviceList);
1271
+ this.offlineDevicesCountRawOld = deviceList.length;
1272
+ await this.setStateAsync('lastNotification', msg + deviceList, true);
1273
+ await this.sendNotification(msg + deviceList);
1228
1274
  }
1229
1275
  } catch (error) {
1230
1276
  this.errorReporting('[sendOfflineMessage]', error);
1231
1277
  }
1232
1278
  this.log.debug(`Finished the function: ${this.sendOfflineNotifications.name}`);
1233
- }//<--End of offline notification
1279
+ } //<--End of offline notification
1234
1280
 
1281
+ /**
1282
+ * send shedule message with offline devices
1283
+ */
1235
1284
  async sendOfflineNotificationsShedule() {
1236
- // send daily an overview with offline devices
1237
-
1238
- const time = (this.config.checkSendOfflineTime).split(':');
1285
+ const time = this.config.checkSendOfflineTime.split(':');
1239
1286
 
1240
1287
  const checkDays = []; // list of selected days
1241
1288
 
@@ -1248,8 +1295,9 @@ class DeviceWatcher extends utils.Adapter {
1248
1295
  if (this.config.checkOfflineSaturday) checkDays.push(6);
1249
1296
  if (this.config.checkOfflineSunday) checkDays.push(0);
1250
1297
 
1251
- if (checkDays.length >= 1) { // check if an day is selected
1252
- this.log.debug(`Number of selected days for daily offline message: ${checkDays.length}. Send Message on: ${(checkDays).join(', ')} ...`);
1298
+ if (checkDays.length >= 1) {
1299
+ // check if an day is selected
1300
+ this.log.debug(`Number of selected days for daily offline message: ${checkDays.length}. Send Message on: ${checkDays.join(', ')} ...`);
1253
1301
  } else {
1254
1302
  this.log.warn(`No days selected for daily offline message. Please check the instance configuration!`);
1255
1303
  return; // cancel function if no day is selected
@@ -1261,8 +1309,8 @@ class DeviceWatcher extends utils.Adapter {
1261
1309
  try {
1262
1310
  let deviceList = '';
1263
1311
 
1264
- for (const id of this.offlineDevices) {
1265
- if (!this.blacklistNotify.includes(id['Device'])) {
1312
+ for (const id of this.offlineDevicesRaw) {
1313
+ if (!this.blacklistNotify.includes(id['Path'])) {
1266
1314
  deviceList = `${deviceList}\n${id['Device']} (${id['Last contact']})`;
1267
1315
  }
1268
1316
  }
@@ -1273,14 +1321,16 @@ class DeviceWatcher extends utils.Adapter {
1273
1321
 
1274
1322
  this.sendNotification(`Geräte Offline: ${deviceList}`);
1275
1323
  }
1276
-
1277
1324
  } catch (error) {
1278
1325
  this.errorReporting('[sendOfflineNotificationsShedule]', error);
1279
1326
  }
1280
1327
  });
1281
1328
  }
1282
- }//<--End of daily offline notification
1329
+ } //<--End of daily offline notification
1283
1330
 
1331
+ /**
1332
+ * reset arrays and counts
1333
+ */
1284
1334
  async resetVars() {
1285
1335
  //Reset all arrays and counts
1286
1336
  this.log.debug(`Function started: ${this.resetVars.name}`);
@@ -1292,6 +1342,13 @@ class DeviceWatcher extends utils.Adapter {
1292
1342
  this.batteryLowPowered = [];
1293
1343
  this.listAllDevices = [];
1294
1344
  this.listAllDevicesRaw = [];
1345
+
1346
+ // raws
1347
+ this.batteryLowPoweredRaw = [];
1348
+ this.offlineDevicesRaw = [];
1349
+ this.lowBatteryPoweredCountRaw = 0;
1350
+ this.offlineDevicesCountRaw = 0;
1351
+
1295
1352
  // counts
1296
1353
  this.offlineDevicesCount = 0;
1297
1354
  this.deviceCounter = 0;
@@ -1302,7 +1359,6 @@ class DeviceWatcher extends utils.Adapter {
1302
1359
  this.log.debug(`Function finished: ${this.resetVars.name}`);
1303
1360
  } // <-- end of resetVars
1304
1361
 
1305
-
1306
1362
  /**
1307
1363
  * @param {string} [adptName] - Adaptername
1308
1364
  */
@@ -1312,7 +1368,6 @@ class DeviceWatcher extends utils.Adapter {
1312
1368
  this.log.debug(`Start the function: ${this.writeDatapoints.name}`);
1313
1369
 
1314
1370
  try {
1315
-
1316
1371
  let dpSubFolder;
1317
1372
  //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
1318
1373
  if (adptName) {
@@ -1328,62 +1383,93 @@ class DeviceWatcher extends utils.Adapter {
1328
1383
 
1329
1384
  if (this.deviceCounter == 0) {
1330
1385
  // if no device is count, write the JSON List with default value
1331
- this.listAllDevices = [{ 'Device': '--none--', 'Adapter': '', 'Battery': '', 'Last contact': '', 'Signal strength': '' }];
1386
+ this.listAllDevices = [{ Device: '--none--', Adapter: '', Battery: '', 'Last contact': '', 'Signal strength': '' }];
1332
1387
  }
1333
1388
  await this.setStateAsync(`${dpSubFolder}listAll`, { val: JSON.stringify(this.listAllDevices), ack: true });
1334
1389
 
1335
1390
  if (this.linkQualityCount == 0) {
1336
1391
  // if no device is count, write the JSON List with default value
1337
- this.linkQualityDevices = [{ 'Device': '--none--', 'Adapter': '', 'Signal strength': '' }];
1392
+ this.linkQualityDevices = [{ Device: '--none--', Adapter: '', 'Signal strength': '' }];
1338
1393
  }
1339
1394
  //write JSON list
1340
- await this.setStateAsync(`${dpSubFolder}linkQualityList`, { val: JSON.stringify(this.linkQualityDevices), ack: true });
1395
+ await this.setStateAsync(`${dpSubFolder}linkQualityList`, {
1396
+ val: JSON.stringify(this.linkQualityDevices),
1397
+ ack: true,
1398
+ });
1341
1399
  //write HTML list
1342
- if (this.config.createHtmlList) await this.setStateAsync(`${dpSubFolder}linkQualityListHTML`, { val: await this.creatLinkQualityListHTML(this.linkQualityDevices, this.linkQualityCount), ack: true });
1400
+ if (this.config.createHtmlList)
1401
+ await this.setStateAsync(`${dpSubFolder}linkQualityListHTML`, {
1402
+ val: await this.creatLinkQualityListHTML(this.linkQualityDevices, this.linkQualityCount),
1403
+ ack: true,
1404
+ });
1343
1405
 
1344
1406
  if (this.offlineDevicesCount == 0) {
1345
1407
  // if no device is count, write the JSON List with default value
1346
- this.offlineDevices = [{ 'Device': '--none--', 'Adapter': '', 'Last contact': '' }];
1408
+ this.offlineDevices = [{ Device: '--none--', Adapter: '', 'Last contact': '' }];
1347
1409
  }
1348
1410
  //write JSON list
1349
- await this.setStateAsync(`${dpSubFolder}offlineList`, { val: JSON.stringify(this.offlineDevices), ack: true });
1411
+ await this.setStateAsync(`${dpSubFolder}offlineList`, {
1412
+ val: JSON.stringify(this.offlineDevices),
1413
+ ack: true,
1414
+ });
1350
1415
  //write HTML list
1351
- if (this.config.createHtmlList) await this.setStateAsync(`${dpSubFolder}offlineListHTML`, { val: await this.createOfflineListHTML(this.offlineDevices, this.offlineDevicesCount), ack: true });
1416
+ if (this.config.createHtmlList)
1417
+ await this.setStateAsync(`${dpSubFolder}offlineListHTML`, {
1418
+ val: await this.createOfflineListHTML(this.offlineDevices, this.offlineDevicesCount),
1419
+ ack: true,
1420
+ });
1352
1421
 
1353
1422
  if (this.batteryPoweredCount == 0) {
1354
1423
  // if no device is count, write the JSON List with default value
1355
- this.batteryPowered = [{ 'Device': '--none--', 'Adapter': '', 'Battery': '' }];
1424
+ this.batteryPowered = [{ Device: '--none--', Adapter: '', Battery: '' }];
1356
1425
  }
1357
1426
  //write JSON list
1358
- await this.setStateAsync(`${dpSubFolder}batteryList`, { val: JSON.stringify(this.batteryPowered), ack: true });
1427
+ await this.setStateAsync(`${dpSubFolder}batteryList`, {
1428
+ val: JSON.stringify(this.batteryPowered),
1429
+ ack: true,
1430
+ });
1359
1431
  //write HTML list
1360
- if (this.config.createHtmlList) await this.setStateAsync(`${dpSubFolder}batteryListHTML`, { val: await this.createBatteryListHTML(this.batteryPowered, this.batteryPoweredCount, false), ack: true });
1432
+ if (this.config.createHtmlList)
1433
+ await this.setStateAsync(`${dpSubFolder}batteryListHTML`, {
1434
+ val: await this.createBatteryListHTML(this.batteryPowered, this.batteryPoweredCount, false),
1435
+ ack: true,
1436
+ });
1361
1437
 
1362
1438
  if (this.lowBatteryPoweredCount == 0) {
1363
1439
  // if no device is count, write the JSON List with default value
1364
- this.batteryLowPowered = [{ 'Device': '--none--', 'Adapter': '', 'Battery': '' }];
1440
+ this.batteryLowPowered = [{ Device: '--none--', Adapter: '', Battery: '' }];
1365
1441
  }
1366
1442
  //write JSON list
1367
- await this.setStateAsync(`${dpSubFolder}lowBatteryList`, { val: JSON.stringify(this.batteryLowPowered), ack: true });
1443
+ await this.setStateAsync(`${dpSubFolder}lowBatteryList`, {
1444
+ val: JSON.stringify(this.batteryLowPowered),
1445
+ ack: true,
1446
+ });
1368
1447
  //write HTML list
1369
- if (this.config.createHtmlList) await this.setStateAsync(`${dpSubFolder}lowBatteryListHTML`, { val: await this.createBatteryListHTML(this.batteryLowPowered, this.lowBatteryPoweredCount, true), ack: true });
1448
+ if (this.config.createHtmlList)
1449
+ await this.setStateAsync(`${dpSubFolder}lowBatteryListHTML`, {
1450
+ val: await this.createBatteryListHTML(this.batteryLowPowered, this.lowBatteryPoweredCount, true),
1451
+ ack: true,
1452
+ });
1370
1453
 
1371
1454
  // create timestamp of last run
1372
1455
  const lastCheck = this.formatDate(new Date(), 'DD.MM.YYYY') + ' - ' + this.formatDate(new Date(), 'hh:mm:ss');
1373
1456
  await this.setStateAsync('lastCheck', lastCheck, true);
1374
- }
1375
- catch (error) {
1457
+ } catch (error) {
1376
1458
  this.errorReporting('[writeDatapoints]', error);
1377
1459
  }
1378
1460
  this.log.debug(`Function finished: ${this.writeDatapoints.name}`);
1379
- }//<--End of writing Datapoints
1461
+ } //<--End of writing Datapoints
1380
1462
 
1381
1463
  /**
1382
1464
  * @param {object} devices - Device
1383
1465
  * @param {number} deviceCount - Counted devices
1384
1466
  */
1385
1467
  async creatLinkQualityListHTML(devices, deviceCount) {
1386
- devices = devices.sort((a, b) => { return a.Device.localeCompare(b.Device); });
1468
+ devices = devices.sort((a, b) => {
1469
+ a = a.Device || '';
1470
+ b = b.Device || '';
1471
+ return a.localeCompare(b);
1472
+ });
1387
1473
  let html = `<center>
1388
1474
  <b>Link Quality Devices:<font> ${deviceCount}</b><small></small></font>
1389
1475
  <p></p>
@@ -1415,7 +1501,11 @@ class DeviceWatcher extends utils.Adapter {
1415
1501
  * @param {number} deviceCount - Counted devices
1416
1502
  */
1417
1503
  async createOfflineListHTML(devices, deviceCount) {
1418
- devices = devices.sort((a, b) => { return a.Device.localeCompare(b.Device); });
1504
+ devices = devices.sort((a, b) => {
1505
+ a = a.Device || '';
1506
+ b = b.Device || '';
1507
+ return a.localeCompare(b);
1508
+ });
1419
1509
  let html = `<center>
1420
1510
  <b>Offline Devices: <font color=${deviceCount == 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
1421
1511
  <p></p>
@@ -1448,7 +1538,11 @@ class DeviceWatcher extends utils.Adapter {
1448
1538
  * @param {object} [isLowBatteryList] - list Low Battery Devices
1449
1539
  */
1450
1540
  async createBatteryListHTML(devices, deviceCount, isLowBatteryList) {
1451
- devices = devices.sort((a, b) => { return a.Device.localeCompare(b.Device); });
1541
+ devices = devices.sort((a, b) => {
1542
+ a = a.Device || '';
1543
+ b = b.Device || '';
1544
+ return a.localeCompare(b);
1545
+ });
1452
1546
  let html = `<center>
1453
1547
  <b>${isLowBatteryList == true ? 'Schwache ' : ''}Batterie Devices: <font color=${isLowBatteryList == true ? (deviceCount > 0 ? 'orange' : '#3bcf0e') : ''}>${deviceCount}</b></font>
1454
1548
  <p></p>
@@ -1462,7 +1556,6 @@ class DeviceWatcher extends utils.Adapter {
1462
1556
  <tr>
1463
1557
  <td colspan="5"><hr></td>
1464
1558
  </tr>`;
1465
-
1466
1559
  for (const device of devices) {
1467
1560
  html += `<tr>
1468
1561
  <td><font>${device.Device}</font></td>
@@ -1473,7 +1566,6 @@ class DeviceWatcher extends utils.Adapter {
1473
1566
  } else {
1474
1567
  html += `<td align=right><font color=#3bcf0e>${device.Battery}</font></td>`;
1475
1568
  }
1476
-
1477
1569
  html += `</tr>`;
1478
1570
  }
1479
1571
 
@@ -1486,7 +1578,6 @@ class DeviceWatcher extends utils.Adapter {
1486
1578
  * @param {object} adptName - Adaptername of devices
1487
1579
  */
1488
1580
  async createDPsForEachAdapter(adptName) {
1489
-
1490
1581
  await this.setObjectNotExistsAsync(`${adptName}`, {
1491
1582
  type: 'channel',
1492
1583
  common: {
@@ -1496,210 +1587,210 @@ class DeviceWatcher extends utils.Adapter {
1496
1587
  });
1497
1588
 
1498
1589
  await this.setObjectNotExistsAsync(`${adptName}.offlineCount`, {
1499
- 'type': 'state',
1500
- 'common': {
1501
- 'name': {
1502
- 'en': 'Number of devices offline',
1503
- 'de': 'Anzahl der Geräte offline',
1504
- 'ru': 'Количество устройств offline',
1505
- 'pt': 'Número de dispositivos offline',
1506
- 'nl': 'Nummer van apparatuur offline',
1507
- 'fr': 'Nombre de dispositifs hors ligne',
1508
- 'it': 'Numero di dispositivi offline',
1509
- 'es': 'Número de dispositivos sin conexión',
1510
- 'pl': 'Ilość urządzeń offline',
1511
- 'zh-cn': '线内装置数量'
1590
+ type: 'state',
1591
+ common: {
1592
+ name: {
1593
+ en: 'Number of devices offline',
1594
+ de: 'Anzahl der Geräte offline',
1595
+ ru: 'Количество устройств offline',
1596
+ pt: 'Número de dispositivos offline',
1597
+ nl: 'Nummer van apparatuur offline',
1598
+ fr: 'Nombre de dispositifs hors ligne',
1599
+ it: 'Numero di dispositivi offline',
1600
+ es: 'Número de dispositivos sin conexión',
1601
+ pl: 'Ilość urządzeń offline',
1602
+ 'zh-cn': '线内装置数量',
1512
1603
  },
1513
- 'type': 'number',
1514
- 'role': 'value',
1515
- 'read': true,
1516
- 'write': false,
1604
+ type: 'number',
1605
+ role: 'value',
1606
+ read: true,
1607
+ write: false,
1517
1608
  },
1518
- 'native': {}
1609
+ native: {},
1519
1610
  });
1520
1611
 
1521
1612
  await this.setObjectNotExistsAsync(`${adptName}.offlineList`, {
1522
- 'type': 'state',
1523
- 'common': {
1524
- 'name': {
1525
- 'en': 'List of offline devices',
1526
- 'de': 'Liste der Offline-Geräte',
1527
- 'ru': 'Список оффлайн устройств',
1528
- 'pt': 'Lista de dispositivos off-line',
1529
- 'nl': 'List van offline apparatuur',
1530
- 'fr': 'Liste des dispositifs hors ligne',
1531
- 'it': 'Elenco dei dispositivi offline',
1532
- 'es': 'Lista de dispositivos sin conexión',
1533
- 'pl': 'Lista urządzeń offline',
1534
- 'zh-cn': '线装置清单'
1613
+ type: 'state',
1614
+ common: {
1615
+ name: {
1616
+ en: 'List of offline devices',
1617
+ de: 'Liste der Offline-Geräte',
1618
+ ru: 'Список оффлайн устройств',
1619
+ pt: 'Lista de dispositivos off-line',
1620
+ nl: 'List van offline apparatuur',
1621
+ fr: 'Liste des dispositifs hors ligne',
1622
+ it: 'Elenco dei dispositivi offline',
1623
+ es: 'Lista de dispositivos sin conexión',
1624
+ pl: 'Lista urządzeń offline',
1625
+ 'zh-cn': '线装置清单',
1535
1626
  },
1536
- 'type': 'array',
1537
- 'role': 'json',
1538
- 'read': true,
1539
- 'write': false,
1627
+ type: 'array',
1628
+ role: 'json',
1629
+ read: true,
1630
+ write: false,
1540
1631
  },
1541
- 'native': {}
1632
+ native: {},
1542
1633
  });
1543
1634
 
1544
1635
  await this.setObjectNotExistsAsync(`${adptName}.listAll`, {
1545
- 'type': 'state',
1546
- 'common': {
1547
- 'name': {
1548
- 'en': 'List of all devices',
1549
- 'de': 'Liste aller Geräte',
1550
- 'ru': 'Список всех устройств',
1551
- 'pt': 'Lista de todos os dispositivos',
1552
- 'nl': 'List van alle apparaten',
1553
- 'fr': 'Liste de tous les dispositifs',
1554
- 'it': 'Elenco di tutti i dispositivi',
1555
- 'es': 'Lista de todos los dispositivos',
1556
- 'pl': 'Lista wszystkich urządzeń',
1557
- 'zh-cn': '所有装置清单'
1636
+ type: 'state',
1637
+ common: {
1638
+ name: {
1639
+ en: 'List of all devices',
1640
+ de: 'Liste aller Geräte',
1641
+ ru: 'Список всех устройств',
1642
+ pt: 'Lista de todos os dispositivos',
1643
+ nl: 'List van alle apparaten',
1644
+ fr: 'Liste de tous les dispositifs',
1645
+ it: 'Elenco di tutti i dispositivi',
1646
+ es: 'Lista de todos los dispositivos',
1647
+ pl: 'Lista wszystkich urządzeń',
1648
+ 'zh-cn': '所有装置清单',
1558
1649
  },
1559
- 'type': 'array',
1560
- 'role': 'json',
1561
- 'read': true,
1562
- 'write': false,
1650
+ type: 'array',
1651
+ role: 'json',
1652
+ read: true,
1653
+ write: false,
1563
1654
  },
1564
- 'native': {}
1655
+ native: {},
1565
1656
  });
1566
1657
 
1567
1658
  await this.setObjectNotExistsAsync(`${adptName}.linkQualityList`, {
1568
- 'type': 'state',
1569
- 'common': {
1570
- 'name': {
1571
- 'en': 'List of devices with signal strength',
1572
- 'de': 'Liste der Geräte mit Signalstärke',
1573
- 'ru': 'Список устройств с силой сигнала',
1574
- 'pt': 'Lista de dispositivos com força de sinal',
1575
- 'nl': 'List van apparaten met signaalkracht',
1576
- 'fr': 'Liste des dispositifs avec force de signal',
1577
- 'it': 'Elenco dei dispositivi con forza del segnale',
1578
- 'es': 'Lista de dispositivos con fuerza de señal',
1579
- 'pl': 'Lista urządzeń z siłą sygnałową',
1580
- 'zh-cn': '具有信号实力的装置清单'
1659
+ type: 'state',
1660
+ common: {
1661
+ name: {
1662
+ en: 'List of devices with signal strength',
1663
+ de: 'Liste der Geräte mit Signalstärke',
1664
+ ru: 'Список устройств с силой сигнала',
1665
+ pt: 'Lista de dispositivos com força de sinal',
1666
+ nl: 'List van apparaten met signaalkracht',
1667
+ fr: 'Liste des dispositifs avec force de signal',
1668
+ it: 'Elenco dei dispositivi con forza del segnale',
1669
+ es: 'Lista de dispositivos con fuerza de señal',
1670
+ pl: 'Lista urządzeń z siłą sygnałową',
1671
+ 'zh-cn': '具有信号实力的装置清单',
1581
1672
  },
1582
- 'type': 'array',
1583
- 'role': 'json',
1584
- 'read': true,
1585
- 'write': false,
1673
+ type: 'array',
1674
+ role: 'json',
1675
+ read: true,
1676
+ write: false,
1586
1677
  },
1587
- 'native': {}
1678
+ native: {},
1588
1679
  });
1589
1680
 
1590
1681
  await this.setObjectNotExistsAsync(`${adptName}.countAll`, {
1591
- 'type': 'state',
1592
- 'common': {
1593
- 'name': {
1594
- 'en': 'Number of all devices',
1595
- 'de': 'Anzahl aller Geräte',
1596
- 'ru': 'Количество всех устройств',
1597
- 'pt': 'Número de todos os dispositivos',
1598
- 'nl': 'Nummer van alle apparaten',
1599
- 'fr': 'Nombre de tous les appareils',
1600
- 'it': 'Numero di tutti i dispositivi',
1601
- 'es': 'Número de todos los dispositivos',
1602
- 'pl': 'Ilość wszystkich urządzeń',
1603
- 'zh-cn': '所有装置的数目'
1682
+ type: 'state',
1683
+ common: {
1684
+ name: {
1685
+ en: 'Number of all devices',
1686
+ de: 'Anzahl aller Geräte',
1687
+ ru: 'Количество всех устройств',
1688
+ pt: 'Número de todos os dispositivos',
1689
+ nl: 'Nummer van alle apparaten',
1690
+ fr: 'Nombre de tous les appareils',
1691
+ it: 'Numero di tutti i dispositivi',
1692
+ es: 'Número de todos los dispositivos',
1693
+ pl: 'Ilość wszystkich urządzeń',
1694
+ 'zh-cn': '所有装置的数目',
1604
1695
  },
1605
- 'type': 'number',
1606
- 'role': 'value',
1607
- 'read': true,
1608
- 'write': false,
1696
+ type: 'number',
1697
+ role: 'value',
1698
+ read: true,
1699
+ write: false,
1609
1700
  },
1610
- 'native': {}
1701
+ native: {},
1611
1702
  });
1612
1703
 
1613
1704
  await this.setObjectNotExistsAsync(`${adptName}.batteryList`, {
1614
- 'type': 'state',
1615
- 'common': {
1616
- 'name': {
1617
- 'en': 'List of devices with battery state',
1618
- 'de': 'Liste der Geräte mit Batteriezustand',
1619
- 'ru': 'Список устройств с состоянием батареи',
1620
- 'pt': 'Lista de dispositivos com estado da bateria',
1621
- 'nl': 'List van apparaten met batterij staat',
1622
- 'fr': 'Liste des appareils avec état de batterie',
1623
- 'it': 'Elenco dei dispositivi con stato della batteria',
1624
- 'es': 'Lista de dispositivos con estado de batería',
1625
- 'pl': 'Lista urządzeń z baterią stanową',
1626
- 'zh-cn': '电池国装置清单'
1705
+ type: 'state',
1706
+ common: {
1707
+ name: {
1708
+ en: 'List of devices with battery state',
1709
+ de: 'Liste der Geräte mit Batteriezustand',
1710
+ ru: 'Список устройств с состоянием батареи',
1711
+ pt: 'Lista de dispositivos com estado da bateria',
1712
+ nl: 'List van apparaten met batterij staat',
1713
+ fr: 'Liste des appareils avec état de batterie',
1714
+ it: 'Elenco dei dispositivi con stato della batteria',
1715
+ es: 'Lista de dispositivos con estado de batería',
1716
+ pl: 'Lista urządzeń z baterią stanową',
1717
+ 'zh-cn': '电池国装置清单',
1627
1718
  },
1628
- 'type': 'array',
1629
- 'role': 'json',
1630
- 'read': true,
1631
- 'write': false,
1719
+ type: 'array',
1720
+ role: 'json',
1721
+ read: true,
1722
+ write: false,
1632
1723
  },
1633
- 'native': {}
1724
+ native: {},
1634
1725
  });
1635
1726
 
1636
1727
  await this.setObjectNotExistsAsync(`${adptName}.lowBatteryList`, {
1637
- 'type': 'state',
1638
- 'common': {
1639
- 'name': {
1640
- 'en': 'List of devices with low battery state',
1641
- 'de': 'Liste der Geräte mit niedrigem Batteriezustand',
1642
- 'ru': 'Список устройств с низким состоянием батареи',
1643
- 'pt': 'Lista de dispositivos com baixo estado da bateria',
1644
- 'nl': 'List van apparaten met lage batterij staat',
1645
- 'fr': 'Liste des appareils à faible état de batterie',
1646
- 'it': 'Elenco di dispositivi con stato di batteria basso',
1647
- 'es': 'Lista de dispositivos con estado de batería bajo',
1648
- 'pl': 'Lista urządzeń o niskim stanie baterii',
1649
- 'zh-cn': '低电池国家装置清单'
1728
+ type: 'state',
1729
+ common: {
1730
+ name: {
1731
+ en: 'List of devices with low battery state',
1732
+ de: 'Liste der Geräte mit niedrigem Batteriezustand',
1733
+ ru: 'Список устройств с низким состоянием батареи',
1734
+ pt: 'Lista de dispositivos com baixo estado da bateria',
1735
+ nl: 'List van apparaten met lage batterij staat',
1736
+ fr: 'Liste des appareils à faible état de batterie',
1737
+ it: 'Elenco di dispositivi con stato di batteria basso',
1738
+ es: 'Lista de dispositivos con estado de batería bajo',
1739
+ pl: 'Lista urządzeń o niskim stanie baterii',
1740
+ 'zh-cn': '低电池国家装置清单',
1650
1741
  },
1651
- 'type': 'array',
1652
- 'role': 'json',
1653
- 'read': true,
1654
- 'write': false,
1742
+ type: 'array',
1743
+ role: 'json',
1744
+ read: true,
1745
+ write: false,
1655
1746
  },
1656
- 'native': {}
1747
+ native: {},
1657
1748
  });
1658
1749
 
1659
1750
  await this.setObjectNotExistsAsync(`${adptName}.lowBatteryCount`, {
1660
- 'type': 'state',
1661
- 'common': {
1662
- 'name': {
1663
- 'en': 'Number of devices with low battery',
1664
- 'de': 'Anzahl der Geräte mit niedriger Batterie',
1665
- 'ru': 'Количество устройств c низкой батареей',
1666
- 'pt': 'Número de dispositivos com bateria baixa',
1667
- 'nl': 'Nummer van apparaten met lage batterij',
1668
- 'fr': 'Nombre de dispositifs avec batterie basse',
1669
- 'it': 'Numero di dispositivi con batteria bassa',
1670
- 'es': 'Número de dispositivos con batería baja',
1671
- 'pl': 'Liczba urządzeń z niską baterią',
1672
- 'zh-cn': '低电池的装置数量'
1751
+ type: 'state',
1752
+ common: {
1753
+ name: {
1754
+ en: 'Number of devices with low battery',
1755
+ de: 'Anzahl der Geräte mit niedriger Batterie',
1756
+ ru: 'Количество устройств c низкой батареей',
1757
+ pt: 'Número de dispositivos com bateria baixa',
1758
+ nl: 'Nummer van apparaten met lage batterij',
1759
+ fr: 'Nombre de dispositifs avec batterie basse',
1760
+ it: 'Numero di dispositivi con batteria bassa',
1761
+ es: 'Número de dispositivos con batería baja',
1762
+ pl: 'Liczba urządzeń z niską baterią',
1763
+ 'zh-cn': '低电池的装置数量',
1673
1764
  },
1674
- 'type': 'number',
1675
- 'role': 'value',
1676
- 'read': true,
1677
- 'write': false,
1765
+ type: 'number',
1766
+ role: 'value',
1767
+ read: true,
1768
+ write: false,
1678
1769
  },
1679
- 'native': {}
1770
+ native: {},
1680
1771
  });
1681
1772
 
1682
1773
  await this.setObjectNotExistsAsync(`${adptName}.batteryCount`, {
1683
- 'type': 'state',
1684
- 'common': {
1685
- 'name': {
1686
- 'en': 'Number of devices with battery',
1687
- 'de': 'Anzahl der Geräte mit Batterie',
1688
- 'ru': 'Количество устройств c батареей',
1689
- 'pt': 'Número de dispositivos com bateria',
1690
- 'nl': 'Nummer van apparaten met batterij',
1691
- 'fr': 'Nombre de dispositifs avec batterie',
1692
- 'it': 'Numero di dispositivi con batteria',
1693
- 'es': 'Número de dispositivos con batería',
1694
- 'pl': 'Liczba urządzeń z baterią',
1695
- 'zh-cn': '电池的装置数量'
1774
+ type: 'state',
1775
+ common: {
1776
+ name: {
1777
+ en: 'Number of devices with battery',
1778
+ de: 'Anzahl der Geräte mit Batterie',
1779
+ ru: 'Количество устройств c батареей',
1780
+ pt: 'Número de dispositivos com bateria',
1781
+ nl: 'Nummer van apparaten met batterij',
1782
+ fr: 'Nombre de dispositifs avec batterie',
1783
+ it: 'Numero di dispositivi con batteria',
1784
+ es: 'Número de dispositivos con batería',
1785
+ pl: 'Liczba urządzeń z baterią',
1786
+ 'zh-cn': '电池的装置数量',
1696
1787
  },
1697
- 'type': 'number',
1698
- 'role': 'value',
1699
- 'read': true,
1700
- 'write': false,
1788
+ type: 'number',
1789
+ role: 'value',
1790
+ read: true,
1791
+ write: false,
1701
1792
  },
1702
- 'native': {}
1793
+ native: {},
1703
1794
  });
1704
1795
  }
1705
1796
 
@@ -1707,7 +1798,6 @@ class DeviceWatcher extends utils.Adapter {
1707
1798
  * @param {object} [adptName] - Adaptername of devices
1708
1799
  **/
1709
1800
  async createHtmlListDatapoints(adptName) {
1710
-
1711
1801
  let dpSubFolder;
1712
1802
  //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
1713
1803
  if (adptName) {
@@ -1717,95 +1807,95 @@ class DeviceWatcher extends utils.Adapter {
1717
1807
  }
1718
1808
 
1719
1809
  await this.setObjectNotExistsAsync(`${dpSubFolder}offlineListHTML`, {
1720
- 'type': 'state',
1721
- 'common': {
1722
- 'name': {
1723
- 'en': 'HTML List of offline devices',
1724
- 'de': 'HTML Liste der Offline-Geräte',
1725
- 'ru': 'HTML Список оффлайн устройств',
1726
- 'pt': 'HTML Lista de dispositivos off-line',
1727
- 'nl': 'HTML List van offline apparatuur',
1728
- 'fr': 'HTML Liste des dispositifs hors ligne',
1729
- 'it': 'HTML Elenco dei dispositivi offline',
1730
- 'es': 'HTML Lista de dispositivos sin conexión',
1731
- 'pl': 'HTML Lista urządzeń offline',
1732
- 'zh-cn': 'HTML 线装置清单'
1810
+ type: 'state',
1811
+ common: {
1812
+ name: {
1813
+ en: 'HTML List of offline devices',
1814
+ de: 'HTML Liste der Offline-Geräte',
1815
+ ru: 'HTML Список оффлайн устройств',
1816
+ pt: 'HTML Lista de dispositivos off-line',
1817
+ nl: 'HTML List van offline apparatuur',
1818
+ fr: 'HTML Liste des dispositifs hors ligne',
1819
+ it: 'HTML Elenco dei dispositivi offline',
1820
+ es: 'HTML Lista de dispositivos sin conexión',
1821
+ pl: 'HTML Lista urządzeń offline',
1822
+ 'zh-cn': 'HTML 线装置清单',
1733
1823
  },
1734
- 'type': 'string',
1735
- 'role': 'html',
1736
- 'read': true,
1737
- 'write': false,
1824
+ type: 'string',
1825
+ role: 'html',
1826
+ read: true,
1827
+ write: false,
1738
1828
  },
1739
- 'native': {}
1829
+ native: {},
1740
1830
  });
1741
1831
 
1742
1832
  await this.setObjectNotExistsAsync(`${dpSubFolder}linkQualityListHTML`, {
1743
- 'type': 'state',
1744
- 'common': {
1745
- 'name': {
1746
- 'en': 'HTML List of devices with signal strength',
1747
- 'de': 'HTML Liste der Geräte mit Signalstärke',
1748
- 'ru': 'HTML Список устройств с силой сигнала',
1749
- 'pt': 'HTML Lista de dispositivos com força de sinal',
1750
- 'nl': 'HTML List van apparaten met signaalkracht',
1751
- 'fr': 'HTML Liste des dispositifs avec force de signal',
1752
- 'it': 'HTML Elenco dei dispositivi con forza del segnale',
1753
- 'es': 'HTML Lista de dispositivos con fuerza de señal',
1754
- 'pl': 'HTML Lista urządzeń z siłą sygnałową',
1755
- 'zh-cn': 'HTML 具有信号实力的装置清单'
1833
+ type: 'state',
1834
+ common: {
1835
+ name: {
1836
+ en: 'HTML List of devices with signal strength',
1837
+ de: 'HTML Liste der Geräte mit Signalstärke',
1838
+ ru: 'HTML Список устройств с силой сигнала',
1839
+ pt: 'HTML Lista de dispositivos com força de sinal',
1840
+ nl: 'HTML List van apparaten met signaalkracht',
1841
+ fr: 'HTML Liste des dispositifs avec force de signal',
1842
+ it: 'HTML Elenco dei dispositivi con forza del segnale',
1843
+ es: 'HTML Lista de dispositivos con fuerza de señal',
1844
+ pl: 'HTML Lista urządzeń z siłą sygnałową',
1845
+ 'zh-cn': 'HTML 具有信号实力的装置清单',
1756
1846
  },
1757
- 'type': 'string',
1758
- 'role': 'value',
1759
- 'read': true,
1760
- 'write': false,
1847
+ type: 'string',
1848
+ role: 'value',
1849
+ read: true,
1850
+ write: false,
1761
1851
  },
1762
- 'native': {}
1852
+ native: {},
1763
1853
  });
1764
1854
 
1765
1855
  await this.setObjectNotExistsAsync(`${dpSubFolder}batteryListHTML`, {
1766
- 'type': 'state',
1767
- 'common': {
1768
- 'name': {
1769
- 'en': 'HTML List of devices with battery state',
1770
- 'de': 'HTML Liste der Geräte mit Batteriezustand',
1771
- 'ru': 'HTML Список устройств с состоянием батареи',
1772
- 'pt': 'HTML Lista de dispositivos com estado da bateria',
1773
- 'nl': 'HTML List van apparaten met batterij staat',
1774
- 'fr': 'HTML Liste des appareils avec état de batterie',
1775
- 'it': 'HTML Elenco dei dispositivi con stato della batteria',
1776
- 'es': 'HTML Lista de dispositivos con estado de batería',
1777
- 'pl': 'HTML Lista urządzeń z baterią stanową',
1778
- 'zh-cn': 'HTML 电池国装置清单'
1856
+ type: 'state',
1857
+ common: {
1858
+ name: {
1859
+ en: 'HTML List of devices with battery state',
1860
+ de: 'HTML Liste der Geräte mit Batteriezustand',
1861
+ ru: 'HTML Список устройств с состоянием батареи',
1862
+ pt: 'HTML Lista de dispositivos com estado da bateria',
1863
+ nl: 'HTML List van apparaten met batterij staat',
1864
+ fr: 'HTML Liste des appareils avec état de batterie',
1865
+ it: 'HTML Elenco dei dispositivi con stato della batteria',
1866
+ es: 'HTML Lista de dispositivos con estado de batería',
1867
+ pl: 'HTML Lista urządzeń z baterią stanową',
1868
+ 'zh-cn': 'HTML 电池国装置清单',
1779
1869
  },
1780
- 'type': 'string',
1781
- 'role': 'html',
1782
- 'read': true,
1783
- 'write': false,
1870
+ type: 'string',
1871
+ role: 'html',
1872
+ read: true,
1873
+ write: false,
1784
1874
  },
1785
- 'native': {}
1875
+ native: {},
1786
1876
  });
1787
1877
 
1788
1878
  await this.setObjectNotExistsAsync(`${dpSubFolder}lowBatteryListHTML`, {
1789
- 'type': 'state',
1790
- 'common': {
1791
- 'name': {
1792
- 'en': 'HTML List of devices with low battery state',
1793
- 'de': 'HTML Liste der Geräte mit niedrigem Batteriezustand',
1794
- 'ru': 'HTML Список устройств с низким состоянием батареи',
1795
- 'pt': 'HTML Lista de dispositivos com baixo estado da bateria',
1796
- 'nl': 'HTML List van apparaten met lage batterij staat',
1797
- 'fr': 'HTML Liste des appareils à faible état de batterie',
1798
- 'it': 'HTML Elenco di dispositivi con stato di batteria basso',
1799
- 'es': 'HTML Lista de dispositivos con estado de batería bajo',
1800
- 'pl': 'HTML Lista urządzeń o niskim stanie baterii',
1801
- 'zh-cn': 'HTML 低电池国家装置清单'
1879
+ type: 'state',
1880
+ common: {
1881
+ name: {
1882
+ en: 'HTML List of devices with low battery state',
1883
+ de: 'HTML Liste der Geräte mit niedrigem Batteriezustand',
1884
+ ru: 'HTML Список устройств с низким состоянием батареи',
1885
+ pt: 'HTML Lista de dispositivos com baixo estado da bateria',
1886
+ nl: 'HTML List van apparaten met lage batterij staat',
1887
+ fr: 'HTML Liste des appareils à faible état de batterie',
1888
+ it: 'HTML Elenco di dispositivi con stato di batteria basso',
1889
+ es: 'HTML Lista de dispositivos con estado de batería bajo',
1890
+ pl: 'HTML Lista urządzeń o niskim stanie baterii',
1891
+ 'zh-cn': 'HTML 低电池国家装置清单',
1802
1892
  },
1803
- 'type': 'string',
1804
- 'role': 'html',
1805
- 'read': true,
1806
- 'write': false,
1893
+ type: 'string',
1894
+ role: 'html',
1895
+ read: true,
1896
+ write: false,
1807
1897
  },
1808
- 'native': {}
1898
+ native: {},
1809
1899
  });
1810
1900
  }
1811
1901
 
@@ -1828,10 +1918,9 @@ class DeviceWatcher extends utils.Adapter {
1828
1918
  }
1829
1919
  } // <-- end of errorReporting
1830
1920
 
1831
-
1832
1921
  /**
1833
- * @param {() => void} callback
1834
- */
1922
+ * @param {() => void} callback
1923
+ */
1835
1924
  onUnload(callback) {
1836
1925
  try {
1837
1926
  if (this.refreshDataTimeout) {