iobroker.zigbee2mqtt 2.4.0 → 2.4.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/README.md CHANGED
@@ -30,6 +30,10 @@ This adapter allows to control the data points of the devices of a Zigbee2MQTT i
30
30
  Placeholder for the next version (at the beginning of the line):
31
31
  ### **WORK IN PROGRESS**
32
32
  -->
33
+ ### 2.4.1 (2022-11-16)
34
+
35
+ - (o0shojo0o) fix based on [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)
36
+
33
37
  ### 2.4.0 (2022-11-08)
34
38
 
35
39
  - (o0shojo0o) fix for devices with multiple endpoints ([#57](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/57)).
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "zigbee2mqtt",
4
- "version": "2.4.0",
4
+ "version": "2.4.1",
5
5
  "news": {
6
+ "2.4.1": {
7
+ "en": "fix based on [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
8
+ "de": "(https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
9
+ "ru": "исправить на [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
10
+ "pt": "correção com base em [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#comment-1316656378)",
11
+ "nl": "quality over Quantity Releases Vertaling:",
12
+ "fr": "fix based on [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
13
+ "it": "fix based on [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
14
+ "es": "fijado basado en [review](https://github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656378)",
15
+ "pl": "recenzent oparty na przeglądzie (https:/github.com/ioBroker/ioBroker.repositories/pull/1976#issuecomment-1316656363636378)",
16
+ "uk": "javaScript licenses API Веб-сайт Go1.13.8",
17
+ "zh-cn": "fix 基于[审查](http://github.com/ioBroker/ioBroker.reories/pull/1976#issuement-1316656378)"
18
+ },
6
19
  "2.4.0": {
7
20
  "en": "fix for devices with multiple endpoints ([#57](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/57)).\nadded option `Brightness move should also turn the light on or off`\nadded state toggle for groups \nmore dynamic during data point creation ([#48](https://github.com/o0shojo0o/ioBroker.zigbee2mqtt/issues/48)).",
8
21
  "de": "fix für Geräte mit mehreren Endpunkten [#57](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/57).\nzusätzliche Option `Brightness move sollte auch das Licht ein- oder ausschalten `\nzusatzzustandswinkel für gruppen\nmehr Dynamik bei der Erstellung von Datenpunkten [#48](https://github.com/o0shojo0o/ioBroker.zigbee2mqt/issues/48).",
@@ -80,19 +93,6 @@
80
93
  "pl": "dodano możliwość synchronizacji kolorowej synchronizacji z kolorami\nnaprawić filtry i debugDevices\nwiele błędów\nteraz ustalono odpowiednie min/max w kolorowym tempie\nlepsza obsługa błędów dla połączeń powiązań",
81
94
  "uk": "додано варіант синхронізації кольору з кольором\nвиправити logfilter і debugDevices\nбагато помилок\nтепер встановлюємо правильний хв/макс за кольором\nкраща обробка помилок для підключення",
82
95
  "zh-cn": "添加了用颜色的气温合办法\nfix 木图和溶剂\n批发\n现将正确的分钟/升值确定为色色彩。\na. 处理联系的错误"
83
- },
84
- "2.0.0": {
85
- "en": "*!!!BREAKING CHANGE!!!**\n\nadded configurable connection to Zigbee2MQTT (Settings must be renewed)\nWebsocket\nExternal MQTT-Server\nInternal MQTT-Server\noptimized state writing performance in ioBroker\nfixed the correct set of the connection status",
86
- "de": "*! BREAKING CHANGE*\n\nzusätzliche konfigurierbare Verbindung zu Zigbee2MQTT (Einstellungen müssen erneuert werden)\nWebsocket\nExterner MQTT-Server\nInterner MQTT-Server\noptimierte Zustandsschreibleistung in ioBroker\nden korrekten satz des verbindungsstatus festlegt",
87
- "ru": "*! ИЗМЕНЕНИЕ ЗАВТРА*\n\nдобавлена настраиваемая связь с Zigbee2MQTT (Настройки должны быть обновлены)\nWebsocket\nВнешний MQTT-Server\nВнутренний MQTT-Server\nоптимизированное представление государственной записи в ioBroker\nисправил правильный набор состояния соединения",
88
- "pt": "*! QUE GRANDE MUDANÇA\n\nconexão configurável adicionada ao Zigbee2MQTT (As inscrições devem ser renovadas)\nWebsocket\nMQTT externo-Server\nMQTT interno-Server\ndesempenho de escrita de estado otimizado no ioBroker\nfixou o conjunto correto do status da conexão",
89
- "nl": "♪ \n\nvoegde connectie toe aan Zigbee2MQT (Settings moet vernieuwd)\nWebsocket\nExterne MQTT-Server\nInterne MQTT-Server\noptimaal staatsschrijving in ioBroker\nde correcte set van de connectie status",
90
- "fr": "*! CHANGE DE BREAKING*\n\nconnexion configurable ajoutée à Zigbee2MQTT (Les paramètres doivent être renouvelés)\nWebsocket\nMQTT-Serveur externe\nInterne MQTT-Serveur\nperformance d'écriture d'état optimisée en ioBroker\nfixe l'ensemble correct du statut de connexion",
91
- "it": "# CAMBIAMENTO\n\naggiunta di connessione configurabile a Zigbee2MQTT (I posti devono essere rinnovati)\nWebsocket\nMQTT-Server esterno\nInterno MQTT-Server\nprestazioni di scrittura dello stato ottimizzate in ioBroker\nfisso l'insieme corretto dello stato di connessione",
92
- "es": "*! ¡CAMBIANDO\n\nconexión configurable agregada a Zigbee2MQTT (Se debe renovar la configuración)\nWebsocket\nMQTT externo-Server\nInterno MQTT-Server\nrendimiento de escritura de estado optimizado en ioBroker\nfija el conjunto correcto del estado de conexión",
93
- "pl": "! BREAKING CHANGE! (ANG.)\n\nzigbee2MQTT dodano połączenie konfigurowalne. (Odrodzenie się)\nStrona internetowa\nOficjalna strona MQTT-Server\nOficjalna strona MQTT\nzoptymalizowany stan pisania w ioBrokerze\nustalono poprawny zbiór statusu związku",
94
- "uk": "* БРЕАКІНГ ЧАНГ*\n\nдодано налаштування підключення до Zigbee2MQTT (Налаштування повинні бути відновлені)\nВеб-сайт\nЗовнішній MQTT-Server\nВнутрішній MQTT-Server\nоптимізоване державне письмо продуктивність в ioBroker\nвиправлено правильний набір статусу підключення",
95
- "zh-cn": "页:1 BREAKREANGE*\n\n兹格贝雷2 MQTT的可图联系 (必须重启)\n网站\n外贸总协定\n内贸总协定\n最佳国家书面表现\na. 固定的联络点地位"
96
96
  }
97
97
  },
98
98
  "titleLang": {
@@ -235,7 +235,7 @@ class DeviceController {
235
235
  }
236
236
 
237
237
  if (ieee_address != undefined) {
238
- this.adapter.setStateAsync(`${ieee_address}.available`, false, true);
238
+ this.adapter.setState(`${ieee_address}.available`, false, true);
239
239
  this.adapter.extendObject(`${ieee_address}`, { common: { name: 'Device removed!', } });
240
240
  delete this.createCache[ieee_address];
241
241
  }
@@ -1,7 +1,7 @@
1
1
  const core = require('@iobroker/adapter-core');
2
2
  const Aedes = require('aedes');
3
3
  const net = require('net');
4
-
4
+ let mqttServer;
5
5
 
6
6
  class MqttServerController {
7
7
  constructor(adapter) {
@@ -14,7 +14,7 @@ class MqttServerController {
14
14
  const db = new NedbPersistence({ path: `${core.getAbsoluteInstanceDataDir(this.adapter)}/mqttData`, prefix: '' });
15
15
  // @ts-ignore
16
16
  const aedes = Aedes({ persistence: db });
17
- const mqttServer = net.createServer(aedes.handle);
17
+ mqttServer = net.createServer(aedes.handle);
18
18
  mqttServer.listen(this.adapter.config.mqttServerPort, this.adapter.config.mqttServerIPBind, () => {
19
19
  this.adapter.log.info(`Statring MQTT-Server on IP ${this.adapter.config.mqttServerIPBind} and Port ${this.adapter.config.mqttServerPort}`);
20
20
  });
@@ -27,7 +27,7 @@ class MqttServerController {
27
27
  try {
28
28
  // @ts-ignore
29
29
  const aedes = Aedes();
30
- const mqttServer = net.createServer(aedes.handle);
30
+ mqttServer = net.createServer(aedes.handle);
31
31
  mqttServer.listen(this.adapter.config.mqttServerPort, this.adapter.config.mqttServerIPBind, () => {
32
32
  this.adapter.log.info(`Statring DummyMQTT-Server on IP ${this.adapter.config.mqttServerIPBind} and Port ${this.adapter.config.mqttServerPort}`);
33
33
  });
@@ -35,6 +35,12 @@ class MqttServerController {
35
35
  this.adapter.log.error(err);
36
36
  }
37
37
  }
38
+
39
+ closeServer() {
40
+ if (mqttServer && !mqttServer.closed()) {
41
+ mqttServer.close();
42
+ }
43
+ }
38
44
  }
39
45
 
40
46
  module.exports = {
@@ -140,12 +140,12 @@ class StatesController {
140
140
  for (const device of this.groupCache.concat(this.deviceCache)) {
141
141
  for (const state of device.states) {
142
142
  if (state.write == true) {
143
- this.adapter.subscribeStatesAsync(`${device.ieee_address}.${state.id}`);
143
+ this.adapter.subscribeStates(`${device.ieee_address}.${state.id}`);
144
144
  }
145
145
  }
146
146
  }
147
- this.adapter.subscribeStatesAsync('info.debugmessages');
148
- this.adapter.subscribeStatesAsync('info.logfilter');
147
+ this.adapter.subscribeStates('info.debugmessages');
148
+ this.adapter.subscribeStates('info.logfilter');
149
149
  }
150
150
 
151
151
  async setAllAvailableToFalse() {
@@ -72,6 +72,12 @@ class WebsocketController {
72
72
  }, restartTimeout);
73
73
  }
74
74
 
75
+ closeConnection() {
76
+ if (wsClient && wsClient.readyState !== WebSocket.CLOSED) {
77
+ wsClient.close();
78
+ }
79
+ }
80
+
75
81
  async allTimerClear() {
76
82
  clearTimeout(pingTimeout);
77
83
  clearTimeout(ping);
package/main.js CHANGED
@@ -52,7 +52,7 @@ class Zigbee2mqtt extends core.Adapter {
52
52
  // Initialize your adapter here
53
53
  adapterInfo(this.config, this.log);
54
54
 
55
- this.setStateAsync('info.connection', false, true);
55
+ this.setState('info.connection', false, true);
56
56
 
57
57
  const debugDevicesState = await this.getStateAsync('info.debugmessages');
58
58
  if (debugDevicesState && debugDevicesState.val) {
@@ -126,7 +126,7 @@ class Zigbee2mqtt extends core.Adapter {
126
126
  });
127
127
 
128
128
  wsClient.on('close', async () => {
129
- this.setStateChangedAsync('info.connection', false, true);
129
+ this.setStateChanged('info.connection', false, true);
130
130
  await statesController.setAllAvailableToFalse();
131
131
  this.log.warn('Websocket disconnected');
132
132
  });
@@ -149,7 +149,7 @@ class Zigbee2mqtt extends core.Adapter {
149
149
  if (messageObj.payload.state != 'online') {
150
150
  statesController.setAllAvailableToFalse();
151
151
  }
152
- this.setStateChangedAsync('info.connection', messageObj.payload.state == 'online', true);
152
+ this.setStateChanged('info.connection', messageObj.payload.state == 'online', true);
153
153
  break;
154
154
  case 'bridge/devices':
155
155
  await deviceController.createDeviceDefinitions(messageObj.payload);
@@ -220,6 +220,11 @@ class Zigbee2mqtt extends core.Adapter {
220
220
 
221
221
  async onUnload(callback) {
222
222
  try {
223
+ if (mqttClient && !mqttClient.closed) {
224
+ mqttClient.close();
225
+ }
226
+ mqttServerController.closeServer();
227
+ websocketController.closeConnection();
223
228
  await statesController.setAllAvailableToFalse();
224
229
  await websocketController.allTimerClear();
225
230
  await statesController.allTimerClear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.zigbee2mqtt",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Zigbee2MQTT adapter for ioBroker",
5
5
  "author": {
6
6
  "name": "Dennis Rathjen",
@@ -24,7 +24,7 @@
24
24
  "aedes-persistence-nedb": "^2.0.3",
25
25
  "mqtt": "^4.3.7",
26
26
  "net": "^1.0.2",
27
- "ws": "^8.10.0"
27
+ "ws": "^8.11.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@alcalzone/release-script-plugin-iobroker": "^3.5.9",
@@ -33,22 +33,22 @@
33
33
  "@iobroker/adapter-dev": "^1.2.0",
34
34
  "@iobroker/testing": "^4.1.0",
35
35
  "@tsconfig/node14": "^1.0.3",
36
- "@types/chai": "^4.3.3",
36
+ "@types/chai": "^4.3.4",
37
37
  "@types/chai-as-promised": "^7.1.5",
38
38
  "@types/mocha": "^10.0.0",
39
39
  "@types/node": "^18.11.9",
40
40
  "@types/proxyquire": "^1.3.28",
41
41
  "@types/sinon": "^10.0.13",
42
- "@types/sinon-chai": "^3.2.8",
43
- "chai": "^4.3.6",
42
+ "@types/sinon-chai": "^3.2.9",
43
+ "chai": "^4.3.7",
44
44
  "chai-as-promised": "^7.1.1",
45
- "eslint": "^8.26.0",
45
+ "eslint": "^8.27.0",
46
46
  "eslint-config-prettier": "^8.5.0",
47
47
  "eslint-plugin-prettier": "^4.2.1",
48
48
  "mocha": "^10.1.0",
49
49
  "prettier": "^2.7.1",
50
50
  "proxyquire": "^2.1.3",
51
- "sinon": "^14.0.1",
51
+ "sinon": "^14.0.2",
52
52
  "sinon-chai": "^3.7.0",
53
53
  "typescript": "~4.8.4"
54
54
  },