iobroker.zigbee2mqtt 2.7.0 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,6 +32,15 @@ This adapter allows to control the data points of the devices of a Zigbee2MQTT i
32
32
  Placeholder for the next version (at the beginning of the line):
33
33
  ### **WORK IN PROGRESS**
34
34
  -->
35
+ ### 2.7.2 (2023-02-01)
36
+
37
+ - (o0shojo0o) rework of the detection of removed devices
38
+
39
+ ### 2.7.1 (2023-01-24)
40
+
41
+ - (o0shojo0o) added option for use folder description
42
+ - (o0shojo0o) use the iobroker device folder description for device description or events
43
+
35
44
  ### 2.7.0 (2023-01-18)
36
45
 
37
46
  - (o0shojo0o) added support for wildcard actions (eg. *_single) ([#116](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/116))
@@ -24,5 +24,6 @@
24
24
  "Brightness move should also turn the light on or off": "Brightness move soll auch das Licht ein- oder ausschalten",
25
25
  "Brightness step should also turn the light on or off": "Brightness step soll auch das Licht ein- oder ausschalten",
26
26
  "Use Auth-Token": "Auth-Token verwenden",
27
- "Auth-Token (special characters are not supported)": "Auth-Token (Sonderzeichen werden nicht unterstützt)"
28
- }
27
+ "Auth-Token (special characters are not supported)": "Auth-Token (Sonderzeichen werden nicht unterstützt)",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Die Ereignisse wie „Gerät entfernt“ oder „Deaktiviert“ werden in der Beschreibung statt im Namen angezeigt."
29
+ }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Other configurations",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Proxy Zigbee2MQTT logs to ioBroker logs",
26
26
  "Brightness move should also turn the light on or off": "Brightness move should also turn the light on or off",
27
- "Brightness step should also turn the light on or off": "Brightness step should also turn the light on or off"
27
+ "Brightness step should also turn the light on or off": "Brightness step should also turn the light on or off",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Otras configuraciones",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Proxy de registros Zigbee2MQTT a registros de ioBroker",
26
26
  "Brightness move should also turn the light on or off": "El movimiento de brillo también debe encender o apagar la luz",
27
- "Brightness step should also turn the light on or off": "El paso de brillo también debe encender o apagar la luz"
27
+ "Brightness step should also turn the light on or off": "El paso de brillo también debe encender o apagar la luz",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Los eventos como 'Dispositivo eliminado' o 'Deshabilitado' se muestran en la descripción en lugar del nombre."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Autres configurations",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Proxy Zigbee2MQTT se connecte aux journaux ioBroker",
26
26
  "Brightness move should also turn the light on or off": "Le mouvement de luminosité devrait également allumer ou éteindre la lumière",
27
- "Brightness step should also turn the light on or off": "L'étape de luminosité devrait également allumer ou éteindre la lumière"
27
+ "Brightness step should also turn the light on or off": "L'étape de luminosité devrait également allumer ou éteindre la lumière",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Les événements tels que 'Appareil supprimé' ou 'Désactivé' sont affichés dans la description plutôt que dans le nom."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Altre configurazioni",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Il proxy Zigbee2MQTT registra nei registri ioBroker",
26
26
  "Brightness move should also turn the light on or off": "Lo spostamento della luminosità dovrebbe anche accendere o spegnere la luce",
27
- "Brightness step should also turn the light on or off": "Il passo di luminosità dovrebbe anche accendere o spegnere la luce"
27
+ "Brightness step should also turn the light on or off": "Il passo di luminosità dovrebbe anche accendere o spegnere la luce",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Gli eventi come \"Dispositivo rimosso\" o \"Disabilitato\" vengono visualizzati nella descrizione anziché nel nome."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Andere configuraties",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Proxy Zigbee2MQTT logt naar ioBroker-logboeken",
26
26
  "Brightness move should also turn the light on or off": "Helderheidsbeweging zou ook het licht aan of uit moeten zetten",
27
- "Brightness step should also turn the light on or off": "De helderheidsstap moet het licht ook in- of uitschakelen"
27
+ "Brightness step should also turn the light on or off": "De helderheidsstap moet het licht ook in- of uitschakelen",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "De gebeurtenissen zoals 'Apparaat verwijderd' of 'Uitgeschakeld' worden weergegeven in de beschrijving in plaats van in de naam."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Inne konfiguracje",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Proxy Zigbee2MQTT loguje się do logów ioBroker",
26
26
  "Brightness move should also turn the light on or off": "Ruch jasności powinien również włączać lub wyłączać światło",
27
- "Brightness step should also turn the light on or off": "Krok jasności powinien również włączać lub wyłączać światło"
27
+ "Brightness step should also turn the light on or off": "Krok jasności powinien również włączać lub wyłączać światło",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Zdarzenia takie jak „Urządzenie usunięte” lub „Wyłączone” są wyświetlane w opisie zamiast w nazwie."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Outras configurações",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Logs proxy Zigbee2MQTT para logs ioBroker",
26
26
  "Brightness move should also turn the light on or off": "O movimento de brilho também deve ligar ou desligar a luz",
27
- "Brightness step should also turn the light on or off": "A etapa de brilho também deve ligar ou desligar a luz"
27
+ "Brightness step should also turn the light on or off": "A etapa de brilho também deve ligar ou desligar a luz",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Os eventos como 'Dispositivo removido' ou 'Desativado' são exibidos na descrição em vez de no nome."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Другие конфигурации",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Проксировать журналы Zigbee2MQTT в журналы ioBroker",
26
26
  "Brightness move should also turn the light on or off": "Изменение яркости также должно включать или выключать свет.",
27
- "Brightness step should also turn the light on or off": "Шаг яркости также должен включать или выключать свет."
27
+ "Brightness step should also turn the light on or off": "Шаг яркости также должен включать или выключать свет.",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Такие события, как «Устройство удалено» или «Отключено», отображаются в описании, а не в названии."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "Інші конфігурації",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "Журнали проксі Zigbee2MQTT до журналів ioBroker",
26
26
  "Brightness move should also turn the light on or off": "Переміщення яскравості також повинно вмикати або вимикати світло",
27
- "Brightness step should also turn the light on or off": "Крок яскравості також повинен вмикати або вимикати світло"
27
+ "Brightness step should also turn the light on or off": "Крок яскравості також повинен вмикати або вимикати світло",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "Такі події, як «Пристрій видалено» або «Вимкнено», відображаються в описі, а не в назві."
28
29
  }
@@ -24,5 +24,6 @@
24
24
  "Other configurations": "其他配置",
25
25
  "Proxy Zigbee2MQTT logs to ioBroker logs": "代理 Zigbee2MQTT 日志到 ioBroker 日志",
26
26
  "Brightness move should also turn the light on or off": "亮度移动也应该打开或关闭灯",
27
- "Brightness step should also turn the light on or off": "亮度步骤也应该打开或关闭灯"
27
+ "Brightness step should also turn the light on or off": "亮度步骤也应该打开或关闭灯",
28
+ "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.": "“设备已移除”或“已禁用”等事件显示在描述中而不是名称中。"
28
29
  }
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "connectionType": {
12
12
  "label": "Select connection to Zigbee2MQTT",
13
- "sm": 4,
13
+ "sm": 5,
14
14
  "type": "select",
15
15
  "options": [
16
16
  {
@@ -60,7 +60,7 @@
60
60
  "type": "password",
61
61
  "label": "Auth-Token (special characters are not supported)",
62
62
  "newLine": true,
63
- "lg": 2,
63
+ "lg": 5,
64
64
  "hidden": "data.wsTokenEnabled != true || data.connectionType != 'ws'"
65
65
  },
66
66
  "dummyMqtt": {
@@ -171,6 +171,11 @@
171
171
  "type": "checkbox",
172
172
  "label": "Proxy Zigbee2MQTT logs to ioBroker logs",
173
173
  "newLine": true
174
+ },
175
+ "useEventInDesc": {
176
+ "type": "checkbox",
177
+ "label": "The events such as 'Device removed' or 'Disabled' are displayed in the description instead of in the name.",
178
+ "newLine": true
174
179
  }
175
180
  }
176
181
  }
package/io-package.json CHANGED
@@ -1,8 +1,34 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "zigbee2mqtt",
4
- "version": "2.7.0",
4
+ "version": "2.7.2",
5
5
  "news": {
6
+ "2.7.2": {
7
+ "en": "rework of the detection of removed devices",
8
+ "de": "nacharbeiten der erkennung von entfernten geräten",
9
+ "ru": "переработка обнаружения удаленных устройств",
10
+ "pt": "retrabalho da detecção de dispositivos removidos",
11
+ "nl": "_",
12
+ "fr": "retravail de la détection des dispositifs enlevés",
13
+ "it": "rielaborazione del rilevamento dei dispositivi rimossi",
14
+ "es": "rework of the detection of removed devices",
15
+ "pl": "przepraszanie detekcji usuniętych urządzeń",
16
+ "uk": "реконструкція виявлення видалених пристроїв",
17
+ "zh-cn": "清除装置的探查工作"
18
+ },
19
+ "2.7.1": {
20
+ "en": "added option for use folder description\nuse the iobroker device folder description for device description or events",
21
+ "de": "zusatzoption für die ordnerbeschreibung\ndie beschreibung des iobroker geräteordners für gerätebeschreibung oder ereignisse",
22
+ "ru": "добавлена опция для использования описания папки\nиспользуйте описание папки iobroker для описания устройства или событий",
23
+ "pt": "opção adicionada para a descrição da pasta de uso\nuse a descrição da pasta do dispositivo iobroker para descrição do dispositivo ou eventos",
24
+ "nl": "voegde de optie toe voor gebruik van de beschrijving\ngebruik de beschrijving van het iobroker apparaat voor beschrijving of gebeurtenissen",
25
+ "fr": "option ajoutée pour la description du dossier d'utilisation\nutiliser la description du dossier de périphérique iobroker pour la description de périphérique ou les événements",
26
+ "it": "opzione aggiunta per l'uso descrizione della cartella\nutilizzare la descrizione della cartella del dispositivo iobroker per la descrizione o gli eventi del dispositivo",
27
+ "es": "opción adicional para la descripción de la carpeta de uso\nutilizar la descripción de la carpeta del dispositivo iobroker para la descripción del dispositivo o eventos",
28
+ "pl": "dodać opcję do opisu folder\nużywanie iobrokerowego opisu danych dla opisu urządzenia lub zdarzeń",
29
+ "uk": "доданий варіант для опису папок\nвикористовувати опис папки іоброкера для опису пристрою або подій",
30
+ "zh-cn": "增加使用时说明的选择\n对装置说明或事件使用零散器装置的描述"
31
+ },
6
32
  "2.7.0": {
7
33
  "en": "added support for wildcard actions (eg. *_single) ([#116](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/116))\nadded error handling optimizations ([more](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1382038679))\nadded option `auth_token` for websocket connection ([#112](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/112))\nwebsocket timeout increased",
8
34
  "de": "unterstützung für Wildcard-Aktionen (z.B. *_single) [#116](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/116)\nfehlerbehandlungsoptimierungen [mehr](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1382038679)\nzusatzoption auth_token für Websocket-Verbindung [#112](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/112)\nwebsocket timeout erhöht",
@@ -67,32 +93,6 @@
67
93
  "pl": "zobacz też: #79 (https:/github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/79)",
68
94
  "uk": "[79] (https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/79)",
69
95
  "zh-cn": "更好的国家辨认(http://github.com/oshojo0o/ioBroker.zigbee2mqt/issues/79)"
70
- },
71
- "2.4.3": {
72
- "en": "fix availability when `friendly_name` `/` contains",
73
- "de": "verfügbarkeit korrigieren bei friendly_name `/` enthält",
74
- "ru": "исправить доступность когда friendly_name `/` содержит",
75
- "pt": "corrigir disponibilidade quando friendly_name `/` contém",
76
- "nl": "_ _",
77
- "fr": "fixer la disponibilité lorsque friendly_name `/` contient",
78
- "it": "fissare la disponibilità quando amichevole_name `/` contiene",
79
- "es": "fijar disponibilidad cuando friendly_name `/` contiene",
80
- "pl": "ustanowić dostęp do przyjaznej nazwy. zawierać",
81
- "uk": "застосувати доступність при дружній_ім`я `/` в наявності",
82
- "zh-cn": "f 在友好的情况下,可提供“/”一词 内载"
83
- },
84
- "2.4.2": {
85
- "en": "added correct handling of `move_to_saturation`, `hue_move` and `brightness_move_to_level` ([#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/68))\nfix when `friendly_name` `/` contains",
86
- "de": "die korrekte Handhabung von move_to_saturation, hue_move und bright_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/68)\nbei freundlich_name `/` enthält",
87
- "ru": "добавлена правильная обработка move_to_saturation, hue_move и brightness_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/68)\nисправить, когда friendly_name `/` содержит",
88
- "pt": "adicionado manuseio correto de move_to_saturation, hue_move e brilho_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/68)\ncorrigir quando friendly_name `/` contém",
89
- "nl": "voegde de juiste behandeling van verplaatsing, huemove and brightnessmovetolevel 68) (httub /0shojoo-0-Bio-Broctrotqusts)\nvertaling: _",
90
- "fr": "ajouté correct handling of move_to_saturation, hue_move and brightness_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/68)\nfixer lorsque friendly_name `/` contient",
91
- "it": "aggiunto corretta gestione di move_to_saturation, hue_move e luminosità_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/68)\nfissare quando amichevole_name `/` contiene",
92
- "es": "añadido correcto manejo de move_to_saturation, hue_move and brightness_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/68)\narreglar cuando friendly_name `/ contiene",
93
- "pl": "(Prawdziwa obsługa ruchu_to_saturation, hue_move and brightness_move_to_level #68(https:/github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/68)\nustanowić się, gdy przyjaźnić nazwisko/'. zawierać",
94
- "uk": "додано правильну обробку рухом_to_saturation, hue_move_move_to_level [#68](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/68)\nфіксація при дружній_ім`я `/` в наявності",
95
- "zh-cn": "进一步正确地处理搬迁问题:流向、障碍和光明_move_to_级[#68](http://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/68)\nfix 友好时的名称:“/” 内载"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -143,6 +143,7 @@
143
143
  "mode": "daemon",
144
144
  "type": "hardware",
145
145
  "compact": true,
146
+ "stopTimeout": 2000,
146
147
  "connectionType": "local",
147
148
  "dataSource": "push",
148
149
  "adminUI": {
@@ -199,7 +200,8 @@
199
200
  "useKelvin": false,
200
201
  "colorTempSyncColor": false,
201
202
  "brightnessMoveOnOff": false,
202
- "brightnessStepOnOff": false
203
+ "brightnessStepOnOff": false,
204
+ "useEventInDesc": true
203
205
  },
204
206
  "objects": [],
205
207
  "instanceObjects": [
@@ -198,51 +198,67 @@ class DeviceController {
198
198
  this.groupCache.push(newDevice);
199
199
  }
200
200
 
201
- async createGroupDefinitions(exposes) {
201
+ async createGroupDefinitions(groupsMessage) {
202
202
  utils.clearArray(this.groupCache);
203
- for (const expose of exposes) {
204
- await this.defineGroupDevice(expose.friendly_name, `group_${expose.id}`, expose.scenes);
203
+ for (const groupMessage of groupsMessage) {
204
+ if (this.logCustomizations.debugDevices.includes(groupMessage.id)) {
205
+ this.adapter.log.warn(`--->>> fromZ2M -> ${groupMessage.id} exposes: ${JSON.stringify(groupMessage)}`);
206
+ }
207
+ await this.defineGroupDevice(groupMessage.friendly_name, `group_${groupMessage.id}`, groupMessage.scenes);
205
208
  }
206
209
  }
207
210
 
208
211
  async createOrUpdateDevices() {
209
212
  for (const device of this.groupCache.concat(this.deviceCache)) {
210
- let deviceName = device.id == device.ieee_address ? '' : device.id;
213
+ let deviceName = await this.getDeviceName(device);
214
+ let description = await this.getDeviceDescription(device);
211
215
 
212
216
  if (deviceName == '' && device.description) {
213
217
  deviceName = device.description;
218
+ description = '';
214
219
  }
215
220
 
216
221
  // Manipulate deviceName if the device is disabled, so the update of the device is triggered as well
217
222
  if (device.disabled && device.disabled == true) {
218
- deviceName = `[Disabled] ${deviceName}`;
223
+ if (this.config.useEventInDesc == true) {
224
+ description = 'Device is disabled!';
225
+ }
226
+ else {
227
+ deviceName = `[Disabled] ${deviceName}`;
228
+ }
229
+
219
230
  }
220
231
 
221
- if (!this.createCache[device.ieee_address] || this.createCache[device.ieee_address].name != deviceName) {
232
+ if (!this.createCache[device.ieee_address] || this.createCache[device.ieee_address].name != deviceName || this.createCache[device.ieee_address].description != description) {
222
233
  const deviceObj = {
223
234
  type: 'device',
224
235
  common: {
225
236
  name: deviceName,
237
+ desc: description,
238
+ statusStates: { onlineId: '' }
226
239
  },
227
-
228
- native: {}
240
+ native: {
241
+ deviceRemoved: false,
242
+ groupDevice: false
243
+ }
229
244
  };
230
245
 
231
- // Only the onlineId is set if the device is not disabled and is not a group
232
- if (!device.ieee_address.includes('group_') && (!device.disabled || device.disabled == false)) {
233
- deviceObj.common.statusStates = {
234
- onlineId: `${this.adapter.name}.${this.adapter.instance}.${device.ieee_address}.available`
235
- };
246
+ // Group Device
247
+ if (device.ieee_address.includes('group_')) {
248
+ deviceObj.native.groupDevice = true;
249
+ }
250
+ // Disabled Device
251
+ else if (device.disabled || device.disabled == true) {
252
+ // Placeholder for possible later logic
236
253
  }
254
+ // Only the onlineId is set if the device is not disabled and is not a group
237
255
  else {
238
- deviceObj.common.statusStates = {
239
- onlineId: ''
240
- };
256
+ deviceObj.common.statusStates.onlineId = `${this.adapter.name}.${this.adapter.instance}.${device.ieee_address}.available`;
241
257
  }
242
258
 
243
259
  //@ts-ignore
244
260
  await this.adapter.extendObjectAsync(device.ieee_address, deviceObj);
245
- this.createCache[device.ieee_address] = { name: deviceName };
261
+ this.createCache[device.ieee_address] = { name: deviceName, description: description };
246
262
  }
247
263
 
248
264
  // Here it is checked whether the scenes match the current data from z2m.
@@ -278,24 +294,41 @@ class DeviceController {
278
294
  }
279
295
  }
280
296
 
281
- processRemoveEvent(messageObj) {
282
- let ieee_address = undefined;
283
- if (messageObj.payload && messageObj.payload.type == 'device_leave') {
284
- ieee_address = messageObj.payload.data.ieee_address;
285
- }
297
+ async checkAndProgressDeviceRemove() {
298
+ let description = '';
299
+ let deviceName = '';
300
+ let iobDevices = await this.adapter.getDevicesAsync();
301
+ // Do not consider devices already marked as "deviceRemoved"
302
+ iobDevices = iobDevices.filter(x => x.native.deviceRemoved == false);
303
+ // Do not consider groups
304
+ iobDevices = iobDevices.filter(x => x.native.groupDevice == false);
286
305
 
287
- //{"data":{"block":false,"force":true,"id":"0xa4c138c954baaf54"},"status":"ok","transaction":"zhvjf-5"}
288
- if (messageObj.payload && messageObj.payload.data) {
289
- const device = this.deviceCache.find(x => x.id == messageObj.payload.data.id);
290
- if (device) {
291
- ieee_address = device.ieee_address;
292
- }
293
- }
306
+ for (const iobDevice of iobDevices) {
307
+ const ieee_address = iobDevice._id.split('.')[2];
308
+ //Check whether the devices found from the object tree are also available in the DeviceCache
309
+ if (!this.deviceCache.find(x => x.ieee_address == ieee_address)) {
310
+ deviceName = iobDevice.common.name;
294
311
 
295
- if (ieee_address != undefined) {
296
- this.adapter.setState(`${ieee_address}.available`, false, true);
297
- this.adapter.extendObject(`${ieee_address}`, { common: { name: 'Device removed!', } });
298
- delete this.createCache[ieee_address];
312
+ if (this.config.useEventInDesc == true) {
313
+ description = 'Device was removed!';
314
+ }
315
+ else {
316
+ deviceName = `[Removed] ${deviceName}`;
317
+ }
318
+
319
+ this.adapter.extendObject(`${ieee_address}`, {
320
+ common: {
321
+ name: deviceName,
322
+ desc: description
323
+ },
324
+ native: {
325
+ deviceRemoved: true
326
+ }
327
+ });
328
+ this.adapter.setStateChangedAsync(`${ieee_address}.available`, false, true);
329
+
330
+ delete this.createCache[ieee_address];
331
+ }
299
332
  }
300
333
  }
301
334
 
@@ -326,6 +359,14 @@ class DeviceController {
326
359
  }
327
360
  return iobState;
328
361
  }
362
+
363
+ getDeviceName(device) {
364
+ return device.id == device.ieee_address ? '' : device.id;
365
+ }
366
+
367
+ getDeviceDescription(device) {
368
+ return device.description ? device.description : '';
369
+ }
329
370
  }
330
371
 
331
372
  module.exports = {
@@ -133,12 +133,17 @@ class StatesController {
133
133
  }
134
134
 
135
135
  async setAllAvailableToFalse() {
136
- for (const device of this.deviceCache) {
137
- for (const state of device.states) {
138
- if (state.id == 'available') {
139
- await this.adapter.setStateChangedAsync(`${device.ieee_address}.${state.id}`, false, true);
140
- }
141
- }
136
+ // for (const device of this.deviceCache) {
137
+ // for (const state of device.states) {
138
+ // if (state.id == 'available') {
139
+ // await this.adapter.setStateChangedAsync(`${device.ieee_address}.${state.id}`, false, true);
140
+ // }
141
+ // }
142
+ // }
143
+
144
+ const availableStates = await this.adapter.getStatesAsync('*.available');
145
+ for (const availableState in availableStates) {
146
+ await this.adapter.setStateChangedAsync(availableState, false, true);
142
147
  }
143
148
  }
144
149
 
package/main.js CHANGED
@@ -153,6 +153,7 @@ class Zigbee2mqtt extends core.Adapter {
153
153
  case 'bridge/devices':
154
154
  await deviceController.createDeviceDefinitions(messageObj.payload);
155
155
  await deviceController.createOrUpdateDevices();
156
+ await deviceController.checkAndProgressDeviceRemove();
156
157
  await statesController.subscribeWritableStates();
157
158
  statesController.processQueue();
158
159
  break;
@@ -163,13 +164,13 @@ class Zigbee2mqtt extends core.Adapter {
163
164
  statesController.processQueue();
164
165
  break;
165
166
  case 'bridge/event':
166
- deviceController.processRemoveEvent(messageObj);
167
167
  break;
168
168
  case 'bridge/response/device/remove':
169
- deviceController.processRemoveEvent(messageObj);
170
169
  break;
171
170
  case 'bridge/response/device/options':
172
171
  break;
172
+ case 'bridge/response/permit_join':
173
+ break;
173
174
  case 'bridge/extensions':
174
175
  break;
175
176
  case 'bridge/logging':
@@ -177,6 +178,8 @@ class Zigbee2mqtt extends core.Adapter {
177
178
  z2mController.proxyZ2MLogs(messageObj);
178
179
  }
179
180
  break;
181
+ case 'bridge/response/device/configure':
182
+ break;
180
183
  case 'bridge/response/device/rename':
181
184
  await deviceController.renameDeviceInCache(messageObj);
182
185
  await deviceController.createOrUpdateDevices();
@@ -210,7 +213,6 @@ class Zigbee2mqtt extends core.Adapter {
210
213
  }
211
214
  // States
212
215
  } else {
213
- //console.log(JSON.stringify(messageObj));
214
216
  statesController.processDeviceMessage(messageObj);
215
217
  }
216
218
  }
@@ -219,33 +221,45 @@ class Zigbee2mqtt extends core.Adapter {
219
221
  }
220
222
 
221
223
  async onUnload(callback) {
222
- try {
224
+ // Close MQTT connections
225
+ if (['exmqtt', 'intmqtt'].includes(this.config.connectionType)) {
223
226
  if (mqttClient && !mqttClient.closed) {
224
- mqttClient.close();
227
+ try {
228
+ mqttClient.close();
229
+ } catch (e) {
230
+ this.log.error(e);
231
+ }
225
232
  }
226
- websocketController.closeConnection();
227
- } catch (e) {
228
- this.log.error(e);
229
233
  }
230
-
231
- try {
232
- mqttServerController.closeServer();
233
- } catch (e) {
234
- this.log.error(e);
234
+ // Internal or Dummy MQTT-Server
235
+ if (this.config.connectionType == 'intmqtt' || this.config.dummyMqtt == true) {
236
+ try {
237
+ mqttServerController.closeServer();
238
+ } catch (e) {
239
+ this.log.error(e);
240
+ }
235
241
  }
236
-
242
+ // Websocket
243
+ else if (this.config.connectionType == 'ws') {
244
+ try {
245
+ websocketController.closeConnection();
246
+ } catch (e) {
247
+ this.log.error(e);
248
+ }
249
+ }
250
+ // Set all device available states of false
237
251
  try {
238
252
  await statesController.setAllAvailableToFalse();
239
253
  } catch (e) {
240
254
  this.log.error(e);
241
255
  }
242
-
256
+ // Clear all websocket timers
243
257
  try {
244
258
  await websocketController.allTimerClear();
245
259
  } catch (e) {
246
260
  this.log.error(e);
247
261
  }
248
-
262
+ // Clear all state timers
249
263
  try {
250
264
  await statesController.allTimerClear();
251
265
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee2mqtt",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "description": "Zigbee2MQTT adapter for ioBroker",
5
5
  "author": {
6
6
  "name": "Dennis Rathjen",
@@ -42,7 +42,7 @@
42
42
  "@types/sinon-chai": "^3.2.9",
43
43
  "chai": "^4.3.7",
44
44
  "chai-as-promised": "^7.1.1",
45
- "eslint": "^8.31.0",
45
+ "eslint": "^8.33.0",
46
46
  "eslint-config-prettier": "^8.6.0",
47
47
  "eslint-plugin-prettier": "^4.2.1",
48
48
  "mocha": "^10.2.0",