iobroker.device-watcher 2.13.1 → 2.15.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/crud.js CHANGED
@@ -1,1932 +1,1985 @@
1
- const translations = require("./translations");
2
- const tools = require("./tools");
3
-
4
- /**
5
- * @param {object} adptName - Adaptername of devices
6
- */
7
- async function createDPsForEachAdapter(adaptr, adptName) {
8
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}`, {
9
- type: 'channel',
10
- common: {
11
- name: adptName,
12
- },
13
- native: {},
14
- });
15
-
16
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.offlineCount`, {
17
- type: 'state',
18
- common: {
19
- name: {
20
- en: 'Number of devices offline',
21
- de: 'Anzahl der Geräte offline',
22
- ru: 'Количество устройств оффлайн',
23
- pt: 'Número de dispositivos offline',
24
- nl: 'Aantal offline apparaten',
25
- fr: 'Nombre de dispositifs hors ligne',
26
- it: 'Numero di dispositivi offline',
27
- es: 'Número de dispositivos sin conexión',
28
- pl: 'Liczba urządzeń offline',
29
- 'zh-cn': '离线设备数量',
30
- },
31
- type: 'number',
32
- role: 'value',
33
- read: true,
34
- write: false,
35
- },
36
- native: {},
37
- });
38
-
39
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.offlineList`, {
40
- type: 'state',
41
- common: {
42
- name: {
43
- en: 'List of offline devices',
44
- de: 'Liste der Offline-Geräte',
45
- ru: 'Список оффлайн устройств',
46
- pt: 'Lista de dispositivos offline',
47
- nl: 'Lijst van offline apparaten',
48
- fr: 'Liste des dispositifs hors ligne',
49
- it: 'Elenco dei dispositivi offline',
50
- es: 'Lista de dispositivos sin conexión',
51
- pl: 'Lista urządzeń offline',
52
- 'zh-cn': '离线设备列表',
53
- },
54
- type: 'array',
55
- role: 'json',
56
- read: true,
57
- write: false,
58
- },
59
- native: {},
60
- });
61
-
62
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceOffline`, {
63
- type: 'state',
64
- common: {
65
- name: {
66
- en: 'Is one device offline',
67
- de: 'Ist ein Gerät offline',
68
- ru: 'Есть ли одно устройство оффлайн',
69
- pt: ' um dispositivo offline',
70
- nl: 'Is er een apparaat offline',
71
- fr: 'Y a-t-il un appareil hors ligne',
72
- it: 'C\'è un dispositivo offline',
73
- es: '¿Hay un dispositivo sin conexión?',
74
- pl: 'Czy jedno urządzenie jest offline',
75
- uk: 'Чи є один пристрій офлайн',
76
- 'zh-cn': '是否有一台设备离线',
77
- },
78
- type: 'boolean',
79
- role: 'state',
80
- read: true,
81
- write: false,
82
- def: false,
83
- },
84
- native: {},
85
- });
86
-
87
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.listAllRawJSON`, {
88
- type: 'state',
89
- common: {
90
- name: {
91
- en: 'JSON RAW List of all devices',
92
- de: 'JSON RAW Liste aller Geräte',
93
- ru: 'JSON RAW Список всех устройств',
94
- pt: 'JSON RAW Lista de todos os dispositivos',
95
- nl: 'JSON RAW Lijst van alle apparaten',
96
- fr: 'JSON RAW Liste de tous les dispositifs',
97
- it: 'JSON RAW Elenco di tutti i dispositivi',
98
- es: 'JSON RAW Lista de todos los dispositivos',
99
- pl: 'JSON RAW Lista wszystkich urządzeń',
100
- uk: 'JSON RAW Список усіх пристроїв',
101
- 'zh-cn': 'JSON RAW 所有设备列表',
102
- },
103
- type: 'array',
104
- role: 'json',
105
- read: true,
106
- write: false,
107
- },
108
- native: {},
109
- });
110
-
111
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.listAll`, {
112
- type: 'state',
113
- common: {
114
- name: {
115
- en: 'List of all devices',
116
- de: 'Liste aller Geräte',
117
- ru: 'Список всех устройств',
118
- pt: 'Lista de todos os dispositivos',
119
- nl: 'Lijst van alle apparaten',
120
- fr: 'Liste de tous les dispositifs',
121
- it: 'Elenco di tutti i dispositivi',
122
- es: 'Lista de todos los dispositivos',
123
- pl: 'Lista wszystkich urządzeń',
124
- 'zh-cn': '所有设备的列表',
125
- },
126
- type: 'array',
127
- role: 'json',
128
- read: true,
129
- write: false,
130
- },
131
- native: {},
132
- });
133
-
134
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.linkQualityList`, {
135
- type: 'state',
136
- common: {
137
- name: {
138
- en: 'List of devices with signal strength',
139
- de: 'Liste der Geräte mit Signalstärke',
140
- ru: 'Список устройств с уровнем сигнала',
141
- pt: 'Lista de dispositivos com força de sinal',
142
- nl: 'Lijst van apparaten met signaalkracht',
143
- fr: 'Liste des dispositifs avec force de signal',
144
- it: 'Elenco dei dispositivi con forza del segnale',
145
- es: 'Lista de dispositivos con fuerza de señal',
146
- pl: 'Lista urządzeń z siłą sygnału',
147
- 'zh-cn': '具有信号强度的设备列表',
148
- },
149
- type: 'array',
150
- role: 'json',
151
- read: true,
152
- write: false,
153
- },
154
- native: {},
155
- });
156
-
157
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.countAll`, {
158
- type: 'state',
159
- common: {
160
- name: {
161
- en: 'Number of all devices',
162
- de: 'Anzahl aller Geräte',
163
- ru: 'Количество всех устройств',
164
- pt: 'Número de todos os dispositivos',
165
- nl: 'Aantal van alle apparaten',
166
- fr: 'Nombre de tous les appareils',
167
- it: 'Numero di tutti i dispositivi',
168
- es: 'Número de todos los dispositivos',
169
- pl: 'Liczba wszystkich urządzeń',
170
- 'zh-cn': '所有设备的数量',
171
- },
172
- type: 'number',
173
- role: 'value',
174
- read: true,
175
- write: false,
176
- },
177
- native: {},
178
- });
179
-
180
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.batteryList`, {
181
- type: 'state',
182
- common: {
183
- name: {
184
- en: 'List of devices with battery state',
185
- de: 'Liste der Geräte mit Batteriezustand',
186
- ru: 'Список устройств с состоянием батареи',
187
- pt: 'Lista de dispositivos com estado da bateria',
188
- nl: 'Lijst van apparaten met batterijstatus',
189
- fr: 'Liste des appareils avec état de batterie',
190
- it: 'Elenco dei dispositivi con stato della batteria',
191
- es: 'Lista de dispositivos con estado de batería',
192
- pl: 'Lista urządzeń ze stanem baterii',
193
- 'zh-cn': '具有电池状态的设备列表',
194
- },
195
- type: 'array',
196
- role: 'json',
197
- read: true,
198
- write: false,
199
- },
200
- native: {},
201
- });
202
-
203
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.lowBatteryList`, {
204
- type: 'state',
205
- common: {
206
- name: {
207
- en: 'List of devices with low battery state',
208
- de: 'Liste der Geräte mit niedrigem Batteriezustand',
209
- ru: 'Список устройств с низким уровнем заряда батареи',
210
- pt: 'Lista de dispositivos com baixo estado da bateria',
211
- nl: 'Lijst van apparaten met lage batterijstatus',
212
- fr: 'Liste des appareils à faible état de batterie',
213
- it: 'Elenco di dispositivi con stato di batteria basso',
214
- es: 'Lista de dispositivos con estado de batería bajo',
215
- pl: 'Lista urządzeń o niskim stanie baterii',
216
- 'zh-cn': '低电量设备列表',
217
- },
218
- type: 'array',
219
- role: 'json',
220
- read: true,
221
- write: false,
222
- },
223
- native: {},
224
- });
225
-
226
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.lowBatteryCount`, {
227
- type: 'state',
228
- common: {
229
- name: {
230
- en: 'Number of devices with low battery',
231
- de: 'Anzahl der Geräte mit niedriger Batterie',
232
- ru: 'Количество устройств с низким зарядом батареи',
233
- pt: 'Número de dispositivos com bateria baixa',
234
- nl: 'Aantal apparaten met lage batterij',
235
- fr: 'Nombre de dispositifs avec batterie faible',
236
- it: 'Numero di dispositivi con batteria scarica',
237
- es: 'Número de dispositivos con batería baja',
238
- pl: 'Liczba urządzeń z niskim poziomem baterii',
239
- 'zh-cn': '低电量设备的数量',
240
- },
241
- type: 'number',
242
- role: 'value',
243
- read: true,
244
- write: false,
245
- },
246
- native: {},
247
- });
248
-
249
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceLowBat`, {
250
- type: 'state',
251
- common: {
252
- name: {
253
- en: 'Is one device with low battery',
254
- de: 'Ist ein Gerät mit niedrigem Akku',
255
- ru: 'Есть ли устройство с низким зарядом батареи',
256
- pt: 'É um dispositivo com bateria baixa',
257
- nl: 'Is er een apparaat met lage batterij',
258
- fr: 'Y a-t-il un appareil avec batterie faible',
259
- it: 'C\'è un dispositivo con batteria scarica',
260
- es: '¿Hay un dispositivo con batería baja?',
261
- pl: 'Czy jest jedno urządzenie z niskim poziomem baterii',
262
- uk: 'Чи є пристрій з низьким зарядом батареї',
263
- 'zh-cn': '是否有设备电量低',
264
- },
265
- type: 'boolean',
266
- role: 'state',
267
- read: true,
268
- write: false,
269
- def: false,
270
- },
271
- native: {},
272
- });
273
-
274
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.batteryCount`, {
275
- type: 'state',
276
- common: {
277
- name: {
278
- en: 'Number of devices with battery',
279
- de: 'Anzahl der Geräte mit Batterie',
280
- ru: 'Количество устройств с батареей',
281
- pt: 'Número de dispositivos com bateria',
282
- nl: 'Aantal apparaten met batterij',
283
- fr: 'Nombre de dispositifs avec batterie',
284
- it: 'Numero di dispositivi con batteria',
285
- es: 'Número de dispositivos con batería',
286
- pl: 'Liczba urządzeń z baterią',
287
- 'zh-cn': '带电池的设备数量',
288
- },
289
- type: 'number',
290
- role: 'value',
291
- read: true,
292
- write: false,
293
- },
294
- native: {},
295
- });
296
-
297
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.upgradableCount`, {
298
- type: 'state',
299
- common: {
300
- name: {
301
- en: 'Number of devices with available updates',
302
- de: 'Anzahl der Geräte mit verfügbaren Updates',
303
- ru: 'Количество устройств с доступными обновлениями',
304
- pt: 'Número de dispositivos com atualizações disponíveis',
305
- nl: 'Aantal apparaten met beschikbare updates',
306
- fr: 'Nombre de dispositifs avec mises à jour disponibles',
307
- it: 'Numero di dispositivi con aggiornamenti disponibili',
308
- es: 'Número de dispositivos con actualizaciones disponibles',
309
- pl: 'Liczba urządzeń z dostępnymi aktualizacjami',
310
- uk: 'Кількість пристроїв з доступними оновленнями',
311
- 'zh-cn': '具有可用更新的设备数量',
312
- },
313
- type: 'number',
314
- role: 'value',
315
- read: true,
316
- write: false,
317
- },
318
- native: {},
319
- });
320
-
321
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.upgradableList`, {
322
- type: 'state',
323
- common: {
324
- name: {
325
- en: 'JSON List of devices with available updates',
326
- de: 'JSON Liste der Geräte mit verfügbaren Updates',
327
- ru: 'JSON список устройств с доступными обновлениями',
328
- pt: 'JSON Lista de dispositivos com atualizações disponíveis',
329
- nl: 'JSON Lijst van apparaten met beschikbare updates',
330
- fr: 'JSON Liste des appareils avec mises à jour disponibles',
331
- it: 'JSON Elenco dei dispositivi con aggiornamenti disponibili',
332
- es: 'JSON Lista de dispositivos con actualizaciones disponibles',
333
- pl: 'JSON Lista urządzeń z dostępnymi aktualizacjami',
334
- uk: 'JSON список пристроїв з доступними оновленнями',
335
- 'zh-cn': '具有可用更新的设备的 JSON 列表',
336
- },
337
- type: 'array',
338
- role: 'json',
339
- read: true,
340
- write: false,
341
- },
342
- native: {},
343
- });
344
-
345
- await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceUpdatable`, {
346
- type: 'state',
347
- common: {
348
- name: {
349
- en: 'Is one device updatable',
350
- de: 'Ist ein Gerät aktualisierbar',
351
- ru: 'Можно ли обновить одно устройство',
352
- pt: 'É um dispositivo atualizável',
353
- nl: 'Is er een apparaat dat kan worden bijgewerkt',
354
- fr: "Y a-t-il un appareil qui peut être mis à jour",
355
- it: 'C\'è un dispositivo aggiornabile',
356
- es: '¿Hay un dispositivo actualizable?',
357
- pl: 'Czy jest jedno urządzenie do zaktualizowania',
358
- uk: 'Чи є пристрій, який можна оновити',
359
- 'zh-cn': '是否有设备可更新',
360
- },
361
- type: 'boolean',
362
- role: 'state',
363
- read: true,
364
- write: false,
365
- def: false,
366
- },
367
- native: {},
368
- });
369
- }
370
-
371
- /**
372
- * delete datapoints for each adapter
373
- * @param {object} adptName - Adaptername of devices
374
- */
375
- async function deleteDPsForEachAdapter(adaptr, adptName) {
376
- await adaptr.delObjectAsync(`devices.${adptName}`);
377
- await adaptr.delObjectAsync(`devices.${adptName}.offlineCount`);
378
- await adaptr.delObjectAsync(`devices.${adptName}.offlineList`);
379
- await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceOffline`);
380
- await adaptr.delObjectAsync(`devices.${adptName}.listAllRawJSON`);
381
- await adaptr.delObjectAsync(`devices.${adptName}.listAll`);
382
- await adaptr.delObjectAsync(`devices.${adptName}.linkQualityList`);
383
- await adaptr.delObjectAsync(`devices.${adptName}.countAll`);
384
- await adaptr.delObjectAsync(`devices.${adptName}.batteryList`);
385
- await adaptr.delObjectAsync(`devices.${adptName}.lowBatteryList`);
386
- await adaptr.delObjectAsync(`devices.${adptName}.lowBatteryCount`);
387
- await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceLowBat`);
388
- await adaptr.delObjectAsync(`devices.${adptName}.batteryCount`);
389
- await adaptr.delObjectAsync(`devices.${adptName}.upgradableCount`);
390
- await adaptr.delObjectAsync(`devices.${adptName}.upgradableList`);
391
- await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceUpdatable`);
392
- }
393
-
394
- /**
395
- * create HTML list datapoints
396
- * @param {object} [adptName] - Adaptername of devices
397
- **/
398
- async function createHtmlListDatapoints(adaptr, adptName) {
399
- let dpSubFolder;
400
- //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
401
- if (adptName) {
402
- dpSubFolder = `${adptName}.`;
403
- } else {
404
- dpSubFolder = '';
405
- }
406
-
407
- await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}offlineListHTML`, {
408
- type: 'state',
409
- common: {
410
- name: {
411
- en: 'HTML List of offline devices',
412
- de: 'HTML Liste der Offline-Geräte',
413
- ru: 'HTML список оффлайн устройств',
414
- pt: 'HTML Lista de dispositivos offline',
415
- nl: 'HTML Lijst van offline apparaten',
416
- fr: 'HTML Liste des dispositifs hors ligne',
417
- it: 'HTML Elenco dei dispositivi offline',
418
- es: 'HTML Lista de dispositivos sin conexión',
419
- pl: 'HTML Lista urządzeń offline',
420
- 'zh-cn': 'HTML 离线设备列表',
421
- },
422
- type: 'string',
423
- role: 'html',
424
- read: true,
425
- write: false,
426
- },
427
- native: {},
428
- });
429
-
430
- await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}linkQualityListHTML`, {
431
- type: 'state',
432
- common: {
433
- name: {
434
- en: 'HTML List of devices with signal strength',
435
- de: 'HTML Liste der Geräte mit Signalstärke',
436
- ru: 'HTML список устройств с уровнем сигнала',
437
- pt: 'HTML Lista de dispositivos com força de sinal',
438
- nl: 'HTML Lijst van apparaten met signaalkracht',
439
- fr: 'HTML Liste des dispositifs avec force de signal',
440
- it: 'HTML Elenco dei dispositivi con forza del segnale',
441
- es: 'HTML Lista de dispositivos con fuerza de señal',
442
- pl: 'HTML Lista urządzeń z siłą sygnału',
443
- 'zh-cn': 'HTML 具有信号强度的设备列表',
444
- },
445
- type: 'string',
446
- role: 'value',
447
- read: true,
448
- write: false,
449
- },
450
- native: {},
451
- });
452
-
453
- await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}batteryListHTML`, {
454
- type: 'state',
455
- common: {
456
- name: {
457
- en: 'HTML List of devices with battery state',
458
- de: 'HTML Liste der Geräte mit Batteriezustand',
459
- ru: 'HTML список устройств с состоянием батареи',
460
- pt: 'HTML Lista de dispositivos com estado da bateria',
461
- nl: 'HTML Lijst van apparaten met batterijstatus',
462
- fr: 'HTML Liste des appareils avec état de batterie',
463
- it: 'HTML Elenco dei dispositivi con stato della batteria',
464
- es: 'HTML Lista de dispositivos con estado de batería',
465
- pl: 'HTML Lista urządzeń ze stanem baterii',
466
- 'zh-cn': 'HTML 具有电池状态的设备列表',
467
- },
468
- type: 'string',
469
- role: 'html',
470
- read: true,
471
- write: false,
472
- },
473
- native: {},
474
- });
475
-
476
- await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}lowBatteryListHTML`, {
477
- type: 'state',
478
- common: {
479
- name: {
480
- en: 'HTML List of devices with low battery state',
481
- de: 'HTML Liste der Geräte mit niedrigem Batteriezustand',
482
- ru: 'HTML список устройств с низким уровнем заряда батареи',
483
- pt: 'HTML Lista de dispositivos com baixo estado da bateria',
484
- nl: 'HTML Lijst van apparaten met lage batterijstatus',
485
- fr: 'HTML Liste des appareils à faible état de batterie',
486
- it: 'HTML Elenco di dispositivi con stato di batteria basso',
487
- es: 'HTML Lista de dispositivos con estado de batería bajo',
488
- pl: 'HTML Lista urządzeń o niskim stanie baterii',
489
- 'zh-cn': 'HTML 低电量设备列表',
490
- },
491
- type: 'string',
492
- role: 'html',
493
- read: true,
494
- write: false,
495
- },
496
- native: {},
497
- });
498
- }
499
-
500
- /**
501
- * delete html datapoints
502
- * @param {object} [adptName] - Adaptername of devices
503
- **/
504
- async function deleteHtmlListDatapoints(adaptr, adptName) {
505
- // delete the datapoints in subfolders with the adaptername otherwise delete the dP's in the root folder
506
- let dpSubFolder;
507
- if (adptName) {
508
- dpSubFolder = `${adptName}.`;
509
- } else {
510
- dpSubFolder = '';
511
- }
512
-
513
- await adaptr.delObjectAsync(`devices.${dpSubFolder}offlineListHTML`);
514
- await adaptr.delObjectAsync(`devices.${dpSubFolder}linkQualityListHTML`);
515
- await adaptr.delObjectAsync(`devices.${dpSubFolder}batteryListHTML`);
516
- await adaptr.delObjectAsync(`devices.${dpSubFolder}lowBatteryListHTML`);
517
- }
518
-
519
- /**
520
- * create HTML list datapoints for instances
521
- **/
522
- async function createHtmlListDatapointsInstances(adaptr) {
523
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists`, {
524
- type: 'channel',
525
- common: {
526
- name: {
527
- en: 'HTML lists for adapter and instances',
528
- de: 'HTML-Listen für Adapter und Instanzen',
529
- ru: 'HTML списки для адаптера и экземпляров',
530
- pt: 'Listas HTML para adaptador e instâncias',
531
- nl: 'HTML lijsten voor adapter en instanties',
532
- fr: "Listes HTML pour l'adaptateur et les instances",
533
- it: 'Elenchi HTML per adattatore e istanze',
534
- es: 'Listas HTML para adaptador e instancias',
535
- pl: 'Listy HTML dla adaptera i instancji',
536
- uk: 'HTML списки для адаптера та екземплярів',
537
- 'zh-cn': '适配器和实例的 HTML 列表',
538
- },
539
- },
540
- native: {},
541
- });
542
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`, {
543
- type: 'state',
544
- common: {
545
- name: {
546
- en: 'HTML List of all instances',
547
- de: 'HTML Liste aller Instanzen',
548
- ru: 'HTML список всех экземпляров',
549
- pt: 'HTML Lista de todas as instâncias',
550
- nl: 'HTML Lijst van alle instanties',
551
- fr: 'HTML Liste de toutes les instances',
552
- it: 'HTML Elenco di tutte le istanze',
553
- es: 'HTML Lista de todas las instancias',
554
- pl: 'HTML Lista wszystkich instancji',
555
- uk: 'HTML список усіх екземплярів',
556
- 'zh-cn': 'HTML 所有实例的列表',
557
- },
558
- type: 'string',
559
- role: 'html',
560
- read: true,
561
- write: false,
562
- },
563
- native: {},
564
- });
565
-
566
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`, {
567
- type: 'state',
568
- common: {
569
- name: {
570
- en: 'HTML List of all active instances',
571
- de: 'HTML Liste aller aktiven Instanzen',
572
- ru: 'HTML список всех активных экземпляров',
573
- pt: 'HTML Lista de todas as instâncias ativas',
574
- nl: 'HTML Lijst van alle actieve instanties',
575
- fr: 'HTML Liste de toutes les instances actives',
576
- it: 'HTML Elenco di tutte le istanze attive',
577
- es: 'HTML Lista de todas las instancias activas',
578
- pl: 'HTML Lista wszystkich aktywnych instancji',
579
- uk: 'HTML список усіх активних екземплярів',
580
- 'zh-cn': 'HTML 所有活动实例的列表',
581
- },
582
- type: 'string',
583
- role: 'value',
584
- read: true,
585
- write: false,
586
- },
587
- native: {},
588
- });
589
-
590
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`, {
591
- type: 'state',
592
- common: {
593
- name: {
594
- en: 'HTML List of all deactivated instances',
595
- de: 'HTML Liste aller deaktivierten Instanzen',
596
- ru: 'HTML список всех деактивированных экземпляров',
597
- pt: 'HTML Lista de todas as instâncias desativadas',
598
- nl: 'HTML Lijst van alle gedeactiveerde instanties',
599
- fr: 'HTML Liste de toutes les instances désactivées',
600
- it: 'HTML Elenco di tutte le istanze disattivate',
601
- es: 'HTML Lista de todas las instancias desactivadas',
602
- pl: 'HTML Lista wszystkich dezaktywowanych instancji',
603
- uk: 'HTML список усіх деактивованих екземплярів',
604
- 'zh-cn': 'HTML 所有已停用实例的列表',
605
- },
606
- type: 'string',
607
- role: 'html',
608
- read: true,
609
- write: false,
610
- },
611
- native: {},
612
- });
613
-
614
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`, {
615
- type: 'state',
616
- common: {
617
- name: {
618
- en: 'HTML List of instances with error',
619
- de: 'HTML Liste der Instanzen mit Fehler',
620
- ru: 'HTML список экземпляров с ошибкой',
621
- pt: 'HTML Lista de instâncias com erro',
622
- nl: 'HTML Lijst van instanties met fouten',
623
- fr: 'HTML Liste des instances avec erreur',
624
- it: 'HTML Elenco delle istanze con errore',
625
- es: 'HTML Lista de instancias con error',
626
- pl: 'HTML Lista instancji z błędem',
627
- uk: 'HTML список екземплярів з помилкою',
628
- 'zh-cn': 'HTML 含错误实例的列表',
629
- },
630
- type: 'string',
631
- role: 'html',
632
- read: true,
633
- write: false,
634
- },
635
- native: {},
636
- });
637
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`, {
638
- type: 'state',
639
- common: {
640
- name: {
641
- en: 'HTML list of adapters with available updates',
642
- de: 'HTML-Liste der Adapter mit verfügbaren Updates',
643
- ru: 'HTML список адаптеров с доступными обновлениями',
644
- pt: 'Lista HTML de adaptadores com atualizações disponíveis',
645
- nl: 'HTML lijst van adapters met beschikbare updates',
646
- fr: 'Liste HTML des adaptateurs avec mises à jour disponibles',
647
- it: 'Elenco HTML degli adattatori con aggiornamenti disponibili',
648
- es: 'Lista HTML de adaptadores con actualizaciones disponibles',
649
- pl: 'Lista adapterów HTML z dostępnymi aktualizacjami',
650
- uk: 'HTML список адаптерів з доступними оновленнями',
651
- 'zh-cn': 'HTML 具有可用更新的适配器列表',
652
- },
653
- type: 'string',
654
- role: 'html',
655
- read: true,
656
- write: false,
657
- },
658
- native: {},
659
- });
660
- }
661
-
662
- /**
663
- * delete html datapoints for instances
664
- **/
665
- async function deleteHtmlListDatapointsInstances(adaptr) {
666
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`);
667
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`);
668
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`);
669
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`);
670
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`);
671
- await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists`);
672
- }
673
-
674
-
675
- /*=============================================
676
- = functions to create html lists =
677
- =============================================*/
678
- /**
679
- * @param {string} type - type of list
680
- * @param {object} devices - Device
681
- * @param {number} deviceCount - Counted devices
682
- * @param {object} isLowBatteryList - list Low Battery Devices
683
- */
684
- async function createListHTML(adaptr, type, devices, deviceCount, isLowBatteryList) {
685
- let html;
686
- switch (type) {
687
- case 'linkQualityList':
688
- devices = devices.sort((a, b) => {
689
- a = a.Device || '';
690
- b = b.Device || '';
691
- return a.localeCompare(b);
692
- });
693
- html = `<center>
694
- <b>${[translations.Link_quality_devices[adaptr.config.userSelectedLanguage]]}:<font> ${deviceCount}</b><small></small></font>
695
- <p></p>
696
- </center>
697
- <table width=100%>
698
- <tr>
699
- <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
700
- <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
701
- <th align=right>${[translations.Signal_strength[adaptr.config.userSelectedLanguage]]}</th>
702
- </tr>
703
- <tr>
704
- <td colspan="5"><hr></td>
705
- </tr>`;
706
-
707
- for (const device of devices) {
708
- html += `<tr>
709
- <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
710
- <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
711
- <td align=right><font>${device[translations.Signal_strength[adaptr.config.userSelectedLanguage]]}</font></td>
712
- </tr>`;
713
- }
714
-
715
- html += '</table>';
716
- break;
717
-
718
- case 'offlineList':
719
- devices = devices.sort((a, b) => {
720
- a = a.Device || '';
721
- b = b.Device || '';
722
- return a.localeCompare(b);
723
- });
724
- html = `<center>
725
- <b>${[translations.offline_devices[adaptr.config.userSelectedLanguage]]}: <font color=${deviceCount === 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
726
- <p></p>
727
- </center>
728
- <table width=100%>
729
- <tr>
730
- <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
731
- <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
732
- <th align=center>${[translations.Last_Contact[adaptr.config.userSelectedLanguage]]}</th>
733
- </tr>
734
- <tr>
735
- <td colspan="5"><hr></td>
736
- </tr>`;
737
-
738
- for (const device of devices) {
739
- html += `<tr>
740
- <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
741
- <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
742
- <td align=center><font color=orange>${device[translations.Last_Contact[adaptr.config.userSelectedLanguage]]}</font></td>
743
- </tr>`;
744
- }
745
-
746
- html += '</table>';
747
- break;
748
-
749
- case 'batteryList':
750
- devices = devices.sort((a, b) => {
751
- a = a.Device || '';
752
- b = b.Device || '';
753
- return a.localeCompare(b);
754
- });
755
- html = `<center>
756
- <b>${isLowBatteryList === true ? `${[translations.low[adaptr.config.userSelectedLanguage]]} ` : ''}${[translations.battery_devices[adaptr.config.userSelectedLanguage]]}:
757
- <font color=${isLowBatteryList === true ? (deviceCount > 0 ? 'orange' : '#3bcf0e') : ''}>${deviceCount}</b></font>
758
- <p></p>
759
- </center>
760
- <table width=100%>
761
- <tr>
762
- <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
763
- <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
764
- <th align=${isLowBatteryList ? 'center' : 'right'}>${[translations.Battery[adaptr.config.userSelectedLanguage]]}</th>
765
- </tr>
766
- <tr>
767
- <td colspan="5"><hr></td>
768
- </tr>`;
769
- for (const device of devices) {
770
- html += `<tr>
771
- <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
772
- <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>`;
773
-
774
- if (isLowBatteryList) {
775
- html += `<td align=center><font color=orange>${device[translations.Battery[adaptr.config.userSelectedLanguage]]}</font></td>`;
776
- } else {
777
- html += `<td align=right><font color=#3bcf0e>${device[translations.Battery[adaptr.config.userSelectedLanguage]]}</font></td>`;
778
- }
779
- html += `</tr>`;
780
- }
781
-
782
- html += '</table>';
783
- break;
784
- }
785
- return html;
786
- }
787
-
788
- /**
789
- * @param {string} type - type of list
790
- * @param {object} instances - Instance
791
- * @param {number} instancesCount - Counted devices
792
- */
793
- async function createListHTMLInstances(adaptr, type, instances, instancesCount) {
794
- let html;
795
- switch (type) {
796
- case 'allInstancesList':
797
- instances = instances.sort((a, b) => {
798
- a = a.Instance || '';
799
- b = b.Instance || '';
800
- return a.localeCompare(b);
801
- });
802
- html = `<center>
803
- <b>${[translations.All_Instances[adaptr.config.userSelectedLanguage]]}:<font> ${instancesCount}</b><small></small></font>
804
- <p></p>
805
- </center>
806
- <table width=100%>
807
- <tr>
808
- <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
809
- <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
810
- <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
811
- </tr>
812
- <tr>
813
- <td colspan="5"><hr></td>
814
- </tr>`;
815
-
816
- for (const instanceData of instances) {
817
- html += `<tr>
818
- <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
819
- <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
820
- <td align=center><font>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
821
- </tr>`;
822
- }
823
-
824
- html += '</table>';
825
- break;
826
-
827
- case 'allActiveInstancesList':
828
- instances = instances.sort((a, b) => {
829
- a = a.Instance || '';
830
- b = b.Instances || '';
831
- return a.localeCompare(b);
832
- });
833
- html = `<center>
834
- <b>${[translations.Active_Instances[adaptr.config.userSelectedLanguage]]}: <font> ${instancesCount}</b><small></small></font>
835
- <p></p>
836
- </center>
837
- <table width=100%>
838
- <tr>
839
- <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
840
- <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
841
- <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
842
- </tr>
843
- <tr>
844
- <td colspan="5"><hr></td>
845
- </tr>`;
846
-
847
- for (const instanceData of instances) {
848
- html += `<tr>
849
- <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
850
- <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
851
- <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
852
- </tr>`;
853
- }
854
-
855
- html += '</table>';
856
- break;
857
-
858
- case 'errorInstanceList':
859
- instances = instances.sort((a, b) => {
860
- a = a.Instance || '';
861
- b = b.Instances || '';
862
- return a.localeCompare(b);
863
- });
864
- html = `<center>
865
- <b>${[translations.Error_Instances[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
866
- <p></p>
867
- </center>
868
- <table width=100%>
869
- <tr>
870
- <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
871
- <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
872
- <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
873
- </tr>
874
- <tr>
875
- <td colspan="5"><hr></td>
876
- </tr>`;
877
-
878
- for (const instanceData of instances) {
879
- html += `<tr>
880
- <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
881
- <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
882
- <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
883
- </tr>`;
884
- }
885
-
886
- html += '</table>';
887
- break;
888
-
889
- case 'deactivatedInstanceList':
890
- instances = instances.sort((a, b) => {
891
- a = a.Instance || '';
892
- b = b.Instances || '';
893
- return a.localeCompare(b);
894
- });
895
- html = `<center>
896
- <b>${[translations.Deactivated_Instances[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
897
- <p></p>
898
- </center>
899
- <table width=100%>
900
- <tr>
901
- <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
902
- <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
903
- <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
904
- </tr>
905
- <tr>
906
- <td colspan="5"><hr></td>
907
- </tr>`;
908
-
909
- for (const instanceData of instances) {
910
- if (!instanceData.isAlive) {
911
- html += `<tr>
912
- <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
913
- <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
914
- <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
915
- </tr>`;
916
- }
917
- }
918
-
919
- html += '</table>';
920
- break;
921
-
922
- case 'updateAdapterList':
923
- html = `<center>
924
- <b>${[translations.Updatable_adapters[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
925
- <p></p>
926
- </center>
927
- <table width=100%>
928
- <tr>
929
- <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
930
- <th align=center>${[translations.Installed_Version[adaptr.config.userSelectedLanguage]]}</th>
931
- <th align=center>${[translations.Available_Version[adaptr.config.userSelectedLanguage]]}</th>
932
- </tr>
933
- <tr>
934
- <td colspan="5"><hr></td>
935
- </tr>`;
936
-
937
- for (const instanceData of instances.values()) {
938
- if (instanceData.updateAvailable !== ' - ') {
939
- html += `<tr>
940
- <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
941
- <td align=center><font>${instanceData[translations.Installed_Version[adaptr.config.userSelectedLanguage]]}</font></td>
942
- <td align=center><font color=orange>${instanceData[translations.Available_Version[adaptr.config.userSelectedLanguage]]}</font></td>
943
- </tr>`;
944
- }
945
- }
946
-
947
- html += '</table>';
948
- break;
949
- }
950
- return html;
951
- }
952
-
953
-
954
- /**
955
- * create blacklist
956
- */
957
- async function createBlacklist(adaptr) {
958
- adaptr.log.debug(`Start the function createBlacklist`);
959
-
960
- // DEVICES
961
- const myBlacklist = adaptr.config.tableBlacklist;
962
- if (myBlacklist.length >= 1) {
963
- for (const i in myBlacklist) {
964
- try {
965
- const blacklistParse = tools.parseData(myBlacklist[i].devices);
966
- // push devices in list to ignor device in lists
967
- if (myBlacklist[i].checkIgnorLists) {
968
- adaptr.blacklistLists.push(blacklistParse.path);
969
- }
970
- if (myBlacklist[i].checkIgnorAdapterLists) {
971
- adaptr.blacklistAdapterLists.push(blacklistParse.path);
972
- }
973
- // push devices in list to ignor device in notifications
974
- if (myBlacklist[i].checkIgnorNotify) {
975
- adaptr.blacklistNotify.push(blacklistParse.path);
976
- }
977
- } catch (error) {
978
- adaptr.log.error(`[createBlacklist] - ${error}`);
979
- }
980
- if (adaptr.blacklistLists.length >= 1) adaptr.log.info(`Found devices/services on blacklist for lists: ${adaptr.blacklistLists}`);
981
- if (adaptr.blacklistAdapterLists.length >= 1) adaptr.log.info(`Found devices/services on blacklist for own adapter lists: ${adaptr.blacklistAdapterLists}`);
982
- if (adaptr.blacklistNotify.length >= 1) adaptr.log.info(`Found devices/services on blacklist for notifications: ${adaptr.blacklistNotify}`);
983
- }
984
- }
985
-
986
- // INSTANCES
987
- const myBlacklistInstances = adaptr.config.tableBlacklistInstances;
988
- if (myBlacklistInstances.length >= 1) {
989
- for (const i in myBlacklistInstances) {
990
- try {
991
- const blacklistParse = tools.parseData(myBlacklistInstances[i].instances);
992
- // push devices in list to ignor device in lists
993
- if (myBlacklistInstances[i].checkIgnorLists) {
994
- adaptr.blacklistInstancesLists.push(blacklistParse.instanceID);
995
- }
996
- // push devices in list to ignor device in notifications
997
- if (myBlacklistInstances[i].checkIgnorNotify) {
998
- adaptr.blacklistInstancesNotify.push(blacklistParse.instanceID);
999
- }
1000
- } catch (error) {
1001
- adaptr.log.error(`[createBlacklist] - ${error}`);
1002
- }
1003
- }
1004
- if (adaptr.blacklistInstancesLists.length >= 1) adaptr.log.info(`Found instances items on blacklist for lists: ${adaptr.blacklistInstancesLists}`);
1005
- if (adaptr.blacklistInstancesNotify.length >= 1) adaptr.log.info(`Found instances items on blacklist for notifications: ${adaptr.blacklistInstancesNotify}`);
1006
- }
1007
- }
1008
-
1009
- /**
1010
- * create list with time for instances
1011
- */
1012
- async function createTimeListInstances(adaptr) {
1013
- // INSTANCES
1014
- const userTimeListInstances = adaptr.config.tableTimeInstance;
1015
- if (userTimeListInstances.length >= 1) {
1016
- for (const i in userTimeListInstances) {
1017
- try {
1018
- const userTimeListparse = tools.parseData(userTimeListInstances[i].instancesTime);
1019
- // push devices in list to ignor device in lists
1020
- adaptr.userTimeInstancesList.set(userTimeListparse.instanceName, {
1021
- deactivationTime: userTimeListInstances[i].deactivationTime,
1022
- errorTime: userTimeListInstances[i].errorTime,
1023
- });
1024
- } catch (error) {
1025
- adaptr.log.error(`[createTimeListInstances] - ${error}`);
1026
- }
1027
- }
1028
- if (adaptr.userTimeInstancesList.size >= 1) adaptr.log.info(`Found instances items on lists for timesettings: ${Array.from(adaptr.userTimeInstancesList.keys())}`);
1029
- }
1030
- }
1031
-
1032
- /**
1033
- * @param {object} i - Device Object
1034
- */
1035
- async function createData(adaptr, i) {
1036
- try {
1037
- const devices = await adaptr.getForeignStatesAsync(adaptr.selAdapter[i].Selektor);
1038
- const adapterID = adaptr.selAdapter[i].adapterID;
1039
-
1040
- /*---------- Start of loop ----------*/
1041
- for (const [id] of Object.entries(devices)) {
1042
- if (id.endsWith('.')) continue;
1043
- const mainSelector = id;
1044
-
1045
- /*=============================================
1046
- = get Instanz =
1047
- =============================================*/
1048
- const instance = id.slice(0, id.indexOf('.') + 2);
1049
-
1050
- const instanceDeviceConnectionDP = `${instance}.info.connection`;
1051
- const instancedeviceConnected = await tools.getInitValue(adaptr, instanceDeviceConnectionDP);
1052
- adaptr.subscribeForeignStates(instanceDeviceConnectionDP);
1053
- adaptr.subscribeForeignObjects(`${adaptr.selAdapter[i].Selektor}`);
1054
- // adaptr.subscribeForeignObjects('*');
1055
- //adaptr.subscribeForeignStates('*');
1056
- /*=============================================
1057
- = Get device name =
1058
- =============================================*/
1059
- const deviceName = await adaptr.getDeviceName(id, i);
1060
-
1061
- /*=============================================
1062
- = Get adapter name =
1063
- =============================================*/
1064
- const adapter = adaptr.selAdapter[i].adapter;
1065
-
1066
- /*=============================================
1067
- = Get path to datapoints =
1068
- =============================================*/
1069
- const currDeviceString = id.slice(0, id.lastIndexOf('.') + 1 - 1);
1070
- const shortCurrDeviceString = currDeviceString.slice(0, currDeviceString.lastIndexOf('.') + 1 - 1);
1071
-
1072
- // subscribe to object device path
1073
- adaptr.subscribeForeignStates(currDeviceString);
1074
-
1075
- /*=============================================
1076
- = Get signal strength =
1077
- =============================================*/
1078
- let deviceQualityDP = currDeviceString + adaptr.selAdapter[i].rssiState;
1079
- let deviceQualityState;
1080
-
1081
- switch (adapterID) {
1082
- case 'mihomeVacuum':
1083
- deviceQualityDP = shortCurrDeviceString + adaptr.selAdapter[i].rssiState;
1084
- deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1085
- break;
1086
-
1087
- case 'netatmo':
1088
- deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1089
- if (!deviceQualityState) {
1090
- deviceQualityDP = currDeviceString + adaptr.selAdapter[i].rfState;
1091
- deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1092
- }
1093
- break;
1094
-
1095
- default:
1096
- deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1097
- break;
1098
- }
1099
- //subscribe to states
1100
- adaptr.subscribeForeignStates(deviceQualityDP);
1101
-
1102
- const signalData = await adaptr.calculateSignalStrength(deviceQualityState, adapterID);
1103
- let linkQuality = signalData[0];
1104
- const linkQualityRaw = signalData[1];
1105
-
1106
- /*=============================================
1107
- = Get battery data =
1108
- =============================================*/
1109
- let deviceBatteryStateDP;
1110
- let deviceBatteryState;
1111
- let batteryHealth;
1112
- let batteryHealthRaw;
1113
- let batteryUnitRaw;
1114
- let lowBatIndicator;
1115
- let isBatteryDevice;
1116
- let isLowBatDP;
1117
- let faultReportingDP;
1118
- let faultReportingState;
1119
-
1120
- const deviceChargerStateDP = currDeviceString + adaptr.selAdapter[i].charger;
1121
- const deviceChargerState = await tools.getInitValue(adaptr, deviceChargerStateDP);
1122
-
1123
- if (deviceChargerState === undefined || deviceChargerState === false) {
1124
- // Get battery states
1125
- switch (adapterID) {
1126
- case 'hmrpc':
1127
- deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery;
1128
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1129
-
1130
- if (deviceBatteryState === undefined) {
1131
- deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].hmDNBattery;
1132
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1133
- }
1134
- break;
1135
- case 'hueExt':
1136
- case 'mihomeVacuum':
1137
- case 'mqttNuki':
1138
- case 'loqedSmartLock':
1139
- deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].battery;
1140
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1141
-
1142
- if (deviceBatteryState === undefined) {
1143
- deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].battery2;
1144
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1145
- }
1146
- break;
1147
- default:
1148
- deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery;
1149
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1150
-
1151
- if (deviceBatteryState === undefined) {
1152
- deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery2;
1153
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1154
-
1155
- if (deviceBatteryState === undefined) {
1156
- deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery3;
1157
- deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1158
- }
1159
- }
1160
- break;
1161
- }
1162
-
1163
- // Get low bat states
1164
- isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat;
1165
- let deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1166
-
1167
- if (deviceLowBatState === undefined) {
1168
- isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat2;
1169
- deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1170
-
1171
- if (deviceLowBatState === undefined) {
1172
- isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat3;
1173
- deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1174
- }
1175
- }
1176
- if (deviceLowBatState === undefined) isLowBatDP = 'none';
1177
-
1178
- faultReportingDP = shortCurrDeviceString + adaptr.selAdapter[i].faultReporting;
1179
- faultReportingState = await tools.getInitValue(adaptr, faultReportingDP);
1180
-
1181
- //subscribe to states
1182
- adaptr.subscribeForeignStates(deviceBatteryStateDP);
1183
- adaptr.subscribeForeignStates(isLowBatDP);
1184
- adaptr.subscribeForeignStates(faultReportingDP);
1185
-
1186
- const batteryData = await adaptr.getBatteryData(deviceBatteryState, deviceLowBatState, faultReportingState, adapterID);
1187
- batteryHealth = batteryData[0];
1188
- batteryHealthRaw = batteryData[2];
1189
- batteryUnitRaw = batteryData[3];
1190
- isBatteryDevice = batteryData[1];
1191
-
1192
- if (isBatteryDevice) {
1193
- lowBatIndicator = await adaptr.setLowbatIndicator(deviceBatteryState, deviceLowBatState, faultReportingState, adapterID);
1194
- }
1195
- }
1196
-
1197
- /*=============================================
1198
- = Get last contact of device =
1199
- =============================================*/
1200
- let unreachDP = currDeviceString + adaptr.selAdapter[i].reach;
1201
- const deviceStateSelectorHMRPC = shortCurrDeviceString + adaptr.selAdapter[i].stateValue;
1202
- const rssiPeerSelectorHMRPC = currDeviceString + adaptr.selAdapter[i].rssiPeerState;
1203
- let timeSelector = currDeviceString + adaptr.selAdapter[i].timeSelector;
1204
-
1205
- const timeSelectorState = await tools.getInitValue(adaptr, timeSelector);
1206
- if (timeSelectorState === undefined) {
1207
- timeSelector = shortCurrDeviceString + adaptr.selAdapter[i].timeSelector;
1208
- }
1209
-
1210
- let deviceUnreachState = await tools.getInitValue(adaptr, unreachDP);
1211
- if (deviceUnreachState === undefined) {
1212
- unreachDP = shortCurrDeviceString + adaptr.selAdapter[i].reach;
1213
- deviceUnreachState = await tools.getInitValue(adaptr, shortCurrDeviceString + adaptr.selAdapter[i].reach);
1214
- }
1215
-
1216
- // subscribe to states
1217
- adaptr.subscribeForeignStates(timeSelector);
1218
- adaptr.subscribeForeignStates(unreachDP);
1219
- adaptr.subscribeForeignStates(deviceStateSelectorHMRPC);
1220
- adaptr.subscribeForeignStates(rssiPeerSelectorHMRPC);
1221
-
1222
- const onlineState = await adaptr.getOnlineState(timeSelector, adapterID, unreachDP, linkQuality, deviceUnreachState, deviceStateSelectorHMRPC, rssiPeerSelectorHMRPC);
1223
- let deviceState;
1224
- let lastContactString;
1225
-
1226
- if (onlineState !== undefined && onlineState !== null) {
1227
- lastContactString = onlineState[0];
1228
- deviceState = onlineState[1];
1229
- linkQuality = onlineState[2];
1230
- }
1231
-
1232
- /*=============================================
1233
- = Get update data =
1234
- =============================================*/
1235
- let isUpgradable;
1236
- let deviceUpdateDP;
1237
-
1238
- if (adaptr.config.checkSendDeviceUpgrade) {
1239
- deviceUpdateDP = currDeviceString + adaptr.selAdapter[i].upgrade;
1240
- let deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1241
- if (deviceUpdateSelector === undefined) {
1242
- deviceUpdateDP = shortCurrDeviceString + adaptr.selAdapter[i].upgrade;
1243
- deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1244
- if (deviceUpdateSelector === undefined) {
1245
- const shortShortCurrDeviceString = shortCurrDeviceString.slice(0, shortCurrDeviceString.lastIndexOf('.') + 1 - 1);
1246
- deviceUpdateDP = shortShortCurrDeviceString + adaptr.selAdapter[i].upgrade;
1247
- deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1248
- }
1249
- }
1250
-
1251
- if (deviceUpdateSelector !== undefined) {
1252
- isUpgradable = await adaptr.checkDeviceUpdate(adapterID, deviceUpdateSelector);
1253
- } else {
1254
- isUpgradable = ' - ';
1255
- }
1256
-
1257
- // subscribe to states
1258
- adaptr.subscribeForeignStates(deviceUpdateDP);
1259
- // adaptr.subscribeForeignStates('*');
1260
- }
1261
-
1262
- /*=============================================
1263
- = Fill Raw Lists =
1264
- =============================================*/
1265
- const setupList = () => {
1266
- adaptr.listAllDevicesRaw.set(currDeviceString, {
1267
- Path: id,
1268
- mainSelector: mainSelector,
1269
- instanceDeviceConnectionDP: instanceDeviceConnectionDP,
1270
- instancedeviceConnected: instancedeviceConnected,
1271
- instance: instance,
1272
- Device: deviceName,
1273
- adapterID: adapterID,
1274
- Adapter: adapter,
1275
- timeSelector: timeSelector,
1276
- isBatteryDevice: isBatteryDevice,
1277
- Battery: batteryHealth,
1278
- BatteryRaw: batteryHealthRaw,
1279
- BatteryUnitRaw: batteryUnitRaw,
1280
- batteryDP: deviceBatteryStateDP,
1281
- LowBat: lowBatIndicator,
1282
- LowBatDP: isLowBatDP,
1283
- faultReport: faultReportingState,
1284
- faultReportDP: faultReportingDP,
1285
- SignalStrengthDP: deviceQualityDP,
1286
- SignalStrength: linkQuality,
1287
- SignalStrengthRaw: linkQualityRaw,
1288
- UnreachState: deviceUnreachState,
1289
- UnreachDP: unreachDP,
1290
- deviceStateSelectorHMRPC: deviceStateSelectorHMRPC,
1291
- rssiPeerSelectorHMRPC: rssiPeerSelectorHMRPC,
1292
- LastContact: lastContactString,
1293
- Status: deviceState,
1294
- UpdateDP: deviceUpdateDP,
1295
- Upgradable: isUpgradable,
1296
- });
1297
- };
1298
-
1299
- if (!adaptr.configListOnlyBattery) {
1300
- // Add all devices
1301
- setupList();
1302
- } else {
1303
- // Add only devices with battery in the rawlist
1304
- if (!isBatteryDevice) {
1305
- continue;
1306
- }
1307
-
1308
- setupList();
1309
- }
1310
- } // <-- end of loop
1311
- } catch (error) {
1312
- adaptr.log.error(`[createData - create data of devices] - ${error}`);
1313
- }
1314
- } // <-- end of createData
1315
-
1316
-
1317
- /**
1318
- * Create Lists
1319
- * @param {string | undefined} [adptName]
1320
- */
1321
- async function createLists(adaptr, adptName) {
1322
- adaptr.linkQualityDevices = [];
1323
- adaptr.batteryPowered = [];
1324
- adaptr.batteryLowPowered = [];
1325
- adaptr.listAllDevicesUserRaw = [];
1326
- adaptr.listAllDevices = [];
1327
- adaptr.offlineDevices = [];
1328
- adaptr.batteryLowPoweredRaw = [];
1329
- adaptr.offlineDevicesRaw = [];
1330
- adaptr.upgradableDevicesRaw = [];
1331
- adaptr.upgradableList = [];
1332
-
1333
- if (adptName === undefined) {
1334
- adptName = '';
1335
- }
1336
-
1337
- for (const deviceData of adaptr.listAllDevicesRaw.values()) {
1338
- /*---------- fill raw lists ----------*/
1339
- // low bat list
1340
- if (deviceData.LowBat && deviceData.Status !== 'Offline') {
1341
- adaptr.batteryLowPoweredRaw.push({
1342
- Path: deviceData.Path,
1343
- Device: deviceData.Device,
1344
- Adapter: deviceData.Adapter,
1345
- Battery: deviceData.Battery,
1346
- });
1347
- }
1348
- // offline raw list
1349
- if (deviceData.Status === 'Offline') {
1350
- adaptr.offlineDevicesRaw.push({
1351
- Path: deviceData.Path,
1352
- Device: deviceData.Device,
1353
- Adapter: deviceData.Adapter,
1354
- LastContact: deviceData.LastContact,
1355
- });
1356
- }
1357
-
1358
- // upgradable raw list
1359
- if (deviceData.Upgradable === true) {
1360
- adaptr.upgradableDevicesRaw.push({
1361
- Path: deviceData.Path,
1362
- Device: deviceData.Device,
1363
- Adapter: deviceData.Adapter,
1364
- });
1365
- }
1366
-
1367
- if (adptName === '' && !adaptr.blacklistLists.includes(deviceData.Path)) {
1368
- await adaptr.theLists(deviceData);
1369
- }
1370
-
1371
- if (adaptr.config.createOwnFolder && adptName !== '') {
1372
- if (!deviceData.adapterID.includes(adptName)) continue;
1373
- /*---------- fill user lists for each adapter ----------*/
1374
- if (adaptr.blacklistAdapterLists.includes(deviceData.Path)) continue;
1375
- await adaptr.theLists(deviceData);
1376
- }
1377
- }
1378
- await tools.countDevices(adaptr);
1379
- }
1380
-
1381
-
1382
- /**
1383
- * @param {string} [adptName] - Adaptername
1384
- */
1385
- async function writeDatapoints(adaptr, adptName) {
1386
- // fill the datapoints
1387
- adaptr.log.debug(`Start the function writeDatapoints`);
1388
-
1389
- try {
1390
- let dpSubFolder;
1391
- //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
1392
- if (adptName) {
1393
- dpSubFolder = adptName + '.';
1394
- } else {
1395
- dpSubFolder = '';
1396
- }
1397
-
1398
- // Write Datapoints for counts
1399
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineCount`, { val: adaptr.offlineDevicesCount, ack: true });
1400
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}countAll`, { val: adaptr.deviceCounter, ack: true });
1401
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryCount`, { val: adaptr.batteryPoweredCount, ack: true });
1402
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryCount`, { val: adaptr.lowBatteryPoweredCount, ack: true });
1403
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}upgradableCount`, { val: adaptr.upgradableDevicesCount, ack: true });
1404
- // List all devices
1405
- if (adaptr.deviceCounter === 0) {
1406
- // if no device is count, write the JSON List with default value
1407
- adaptr.listAllDevices = [
1408
- {
1409
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1410
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1411
- [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1412
- [translations.Signal_strength[adaptr.config.userSelectedLanguage]]: '',
1413
- [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1414
- [translations.Status[adaptr.config.userSelectedLanguage]]: '',
1415
- },
1416
- ];
1417
- adaptr.listAllDevicesUserRaw = [
1418
- {
1419
- Device: '--none--',
1420
- Adapter: '',
1421
- Instance: '',
1422
- 'Instance connected': '',
1423
- isBatteryDevice: '',
1424
- Battery: '',
1425
- BatteryRaw: '',
1426
- isLowBat: '',
1427
- 'Signal strength': '',
1428
- 'Last contact': '',
1429
- UpdateAvailable: '',
1430
- Status: '',
1431
- },
1432
- ];
1433
- }
1434
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}listAll`, { val: JSON.stringify(adaptr.listAllDevices), ack: true });
1435
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}listAllRawJSON`, { val: JSON.stringify(adaptr.listAllDevicesUserRaw), ack: true });
1436
-
1437
- // List link quality
1438
- if (adaptr.linkQualityCount === 0) {
1439
- // if no device is count, write the JSON List with default value
1440
- adaptr.linkQualityDevices = [
1441
- {
1442
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1443
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1444
- [translations.Signal_strength[adaptr.config.userSelectedLanguage]]: '',
1445
- },
1446
- ];
1447
- }
1448
- //write JSON list
1449
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}linkQualityList`, {
1450
- val: JSON.stringify(adaptr.linkQualityDevices),
1451
- ack: true,
1452
- });
1453
-
1454
- // List offline devices
1455
- if (adaptr.offlineDevicesCount === 0) {
1456
- // if no device is count, write the JSON List with default value
1457
- adaptr.offlineDevices = [
1458
- {
1459
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1460
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1461
- [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1462
- },
1463
- ];
1464
- }
1465
- //write JSON list
1466
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineList`, {
1467
- val: JSON.stringify(adaptr.offlineDevices),
1468
- ack: true,
1469
- });
1470
-
1471
- // List updatable
1472
- if (adaptr.upgradableDevicesCount === 0) {
1473
- // if no device is count, write the JSON List with default value
1474
- adaptr.upgradableList = [
1475
- {
1476
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1477
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1478
- [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1479
- },
1480
- ];
1481
- }
1482
- //write JSON list
1483
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}upgradableList`, {
1484
- val: JSON.stringify(adaptr.upgradableList),
1485
- ack: true,
1486
- });
1487
-
1488
- // List battery powered
1489
- if (adaptr.batteryPoweredCount === 0) {
1490
- // if no device is count, write the JSON List with default value
1491
- adaptr.batteryPowered = [
1492
- {
1493
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1494
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1495
- [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1496
- },
1497
- ];
1498
- }
1499
- //write JSON list
1500
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryList`, {
1501
- val: JSON.stringify(adaptr.batteryPowered),
1502
- ack: true,
1503
- });
1504
-
1505
- // list battery low powered
1506
- if (adaptr.lowBatteryPoweredCount === 0) {
1507
- // if no device is count, write the JSON List with default value
1508
- adaptr.batteryLowPowered = [
1509
- {
1510
- [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1511
- [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1512
- [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1513
- },
1514
- ];
1515
- }
1516
- //write JSON list
1517
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryList`, {
1518
- val: JSON.stringify(adaptr.batteryLowPowered),
1519
- ack: true,
1520
- });
1521
-
1522
- // set booleans datapoints
1523
- if (adaptr.offlineDevicesCount === 0) {
1524
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceOffline`, {
1525
- val: false,
1526
- ack: true,
1527
- });
1528
- } else {
1529
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceOffline`, {
1530
- val: true,
1531
- ack: true,
1532
- });
1533
- }
1534
-
1535
- if (adaptr.lowBatteryPoweredCount === 0) {
1536
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceLowBat`, {
1537
- val: false,
1538
- ack: true,
1539
- });
1540
- } else {
1541
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceLowBat`, {
1542
- val: true,
1543
- ack: true,
1544
- });
1545
- }
1546
-
1547
- if (adaptr.upgradableDevicesCount === 0) {
1548
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceUpdatable`, {
1549
- val: false,
1550
- ack: true,
1551
- });
1552
- } else {
1553
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceUpdatable`, {
1554
- val: true,
1555
- ack: true,
1556
- });
1557
- }
1558
-
1559
- //write HTML list
1560
- if (adaptr.configCreateHtmlList) {
1561
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}linkQualityListHTML`, {
1562
- val: await this.createListHTML(adaptr, 'linkQualityList', adaptr.linkQualityDevices, adaptr.linkQualityCount, null),
1563
- ack: true,
1564
- });
1565
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineListHTML`, {
1566
- val: await this.createListHTML(adaptr, 'offlineList', adaptr.offlineDevices, adaptr.offlineDevicesCount, null),
1567
- ack: true,
1568
- });
1569
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryListHTML`, {
1570
- val: await this.createListHTML(adaptr, 'batteryList', adaptr.batteryPowered, adaptr.batteryPoweredCount, false),
1571
- ack: true,
1572
- });
1573
- await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryListHTML`, {
1574
- val: await this.createListHTML(adaptr, 'batteryList', adaptr.batteryLowPowered, adaptr.lowBatteryPoweredCount, true),
1575
- ack: true,
1576
- });
1577
-
1578
- if (adaptr.config.checkAdapterInstances) {
1579
- await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`, {
1580
- val: await this.createListHTMLInstances(adaptr, 'allInstancesList', adaptr.listAllInstances, adaptr.countAllInstances),
1581
- ack: true,
1582
- });
1583
- await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`, {
1584
- val: await this.createListHTMLInstances(adaptr, 'allActiveInstancesList', adaptr.listAllActiveInstances, adaptr.countAllActiveInstances),
1585
- ack: true,
1586
- });
1587
- await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`, {
1588
- val: await this.createListHTMLInstances(adaptr, 'errorInstanceList', adaptr.listErrorInstance, adaptr.countErrorInstance),
1589
- ack: true,
1590
- });
1591
- await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`, {
1592
- val: await this.createListHTMLInstances(adaptr, 'deactivatedInstanceList', adaptr.listDeactivatedInstances, adaptr.countDeactivatedInstances),
1593
- ack: true,
1594
- });
1595
- await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`, {
1596
- val: await this.createListHTMLInstances(adaptr, 'updateAdapterList', adaptr.listAdapterUpdates, adaptr.countAdapterUpdates),
1597
- ack: true,
1598
- });
1599
- }
1600
- }
1601
-
1602
- // create timestamp of last run
1603
- const lastCheck = adaptr.formatDate(new Date(), 'DD.MM.YYYY') + ' - ' + adaptr.formatDate(new Date(), 'hh:mm:ss');
1604
- await adaptr.setStateChangedAsync('lastCheck', lastCheck, true);
1605
- } catch (error) {
1606
- adaptr.log.error(`[writeDatapoints] - ${error}`);
1607
- }
1608
- } //<--End of writing Datapoints
1609
-
1610
-
1611
- /**
1612
- * create Datapoints for Instances
1613
- */
1614
- async function createDPsForInstances(adaptr) {
1615
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances`, {
1616
- type: 'channel',
1617
- common: {
1618
- name: {
1619
- en: 'Adapter and Instances',
1620
- de: 'Adapter und Instanzen',
1621
- ru: '??????? ? Instances',
1622
- pt: 'Adaptador e instâncias',
1623
- nl: 'Adapter en Instance',
1624
- fr: 'Adaptateur et instances',
1625
- it: 'Adattatore e istanze',
1626
- es: 'Adaptador e instalaciones',
1627
- pl: 'Adapter and Instances',
1628
- // @ts-ignore
1629
- uk: '??????? ?? ?????????',
1630
- 'zh-cn': '????',
1631
- },
1632
- },
1633
- native: {},
1634
- });
1635
-
1636
- // Instances
1637
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAllInstances`, {
1638
- type: 'state',
1639
- common: {
1640
- name: {
1641
- en: 'JSON List of all instances',
1642
- de: 'JSON Liste aller Instanzen',
1643
- ru: '????? ?????? ???? ?????????',
1644
- pt: 'J. Lista de todas as instâncias',
1645
- nl: 'JSON List van alle instanties',
1646
- fr: 'JSON Liste de tous les cas',
1647
- it: 'JSON Elenco di tutte le istanze',
1648
- es: 'JSON Lista de todos los casos',
1649
- pl: 'JSON Lista wszystkich instancji',
1650
- // @ts-ignore
1651
- uk: '????? ?????? ???? ???????????',
1652
- 'zh-cn': '? ? ???????',
1653
- },
1654
- type: 'array',
1655
- role: 'json',
1656
- read: true,
1657
- write: false,
1658
- },
1659
- native: {},
1660
- });
1661
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAllInstances`, {
1662
- type: 'state',
1663
- common: {
1664
- name: {
1665
- en: 'Number of all instances',
1666
- de: 'Anzahl aller Instanzen',
1667
- ru: '?????????? ???? ?????????',
1668
- pt: 'Número de todas as instâncias',
1669
- nl: 'Nummer van alle gevallen',
1670
- fr: 'Nombre de cas',
1671
- it: 'Numero di tutte le istanze',
1672
- es: 'Número de casos',
1673
- pl: 'Liczba wszystkich instancji',
1674
- // @ts-ignore
1675
- uk: '????????? ???? ???????????',
1676
- 'zh-cn': '??????',
1677
- },
1678
- type: 'number',
1679
- role: 'value',
1680
- read: true,
1681
- write: false,
1682
- },
1683
- native: {},
1684
- });
1685
- // Instances
1686
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAllActiveInstances`, {
1687
- type: 'state',
1688
- common: {
1689
- name: {
1690
- en: 'JSON List of all active instances',
1691
- de: 'JSON Liste aller aktiven Instanzen',
1692
- ru: '????? ?????? ???? ???????? ?????????',
1693
- pt: 'J. Lista de todas as instâncias ativas',
1694
- nl: 'JSON List van alle actieve instanties',
1695
- fr: 'JSON Liste de tous les cas actifs',
1696
- it: 'JSON Elenco di tutte le istanze attive',
1697
- es: 'JSON Lista de todos los casos activos',
1698
- pl: 'JSON Lista wszystkich aktywnych instancji',
1699
- // @ts-ignore
1700
- uk: '????? ?????? ???? ???????? ???????????',
1701
- 'zh-cn': '? ? ????????',
1702
- },
1703
- type: 'array',
1704
- role: 'json',
1705
- read: true,
1706
- write: false,
1707
- },
1708
- native: {},
1709
- });
1710
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAllActiveInstances`, {
1711
- type: 'state',
1712
- common: {
1713
- name: {
1714
- en: 'Number of all active instances',
1715
- de: 'Anzahl aller aktiven Instanzen',
1716
- ru: '?????????? ???? ???????? ?????????',
1717
- pt: 'Número de todas as instâncias ativas',
1718
- nl: 'Nummer van alle actieve instanties',
1719
- fr: 'Nombre de toutes les instances actives',
1720
- it: 'Numero di tutte le istanze attive',
1721
- es: 'Número de casos activos',
1722
- pl: 'Liczba wszystkich czynnych przypadków',
1723
- // @ts-ignore
1724
- uk: '????????? ???? ???????? ???????????',
1725
- 'zh-cn': '?????????',
1726
- },
1727
- type: 'number',
1728
- role: 'value',
1729
- read: true,
1730
- write: false,
1731
- },
1732
- native: {},
1733
- });
1734
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listDeactivatedInstances`, {
1735
- type: 'state',
1736
- common: {
1737
- name: {
1738
- en: 'JSON List of deactivated instances',
1739
- de: 'JSON Liste der deaktivierten Instanzen',
1740
- ru: '????? ?????? ???????????????? ?????????',
1741
- pt: 'J. Lista de instâncias desativadas',
1742
- nl: 'JSON List van gedeactiveerde instanties',
1743
- fr: 'JSON Liste des cas désactivés',
1744
- it: 'JSON Elenco delle istanze disattivate',
1745
- es: 'JSON Lista de casos desactivados',
1746
- pl: 'JSON Lista przypadków deaktywowanych',
1747
- // @ts-ignore
1748
- uk: '????? ??????? ????????????? ???????????',
1749
- 'zh-cn': '? ? ??????',
1750
- },
1751
- type: 'array',
1752
- role: 'json',
1753
- read: true,
1754
- write: false,
1755
- },
1756
- native: {},
1757
- });
1758
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countDeactivatedInstances`, {
1759
- type: 'state',
1760
- common: {
1761
- name: {
1762
- en: 'Number of deactivated instances',
1763
- de: 'Anzahl deaktivierter Instanzen',
1764
- ru: '?????????? ???????????????? ?????????',
1765
- pt: 'Número de instâncias desativadas',
1766
- nl: 'Nummer van gedeactiveerde instanties',
1767
- fr: 'Nombre de cas désactivés',
1768
- it: 'Numero di istanze disattivate',
1769
- es: 'Número de casos desactivados',
1770
- pl: 'Liczba deaktywowanych instancji',
1771
- // @ts-ignore
1772
- uk: '????????? ????????????? ???????????',
1773
- 'zh-cn': 'A. ???????',
1774
- },
1775
- type: 'number',
1776
- role: 'value',
1777
- read: true,
1778
- write: false,
1779
- },
1780
- native: {},
1781
- });
1782
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listInstancesError`, {
1783
- type: 'state',
1784
- common: {
1785
- name: {
1786
- en: 'JSON list of instances with error',
1787
- de: 'JSON-Liste von Instanzen mit Fehler',
1788
- ru: 'JSON ?????? ????????? ? ???????',
1789
- pt: 'Lista de instâncias JSON com erro',
1790
- nl: 'JSON lijst met fouten',
1791
- fr: 'Liste des instances avec erreur',
1792
- it: 'Elenco JSON delle istanze con errore',
1793
- es: 'JSON lista de casos con error',
1794
- pl: 'Lista b??dów JSON',
1795
- // @ts-ignore
1796
- uk: 'JSON ?????? ??????????? ? ????????',
1797
- 'zh-cn': '??????????????',
1798
- },
1799
- type: 'array',
1800
- role: 'json',
1801
- read: true,
1802
- write: false,
1803
- },
1804
- native: {},
1805
- });
1806
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countInstancesError`, {
1807
- type: 'state',
1808
- common: {
1809
- name: {
1810
- en: 'Count of instances with error',
1811
- de: 'Anzahl der Instanzen mit Fehler',
1812
- ru: '?????????? ????????? ? ???????',
1813
- pt: 'Contagem de instâncias com erro',
1814
- nl: 'Graaf van instoringen met fouten',
1815
- fr: 'Nombre de cas avec erreur',
1816
- it: 'Conteggio di istanze con errore',
1817
- es: 'Cuenta de casos con error',
1818
- pl: 'Liczba przyk?adów w przypadku b??dów',
1819
- // @ts-ignore
1820
- uk: '????????? ??????????? ? ????????',
1821
- 'zh-cn': '???????',
1822
- },
1823
- type: 'number',
1824
- role: 'value',
1825
- read: true,
1826
- write: false,
1827
- },
1828
- native: {},
1829
- });
1830
-
1831
- // Adapter
1832
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAdapterUpdates`, {
1833
- type: 'state',
1834
- common: {
1835
- name: {
1836
- en: 'JSON list of adapters with available updates',
1837
- de: 'JSON-Liste der Adapter mit verfügbaren Updates',
1838
- ru: 'JSON ?????? ????????? ? ?????????? ????????????',
1839
- pt: 'Lista de adaptadores JSON com atualizações disponíveis',
1840
- nl: 'JSON lijst met beschikbare updates',
1841
- fr: 'Liste JSON des adaptateurs avec mises à jour disponibles',
1842
- it: 'Elenco di adattatori JSON con aggiornamenti disponibili',
1843
- es: 'JSON lista de adaptadores con actualizaciones disponibles',
1844
- pl: 'JSON lista adapterów z dost?pnymi aktualizacjami',
1845
- // @ts-ignore
1846
- uk: 'JSON ?????? ????????? ? ?????????? ???????????',
1847
- 'zh-cn': '??A',
1848
- },
1849
- type: 'array',
1850
- role: 'json',
1851
- read: true,
1852
- write: false,
1853
- },
1854
- native: {},
1855
- });
1856
- await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAdapterUpdates`, {
1857
- type: 'state',
1858
- common: {
1859
- name: {
1860
- en: 'Number of adapters with available updates',
1861
- de: 'Anzahl der Adapter mit verfügbaren Updates',
1862
- ru: '?????????? ????????? ? ?????????? ????????????',
1863
- pt: 'Número de adaptadores com atualizações disponíveis',
1864
- nl: 'Nummer van adapters met beschikbare updates',
1865
- fr: "Nombre d'adaptateurs avec mises à jour disponibles",
1866
- it: 'Numero di adattatori con aggiornamenti disponibili',
1867
- es: 'Número de adaptadores con actualizaciones disponibles',
1868
- pl: 'Liczba adapterów z dost?pn? aktualizacj?',
1869
- // @ts-ignore
1870
- uk: '????????? ????????? ? ?????????? ???????????',
1871
- 'zh-cn': '????????',
1872
- },
1873
- type: 'number',
1874
- role: 'value',
1875
- read: true,
1876
- write: false,
1877
- },
1878
- native: {},
1879
- });
1880
- }
1881
-
1882
- /**
1883
- * delete Datapoints for Instances
1884
- */
1885
- async function deleteDPsForInstances(adaptr) {
1886
- await adaptr.delObjectAsync(`adapterAndInstances`);
1887
- await adaptr.delObjectAsync(`adapterAndInstances.listAllInstances`);
1888
- await adaptr.delObjectAsync(`adapterAndInstances.countAllInstances`);
1889
- await adaptr.delObjectAsync(`adapterAndInstances.listAllActiveInstances`);
1890
- await adaptr.delObjectAsync(`adapterAndInstances.countAllActiveInstances`);
1891
- await adaptr.delObjectAsync(`adapterAndInstances.listDeactivatedInstances`);
1892
- await adaptr.delObjectAsync(`adapterAndInstances.countDeactivatedInstances`);
1893
- await adaptr.delObjectAsync(`adapterAndInstances.listInstancesError`);
1894
- await adaptr.delObjectAsync(`adapterAndInstances.countInstancesError`);
1895
- await adaptr.delObjectAsync(`adapterAndInstances.listAdapterUpdates`);
1896
- await adaptr.delObjectAsync(`adapterAndInstances.countAdapterUpdates`);
1897
- }
1898
-
1899
- /**
1900
- * create adapter update data
1901
- */
1902
- async function createAdapterUpdateData(adaptr, adapterUpdateListDP) {
1903
-
1904
- // subscribe to datapoint
1905
- adaptr.subscribeForeignStates(adapterUpdateListDP);
1906
-
1907
- await adaptr.getAdapterUpdateData(adapterUpdateListDP);
1908
-
1909
- await adaptr.createAdapterUpdateList();
1910
- }
1911
-
1912
-
1913
- module.exports = {
1914
- createDPsForEachAdapter,
1915
- deleteDPsForEachAdapter,
1916
- createHtmlListDatapoints,
1917
- deleteHtmlListDatapoints,
1918
- createHtmlListDatapointsInstances,
1919
- deleteHtmlListDatapointsInstances,
1920
- createListHTML,
1921
- createListHTMLInstances,
1922
- createBlacklist,
1923
- createTimeListInstances,
1924
- createData,
1925
- createLists,
1926
- writeDatapoints,
1927
- createDPsForInstances,
1928
- deleteDPsForInstances,
1929
- createAdapterUpdateData,
1930
-
1931
- };
1932
-
1
+ const translations = require('./translations');
2
+ const tools = require('./tools');
3
+
4
+ /**
5
+ * @param adaptr
6
+ * @param {object} adptName - Adaptername of devices
7
+ */
8
+ async function createDPsForEachAdapter(adaptr, adptName) {
9
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}`, {
10
+ type: 'channel',
11
+ common: {
12
+ name: adptName,
13
+ },
14
+ native: {},
15
+ });
16
+
17
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.offlineCount`, {
18
+ type: 'state',
19
+ common: {
20
+ name: {
21
+ en: 'Number of devices offline',
22
+ de: 'Anzahl der Geräte offline',
23
+ ru: 'Количество устройств оффлайн',
24
+ pt: 'Número de dispositivos offline',
25
+ nl: 'Aantal offline apparaten',
26
+ fr: 'Nombre de dispositifs hors ligne',
27
+ it: 'Numero di dispositivi offline',
28
+ es: 'Número de dispositivos sin conexión',
29
+ pl: 'Liczba urządzeń offline',
30
+ 'zh-cn': '离线设备数量',
31
+ },
32
+ type: 'number',
33
+ role: 'value',
34
+ read: true,
35
+ write: false,
36
+ },
37
+ native: {},
38
+ });
39
+
40
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.offlineList`, {
41
+ type: 'state',
42
+ common: {
43
+ name: {
44
+ en: 'List of offline devices',
45
+ de: 'Liste der Offline-Geräte',
46
+ ru: 'Список оффлайн устройств',
47
+ pt: 'Lista de dispositivos offline',
48
+ nl: 'Lijst van offline apparaten',
49
+ fr: 'Liste des dispositifs hors ligne',
50
+ it: 'Elenco dei dispositivi offline',
51
+ es: 'Lista de dispositivos sin conexión',
52
+ pl: 'Lista urządzeń offline',
53
+ 'zh-cn': '离线设备列表',
54
+ },
55
+ type: 'array',
56
+ role: 'json',
57
+ read: true,
58
+ write: false,
59
+ },
60
+ native: {},
61
+ });
62
+
63
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceOffline`, {
64
+ type: 'state',
65
+ common: {
66
+ name: {
67
+ en: 'Is one device offline',
68
+ de: 'Ist ein Gerät offline',
69
+ ru: 'Есть ли одно устройство оффлайн',
70
+ pt: ' um dispositivo offline',
71
+ nl: 'Is er een apparaat offline',
72
+ fr: 'Y a-t-il un appareil hors ligne',
73
+ it: "C'è un dispositivo offline",
74
+ es: '¿Hay un dispositivo sin conexión?',
75
+ pl: 'Czy jedno urządzenie jest offline',
76
+ uk: 'Чи є один пристрій офлайн',
77
+ 'zh-cn': '是否有一台设备离线',
78
+ },
79
+ type: 'boolean',
80
+ role: 'state',
81
+ read: true,
82
+ write: false,
83
+ def: false,
84
+ },
85
+ native: {},
86
+ });
87
+
88
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.listAllRawJSON`, {
89
+ type: 'state',
90
+ common: {
91
+ name: {
92
+ en: 'JSON RAW List of all devices',
93
+ de: 'JSON RAW Liste aller Geräte',
94
+ ru: 'JSON RAW Список всех устройств',
95
+ pt: 'JSON RAW Lista de todos os dispositivos',
96
+ nl: 'JSON RAW Lijst van alle apparaten',
97
+ fr: 'JSON RAW Liste de tous les dispositifs',
98
+ it: 'JSON RAW Elenco di tutti i dispositivi',
99
+ es: 'JSON RAW Lista de todos los dispositivos',
100
+ pl: 'JSON RAW Lista wszystkich urządzeń',
101
+ uk: 'JSON RAW Список усіх пристроїв',
102
+ 'zh-cn': 'JSON RAW 所有设备列表',
103
+ },
104
+ type: 'array',
105
+ role: 'json',
106
+ read: true,
107
+ write: false,
108
+ },
109
+ native: {},
110
+ });
111
+
112
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.listAll`, {
113
+ type: 'state',
114
+ common: {
115
+ name: {
116
+ en: 'List of all devices',
117
+ de: 'Liste aller Geräte',
118
+ ru: 'Список всех устройств',
119
+ pt: 'Lista de todos os dispositivos',
120
+ nl: 'Lijst van alle apparaten',
121
+ fr: 'Liste de tous les dispositifs',
122
+ it: 'Elenco di tutti i dispositivi',
123
+ es: 'Lista de todos los dispositivos',
124
+ pl: 'Lista wszystkich urządzeń',
125
+ 'zh-cn': '所有设备的列表',
126
+ },
127
+ type: 'array',
128
+ role: 'json',
129
+ read: true,
130
+ write: false,
131
+ },
132
+ native: {},
133
+ });
134
+
135
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.linkQualityList`, {
136
+ type: 'state',
137
+ common: {
138
+ name: {
139
+ en: 'List of devices with signal strength',
140
+ de: 'Liste der Geräte mit Signalstärke',
141
+ ru: 'Список устройств с уровнем сигнала',
142
+ pt: 'Lista de dispositivos com força de sinal',
143
+ nl: 'Lijst van apparaten met signaalkracht',
144
+ fr: 'Liste des dispositifs avec force de signal',
145
+ it: 'Elenco dei dispositivi con forza del segnale',
146
+ es: 'Lista de dispositivos con fuerza de señal',
147
+ pl: 'Lista urządzeń z siłą sygnału',
148
+ 'zh-cn': '具有信号强度的设备列表',
149
+ },
150
+ type: 'array',
151
+ role: 'json',
152
+ read: true,
153
+ write: false,
154
+ },
155
+ native: {},
156
+ });
157
+
158
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.countAll`, {
159
+ type: 'state',
160
+ common: {
161
+ name: {
162
+ en: 'Number of all devices',
163
+ de: 'Anzahl aller Geräte',
164
+ ru: 'Количество всех устройств',
165
+ pt: 'Número de todos os dispositivos',
166
+ nl: 'Aantal van alle apparaten',
167
+ fr: 'Nombre de tous les appareils',
168
+ it: 'Numero di tutti i dispositivi',
169
+ es: 'Número de todos los dispositivos',
170
+ pl: 'Liczba wszystkich urządzeń',
171
+ 'zh-cn': '所有设备的数量',
172
+ },
173
+ type: 'number',
174
+ role: 'value',
175
+ read: true,
176
+ write: false,
177
+ },
178
+ native: {},
179
+ });
180
+
181
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.batteryList`, {
182
+ type: 'state',
183
+ common: {
184
+ name: {
185
+ en: 'List of devices with battery state',
186
+ de: 'Liste der Geräte mit Batteriezustand',
187
+ ru: 'Список устройств с состоянием батареи',
188
+ pt: 'Lista de dispositivos com estado da bateria',
189
+ nl: 'Lijst van apparaten met batterijstatus',
190
+ fr: 'Liste des appareils avec état de batterie',
191
+ it: 'Elenco dei dispositivi con stato della batteria',
192
+ es: 'Lista de dispositivos con estado de batería',
193
+ pl: 'Lista urządzeń ze stanem baterii',
194
+ 'zh-cn': '具有电池状态的设备列表',
195
+ },
196
+ type: 'array',
197
+ role: 'json',
198
+ read: true,
199
+ write: false,
200
+ },
201
+ native: {},
202
+ });
203
+
204
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.lowBatteryList`, {
205
+ type: 'state',
206
+ common: {
207
+ name: {
208
+ en: 'List of devices with low battery state',
209
+ de: 'Liste der Geräte mit niedrigem Batteriezustand',
210
+ ru: 'Список устройств с низким уровнем заряда батареи',
211
+ pt: 'Lista de dispositivos com baixo estado da bateria',
212
+ nl: 'Lijst van apparaten met lage batterijstatus',
213
+ fr: 'Liste des appareils à faible état de batterie',
214
+ it: 'Elenco di dispositivi con stato di batteria basso',
215
+ es: 'Lista de dispositivos con estado de batería bajo',
216
+ pl: 'Lista urządzeń o niskim stanie baterii',
217
+ 'zh-cn': '低电量设备列表',
218
+ },
219
+ type: 'array',
220
+ role: 'json',
221
+ read: true,
222
+ write: false,
223
+ },
224
+ native: {},
225
+ });
226
+
227
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.lowBatteryCount`, {
228
+ type: 'state',
229
+ common: {
230
+ name: {
231
+ en: 'Number of devices with low battery',
232
+ de: 'Anzahl der Geräte mit niedriger Batterie',
233
+ ru: 'Количество устройств с низким зарядом батареи',
234
+ pt: 'Número de dispositivos com bateria baixa',
235
+ nl: 'Aantal apparaten met lage batterij',
236
+ fr: 'Nombre de dispositifs avec batterie faible',
237
+ it: 'Numero di dispositivi con batteria scarica',
238
+ es: 'Número de dispositivos con batería baja',
239
+ pl: 'Liczba urządzeń z niskim poziomem baterii',
240
+ 'zh-cn': '低电量设备的数量',
241
+ },
242
+ type: 'number',
243
+ role: 'value',
244
+ read: true,
245
+ write: false,
246
+ },
247
+ native: {},
248
+ });
249
+
250
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceLowBat`, {
251
+ type: 'state',
252
+ common: {
253
+ name: {
254
+ en: 'Is one device with low battery',
255
+ de: 'Ist ein Gerät mit niedrigem Akku',
256
+ ru: 'Есть ли устройство с низким зарядом батареи',
257
+ pt: 'É um dispositivo com bateria baixa',
258
+ nl: 'Is er een apparaat met lage batterij',
259
+ fr: 'Y a-t-il un appareil avec batterie faible',
260
+ it: "C'è un dispositivo con batteria scarica",
261
+ es: '¿Hay un dispositivo con batería baja?',
262
+ pl: 'Czy jest jedno urządzenie z niskim poziomem baterii',
263
+ uk: 'Чи є пристрій з низьким зарядом батареї',
264
+ 'zh-cn': '是否有设备电量低',
265
+ },
266
+ type: 'boolean',
267
+ role: 'state',
268
+ read: true,
269
+ write: false,
270
+ def: false,
271
+ },
272
+ native: {},
273
+ });
274
+
275
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.batteryCount`, {
276
+ type: 'state',
277
+ common: {
278
+ name: {
279
+ en: 'Number of devices with battery',
280
+ de: 'Anzahl der Geräte mit Batterie',
281
+ ru: 'Количество устройств с батареей',
282
+ pt: 'Número de dispositivos com bateria',
283
+ nl: 'Aantal apparaten met batterij',
284
+ fr: 'Nombre de dispositifs avec batterie',
285
+ it: 'Numero di dispositivi con batteria',
286
+ es: 'Número de dispositivos con batería',
287
+ pl: 'Liczba urządzeń z baterią',
288
+ 'zh-cn': '带电池的设备数量',
289
+ },
290
+ type: 'number',
291
+ role: 'value',
292
+ read: true,
293
+ write: false,
294
+ },
295
+ native: {},
296
+ });
297
+
298
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.upgradableCount`, {
299
+ type: 'state',
300
+ common: {
301
+ name: {
302
+ en: 'Number of devices with available updates',
303
+ de: 'Anzahl der Geräte mit verfügbaren Updates',
304
+ ru: 'Количество устройств с доступными обновлениями',
305
+ pt: 'Número de dispositivos com atualizações disponíveis',
306
+ nl: 'Aantal apparaten met beschikbare updates',
307
+ fr: 'Nombre de dispositifs avec mises à jour disponibles',
308
+ it: 'Numero di dispositivi con aggiornamenti disponibili',
309
+ es: 'Número de dispositivos con actualizaciones disponibles',
310
+ pl: 'Liczba urządzeń z dostępnymi aktualizacjami',
311
+ uk: 'Кількість пристроїв з доступними оновленнями',
312
+ 'zh-cn': '具有可用更新的设备数量',
313
+ },
314
+ type: 'number',
315
+ role: 'value',
316
+ read: true,
317
+ write: false,
318
+ },
319
+ native: {},
320
+ });
321
+
322
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.upgradableList`, {
323
+ type: 'state',
324
+ common: {
325
+ name: {
326
+ en: 'JSON List of devices with available updates',
327
+ de: 'JSON Liste der Geräte mit verfügbaren Updates',
328
+ ru: 'JSON список устройств с доступными обновлениями',
329
+ pt: 'JSON Lista de dispositivos com atualizações disponíveis',
330
+ nl: 'JSON Lijst van apparaten met beschikbare updates',
331
+ fr: 'JSON Liste des appareils avec mises à jour disponibles',
332
+ it: 'JSON Elenco dei dispositivi con aggiornamenti disponibili',
333
+ es: 'JSON Lista de dispositivos con actualizaciones disponibles',
334
+ pl: 'JSON Lista urządzeń z dostępnymi aktualizacjami',
335
+ uk: 'JSON список пристроїв з доступними оновленнями',
336
+ 'zh-cn': '具有可用更新的设备的 JSON 列表',
337
+ },
338
+ type: 'array',
339
+ role: 'json',
340
+ read: true,
341
+ write: false,
342
+ },
343
+ native: {},
344
+ });
345
+
346
+ await adaptr.setObjectNotExistsAsync(`devices.${adptName}.oneDeviceUpdatable`, {
347
+ type: 'state',
348
+ common: {
349
+ name: {
350
+ en: 'Is one device updatable',
351
+ de: 'Ist ein Gerät aktualisierbar',
352
+ ru: 'Можно ли обновить одно устройство',
353
+ pt: 'É um dispositivo atualizável',
354
+ nl: 'Is er een apparaat dat kan worden bijgewerkt',
355
+ fr: 'Y a-t-il un appareil qui peut être mis à jour',
356
+ it: "C'è un dispositivo aggiornabile",
357
+ es: '¿Hay un dispositivo actualizable?',
358
+ pl: 'Czy jest jedno urządzenie do zaktualizowania',
359
+ uk: 'Чи є пристрій, який можна оновити',
360
+ 'zh-cn': '是否有设备可更新',
361
+ },
362
+ type: 'boolean',
363
+ role: 'state',
364
+ read: true,
365
+ write: false,
366
+ def: false,
367
+ },
368
+ native: {},
369
+ });
370
+ }
371
+
372
+ /**
373
+ * delete datapoints for each adapter
374
+ *
375
+ * @param adaptr
376
+ * @param {object} adptName - Adaptername of devices
377
+ */
378
+ async function deleteDPsForEachAdapter(adaptr, adptName) {
379
+ await adaptr.delObjectAsync(`devices.${adptName}`);
380
+ await adaptr.delObjectAsync(`devices.${adptName}.offlineCount`);
381
+ await adaptr.delObjectAsync(`devices.${adptName}.offlineList`);
382
+ await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceOffline`);
383
+ await adaptr.delObjectAsync(`devices.${adptName}.listAllRawJSON`);
384
+ await adaptr.delObjectAsync(`devices.${adptName}.listAll`);
385
+ await adaptr.delObjectAsync(`devices.${adptName}.linkQualityList`);
386
+ await adaptr.delObjectAsync(`devices.${adptName}.countAll`);
387
+ await adaptr.delObjectAsync(`devices.${adptName}.batteryList`);
388
+ await adaptr.delObjectAsync(`devices.${adptName}.lowBatteryList`);
389
+ await adaptr.delObjectAsync(`devices.${adptName}.lowBatteryCount`);
390
+ await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceLowBat`);
391
+ await adaptr.delObjectAsync(`devices.${adptName}.batteryCount`);
392
+ await adaptr.delObjectAsync(`devices.${adptName}.upgradableCount`);
393
+ await adaptr.delObjectAsync(`devices.${adptName}.upgradableList`);
394
+ await adaptr.delObjectAsync(`devices.${adptName}.oneDeviceUpdatable`);
395
+ }
396
+
397
+ /**
398
+ * create HTML list datapoints
399
+ *
400
+ * @param adaptr
401
+ * @param {object} [adptName] - Adaptername of devices
402
+ */
403
+ async function createHtmlListDatapoints(adaptr, adptName) {
404
+ let dpSubFolder;
405
+ //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
406
+ if (adptName) {
407
+ dpSubFolder = `${adptName}.`;
408
+ } else {
409
+ dpSubFolder = '';
410
+ }
411
+
412
+ await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}offlineListHTML`, {
413
+ type: 'state',
414
+ common: {
415
+ name: {
416
+ en: 'HTML List of offline devices',
417
+ de: 'HTML Liste der Offline-Geräte',
418
+ ru: 'HTML список оффлайн устройств',
419
+ pt: 'HTML Lista de dispositivos offline',
420
+ nl: 'HTML Lijst van offline apparaten',
421
+ fr: 'HTML Liste des dispositifs hors ligne',
422
+ it: 'HTML Elenco dei dispositivi offline',
423
+ es: 'HTML Lista de dispositivos sin conexión',
424
+ pl: 'HTML Lista urządzeń offline',
425
+ 'zh-cn': 'HTML 离线设备列表',
426
+ },
427
+ type: 'string',
428
+ role: 'html',
429
+ read: true,
430
+ write: false,
431
+ },
432
+ native: {},
433
+ });
434
+
435
+ await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}linkQualityListHTML`, {
436
+ type: 'state',
437
+ common: {
438
+ name: {
439
+ en: 'HTML List of devices with signal strength',
440
+ de: 'HTML Liste der Geräte mit Signalstärke',
441
+ ru: 'HTML список устройств с уровнем сигнала',
442
+ pt: 'HTML Lista de dispositivos com força de sinal',
443
+ nl: 'HTML Lijst van apparaten met signaalkracht',
444
+ fr: 'HTML Liste des dispositifs avec force de signal',
445
+ it: 'HTML Elenco dei dispositivi con forza del segnale',
446
+ es: 'HTML Lista de dispositivos con fuerza de señal',
447
+ pl: 'HTML Lista urządzeń z siłą sygnału',
448
+ 'zh-cn': 'HTML 具有信号强度的设备列表',
449
+ },
450
+ type: 'string',
451
+ role: 'value',
452
+ read: true,
453
+ write: false,
454
+ },
455
+ native: {},
456
+ });
457
+
458
+ await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}batteryListHTML`, {
459
+ type: 'state',
460
+ common: {
461
+ name: {
462
+ en: 'HTML List of devices with battery state',
463
+ de: 'HTML Liste der Geräte mit Batteriezustand',
464
+ ru: 'HTML список устройств с состоянием батареи',
465
+ pt: 'HTML Lista de dispositivos com estado da bateria',
466
+ nl: 'HTML Lijst van apparaten met batterijstatus',
467
+ fr: 'HTML Liste des appareils avec état de batterie',
468
+ it: 'HTML Elenco dei dispositivi con stato della batteria',
469
+ es: 'HTML Lista de dispositivos con estado de batería',
470
+ pl: 'HTML Lista urządzeń ze stanem baterii',
471
+ 'zh-cn': 'HTML 具有电池状态的设备列表',
472
+ },
473
+ type: 'string',
474
+ role: 'html',
475
+ read: true,
476
+ write: false,
477
+ },
478
+ native: {},
479
+ });
480
+
481
+ await adaptr.setObjectNotExistsAsync(`devices.${dpSubFolder}lowBatteryListHTML`, {
482
+ type: 'state',
483
+ common: {
484
+ name: {
485
+ en: 'HTML List of devices with low battery state',
486
+ de: 'HTML Liste der Geräte mit niedrigem Batteriezustand',
487
+ ru: 'HTML список устройств с низким уровнем заряда батареи',
488
+ pt: 'HTML Lista de dispositivos com baixo estado da bateria',
489
+ nl: 'HTML Lijst van apparaten met lage batterijstatus',
490
+ fr: 'HTML Liste des appareils à faible état de batterie',
491
+ it: 'HTML Elenco di dispositivi con stato di batteria basso',
492
+ es: 'HTML Lista de dispositivos con estado de batería bajo',
493
+ pl: 'HTML Lista urządzeń o niskim stanie baterii',
494
+ 'zh-cn': 'HTML 低电量设备列表',
495
+ },
496
+ type: 'string',
497
+ role: 'html',
498
+ read: true,
499
+ write: false,
500
+ },
501
+ native: {},
502
+ });
503
+ }
504
+
505
+ /**
506
+ * delete html datapoints
507
+ *
508
+ * @param adaptr
509
+ * @param {object} [adptName] - Adaptername of devices
510
+ */
511
+ async function deleteHtmlListDatapoints(adaptr, adptName) {
512
+ // delete the datapoints in subfolders with the adaptername otherwise delete the dP's in the root folder
513
+ let dpSubFolder;
514
+ if (adptName) {
515
+ dpSubFolder = `${adptName}.`;
516
+ } else {
517
+ dpSubFolder = '';
518
+ }
519
+
520
+ await adaptr.delObjectAsync(`devices.${dpSubFolder}offlineListHTML`);
521
+ await adaptr.delObjectAsync(`devices.${dpSubFolder}linkQualityListHTML`);
522
+ await adaptr.delObjectAsync(`devices.${dpSubFolder}batteryListHTML`);
523
+ await adaptr.delObjectAsync(`devices.${dpSubFolder}lowBatteryListHTML`);
524
+ }
525
+
526
+ /**
527
+ * create HTML list datapoints for instances
528
+ *
529
+ * @param adaptr
530
+ */
531
+ async function createHtmlListDatapointsInstances(adaptr) {
532
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists`, {
533
+ type: 'channel',
534
+ common: {
535
+ name: {
536
+ en: 'HTML lists for adapter and instances',
537
+ de: 'HTML-Listen für Adapter und Instanzen',
538
+ ru: 'HTML списки для адаптера и экземпляров',
539
+ pt: 'Listas HTML para adaptador e instâncias',
540
+ nl: 'HTML lijsten voor adapter en instanties',
541
+ fr: "Listes HTML pour l'adaptateur et les instances",
542
+ it: 'Elenchi HTML per adattatore e istanze',
543
+ es: 'Listas HTML para adaptador e instancias',
544
+ pl: 'Listy HTML dla adaptera i instancji',
545
+ uk: 'HTML списки для адаптера та екземплярів',
546
+ 'zh-cn': '适配器和实例的 HTML 列表',
547
+ },
548
+ },
549
+ native: {},
550
+ });
551
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`, {
552
+ type: 'state',
553
+ common: {
554
+ name: {
555
+ en: 'HTML List of all instances',
556
+ de: 'HTML Liste aller Instanzen',
557
+ ru: 'HTML список всех экземпляров',
558
+ pt: 'HTML Lista de todas as instâncias',
559
+ nl: 'HTML Lijst van alle instanties',
560
+ fr: 'HTML Liste de toutes les instances',
561
+ it: 'HTML Elenco di tutte le istanze',
562
+ es: 'HTML Lista de todas las instancias',
563
+ pl: 'HTML Lista wszystkich instancji',
564
+ uk: 'HTML список усіх екземплярів',
565
+ 'zh-cn': 'HTML 所有实例的列表',
566
+ },
567
+ type: 'string',
568
+ role: 'html',
569
+ read: true,
570
+ write: false,
571
+ },
572
+ native: {},
573
+ });
574
+
575
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`, {
576
+ type: 'state',
577
+ common: {
578
+ name: {
579
+ en: 'HTML List of all active instances',
580
+ de: 'HTML Liste aller aktiven Instanzen',
581
+ ru: 'HTML список всех активных экземпляров',
582
+ pt: 'HTML Lista de todas as instâncias ativas',
583
+ nl: 'HTML Lijst van alle actieve instanties',
584
+ fr: 'HTML Liste de toutes les instances actives',
585
+ it: 'HTML Elenco di tutte le istanze attive',
586
+ es: 'HTML Lista de todas las instancias activas',
587
+ pl: 'HTML Lista wszystkich aktywnych instancji',
588
+ uk: 'HTML список усіх активних екземплярів',
589
+ 'zh-cn': 'HTML 所有活动实例的列表',
590
+ },
591
+ type: 'string',
592
+ role: 'value',
593
+ read: true,
594
+ write: false,
595
+ },
596
+ native: {},
597
+ });
598
+
599
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`, {
600
+ type: 'state',
601
+ common: {
602
+ name: {
603
+ en: 'HTML List of all deactivated instances',
604
+ de: 'HTML Liste aller deaktivierten Instanzen',
605
+ ru: 'HTML список всех деактивированных экземпляров',
606
+ pt: 'HTML Lista de todas as instâncias desativadas',
607
+ nl: 'HTML Lijst van alle gedeactiveerde instanties',
608
+ fr: 'HTML Liste de toutes les instances désactivées',
609
+ it: 'HTML Elenco di tutte le istanze disattivate',
610
+ es: 'HTML Lista de todas las instancias desactivadas',
611
+ pl: 'HTML Lista wszystkich dezaktywowanych instancji',
612
+ uk: 'HTML список усіх деактивованих екземплярів',
613
+ 'zh-cn': 'HTML 所有已停用实例的列表',
614
+ },
615
+ type: 'string',
616
+ role: 'html',
617
+ read: true,
618
+ write: false,
619
+ },
620
+ native: {},
621
+ });
622
+
623
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`, {
624
+ type: 'state',
625
+ common: {
626
+ name: {
627
+ en: 'HTML List of instances with error',
628
+ de: 'HTML Liste der Instanzen mit Fehler',
629
+ ru: 'HTML список экземпляров с ошибкой',
630
+ pt: 'HTML Lista de instâncias com erro',
631
+ nl: 'HTML Lijst van instanties met fouten',
632
+ fr: 'HTML Liste des instances avec erreur',
633
+ it: 'HTML Elenco delle istanze con errore',
634
+ es: 'HTML Lista de instancias con error',
635
+ pl: 'HTML Lista instancji z błędem',
636
+ uk: 'HTML список екземплярів з помилкою',
637
+ 'zh-cn': 'HTML 含错误实例的列表',
638
+ },
639
+ type: 'string',
640
+ role: 'html',
641
+ read: true,
642
+ write: false,
643
+ },
644
+ native: {},
645
+ });
646
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`, {
647
+ type: 'state',
648
+ common: {
649
+ name: {
650
+ en: 'HTML list of adapters with available updates',
651
+ de: 'HTML-Liste der Adapter mit verfügbaren Updates',
652
+ ru: 'HTML список адаптеров с доступными обновлениями',
653
+ pt: 'Lista HTML de adaptadores com atualizações disponíveis',
654
+ nl: 'HTML lijst van adapters met beschikbare updates',
655
+ fr: 'Liste HTML des adaptateurs avec mises à jour disponibles',
656
+ it: 'Elenco HTML degli adattatori con aggiornamenti disponibili',
657
+ es: 'Lista HTML de adaptadores con actualizaciones disponibles',
658
+ pl: 'Lista adapterów HTML z dostępnymi aktualizacjami',
659
+ uk: 'HTML список адаптерів з доступними оновленнями',
660
+ 'zh-cn': 'HTML 具有可用更新的适配器列表',
661
+ },
662
+ type: 'string',
663
+ role: 'html',
664
+ read: true,
665
+ write: false,
666
+ },
667
+ native: {},
668
+ });
669
+ }
670
+
671
+ /**
672
+ * delete html datapoints for instances
673
+ *
674
+ * @param adaptr
675
+ */
676
+ async function deleteHtmlListDatapointsInstances(adaptr) {
677
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`);
678
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`);
679
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`);
680
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`);
681
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`);
682
+ await adaptr.delObjectAsync(`adapterAndInstances.HTML_Lists`);
683
+ }
684
+
685
+ /*=============================================
686
+ = functions to create html lists =
687
+ =============================================*/
688
+ /**
689
+ * @param adaptr
690
+ * @param {string} type - type of list
691
+ * @param {object} devices - Device
692
+ * @param {number} deviceCount - Counted devices
693
+ * @param {object} isLowBatteryList - list Low Battery Devices
694
+ */
695
+ async function createListHTML(adaptr, type, devices, deviceCount, isLowBatteryList) {
696
+ let html;
697
+ switch (type) {
698
+ case 'linkQualityList':
699
+ devices = devices.sort((a, b) => {
700
+ a = a.Device || '';
701
+ b = b.Device || '';
702
+ return a.localeCompare(b);
703
+ });
704
+ html = `<center>
705
+ <b>${[translations.Link_quality_devices[adaptr.config.userSelectedLanguage]]}:<font> ${deviceCount}</b><small></small></font>
706
+ <p></p>
707
+ </center>
708
+ <table width=100%>
709
+ <tr>
710
+ <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
711
+ <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
712
+ <th align=right>${[translations.Signal_strength[adaptr.config.userSelectedLanguage]]}</th>
713
+ </tr>
714
+ <tr>
715
+ <td colspan="5"><hr></td>
716
+ </tr>`;
717
+
718
+ for (const device of devices) {
719
+ html += `<tr>
720
+ <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
721
+ <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
722
+ <td align=right><font>${device[translations.Signal_strength[adaptr.config.userSelectedLanguage]]}</font></td>
723
+ </tr>`;
724
+ }
725
+
726
+ html += '</table>';
727
+ break;
728
+
729
+ case 'offlineList':
730
+ devices = devices.sort((a, b) => {
731
+ a = a.Device || '';
732
+ b = b.Device || '';
733
+ return a.localeCompare(b);
734
+ });
735
+ html = `<center>
736
+ <b>${[translations.offline_devices[adaptr.config.userSelectedLanguage]]}: <font color=${deviceCount === 0 ? '#3bcf0e' : 'orange'}>${deviceCount}</b><small></small></font>
737
+ <p></p>
738
+ </center>
739
+ <table width=100%>
740
+ <tr>
741
+ <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
742
+ <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
743
+ <th align=center>${[translations.Last_Contact[adaptr.config.userSelectedLanguage]]}</th>
744
+ </tr>
745
+ <tr>
746
+ <td colspan="5"><hr></td>
747
+ </tr>`;
748
+
749
+ for (const device of devices) {
750
+ html += `<tr>
751
+ <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
752
+ <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
753
+ <td align=center><font color=orange>${device[translations.Last_Contact[adaptr.config.userSelectedLanguage]]}</font></td>
754
+ </tr>`;
755
+ }
756
+
757
+ html += '</table>';
758
+ break;
759
+
760
+ case 'batteryList':
761
+ devices = devices.sort((a, b) => {
762
+ a = a.Device || '';
763
+ b = b.Device || '';
764
+ return a.localeCompare(b);
765
+ });
766
+ html = `<center>
767
+ <b>${isLowBatteryList === true ? `${[translations.low[adaptr.config.userSelectedLanguage]]} ` : ''}${[translations.battery_devices[adaptr.config.userSelectedLanguage]]}:
768
+ <font color=${isLowBatteryList === true ? (deviceCount > 0 ? 'orange' : '#3bcf0e') : ''}>${deviceCount}</b></font>
769
+ <p></p>
770
+ </center>
771
+ <table width=100%>
772
+ <tr>
773
+ <th align=left>${[translations.Device[adaptr.config.userSelectedLanguage]]}</th>
774
+ <th align=center width=120>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
775
+ <th align=${isLowBatteryList ? 'center' : 'right'}>${[translations.Battery[adaptr.config.userSelectedLanguage]]}</th>
776
+ </tr>
777
+ <tr>
778
+ <td colspan="5"><hr></td>
779
+ </tr>`;
780
+ for (const device of devices) {
781
+ html += `<tr>
782
+ <td><font>${device[translations.Device[adaptr.config.userSelectedLanguage]]}</font></td>
783
+ <td align=center><font>${device[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>`;
784
+
785
+ if (isLowBatteryList) {
786
+ html += `<td align=center><font color=orange>${device[translations.Battery[adaptr.config.userSelectedLanguage]]}</font></td>`;
787
+ } else {
788
+ html += `<td align=right><font color=#3bcf0e>${device[translations.Battery[adaptr.config.userSelectedLanguage]]}</font></td>`;
789
+ }
790
+ html += `</tr>`;
791
+ }
792
+
793
+ html += '</table>';
794
+ break;
795
+ }
796
+ return html;
797
+ }
798
+
799
+ /**
800
+ * @param adaptr
801
+ * @param {string} type - type of list
802
+ * @param {object} instances - Instance
803
+ * @param {number} instancesCount - Counted devices
804
+ */
805
+ async function createListHTMLInstances(adaptr, type, instances, instancesCount) {
806
+ let html;
807
+ switch (type) {
808
+ case 'allInstancesList':
809
+ instances = instances.sort((a, b) => {
810
+ a = a.Instance || '';
811
+ b = b.Instance || '';
812
+ return a.localeCompare(b);
813
+ });
814
+ html = `<center>
815
+ <b>${[translations.All_Instances[adaptr.config.userSelectedLanguage]]}:<font> ${instancesCount}</b><small></small></font>
816
+ <p></p>
817
+ </center>
818
+ <table width=100%>
819
+ <tr>
820
+ <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
821
+ <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
822
+ <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
823
+ </tr>
824
+ <tr>
825
+ <td colspan="5"><hr></td>
826
+ </tr>`;
827
+
828
+ for (const instanceData of instances) {
829
+ html += `<tr>
830
+ <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
831
+ <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
832
+ <td align=center><font>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
833
+ </tr>`;
834
+ }
835
+
836
+ html += '</table>';
837
+ break;
838
+
839
+ case 'allActiveInstancesList':
840
+ instances = instances.sort((a, b) => {
841
+ a = a.Instance || '';
842
+ b = b.Instances || '';
843
+ return a.localeCompare(b);
844
+ });
845
+ html = `<center>
846
+ <b>${[translations.Active_Instances[adaptr.config.userSelectedLanguage]]}: <font> ${instancesCount}</b><small></small></font>
847
+ <p></p>
848
+ </center>
849
+ <table width=100%>
850
+ <tr>
851
+ <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
852
+ <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
853
+ <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
854
+ </tr>
855
+ <tr>
856
+ <td colspan="5"><hr></td>
857
+ </tr>`;
858
+
859
+ for (const instanceData of instances) {
860
+ html += `<tr>
861
+ <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
862
+ <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
863
+ <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
864
+ </tr>`;
865
+ }
866
+
867
+ html += '</table>';
868
+ break;
869
+
870
+ case 'errorInstanceList':
871
+ instances = instances.sort((a, b) => {
872
+ a = a.Instance || '';
873
+ b = b.Instances || '';
874
+ return a.localeCompare(b);
875
+ });
876
+ html = `<center>
877
+ <b>${[translations.Error_Instances[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
878
+ <p></p>
879
+ </center>
880
+ <table width=100%>
881
+ <tr>
882
+ <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
883
+ <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
884
+ <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
885
+ </tr>
886
+ <tr>
887
+ <td colspan="5"><hr></td>
888
+ </tr>`;
889
+
890
+ for (const instanceData of instances) {
891
+ html += `<tr>
892
+ <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
893
+ <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
894
+ <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
895
+ </tr>`;
896
+ }
897
+
898
+ html += '</table>';
899
+ break;
900
+
901
+ case 'deactivatedInstanceList':
902
+ instances = instances.sort((a, b) => {
903
+ a = a.Instance || '';
904
+ b = b.Instances || '';
905
+ return a.localeCompare(b);
906
+ });
907
+ html = `<center>
908
+ <b>${[translations.Deactivated_Instances[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
909
+ <p></p>
910
+ </center>
911
+ <table width=100%>
912
+ <tr>
913
+ <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
914
+ <th align=center>${[translations.Instance[adaptr.config.userSelectedLanguage]]}</th>
915
+ <th align=center width=180>${[translations.Status[adaptr.config.userSelectedLanguage]]}</th>
916
+ </tr>
917
+ <tr>
918
+ <td colspan="5"><hr></td>
919
+ </tr>`;
920
+
921
+ for (const instanceData of instances) {
922
+ if (!instanceData.isAlive) {
923
+ html += `<tr>
924
+ <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
925
+ <td align=center><font>${instanceData[translations.Instance[adaptr.config.userSelectedLanguage]]}</font></td>
926
+ <td align=center><font color=orange>${instanceData[translations.Status[adaptr.config.userSelectedLanguage]]}</font></td>
927
+ </tr>`;
928
+ }
929
+ }
930
+
931
+ html += '</table>';
932
+ break;
933
+
934
+ case 'updateAdapterList':
935
+ html = `<center>
936
+ <b>${[translations.Updatable_adapters[adaptr.config.userSelectedLanguage]]}: <font color=${instancesCount === 0 ? '#3bcf0e' : 'orange'}>${instancesCount}</b><small></small></font>
937
+ <p></p>
938
+ </center>
939
+ <table width=100%>
940
+ <tr>
941
+ <th align=left>${[translations.Adapter[adaptr.config.userSelectedLanguage]]}</th>
942
+ <th align=center>${[translations.Installed_Version[adaptr.config.userSelectedLanguage]]}</th>
943
+ <th align=center>${[translations.Available_Version[adaptr.config.userSelectedLanguage]]}</th>
944
+ </tr>
945
+ <tr>
946
+ <td colspan="5"><hr></td>
947
+ </tr>`;
948
+
949
+ for (const instanceData of instances.values()) {
950
+ if (instanceData.updateAvailable !== ' - ') {
951
+ html += `<tr>
952
+ <td><font>${instanceData[translations.Adapter[adaptr.config.userSelectedLanguage]]}</font></td>
953
+ <td align=center><font>${instanceData[translations.Installed_Version[adaptr.config.userSelectedLanguage]]}</font></td>
954
+ <td align=center><font color=orange>${instanceData[translations.Available_Version[adaptr.config.userSelectedLanguage]]}</font></td>
955
+ </tr>`;
956
+ }
957
+ }
958
+
959
+ html += '</table>';
960
+ break;
961
+ }
962
+ return html;
963
+ }
964
+
965
+ /**
966
+ * create blacklist
967
+ *
968
+ * @param adaptr
969
+ */
970
+ async function createBlacklist(adaptr) {
971
+ adaptr.log.debug(`Start the function createBlacklist`);
972
+
973
+ // DEVICES
974
+ const myBlacklist = adaptr.config.tableBlacklist;
975
+ if (myBlacklist.length >= 1) {
976
+ for (const i in myBlacklist) {
977
+ try {
978
+ const blacklistParse = tools.parseData(myBlacklist[i].devices);
979
+ // push devices in list to ignor device in lists
980
+ if (myBlacklist[i].checkIgnorLists) {
981
+ adaptr.blacklistLists.push(blacklistParse.path);
982
+ }
983
+ if (myBlacklist[i].checkIgnorAdapterLists) {
984
+ adaptr.blacklistAdapterLists.push(blacklistParse.path);
985
+ }
986
+ // push devices in list to ignor device in notifications
987
+ if (myBlacklist[i].checkIgnorNotify) {
988
+ adaptr.blacklistNotify.push(blacklistParse.path);
989
+ }
990
+ } catch (error) {
991
+ adaptr.log.error(`[createBlacklist] - ${error}`);
992
+ }
993
+ if (adaptr.blacklistLists.length >= 1) {
994
+ adaptr.log.info(`Found devices/services on blacklist for lists: ${adaptr.blacklistLists}`);
995
+ }
996
+ if (adaptr.blacklistAdapterLists.length >= 1) {
997
+ adaptr.log.info(`Found devices/services on blacklist for own adapter lists: ${adaptr.blacklistAdapterLists}`);
998
+ }
999
+ if (adaptr.blacklistNotify.length >= 1) {
1000
+ adaptr.log.info(`Found devices/services on blacklist for notifications: ${adaptr.blacklistNotify}`);
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ // INSTANCES
1006
+ const myBlacklistInstances = adaptr.config.tableBlacklistInstances;
1007
+ if (myBlacklistInstances.length >= 1) {
1008
+ for (const i in myBlacklistInstances) {
1009
+ try {
1010
+ const blacklistParse = tools.parseData(myBlacklistInstances[i].instances);
1011
+ // push devices in list to ignor device in lists
1012
+ if (myBlacklistInstances[i].checkIgnorLists) {
1013
+ adaptr.blacklistInstancesLists.push(blacklistParse.instanceID);
1014
+ }
1015
+ // push devices in list to ignor device in notifications
1016
+ if (myBlacklistInstances[i].checkIgnorNotify) {
1017
+ adaptr.blacklistInstancesNotify.push(blacklistParse.instanceID);
1018
+ }
1019
+ } catch (error) {
1020
+ adaptr.log.error(`[createBlacklist] - ${error}`);
1021
+ }
1022
+ }
1023
+ if (adaptr.blacklistInstancesLists.length >= 1) {
1024
+ adaptr.log.info(`Found instances items on blacklist for lists: ${adaptr.blacklistInstancesLists}`);
1025
+ }
1026
+ if (adaptr.blacklistInstancesNotify.length >= 1) {
1027
+ adaptr.log.info(`Found instances items on blacklist for notifications: ${adaptr.blacklistInstancesNotify}`);
1028
+ }
1029
+ }
1030
+ }
1031
+
1032
+ /**
1033
+ * create list with time for instances
1034
+ *
1035
+ * @param adaptr
1036
+ */
1037
+ async function createTimeListInstances(adaptr) {
1038
+ // INSTANCES
1039
+ const userTimeListInstances = adaptr.config.tableTimeInstance;
1040
+
1041
+ if (userTimeListInstances.length >= 1) {
1042
+ for (const i in userTimeListInstances) {
1043
+ try {
1044
+ const userTimeListparse = tools.parseData(userTimeListInstances[i].instancesTime);
1045
+ // push devices in list to ignor device in lists
1046
+ adaptr.userTimeInstancesList.set(userTimeListparse.instanceName, {
1047
+ deactivationTime: userTimeListInstances[i].deactivationTime,
1048
+ errorTime: userTimeListInstances[i].errorTime,
1049
+ });
1050
+ } catch (error) {
1051
+ adaptr.log.error(`[createTimeListInstances] - ${error}`);
1052
+ }
1053
+ }
1054
+ if (adaptr.userTimeInstancesList.size >= 1) {
1055
+ adaptr.log.info(`Found instances items on lists for timesettings: ${Array.from(adaptr.userTimeInstancesList.keys())}`);
1056
+ }
1057
+ }
1058
+ }
1059
+
1060
+ /**
1061
+ * @param adaptr
1062
+ * @param {object} i - Device Object
1063
+ */
1064
+ async function createData(adaptr, i) {
1065
+ try {
1066
+ const devices = await adaptr.getForeignStatesAsync(adaptr.selAdapter[i].selektor);
1067
+ const adapterID = adaptr.selAdapter[i].adapterID;
1068
+
1069
+ /*---------- Start of loop ----------*/
1070
+ for (const [id] of Object.entries(devices)) {
1071
+ if (id.endsWith('.')) {
1072
+ continue;
1073
+ }
1074
+ const mainSelector = id;
1075
+
1076
+ /*=============================================
1077
+ = get Instanz =
1078
+ =============================================*/
1079
+ const instance = id.slice(0, id.indexOf('.') + 2);
1080
+
1081
+ let instanceDeviceConnectionDP = `${instance}.info.connection`;
1082
+ let instanceDeviceConnected = await tools.getInitValue(adaptr, instanceDeviceConnectionDP);
1083
+
1084
+ if (instanceDeviceConnected === undefined) {
1085
+ const sysAdmin = `system.adapter.${instanceDeviceConnectionDP.replace('info.connection', 'connected')}`;
1086
+ instanceDeviceConnectionDP = sysAdmin;
1087
+ instanceDeviceConnected = await tools.getInitValue(adaptr, sysAdmin);
1088
+ }
1089
+
1090
+ adaptr.subscribeForeignStates(instanceDeviceConnectionDP);
1091
+ adaptr.subscribeForeignObjects(`${adaptr.selAdapter[i].selektor}`);
1092
+
1093
+ const deviceName = await adaptr.getDeviceName(id, i);
1094
+
1095
+ const adapter = adaptr.selAdapter[i].adapter;
1096
+
1097
+ /*=============================================
1098
+ = Get path to datapoints =
1099
+ =============================================*/
1100
+ const currDeviceString = id.slice(0, id.lastIndexOf('.') + 1 - 1);
1101
+ const shortCurrDeviceString = currDeviceString.slice(0, currDeviceString.lastIndexOf('.') + 1 - 1);
1102
+
1103
+ // subscribe to object device path
1104
+ adaptr.subscribeForeignStates(currDeviceString);
1105
+
1106
+ /*=============================================
1107
+ = Get signal strength =
1108
+ =============================================*/
1109
+ let deviceQualityDP = currDeviceString + adaptr.selAdapter[i].rssiState;
1110
+ let deviceQualityState;
1111
+ let linkQuality;
1112
+ let linkQualityRaw;
1113
+
1114
+ if (!deviceQualityDP.includes('undefined')) {
1115
+ switch (adapterID) {
1116
+ case 'mihomeVacuum':
1117
+ deviceQualityDP = shortCurrDeviceString + adaptr.selAdapter[i].rssiState;
1118
+ deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1119
+ break;
1120
+
1121
+ case 'netatmo':
1122
+ deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1123
+ if (!deviceQualityState) {
1124
+ deviceQualityDP = currDeviceString + adaptr.selAdapter[i].rfState;
1125
+ deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1126
+ }
1127
+ break;
1128
+
1129
+ default:
1130
+ deviceQualityState = await adaptr.getForeignStateAsync(deviceQualityDP);
1131
+ }
1132
+ //subscribe to states
1133
+ adaptr.subscribeForeignStates(deviceQualityDP);
1134
+
1135
+ const signalData = await adaptr.calculateSignalStrength(deviceQualityState, adapterID);
1136
+ linkQuality = signalData[0];
1137
+ linkQualityRaw = signalData[1];
1138
+ }
1139
+
1140
+ /*=============================================
1141
+ = Get battery data =
1142
+ =============================================*/
1143
+ let deviceBatteryStateDP;
1144
+ let deviceBatteryState;
1145
+ let batteryHealth;
1146
+ let batteryHealthRaw;
1147
+ let batteryUnitRaw;
1148
+ let lowBatIndicator;
1149
+ let isBatteryDevice;
1150
+ let isLowBatDP;
1151
+ let faultReportingDP;
1152
+ let faultReportingState;
1153
+
1154
+ const deviceChargerStateDP = currDeviceString + adaptr.selAdapter[i].charger;
1155
+ const deviceChargerState = await tools.getInitValue(adaptr, deviceChargerStateDP);
1156
+
1157
+ if (deviceChargerState === undefined || deviceChargerState === false) {
1158
+ // Get battery states
1159
+ switch (adapterID) {
1160
+ case 'hmrpc':
1161
+ deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery;
1162
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1163
+
1164
+ if (deviceBatteryState === undefined) {
1165
+ deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].hmDNBattery;
1166
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1167
+ }
1168
+ break;
1169
+ case 'hueExt':
1170
+ case 'mihomeVacuum':
1171
+ case 'mqttNuki':
1172
+ case 'loqedSmartLock':
1173
+ deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].battery;
1174
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1175
+
1176
+ if (deviceBatteryState === undefined) {
1177
+ deviceBatteryStateDP = shortCurrDeviceString + adaptr.selAdapter[i].battery2;
1178
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1179
+ }
1180
+ break;
1181
+ case 'homee': // only battery devices, structure problem like homee.0.*.BatteryLevel-964
1182
+ const devicePrefix = `${currDeviceString}.BatteryLevel-`;
1183
+ const listeDP = await adaptr.getObjectViewAsync('system', 'state', {
1184
+ startkey: `${devicePrefix}`,
1185
+ endkey: `${devicePrefix}\u9999`,
1186
+ });
1187
+
1188
+ if (listeDP.rows.length > 0) {
1189
+ deviceBatteryStateDP = listeDP.rows[0].id;
1190
+ }
1191
+
1192
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1193
+ break;
1194
+
1195
+ default:
1196
+ deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery;
1197
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1198
+
1199
+ if (deviceBatteryState === undefined) {
1200
+ deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery2;
1201
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1202
+
1203
+ if (deviceBatteryState === undefined) {
1204
+ deviceBatteryStateDP = currDeviceString + adaptr.selAdapter[i].battery3;
1205
+ deviceBatteryState = await tools.getInitValue(adaptr, deviceBatteryStateDP);
1206
+ }
1207
+ }
1208
+ break;
1209
+ }
1210
+
1211
+ // Get low bat states
1212
+ isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat;
1213
+ let deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1214
+
1215
+ if (deviceLowBatState === undefined) {
1216
+ isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat2;
1217
+ deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1218
+
1219
+ if (deviceLowBatState === undefined) {
1220
+ isLowBatDP = currDeviceString + adaptr.selAdapter[i].isLowBat3;
1221
+ deviceLowBatState = await tools.getInitValue(adaptr, isLowBatDP);
1222
+ }
1223
+ }
1224
+ if (deviceLowBatState === undefined) {
1225
+ isLowBatDP = 'none';
1226
+ }
1227
+
1228
+ faultReportingDP = shortCurrDeviceString + adaptr.selAdapter[i].faultReporting;
1229
+ faultReportingState = await tools.getInitValue(adaptr, faultReportingDP);
1230
+
1231
+ //subscribe to states
1232
+ adaptr.subscribeForeignStates(deviceBatteryStateDP);
1233
+ adaptr.subscribeForeignStates(isLowBatDP);
1234
+ adaptr.subscribeForeignStates(faultReportingDP);
1235
+
1236
+ const batteryData = await adaptr.getBatteryData(deviceBatteryState, deviceLowBatState, faultReportingState, adapterID);
1237
+
1238
+ batteryHealth = batteryData[0];
1239
+ batteryHealthRaw = batteryData[2];
1240
+ batteryUnitRaw = batteryData[3];
1241
+ isBatteryDevice = batteryData[1];
1242
+
1243
+ if (isBatteryDevice) {
1244
+ lowBatIndicator = await adaptr.setLowbatIndicator(deviceBatteryState, deviceLowBatState, faultReportingState, adapterID);
1245
+ }
1246
+ }
1247
+
1248
+ /*=============================================
1249
+ = Get last contact of device =
1250
+ =============================================*/
1251
+ let deviceStateSelectorHMRPC;
1252
+ let rssiPeerSelectorHMRPC;
1253
+
1254
+ // HMRPC
1255
+ if (adaptr.selAdapter[i].stateValue != undefined) {
1256
+ deviceStateSelectorHMRPC = shortCurrDeviceString + adaptr.selAdapter[i].stateValue;
1257
+ rssiPeerSelectorHMRPC = currDeviceString + adaptr.selAdapter[i].rssiPeerState;
1258
+ adaptr.subscribeForeignStates(deviceStateSelectorHMRPC);
1259
+ adaptr.subscribeForeignStates(rssiPeerSelectorHMRPC);
1260
+ }
1261
+
1262
+ let timeSelector = currDeviceString + adaptr.selAdapter[i].timeSelector;
1263
+ const timeSelectorState = await tools.getInitValue(adaptr, timeSelector);
1264
+
1265
+ if (timeSelectorState === undefined) {
1266
+ timeSelector = shortCurrDeviceString + adaptr.selAdapter[i].timeSelector;
1267
+ }
1268
+
1269
+ let unreachDP = currDeviceString + adaptr.selAdapter[i].reach;
1270
+
1271
+ let deviceUnreachState = await tools.getInitValue(adaptr, unreachDP);
1272
+
1273
+ if (deviceUnreachState === undefined) {
1274
+ unreachDP = shortCurrDeviceString + adaptr.selAdapter[i].reach;
1275
+ deviceUnreachState = await tools.getInitValue(adaptr, shortCurrDeviceString + adaptr.selAdapter[i].reach);
1276
+ }
1277
+
1278
+ // subscribe to states
1279
+ adaptr.subscribeForeignStates(timeSelector);
1280
+ adaptr.subscribeForeignStates(unreachDP);
1281
+
1282
+ const onlineState = await adaptr.getOnlineState(timeSelector, adapterID, unreachDP, linkQuality, deviceUnreachState, deviceStateSelectorHMRPC, rssiPeerSelectorHMRPC);
1283
+
1284
+ let deviceState;
1285
+ let lastContactString;
1286
+
1287
+ if (onlineState !== undefined && onlineState !== null) {
1288
+ lastContactString = onlineState[0];
1289
+ deviceState = onlineState[1];
1290
+ linkQuality = onlineState[2];
1291
+ }
1292
+
1293
+ /*=============================================
1294
+ = Get update data =
1295
+ =============================================*/
1296
+ let isUpgradable = ' - ';
1297
+ let deviceUpdateDP;
1298
+
1299
+ if (adaptr.config.checkSendDeviceUpgrade) {
1300
+ deviceUpdateDP = currDeviceString + adaptr.selAdapter[i].upgrade;
1301
+ let deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1302
+ if (deviceUpdateSelector === undefined) {
1303
+ deviceUpdateDP = shortCurrDeviceString + adaptr.selAdapter[i].upgrade;
1304
+ deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1305
+ if (deviceUpdateSelector === undefined) {
1306
+ const shortShortCurrDeviceString = shortCurrDeviceString.slice(0, shortCurrDeviceString.lastIndexOf('.') + 1 - 1);
1307
+ deviceUpdateDP = shortShortCurrDeviceString + adaptr.selAdapter[i].upgrade;
1308
+ deviceUpdateSelector = await tools.getInitValue(adaptr, deviceUpdateDP);
1309
+ }
1310
+ }
1311
+
1312
+ if (deviceUpdateSelector !== undefined) {
1313
+ isUpgradable = await adaptr.checkDeviceUpdate(adapterID, deviceUpdateSelector);
1314
+ }
1315
+
1316
+ adaptr.subscribeForeignStates(deviceUpdateDP);
1317
+ }
1318
+
1319
+ /*=============================================
1320
+ = Fill Raw Lists =
1321
+ =============================================*/
1322
+ const setupList = () => {
1323
+ adaptr.listAllDevicesRaw.set(currDeviceString, {
1324
+ Path: id,
1325
+ mainSelector: mainSelector,
1326
+ instanceDeviceConnectionDP: instanceDeviceConnectionDP,
1327
+ instanceDeviceConnected: instanceDeviceConnected,
1328
+ instance: instance,
1329
+ Device: deviceName,
1330
+ adapterID: adapterID,
1331
+ Adapter: adapter,
1332
+ timeSelector: timeSelector,
1333
+ isBatteryDevice: isBatteryDevice,
1334
+ Battery: batteryHealth,
1335
+ BatteryRaw: batteryHealthRaw,
1336
+ BatteryUnitRaw: batteryUnitRaw,
1337
+ batteryDP: deviceBatteryStateDP,
1338
+ LowBat: lowBatIndicator,
1339
+ LowBatDP: isLowBatDP,
1340
+ faultReport: faultReportingState,
1341
+ faultReportDP: faultReportingDP,
1342
+ SignalStrengthDP: deviceQualityDP,
1343
+ SignalStrength: linkQuality,
1344
+ SignalStrengthRaw: linkQualityRaw,
1345
+ UnreachState: deviceUnreachState,
1346
+ UnreachDP: unreachDP,
1347
+ deviceStateSelectorHMRPC: deviceStateSelectorHMRPC,
1348
+ rssiPeerSelectorHMRPC: rssiPeerSelectorHMRPC,
1349
+ LastContact: lastContactString,
1350
+ Status: deviceState,
1351
+ UpdateDP: deviceUpdateDP,
1352
+ Upgradable: isUpgradable,
1353
+ });
1354
+ };
1355
+
1356
+ if (!adaptr.configListOnlyBattery) {
1357
+ // Add all devices
1358
+ setupList();
1359
+ } else {
1360
+ // Add only devices with battery in the rawlist
1361
+ if (!isBatteryDevice) {
1362
+ continue;
1363
+ }
1364
+
1365
+ setupList();
1366
+ }
1367
+ } // <-- end of loop
1368
+ } catch (error) {
1369
+ adaptr.log.error(`[createData - create data of devices] - ${error}`);
1370
+ }
1371
+ } // <-- end of createData
1372
+
1373
+ /**
1374
+ * Create Lists
1375
+ *
1376
+ * @param adaptr
1377
+ * @param {string | undefined} [adptName]
1378
+ */
1379
+ async function createLists(adaptr, adptName) {
1380
+ adaptr.linkQualityDevices = [];
1381
+ adaptr.batteryPowered = [];
1382
+ adaptr.batteryLowPowered = [];
1383
+ adaptr.listAllDevicesUserRaw = [];
1384
+ adaptr.listAllDevices = [];
1385
+ adaptr.offlineDevices = [];
1386
+ adaptr.batteryLowPoweredRaw = [];
1387
+ adaptr.offlineDevicesRaw = [];
1388
+ adaptr.upgradableDevicesRaw = [];
1389
+ adaptr.upgradableList = [];
1390
+
1391
+ if (adptName === undefined) {
1392
+ adptName = '';
1393
+ }
1394
+
1395
+ for (const deviceData of adaptr.listAllDevicesRaw.values()) {
1396
+ /*---------- fill raw lists ----------*/
1397
+ // low bat list
1398
+ if (deviceData.LowBat && deviceData.Status !== 'Offline') {
1399
+ adaptr.batteryLowPoweredRaw.push({
1400
+ Path: deviceData.Path,
1401
+ Device: deviceData.Device,
1402
+ Adapter: deviceData.Adapter,
1403
+ Battery: deviceData.Battery,
1404
+ });
1405
+ }
1406
+ // offline raw list
1407
+ if (deviceData.Status === 'Offline') {
1408
+ adaptr.offlineDevicesRaw.push({
1409
+ Path: deviceData.Path,
1410
+ Device: deviceData.Device,
1411
+ Adapter: deviceData.Adapter,
1412
+ LastContact: deviceData.LastContact,
1413
+ });
1414
+ }
1415
+
1416
+ // upgradable raw list
1417
+ if (deviceData.Upgradable === true) {
1418
+ adaptr.upgradableDevicesRaw.push({
1419
+ Path: deviceData.Path,
1420
+ Device: deviceData.Device,
1421
+ Adapter: deviceData.Adapter,
1422
+ });
1423
+ }
1424
+
1425
+ if (adptName === '' && !adaptr.blacklistLists.includes(deviceData.Path)) {
1426
+ await adaptr.theLists(deviceData);
1427
+ }
1428
+
1429
+ if (adaptr.config.createOwnFolder && adptName !== '') {
1430
+ if (!deviceData.adapterID.includes(adptName)) {
1431
+ continue;
1432
+ }
1433
+ /*---------- fill user lists for each adapter ----------*/
1434
+ if (adaptr.blacklistAdapterLists.includes(deviceData.Path)) {
1435
+ continue;
1436
+ }
1437
+ await adaptr.theLists(deviceData);
1438
+ }
1439
+ }
1440
+ await tools.countDevices(adaptr);
1441
+ }
1442
+
1443
+ /**
1444
+ * @param adaptr
1445
+ * @param {string} [adptName] - Adaptername
1446
+ */
1447
+ async function writeDatapoints(adaptr, adptName) {
1448
+ // fill the datapoints
1449
+ adaptr.log.debug(`Start the function writeDatapoints`);
1450
+
1451
+ try {
1452
+ let dpSubFolder;
1453
+ //write the datapoints in subfolders with the adaptername otherwise write the dP's in the root folder
1454
+ if (adptName) {
1455
+ dpSubFolder = `${adptName}.`;
1456
+ } else {
1457
+ dpSubFolder = '';
1458
+ }
1459
+
1460
+ // Write Datapoints for counts
1461
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineCount`, { val: adaptr.offlineDevicesCount, ack: true });
1462
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}countAll`, { val: adaptr.deviceCounter, ack: true });
1463
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryCount`, { val: adaptr.batteryPoweredCount, ack: true });
1464
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryCount`, { val: adaptr.lowBatteryPoweredCount, ack: true });
1465
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}upgradableCount`, { val: adaptr.upgradableDevicesCount, ack: true });
1466
+ // List all devices
1467
+ if (adaptr.deviceCounter === 0) {
1468
+ // if no device is count, write the JSON List with default value
1469
+ adaptr.listAllDevices = [
1470
+ {
1471
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1472
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1473
+ [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1474
+ [translations.Signal_strength[adaptr.config.userSelectedLanguage]]: '',
1475
+ [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1476
+ [translations.Status[adaptr.config.userSelectedLanguage]]: '',
1477
+ },
1478
+ ];
1479
+ adaptr.listAllDevicesUserRaw = [
1480
+ {
1481
+ Device: '--none--',
1482
+ Adapter: '',
1483
+ Instance: '',
1484
+ 'Instance connected': '',
1485
+ isBatteryDevice: '',
1486
+ Battery: '',
1487
+ BatteryRaw: '',
1488
+ isLowBat: '',
1489
+ 'Signal strength': '',
1490
+ 'Last contact': '',
1491
+ UpdateAvailable: '',
1492
+ Status: '',
1493
+ },
1494
+ ];
1495
+ }
1496
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}listAll`, { val: JSON.stringify(adaptr.listAllDevices), ack: true });
1497
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}listAllRawJSON`, { val: JSON.stringify(adaptr.listAllDevicesUserRaw), ack: true });
1498
+
1499
+ // List link quality
1500
+ if (adaptr.linkQualityCount === 0) {
1501
+ // if no device is count, write the JSON List with default value
1502
+ adaptr.linkQualityDevices = [
1503
+ {
1504
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1505
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1506
+ [translations.Signal_strength[adaptr.config.userSelectedLanguage]]: '',
1507
+ },
1508
+ ];
1509
+ }
1510
+ //write JSON list
1511
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}linkQualityList`, {
1512
+ val: JSON.stringify(adaptr.linkQualityDevices),
1513
+ ack: true,
1514
+ });
1515
+
1516
+ // List offline devices
1517
+ if (adaptr.offlineDevicesCount === 0) {
1518
+ // if no device is count, write the JSON List with default value
1519
+ adaptr.offlineDevices = [
1520
+ {
1521
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1522
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1523
+ [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1524
+ },
1525
+ ];
1526
+ }
1527
+ //write JSON list
1528
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineList`, {
1529
+ val: JSON.stringify(adaptr.offlineDevices),
1530
+ ack: true,
1531
+ });
1532
+
1533
+ // List updatable
1534
+ if (adaptr.upgradableDevicesCount === 0) {
1535
+ // if no device is count, write the JSON List with default value
1536
+ adaptr.upgradableList = [
1537
+ {
1538
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1539
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1540
+ [translations.Last_Contact[adaptr.config.userSelectedLanguage]]: '',
1541
+ },
1542
+ ];
1543
+ }
1544
+ //write JSON list
1545
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}upgradableList`, {
1546
+ val: JSON.stringify(adaptr.upgradableList),
1547
+ ack: true,
1548
+ });
1549
+
1550
+ // List battery powered
1551
+ if (adaptr.batteryPoweredCount === 0) {
1552
+ // if no device is count, write the JSON List with default value
1553
+ adaptr.batteryPowered = [
1554
+ {
1555
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1556
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1557
+ [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1558
+ },
1559
+ ];
1560
+ }
1561
+ //write JSON list
1562
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryList`, {
1563
+ val: JSON.stringify(adaptr.batteryPowered),
1564
+ ack: true,
1565
+ });
1566
+
1567
+ // list battery low powered
1568
+ if (adaptr.lowBatteryPoweredCount === 0) {
1569
+ // if no device is count, write the JSON List with default value
1570
+ adaptr.batteryLowPowered = [
1571
+ {
1572
+ [translations.Device[adaptr.config.userSelectedLanguage]]: '--none--',
1573
+ [translations.Adapter[adaptr.config.userSelectedLanguage]]: '',
1574
+ [translations.Battery[adaptr.config.userSelectedLanguage]]: '',
1575
+ },
1576
+ ];
1577
+ }
1578
+ //write JSON list
1579
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryList`, {
1580
+ val: JSON.stringify(adaptr.batteryLowPowered),
1581
+ ack: true,
1582
+ });
1583
+
1584
+ // set booleans datapoints
1585
+ if (adaptr.offlineDevicesCount === 0) {
1586
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceOffline`, {
1587
+ val: false,
1588
+ ack: true,
1589
+ });
1590
+ } else {
1591
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceOffline`, {
1592
+ val: true,
1593
+ ack: true,
1594
+ });
1595
+ }
1596
+
1597
+ if (adaptr.lowBatteryPoweredCount === 0) {
1598
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceLowBat`, {
1599
+ val: false,
1600
+ ack: true,
1601
+ });
1602
+ } else {
1603
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceLowBat`, {
1604
+ val: true,
1605
+ ack: true,
1606
+ });
1607
+ }
1608
+
1609
+ if (adaptr.upgradableDevicesCount === 0) {
1610
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceUpdatable`, {
1611
+ val: false,
1612
+ ack: true,
1613
+ });
1614
+ } else {
1615
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}oneDeviceUpdatable`, {
1616
+ val: true,
1617
+ ack: true,
1618
+ });
1619
+ }
1620
+
1621
+ //write HTML list
1622
+ if (adaptr.configCreateHtmlList) {
1623
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}linkQualityListHTML`, {
1624
+ val: await this.createListHTML(adaptr, 'linkQualityList', adaptr.linkQualityDevices, adaptr.linkQualityCount, null),
1625
+ ack: true,
1626
+ });
1627
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}offlineListHTML`, {
1628
+ val: await this.createListHTML(adaptr, 'offlineList', adaptr.offlineDevices, adaptr.offlineDevicesCount, null),
1629
+ ack: true,
1630
+ });
1631
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}batteryListHTML`, {
1632
+ val: await this.createListHTML(adaptr, 'batteryList', adaptr.batteryPowered, adaptr.batteryPoweredCount, false),
1633
+ ack: true,
1634
+ });
1635
+ await adaptr.setStateChangedAsync(`devices.${dpSubFolder}lowBatteryListHTML`, {
1636
+ val: await this.createListHTML(adaptr, 'batteryList', adaptr.batteryLowPowered, adaptr.lowBatteryPoweredCount, true),
1637
+ ack: true,
1638
+ });
1639
+
1640
+ if (adaptr.config.checkAdapterInstances) {
1641
+ await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllInstancesHTML`, {
1642
+ val: await this.createListHTMLInstances(adaptr, 'allInstancesList', adaptr.listAllInstances, adaptr.countAllInstances),
1643
+ ack: true,
1644
+ });
1645
+ await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAllActiveInstancesHTML`, {
1646
+ val: await this.createListHTMLInstances(adaptr, 'allActiveInstancesList', adaptr.listAllActiveInstances, adaptr.countAllActiveInstances),
1647
+ ack: true,
1648
+ });
1649
+ await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listInstancesErrorHTML`, {
1650
+ val: await this.createListHTMLInstances(adaptr, 'errorInstanceList', adaptr.listErrorInstance, adaptr.countErrorInstance),
1651
+ ack: true,
1652
+ });
1653
+ await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listDeactivatedInstancesHTML`, {
1654
+ val: await this.createListHTMLInstances(adaptr, 'deactivatedInstanceList', adaptr.listDeactivatedInstances, adaptr.countDeactivatedInstances),
1655
+ ack: true,
1656
+ });
1657
+ await adaptr.setStateChangedAsync(`adapterAndInstances.HTML_Lists.listAdapterUpdatesHTML`, {
1658
+ val: await this.createListHTMLInstances(adaptr, 'updateAdapterList', adaptr.listAdapterUpdates, adaptr.countAdapterUpdates),
1659
+ ack: true,
1660
+ });
1661
+ }
1662
+ }
1663
+
1664
+ // create timestamp of last run
1665
+ const lastCheck = `${adaptr.formatDate(new Date(), 'DD.MM.YYYY')} - ${adaptr.formatDate(new Date(), 'hh:mm:ss')}`;
1666
+ await adaptr.setStateChangedAsync('lastCheck', lastCheck, true);
1667
+ } catch (error) {
1668
+ adaptr.log.error(`[writeDatapoints] - ${error}`);
1669
+ }
1670
+ } //<--End of writing Datapoints
1671
+
1672
+ /**
1673
+ * create Datapoints for Instances
1674
+ *
1675
+ * @param adaptr
1676
+ */
1677
+ async function createDPsForInstances(adaptr) {
1678
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances`, {
1679
+ type: 'channel',
1680
+ common: {
1681
+ name: {
1682
+ en: 'Adapter and Instances',
1683
+ de: 'Adapter und Instanzen',
1684
+ ru: 'Адаптер и экземпляры',
1685
+ pt: 'Adaptador e Instâncias',
1686
+ nl: 'Adapter en Instanties',
1687
+ fr: 'Adaptateur et instances',
1688
+ it: 'Adattatore e istanze',
1689
+ es: 'Adaptador e instancias',
1690
+ pl: 'Adapter i Instancje',
1691
+ uk: 'Адаптер та його екземпляри',
1692
+ 'zh-cn': '适配器和实例',
1693
+ },
1694
+ },
1695
+ native: {},
1696
+ });
1697
+
1698
+ // Instances
1699
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAllInstances`, {
1700
+ type: 'state',
1701
+ common: {
1702
+ name: {
1703
+ en: 'JSON List of all instances',
1704
+ de: 'JSON-Liste aller Instanzen',
1705
+ ru: 'JSON-список всех экземпляров',
1706
+ pt: 'Lista JSON de todas as instâncias',
1707
+ nl: 'JSON-lijst van alle instanties',
1708
+ fr: 'Liste JSON de toutes les instances',
1709
+ it: 'Elenco JSON di tutte le istanze',
1710
+ es: 'Lista JSON de todas las instancias',
1711
+ pl: 'Lista JSON wszystkich instancji',
1712
+ uk: 'JSON-список всіх інстанцій',
1713
+ 'zh-cn': '所有实例的JSON列表',
1714
+ },
1715
+ type: 'array',
1716
+ role: 'json',
1717
+ read: true,
1718
+ write: false,
1719
+ },
1720
+ native: {},
1721
+ });
1722
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAllInstances`, {
1723
+ type: 'state',
1724
+ common: {
1725
+ name: {
1726
+ en: 'Number of all instances',
1727
+ de: 'Anzahl aller Instanzen',
1728
+ ru: 'Количество всех экземпляров',
1729
+ pt: 'Número de todas as instâncias',
1730
+ nl: 'Aantal van alle instanties',
1731
+ fr: 'Nombre de toutes les instances',
1732
+ it: 'Numero di tutte le istanze',
1733
+ es: 'Número de todas las instancias',
1734
+ pl: 'Liczba wszystkich instancji',
1735
+ uk: 'Кількість усіх інстанцій',
1736
+ 'zh-cn': '所有实例的数量',
1737
+ },
1738
+ type: 'number',
1739
+ role: 'value',
1740
+ read: true,
1741
+ write: false,
1742
+ },
1743
+ native: {},
1744
+ });
1745
+ // Instances
1746
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAllActiveInstances`, {
1747
+ type: 'state',
1748
+ common: {
1749
+ name: {
1750
+ en: 'JSON List of all active instances',
1751
+ de: 'JSON-Liste aller aktiven Instanzen',
1752
+ ru: 'JSON список всех активных экземпляров',
1753
+ pt: 'Lista JSON de todas as instâncias ativas',
1754
+ nl: 'JSON-lijst van alle actieve instanties',
1755
+ fr: 'Liste JSON de toutes les instances actives',
1756
+ it: 'Elenco JSON di tutte le istanze attive',
1757
+ es: 'Lista JSON de todas las instancias activas',
1758
+ pl: 'JSON lista wszystkich aktywnych instancji',
1759
+ uk: 'JSON список усіх активних екземплярів',
1760
+ 'zh-cn': '所有活动实例的 JSON 列表',
1761
+ },
1762
+ type: 'array',
1763
+ role: 'json',
1764
+ read: true,
1765
+ write: false,
1766
+ },
1767
+ native: {},
1768
+ });
1769
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAllActiveInstances`, {
1770
+ type: 'state',
1771
+ common: {
1772
+ name: {
1773
+ en: 'Number of all active instances',
1774
+ de: 'Anzahl aller aktiven Instanzen',
1775
+ ru: 'Количество всех активных экземпляров',
1776
+ pt: 'Número de todas as instâncias ativas',
1777
+ nl: 'Aantal van alle actieve instanties',
1778
+ fr: 'Nombre de toutes les instances actives',
1779
+ it: 'Numero di tutte le istanze attive',
1780
+ es: 'Número de todas las instancias activas',
1781
+ pl: 'Liczba wszystkich aktywnych instancji',
1782
+ uk: 'Кількість усіх активних екземплярів',
1783
+ 'zh-cn': '所有活动实例的数量',
1784
+ },
1785
+ type: 'number',
1786
+ role: 'value',
1787
+ read: true,
1788
+ write: false,
1789
+ },
1790
+ native: {},
1791
+ });
1792
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listDeactivatedInstances`, {
1793
+ type: 'state',
1794
+ common: {
1795
+ name: {
1796
+ en: 'JSON List of deactivated instances',
1797
+ de: 'JSON-Liste der deaktivierten Instanzen',
1798
+ ru: 'JSON список деактивированных экземпляров',
1799
+ pt: 'JSON Lista de instâncias desativadas',
1800
+ nl: 'JSON-lijst van gedeactiveerde instanties',
1801
+ fr: 'Liste JSON des instances désactivées',
1802
+ it: 'JSON Elenco delle istanze disattivate',
1803
+ es: 'Lista JSON de instancias desactivadas',
1804
+ pl: 'JSON lista dezaktywowanych instancji',
1805
+ uk: 'JSON список деактивованих екземплярів',
1806
+ 'zh-cn': '已停用实例的 JSON 列表',
1807
+ },
1808
+ type: 'array',
1809
+ role: 'json',
1810
+ read: true,
1811
+ write: false,
1812
+ },
1813
+ native: {},
1814
+ });
1815
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countDeactivatedInstances`, {
1816
+ type: 'state',
1817
+ common: {
1818
+ name: {
1819
+ en: 'Number of deactivated instances',
1820
+ de: 'Anzahl deaktivierter Instanzen',
1821
+ ru: 'Количество деактивированных экземпляров',
1822
+ pt: 'Número de instâncias desativadas',
1823
+ nl: 'Aantal gedeactiveerde instanties',
1824
+ fr: "Nombre d'instances désactivées",
1825
+ it: 'Numero di istanze disattivate',
1826
+ es: 'Número de instancias desactivadas',
1827
+ pl: 'Liczba deaktywowanych instancji',
1828
+ uk: 'Кількість деактивованих екземплярів',
1829
+ 'zh-cn': '已停用实例的数量',
1830
+ },
1831
+ type: 'number',
1832
+ role: 'value',
1833
+ read: true,
1834
+ write: false,
1835
+ },
1836
+ native: {},
1837
+ });
1838
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listInstancesError`, {
1839
+ type: 'state',
1840
+ common: {
1841
+ name: {
1842
+ en: 'JSON list of instances with error',
1843
+ de: 'JSON-Liste von Instanzen mit Fehler',
1844
+ ru: 'JSON список экземпляров с ошибкой',
1845
+ pt: 'Lista de instâncias JSON com erro',
1846
+ nl: 'JSON lijst met fouten',
1847
+ fr: 'Liste des instances avec erreur',
1848
+ it: 'Elenco JSON delle istanze con errore',
1849
+ es: 'JSON lista de casos con error',
1850
+ pl: 'JSON lista instancji z błędem',
1851
+ uk: 'JSON список інстанцій з помилкою',
1852
+ 'zh-cn': '含错误实例的 JSON 列表',
1853
+ },
1854
+ type: 'array',
1855
+ role: 'json',
1856
+ read: true,
1857
+ write: false,
1858
+ },
1859
+ native: {},
1860
+ });
1861
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countInstancesError`, {
1862
+ type: 'state',
1863
+ common: {
1864
+ name: {
1865
+ en: 'Count of instances with error',
1866
+ de: 'Anzahl der Instanzen mit Fehler',
1867
+ ru: 'Количество экземпляров с ошибкой',
1868
+ pt: 'Contagem de instâncias com erro',
1869
+ nl: 'Aantal instanties met fouten',
1870
+ fr: "Nombre d'instances avec erreur",
1871
+ it: 'Conteggio delle istanze con errore',
1872
+ es: 'Recuento de instancias con error',
1873
+ pl: 'Liczba instancji z błędem',
1874
+ uk: 'Кількість інстанцій з помилкою',
1875
+ 'zh-cn': '出错实例的数量',
1876
+ },
1877
+ type: 'number',
1878
+ role: 'value',
1879
+ read: true,
1880
+ write: false,
1881
+ },
1882
+ native: {},
1883
+ });
1884
+
1885
+ // Adapter
1886
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.listAdapterUpdates`, {
1887
+ type: 'state',
1888
+ common: {
1889
+ name: {
1890
+ en: 'JSON list of adapters with available updates',
1891
+ de: 'JSON-Liste der Adapter mit verfügbaren Updates',
1892
+ ru: 'JSON список адаптеров с доступными обновлениями',
1893
+ pt: 'Lista de adaptadores JSON com atualizações disponíveis',
1894
+ nl: 'JSON lijst van adapters met beschikbare updates',
1895
+ fr: 'Liste JSON des adaptateurs avec mises à jour disponibles',
1896
+ it: 'Elenco JSON degli adattatori con aggiornamenti disponibili',
1897
+ es: 'JSON lista de adaptadores con actualizaciones disponibles',
1898
+ pl: 'JSON lista adapterów z dostępnymi aktualizacjami',
1899
+ uk: 'JSON список адаптерів з доступними оновленнями',
1900
+ 'zh-cn': '具有可用更新的适配器的 JSON 列表',
1901
+ },
1902
+ type: 'array',
1903
+ role: 'json',
1904
+ read: true,
1905
+ write: false,
1906
+ },
1907
+ native: {},
1908
+ });
1909
+ await adaptr.setObjectNotExistsAsync(`adapterAndInstances.countAdapterUpdates`, {
1910
+ type: 'state',
1911
+ common: {
1912
+ name: {
1913
+ en: 'Number of adapters with available updates',
1914
+ de: 'Anzahl der Adapter mit verfügbaren Updates',
1915
+ ru: 'Количество адаптеров с доступными обновлениями',
1916
+ pt: 'Número de adaptadores com atualizações disponíveis',
1917
+ nl: 'Aantal adapters met beschikbare updates',
1918
+ fr: "Nombre d'adaptateurs avec mises à jour disponibles",
1919
+ it: 'Numero di adattatori con aggiornamenti disponibili',
1920
+ es: 'Número de adaptadores con actualizaciones disponibles',
1921
+ pl: 'Liczba adapterów z dostępnymi aktualizacjami',
1922
+ uk: 'Кількість адаптерів з доступними оновленнями',
1923
+ 'zh-cn': '具有可用更新的适配器数量',
1924
+ },
1925
+ type: 'number',
1926
+ role: 'value',
1927
+ read: true,
1928
+ write: false,
1929
+ },
1930
+ native: {},
1931
+ });
1932
+ }
1933
+
1934
+ /**
1935
+ * delete Datapoints for Instances
1936
+ *
1937
+ * @param adaptr
1938
+ */
1939
+ async function deleteDPsForInstances(adaptr) {
1940
+ await adaptr.delObjectAsync(`adapterAndInstances`);
1941
+ await adaptr.delObjectAsync(`adapterAndInstances.listAllInstances`);
1942
+ await adaptr.delObjectAsync(`adapterAndInstances.countAllInstances`);
1943
+ await adaptr.delObjectAsync(`adapterAndInstances.listAllActiveInstances`);
1944
+ await adaptr.delObjectAsync(`adapterAndInstances.countAllActiveInstances`);
1945
+ await adaptr.delObjectAsync(`adapterAndInstances.listDeactivatedInstances`);
1946
+ await adaptr.delObjectAsync(`adapterAndInstances.countDeactivatedInstances`);
1947
+ await adaptr.delObjectAsync(`adapterAndInstances.listInstancesError`);
1948
+ await adaptr.delObjectAsync(`adapterAndInstances.countInstancesError`);
1949
+ await adaptr.delObjectAsync(`adapterAndInstances.listAdapterUpdates`);
1950
+ await adaptr.delObjectAsync(`adapterAndInstances.countAdapterUpdates`);
1951
+ }
1952
+
1953
+ /**
1954
+ * create adapter update data
1955
+ *
1956
+ * @param adaptr
1957
+ * @param adapterUpdateListDP
1958
+ */
1959
+ async function createAdapterUpdateData(adaptr, adapterUpdateListDP) {
1960
+ // subscribe to datapoint
1961
+ adaptr.subscribeForeignStates(adapterUpdateListDP);
1962
+
1963
+ await adaptr.getAdapterUpdateData(adapterUpdateListDP);
1964
+
1965
+ await adaptr.createAdapterUpdateList();
1966
+ }
1967
+
1968
+ module.exports = {
1969
+ createDPsForEachAdapter,
1970
+ deleteDPsForEachAdapter,
1971
+ createHtmlListDatapoints,
1972
+ deleteHtmlListDatapoints,
1973
+ createHtmlListDatapointsInstances,
1974
+ deleteHtmlListDatapointsInstances,
1975
+ createListHTML,
1976
+ createListHTMLInstances,
1977
+ createBlacklist,
1978
+ createTimeListInstances,
1979
+ createData,
1980
+ createLists,
1981
+ writeDatapoints,
1982
+ createDPsForInstances,
1983
+ deleteDPsForInstances,
1984
+ createAdapterUpdateData,
1985
+ };