iobroker.zigbee 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +433 -425
  3. package/admin/adapter-settings.js +244 -244
  4. package/admin/admin.js +2991 -2991
  5. package/admin/i18n/de/translations.json +108 -108
  6. package/admin/i18n/en/translations.json +108 -108
  7. package/admin/i18n/es/translations.json +102 -102
  8. package/admin/i18n/fr/translations.json +108 -108
  9. package/admin/i18n/it/translations.json +102 -102
  10. package/admin/i18n/nl/translations.json +108 -108
  11. package/admin/i18n/pl/translations.json +108 -108
  12. package/admin/i18n/pt/translations.json +102 -102
  13. package/admin/i18n/ru/translations.json +108 -108
  14. package/admin/i18n/uk/translations.json +108 -108
  15. package/admin/i18n/zh-cn/translations.json +102 -102
  16. package/admin/img/philips_hue_lom001.png +0 -0
  17. package/admin/index.html +163 -163
  18. package/admin/index_m.html +1360 -1360
  19. package/admin/moment.min.js +1 -1
  20. package/admin/shuffle.min.js +2 -2
  21. package/admin/tab_m.html +1021 -1021
  22. package/admin/vis-network.min.css +1 -1
  23. package/admin/vis-network.min.js +26 -26
  24. package/admin/words.js +110 -110
  25. package/docs/de/basedocu.md +19 -19
  26. package/docs/de/readme.md +126 -126
  27. package/docs/en/readme.md +128 -128
  28. package/docs/flashing_via_arduino_(en).md +110 -110
  29. package/docs/ru/readme.md +28 -28
  30. package/docs/tutorial/groups-1.png +0 -0
  31. package/docs/tutorial/groups-2.png +0 -0
  32. package/docs/tutorial/tab-dev-1.png +0 -0
  33. package/io-package.json +27 -27
  34. package/lib/backup.js +171 -171
  35. package/lib/binding.js +319 -319
  36. package/lib/colors.js +465 -465
  37. package/lib/commands.js +4 -2
  38. package/lib/developer.js +151 -151
  39. package/lib/devicemgmt.js +374 -393
  40. package/lib/devices.js +3139 -3139
  41. package/lib/exclude.js +162 -162
  42. package/lib/exposes.js +41 -14
  43. package/lib/groups.js +345 -345
  44. package/lib/json.js +59 -59
  45. package/lib/networkmap.js +55 -55
  46. package/lib/ota.js +198 -198
  47. package/lib/rgb.js +297 -297
  48. package/lib/seriallist.js +48 -48
  49. package/lib/states.js +6420 -6420
  50. package/lib/statescontroller.js +25 -10
  51. package/lib/tools.js +54 -54
  52. package/lib/utils.js +165 -165
  53. package/lib/zbBaseExtension.js +36 -36
  54. package/lib/zbDelayedAction.js +144 -144
  55. package/lib/zbDeviceAvailability.js +319 -319
  56. package/lib/zbDeviceConfigure.js +148 -151
  57. package/lib/zbDeviceEvent.js +48 -48
  58. package/lib/zigbeecontroller.js +1014 -1014
  59. package/package.json +4 -4
  60. package/support/docgen.js +93 -93
package/lib/devicemgmt.js CHANGED
@@ -1,393 +1,374 @@
1
- const dmUtils = require('@jey-cee/dm-utils');
2
- const humanizeDuration = require('humanize-duration');
3
-
4
- class dmZigbee extends dmUtils.DeviceManagement {
5
-
6
- async getInstanceInfo() {
7
- const data = {
8
- ...super.getInstanceInfo(),
9
- apiVersion: 'v1',
10
- actions: [
11
- {
12
- id: 'refresh',
13
- icon: 'fas fa-redo-alt',
14
- title: '',
15
- description: {
16
- en: 'Refresh device list',
17
- de: 'Geräteliste aktualisieren',
18
- ru: 'Обновить список устройств',
19
- pt: 'Atualizar lista de dispositivos',
20
- nl: 'Vernieuw apparaatlijst',
21
- fr: 'Actualiser la liste des appareils',
22
- it: 'Aggiorna elenco dispositivi',
23
- es: 'Actualizar lista de dispositivos',
24
- pl: 'Odśwież listę urządzeń',
25
-
26
- uk: 'Оновити список пристроїв'
27
- },
28
- handler: this.handleRefresh.bind(this)
29
- },
30
- {
31
- id: 'newDevice',
32
- icon: 'fas fa-plus',
33
- title: '',
34
- description: {
35
- en: 'Add new device to Zigbee',
36
- de: 'Neues Gerät zu Zigbee hinzufügen',
37
- ru: 'Добавить новое устройство в Zigbee',
38
- pt: 'Adicionar novo dispositivo ao Zigbee',
39
- nl: 'Voeg nieuw apparaat toe aan Zigbee',
40
- fr: 'Ajouter un nouvel appareil à Zigbee',
41
- it: 'Aggiungi nuovo dispositivo a Zigbee',
42
- es: 'Agregar nuevo dispositivo a Zigbee',
43
- pl: 'Dodaj nowe urządzenie do Zigbee',
44
-
45
- uk: 'Додати новий пристрій до Zigbee'
46
- },
47
- handler: this.handleNewDevice.bind(this)
48
- }
49
- ],
50
- };
51
- return data;
52
- }
53
-
54
- async handleRefresh(context) {
55
- this.adapter.log.info('handleRefresh');
56
- return { refresh: true };
57
- }
58
-
59
- async handleNewDevice(context) {
60
- this.adapter.log.info('handleNewDevice');
61
-
62
- const res = await this.adapter.zbController.permitJoin(permitTime);
63
-
64
- const permitTime = this.adapter.config.countDown;
65
-
66
- const progress = await context.openProgress('Searching...', { label: '0%' });
67
- await this.delay(500);
68
- for (let i = 1; i <= permitTime; i += 1) {
69
- await this.delay(300);
70
- this.log.info(`Progress at ${i}%`);
71
- await progress.update({ value: i, label: `${i}%` });
72
- }
73
-
74
- await this.delay(1000);
75
- await progress.close();
76
-
77
- return { refresh: true };
78
- }
79
-
80
-
81
-
82
- async listDevices() {
83
- const devices = await this.adapter.getDevicesAsync();
84
- const arrDevices = [];
85
- for (const i in devices) {
86
- const status = {};
87
-
88
- if (devices[i].common.type == 'group') continue;
89
-
90
- const available = await this.adapter.getStateAsync(`${devices[i]._id}.available`);
91
- if(available !== null && available !== undefined) {
92
- status.connection = available.val ? 'connected' : 'disconnected';
93
- }
94
-
95
- const link_quality = await this.adapter.getStateAsync(`${devices[i]._id}.link_quality`);
96
- if(link_quality) {
97
- status.rssi = link_quality.val;
98
- }
99
-
100
- const battery = await this.adapter.getStateAsync(`${devices[i]._id}.battery`);
101
- if(battery) {
102
- status.battery = battery.val;
103
- }
104
-
105
- let hastDetails = false;
106
- // Check if device has native.Sender_ID
107
- if(devices[i].native.id) {
108
- hastDetails = true;
109
- }
110
-
111
- const deviceInfo = await this.adapter.zbController.getDevice('0x'+devices[i].native.id);
112
-
113
- const res = {
114
- id: devices[i]._id,
115
- name: devices[i].common.name,
116
- icon: devices[i].common.icon ? '/adapter/zigbee/' + devices[i].common.icon : null,
117
- manufacturer: `${deviceInfo._manufacturerName}` ,
118
- model: `${deviceInfo._modelID}`,
119
- status: status,
120
- hasDetails: hastDetails,
121
- actions: [
122
- /* {
123
- id: 'delete',
124
- icon: 'fa-solid fa-trash-can',
125
- description: {
126
- en: 'Delete this device',
127
- de: 'Gerät löschen',
128
- ru: 'Удалить это устройство',
129
- pt: 'Excluir este dispositivo',
130
- nl: 'Verwijder dit apparaat',
131
- fr: 'Supprimer cet appareil',
132
- it: 'Elimina questo dispositivo',
133
- es: 'Eliminar este dispositivo',
134
- pl: 'Usuń to urządzenie',
135
- 'zh-cn': '删除此设备',
136
- uk: 'Видалити цей пристрій'
137
- },
138
- handler: this.handleDeleteDevice.bind(this)
139
- },*/
140
- {
141
- id: 'rename',
142
- icon: 'fa-solid fa-pen',
143
- description: {
144
- en: 'Rename this device',
145
- de: 'Gerät umbenennen',
146
- ru: 'Переименовать это устройство',
147
- pt: 'Renomear este dispositivo',
148
- nl: 'Hernoem dit apparaat',
149
- fr: 'Renommer cet appareil',
150
- it: 'Rinomina questo dispositivo',
151
- es: 'Renombrar este dispositivo',
152
- pl: 'Zmień nazwę tego urządzenia',
153
- 'zh-cn': '重命名此设备',
154
- uk: 'Перейменуйте цей пристрій'
155
- },
156
- handler: this.handleRenameDevice.bind(this)
157
- }
158
- ]
159
- };
160
- // if id contains gateway remove res.actions
161
- if(devices[i]._id.includes('gateway')) {
162
- res.actions = [];
163
- }
164
- arrDevices.push(res);
165
- }
166
- return arrDevices;
167
- }
168
-
169
- async getDeviceDetails(id, action, context) {
170
- this.adapter.log.info('getDeviceDetails');
171
- const devices = await this.adapter.getDevicesAsync();
172
- const device = devices.find(d => d._id === id);
173
- if(!device) {
174
- return {error: 'Device not found'};
175
- }
176
- if(!device.native.id) {
177
- return null;
178
- }
179
-
180
- const deviceInfo = await this.adapter.zbController.getDevice('0x'+ device.native.id);
181
- const lastSeen = await this.formatDate(deviceInfo._lastSeen);
182
-
183
- const items = {};
184
-
185
- for (const devInfo in deviceInfo._endpoints[0].inputClusters) {
186
-
187
- const val = deviceInfo._endpoints[0].inputClusters[devInfo];
188
- const valType = typeof val;
189
-
190
- if (valType != 'object') {
191
- const item = {
192
- ['inputCluster'+devInfo]: {
193
- type: 'staticText',
194
- text: `inputCluster ${devInfo} : ${val}`,
195
- newLine: true,
196
- },
197
- };
198
- Object.assign(items,item);
199
- }
200
-
201
- }
202
-
203
- const data = {
204
- id: deviceInfo._ieeeAddr,
205
- schema: {
206
- type: 'tabs',
207
- items: {
208
- _tab_Start: {
209
- type: 'panel',
210
- label: 'Main',
211
-
212
- items: {
213
- header_Start: {
214
- type: 'header',
215
- text: `${device.common.name} ${deviceInfo._ieeeAddr}`,
216
- size: 3,
217
- },
218
- _link: {
219
- label: `Manufacturer: ${deviceInfo._manufacturerName}`,
220
- type: 'staticLink',
221
- href: `https://www.zigbee2mqtt.io/supported-devices/#v=${deviceInfo._manufacturerName}`,
222
- button: true,
223
- },
224
- _link2: {
225
- label: `Model : ${device.common.type}`,
226
- type: 'staticLink',
227
- href: `https://www.zigbee2mqtt.io/devices/${device.common.type}.html`,
228
- button: true,
229
- },
230
- _softwareBuildID: {
231
- type: 'staticText',
232
- text: `<b>Software Build Id:</b> ${deviceInfo._softwareBuildID}`,
233
- style: {
234
- fontSize: 14
235
- }
236
- },
237
-
238
- _divider2: {
239
- type: 'divider',
240
- color: 'primary',
241
- },
242
- _interviewCompleted: {
243
- type: 'checkbox',
244
- label: `Interview completed`,
245
- checked: deviceInfo._interviewCompleted == 1 ? 'true' : 'false',
246
- disabled: 'true',
247
- newLine: true,
248
- },
249
- _configure: {
250
- type: 'checkbox',
251
- label: 'is Configured',
252
- help: 'if it possible',
253
- checked: deviceInfo.meta.configured == 1 ? 'true' : 'false',
254
- disabled: 'true',
255
- },
256
- _lastSeen: {
257
- type: 'staticText',
258
- text: `<b>Last seen:</b> ${lastSeen}`,
259
- },
260
- _manufacturerID: {
261
- type: 'staticText',
262
- text: `<b>Manufacturer Id:</b> ${deviceInfo._manufacturerID}`,
263
- newLine: true,
264
- },
265
- _network: {
266
- type: 'staticText',
267
- text: `<b>Network address:</b> 0x${deviceInfo._networkAddress}`,
268
- },
269
- _type: {
270
- type: 'staticText',
271
- text: `<b>Device Type:</b> ${deviceInfo._type}`,
272
- },
273
- _powered: {
274
- type: 'staticText',
275
- text: deviceInfo._powerSource ? `<b>Power:</b> ${deviceInfo._powerSource.toUpperCase()}` : ``,
276
- },
277
- _maxListeners: {
278
- type: 'staticText',
279
- text: `<b>max Listeners:</b> ${deviceInfo._maxListeners}`,
280
- },
281
- },
282
- },
283
- _tab_Details: {
284
- type: 'panel',
285
- label: 'Details',
286
- items,
287
- },
288
- },
289
- },
290
- };
291
-
292
- return data;
293
- }
294
-
295
- async handleDeleteDevice(id, context) {
296
- const devId = id.replace(/zigbee\.\d\./, '');
297
- const deviceInfo = await this.adapter.zbController.getDevice('0x'+ devId);
298
-
299
-
300
- const response = await context.showConfirmation({
301
- en: `Do you really want to delete the device ${deviceInfo._ieeeAddr}?`,
302
- de: `Möchten Sie das Gerät ${deviceInfo._ieeeAddr} wirklich löschen?`,
303
- ru: `Вы действительно хотите удалить устройство ${deviceInfo._ieeeAddr}?`,
304
- pt: `Você realmente deseja excluir o dispositivo ${deviceInfo._ieeeAddr}?`,
305
- nl: `Weet u zeker dat u het apparaat ${deviceInfo._ieeeAddr} wilt verwijderen?`,
306
- fr: `Voulez-vous vraiment supprimer l'appareil ${deviceInfo._ieeeAddr} ?`,
307
- it: `Vuoi davvero eliminare il dispositivo ${deviceInfo._ieeeAddr}?`,
308
- es: `¿Realmente desea eliminar el dispositivo ${deviceInfo._ieeeAddr}?`,
309
- pl: `Czy na pewno chcesz usunąć urządzenie ${deviceInfo._ieeeAddr}?`,
310
- 'zh-cn': `您真的要删除设备 ${deviceInfo._ieeeAddr} 吗?`,
311
- uk: `Ви дійсно бажаєте видалити пристрій ${deviceInfo._ieeeAddr}?`
312
- });
313
-
314
-
315
- // delete device
316
- if(response === false) {
317
- return {refresh: false};
318
- }
319
- const res = await this.adapter.leaveDevice('0x'+ devId);
320
-
321
- if (res !== null) {
322
- this.adapter.log.info(`${devId} deleted`);
323
- return {refresh: true};
324
- } else {
325
- this.adapter.log.error(`Can not delete device ${devId}: ${JSON.stringify(res)}`);
326
- return {refresh: false};
327
- }
328
- }
329
-
330
- async handleRenameDevice(id, context) {
331
- const result = await context.showForm({
332
- type : 'panel',
333
- items: {
334
- newName: {
335
- type: 'text',
336
- trim: false,
337
- placeholder: '',
338
- }
339
- }}, {
340
- data: {
341
- newName: ''
342
- },
343
- title: {
344
- en: 'Enter new name',
345
- de: 'Neuen Namen eingeben',
346
- ru: 'Введите новое имя',
347
- pt: 'Digite um novo nome',
348
- nl: 'Voer een nieuwe naam in',
349
- fr: 'Entrez un nouveau nom',
350
- it: 'Inserisci un nuovo nome',
351
- es: 'Ingrese un nuevo nombre',
352
- pl: 'Wpisz nowe imię',
353
- 'zh-cn': '输入新名称',
354
- uk: 'Введіть нове ім\'я'
355
- }
356
- });
357
- if (result == undefined || result.newName == '') {
358
- return {refresh: false};
359
- }
360
-
361
- const obj = {
362
- common: {
363
- name: result.newName
364
- }
365
- };
366
- const res = await this.adapter.extendObjectAsync(id, obj);
367
- this.adapter.log.info(JSON.stringify(res));
368
- if (res === null) {
369
- this.adapter.log.warn(`Can not rename device ${context.id}: ${JSON.stringify(res)}`);
370
-
371
- }
372
-
373
- return {refresh: true};
374
- }
375
-
376
- async formatDate(time, type) { //'ISO_8601' | 'ISO_8601_local' | 'epoch' | 'relative'
377
- if (type === 'ISO_8601') return new Date(time).toISOString();
378
- else if (type === 'ISO_8601_local') return this.toLocalISOString(new Date(time));
379
- else if (type === 'epoch') return time;
380
- else { // relative
381
- const ago = humanizeDuration(Date.now() - time, {language: 'en', largest: 2, round: true}) + ' ago';
382
- return ago;
383
- }
384
- }
385
-
386
- toLocalISOString(d) {
387
- const off = d.getTimezoneOffset();
388
- return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() - off, d.getSeconds(), d.getMilliseconds()).toISOString();
389
- }
390
-
391
- }
392
-
393
- module.exports = dmZigbee;
1
+ const dmUtils = require('@iobroker/dm-utils');
2
+ const humanizeDuration = require('humanize-duration');
3
+
4
+ class dmZigbee extends dmUtils.DeviceManagement {
5
+
6
+ async getInstanceInfo() {
7
+ const data = {
8
+ ...super.getInstanceInfo(),
9
+ apiVersion: 'v1',
10
+ actions: [
11
+ {
12
+ id: 'newDevice',
13
+ icon: 'fas fa-plus',
14
+ title: '',
15
+ description: {
16
+ en: 'Add new device to Zigbee',
17
+ de: 'Neues Gerät zu Zigbee hinzufügen',
18
+ ru: 'Добавить новое устройство в Zigbee',
19
+ pt: 'Adicionar novo dispositivo ao Zigbee',
20
+ nl: 'Voeg nieuw apparaat toe aan Zigbee',
21
+ fr: 'Ajouter un nouvel appareil à Zigbee',
22
+ it: 'Aggiungi nuovo dispositivo a Zigbee',
23
+ es: 'Agregar nuevo dispositivo a Zigbee',
24
+ pl: 'Dodaj nowe urządzenie do Zigbee',
25
+
26
+ uk: 'Додати новий пристрій до Zigbee'
27
+ },
28
+ handler: this.handleNewDevice.bind(this)
29
+ }
30
+ ],
31
+ };
32
+ return data;
33
+ }
34
+
35
+ async handleRefresh(context) {
36
+ this.adapter.log.info('handleRefresh');
37
+ return { refresh: true };
38
+ }
39
+
40
+ async handleNewDevice(context) {
41
+ this.adapter.log.info('handleNewDevice');
42
+
43
+ const res = await this.adapter.zbController.permitJoin(permitTime);
44
+
45
+ const permitTime = this.adapter.config.countDown;
46
+
47
+ const progress = await context.openProgress('Searching...', { label: '0%' });
48
+ await this.delay(500);
49
+ for (let i = 1; i <= permitTime; i += 1) {
50
+ await this.delay(300);
51
+ this.log.info(`Progress at ${i}%`);
52
+ await progress.update({ value: i, label: `${i}%` });
53
+ }
54
+
55
+ await this.delay(1000);
56
+ await progress.close();
57
+
58
+ return { refresh: true };
59
+ }
60
+
61
+
62
+
63
+ async listDevices() {
64
+ const devices = await this.adapter.getDevicesAsync();
65
+ const arrDevices = [];
66
+ for (const i in devices) {
67
+ const status = {};
68
+
69
+ if (devices[i].common.type == 'group') continue;
70
+
71
+ const available = await this.adapter.getStateAsync(`${devices[i]._id}.available`);
72
+ if(available !== null && available !== undefined) {
73
+ status.connection = available.val ? 'connected' : 'disconnected';
74
+ }
75
+
76
+ const link_quality = await this.adapter.getStateAsync(`${devices[i]._id}.link_quality`);
77
+ if(link_quality) {
78
+ status.rssi = link_quality.val;
79
+ }
80
+
81
+ const battery = await this.adapter.getStateAsync(`${devices[i]._id}.battery`);
82
+ if(battery) {
83
+ status.battery = battery.val;
84
+ }
85
+
86
+ let hastDetails = false;
87
+ // Check if device has native.Sender_ID
88
+ if(devices[i].native.id) {
89
+ hastDetails = true;
90
+ }
91
+
92
+ const deviceInfo = await this.adapter.zbController.getDevice('0x'+devices[i].native.id);
93
+
94
+ const res = {
95
+ id: devices[i]._id,
96
+ name: devices[i].common.name,
97
+ icon: devices[i].common.icon ? '/adapter/zigbee/' + devices[i].common.icon : null,
98
+ manufacturer: `${deviceInfo._manufacturerName}` ,
99
+ model: `${deviceInfo._modelID}`,
100
+ status: status,
101
+ hasDetails: hastDetails,
102
+ actions: [
103
+ /* {
104
+ id: 'delete',
105
+ icon: 'fa-solid fa-trash-can',
106
+ description: {
107
+ en: 'Delete this device',
108
+ de: 'Gerät löschen',
109
+ ru: 'Удалить это устройство',
110
+ pt: 'Excluir este dispositivo',
111
+ nl: 'Verwijder dit apparaat',
112
+ fr: 'Supprimer cet appareil',
113
+ it: 'Elimina questo dispositivo',
114
+ es: 'Eliminar este dispositivo',
115
+ pl: 'Usuń to urządzenie',
116
+ 'zh-cn': '删除此设备',
117
+ uk: 'Видалити цей пристрій'
118
+ },
119
+ handler: this.handleDeleteDevice.bind(this)
120
+ },*/
121
+ {
122
+ id: 'rename',
123
+ icon: 'fa-solid fa-pen',
124
+ description: {
125
+ en: 'Rename this device',
126
+ de: 'Gerät umbenennen',
127
+ ru: 'Переименовать это устройство',
128
+ pt: 'Renomear este dispositivo',
129
+ nl: 'Hernoem dit apparaat',
130
+ fr: 'Renommer cet appareil',
131
+ it: 'Rinomina questo dispositivo',
132
+ es: 'Renombrar este dispositivo',
133
+ pl: 'Zmień nazwę tego urządzenia',
134
+ 'zh-cn': '重命名此设备',
135
+ uk: 'Перейменуйте цей пристрій'
136
+ },
137
+ handler: this.handleRenameDevice.bind(this)
138
+ }
139
+ ]
140
+ };
141
+ // if id contains gateway remove res.actions
142
+ if(devices[i]._id.includes('gateway')) {
143
+ res.actions = [];
144
+ }
145
+ arrDevices.push(res);
146
+ }
147
+ return arrDevices;
148
+ }
149
+
150
+ async getDeviceDetails(id, action, context) {
151
+ this.adapter.log.info('getDeviceDetails');
152
+ const devices = await this.adapter.getDevicesAsync();
153
+ const device = devices.find(d => d._id === id);
154
+ if(!device) {
155
+ return {error: 'Device not found'};
156
+ }
157
+ if(!device.native.id) {
158
+ return null;
159
+ }
160
+
161
+ const deviceInfo = await this.adapter.zbController.getDevice('0x'+ device.native.id);
162
+ const lastSeen = await this.formatDate(deviceInfo._lastSeen);
163
+
164
+ const items = {};
165
+
166
+ for (const devInfo in deviceInfo._endpoints[0].inputClusters) {
167
+
168
+ const val = deviceInfo._endpoints[0].inputClusters[devInfo];
169
+ const valType = typeof val;
170
+
171
+ if (valType != 'object') {
172
+ const item = {
173
+ ['inputCluster'+devInfo]: {
174
+ type: 'staticText',
175
+ text: `inputCluster ${devInfo} : ${val}`,
176
+ newLine: true,
177
+ },
178
+ };
179
+ Object.assign(items,item);
180
+ }
181
+
182
+ }
183
+
184
+ const data = {
185
+ id: deviceInfo._ieeeAddr,
186
+ schema: {
187
+ type: 'tabs',
188
+ items: {
189
+ _tab_Start: {
190
+ type: 'panel',
191
+ label: 'Main',
192
+
193
+ items: {
194
+ header_Start: {
195
+ type: 'header',
196
+ text: `${device.common.name} ${deviceInfo._ieeeAddr}`,
197
+ size: 3,
198
+ },
199
+ _link: {
200
+ label: `Manufacturer: ${deviceInfo._manufacturerName}`,
201
+ type: 'staticLink',
202
+ href: `https://www.zigbee2mqtt.io/supported-devices/#v=${deviceInfo._manufacturerName}`,
203
+ button: true,
204
+ },
205
+ _link2: {
206
+ label: `Model : ${device.common.type}`,
207
+ type: 'staticLink',
208
+ href: `https://www.zigbee2mqtt.io/devices/${device.common.type}.html`,
209
+ button: true,
210
+ },
211
+ _softwareBuildID: {
212
+ type: 'staticText',
213
+ text: `<b>Software Build Id:</b> ${deviceInfo._softwareBuildID}`,
214
+ style: {
215
+ fontSize: 14
216
+ }
217
+ },
218
+
219
+ _divider2: {
220
+ type: 'divider',
221
+ color: 'primary',
222
+ },
223
+ _interviewCompleted: {
224
+ type: 'checkbox',
225
+ label: `Interview completed`,
226
+ checked: deviceInfo._interviewCompleted == 1 ? 'true' : 'false',
227
+ disabled: 'true',
228
+ newLine: true,
229
+ },
230
+ _configure: {
231
+ type: 'checkbox',
232
+ label: 'is Configured',
233
+ help: 'if it possible',
234
+ checked: deviceInfo.meta.configured == 1 ? 'true' : 'false',
235
+ disabled: 'true',
236
+ },
237
+ _lastSeen: {
238
+ type: 'staticText',
239
+ text: `<b>Last seen:</b> ${lastSeen}`,
240
+ },
241
+ _manufacturerID: {
242
+ type: 'staticText',
243
+ text: `<b>Manufacturer Id:</b> ${deviceInfo._manufacturerID}`,
244
+ newLine: true,
245
+ },
246
+ _network: {
247
+ type: 'staticText',
248
+ text: `<b>Network address:</b> 0x${deviceInfo._networkAddress}`,
249
+ },
250
+ _type: {
251
+ type: 'staticText',
252
+ text: `<b>Device Type:</b> ${deviceInfo._type}`,
253
+ },
254
+ _powered: {
255
+ type: 'staticText',
256
+ text: deviceInfo._powerSource ? `<b>Power:</b> ${deviceInfo._powerSource.toUpperCase()}` : ``,
257
+ },
258
+ _maxListeners: {
259
+ type: 'staticText',
260
+ text: `<b>max Listeners:</b> ${deviceInfo._maxListeners}`,
261
+ },
262
+ },
263
+ },
264
+ _tab_Details: {
265
+ type: 'panel',
266
+ label: 'Details',
267
+ items,
268
+ },
269
+ },
270
+ },
271
+ };
272
+
273
+ return data;
274
+ }
275
+
276
+ async handleDeleteDevice(id, context) {
277
+ const devId = id.replace(/zigbee\.\d\./, '');
278
+ const deviceInfo = await this.adapter.zbController.getDevice('0x'+ devId);
279
+
280
+
281
+ const response = await context.showConfirmation({
282
+ en: `Do you really want to delete the device ${deviceInfo._ieeeAddr}?`,
283
+ de: `Möchten Sie das Gerät ${deviceInfo._ieeeAddr} wirklich löschen?`,
284
+ ru: `Вы действительно хотите удалить устройство ${deviceInfo._ieeeAddr}?`,
285
+ pt: `Você realmente deseja excluir o dispositivo ${deviceInfo._ieeeAddr}?`,
286
+ nl: `Weet u zeker dat u het apparaat ${deviceInfo._ieeeAddr} wilt verwijderen?`,
287
+ fr: `Voulez-vous vraiment supprimer l'appareil ${deviceInfo._ieeeAddr} ?`,
288
+ it: `Vuoi davvero eliminare il dispositivo ${deviceInfo._ieeeAddr}?`,
289
+ es: `¿Realmente desea eliminar el dispositivo ${deviceInfo._ieeeAddr}?`,
290
+ pl: `Czy na pewno chcesz usunąć urządzenie ${deviceInfo._ieeeAddr}?`,
291
+ 'zh-cn': `您真的要删除设备 ${deviceInfo._ieeeAddr} 吗?`,
292
+ uk: `Ви дійсно бажаєте видалити пристрій ${deviceInfo._ieeeAddr}?`
293
+ });
294
+
295
+
296
+ // delete device
297
+ if(response === false) {
298
+ return {refresh: false};
299
+ }
300
+ const res = await this.adapter.leaveDevice('0x'+ devId);
301
+
302
+ if (res !== null) {
303
+ this.adapter.log.info(`${devId} deleted`);
304
+ return {refresh: true};
305
+ } else {
306
+ this.adapter.log.error(`Can not delete device ${devId}: ${JSON.stringify(res)}`);
307
+ return {refresh: false};
308
+ }
309
+ }
310
+
311
+ async handleRenameDevice(id, context) {
312
+ const result = await context.showForm({
313
+ type : 'panel',
314
+ items: {
315
+ newName: {
316
+ type: 'text',
317
+ trim: false,
318
+ placeholder: '',
319
+ }
320
+ }}, {
321
+ data: {
322
+ newName: ''
323
+ },
324
+ title: {
325
+ en: 'Enter new name',
326
+ de: 'Neuen Namen eingeben',
327
+ ru: 'Введите новое имя',
328
+ pt: 'Digite um novo nome',
329
+ nl: 'Voer een nieuwe naam in',
330
+ fr: 'Entrez un nouveau nom',
331
+ it: 'Inserisci un nuovo nome',
332
+ es: 'Ingrese un nuevo nombre',
333
+ pl: 'Wpisz nowe imię',
334
+ 'zh-cn': '输入新名称',
335
+ uk: 'Введіть нове ім\'я'
336
+ }
337
+ });
338
+ if (result == undefined || result.newName == '') {
339
+ return {refresh: false};
340
+ }
341
+
342
+ const obj = {
343
+ common: {
344
+ name: result.newName
345
+ }
346
+ };
347
+ const res = await this.adapter.extendObjectAsync(id, obj);
348
+ this.adapter.log.info(JSON.stringify(res));
349
+ if (res === null) {
350
+ this.adapter.log.warn(`Can not rename device ${context.id}: ${JSON.stringify(res)}`);
351
+
352
+ }
353
+
354
+ return {refresh: true};
355
+ }
356
+
357
+ async formatDate(time, type) { //'ISO_8601' | 'ISO_8601_local' | 'epoch' | 'relative'
358
+ if (type === 'ISO_8601') return new Date(time).toISOString();
359
+ else if (type === 'ISO_8601_local') return this.toLocalISOString(new Date(time));
360
+ else if (type === 'epoch') return time;
361
+ else { // relative
362
+ const ago = humanizeDuration(Date.now() - time, {language: 'en', largest: 2, round: true}) + ' ago';
363
+ return ago;
364
+ }
365
+ }
366
+
367
+ toLocalISOString(d) {
368
+ const off = d.getTimezoneOffset();
369
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() - off, d.getSeconds(), d.getMilliseconds()).toISOString();
370
+ }
371
+
372
+ }
373
+
374
+ module.exports = dmZigbee;