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