iobroker.zigbee2mqtt 2.9.0 → 2.10.0
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 +7 -0
- package/admin/i18n/de/translations.json +6 -2
- package/admin/i18n/en/translations.json +4 -1
- package/admin/i18n/es/translations.json +5 -1
- package/admin/i18n/fr/translations.json +5 -1
- package/admin/i18n/it/translations.json +5 -1
- package/admin/i18n/nl/translations.json +5 -1
- package/admin/i18n/pl/translations.json +5 -1
- package/admin/i18n/pt/translations.json +5 -1
- package/admin/i18n/ru/translations.json +5 -1
- package/admin/i18n/uk/translations.json +5 -1
- package/admin/i18n/zh-cn/translations.json +5 -1
- package/admin/jsonConfig.json +18 -0
- package/io-package.json +67 -14
- package/lib/check.js +15 -2
- package/lib/exposes.js +17 -15
- package/lib/messages.js +1 -0
- package/lib/states.js +140 -6
- package/lib/utils.js +17 -0
- package/main.js +26 -3
- package/package.json +9 -9
package/lib/utils.js
CHANGED
|
@@ -118,6 +118,21 @@ function moveArray(source, target) {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
function isObject(item) {
|
|
122
|
+
return (typeof item === 'object' && !Array.isArray(item) && item !== null);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isJson(item) {
|
|
126
|
+
let value = typeof item !== 'string' ? JSON.stringify(item) : item;
|
|
127
|
+
try {
|
|
128
|
+
value = JSON.parse(value);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return typeof value === 'object' && value !== null;
|
|
134
|
+
}
|
|
135
|
+
|
|
121
136
|
module.exports = {
|
|
122
137
|
bulbLevelToAdapterLevel,
|
|
123
138
|
adapterLevelToBulbLevel,
|
|
@@ -130,4 +145,6 @@ module.exports = {
|
|
|
130
145
|
getDeviceIcon,
|
|
131
146
|
clearArray,
|
|
132
147
|
moveArray,
|
|
148
|
+
isObject,
|
|
149
|
+
isJson,
|
|
133
150
|
};
|
package/main.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* Created with @iobroker/create-adapter v2.2.1
|
|
5
4
|
*/
|
|
@@ -8,6 +7,7 @@
|
|
|
8
7
|
// you need to create an adapter
|
|
9
8
|
const core = require('@iobroker/adapter-core');
|
|
10
9
|
const mqtt = require('mqtt');
|
|
10
|
+
const utils = require('./lib/utils');
|
|
11
11
|
const checkConfig = require('./lib/check').checkConfig;
|
|
12
12
|
const adapterInfo = require('./lib/messages').adapterInfo;
|
|
13
13
|
const zigbee2mqttInfo = require('./lib/messages').zigbee2mqttInfo;
|
|
@@ -72,8 +72,18 @@ class Zigbee2mqtt extends core.Adapter {
|
|
|
72
72
|
this.log.warn('Please configure the External MQTT-Server connection!');
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
|
-
mqttClient = mqtt.connect(`mqtt://${this.config.externalMqttServerIP}:${this.config.externalMqttServerPort}`, { clientId: `ioBroker.zigbee2mqtt_${Math.random().toString(16).slice(2, 8)}`, clean: true, reconnectPeriod: 500 });
|
|
76
75
|
|
|
76
|
+
// MQTT connection settings
|
|
77
|
+
const mqttClientOptions = { clientId: `ioBroker.zigbee2mqtt_${Math.random().toString(16).slice(2, 8)}`, clean: true, reconnectPeriod: 500 };
|
|
78
|
+
|
|
79
|
+
// Set external mqtt credentials
|
|
80
|
+
if (this.config.externalMqttServerCredentials == true) {
|
|
81
|
+
mqttClientOptions.username = this.config.externalMqttServerUsername;
|
|
82
|
+
mqttClientOptions.password = this.config.externalMqttServerPassword;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Init connection
|
|
86
|
+
mqttClient = mqtt.connect(`mqtt://${this.config.externalMqttServerIP}:${this.config.externalMqttServerPort}`, mqttClientOptions);
|
|
77
87
|
}
|
|
78
88
|
// Internal MQTT-Server
|
|
79
89
|
else {
|
|
@@ -132,8 +142,12 @@ class Zigbee2mqtt extends core.Adapter {
|
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
async messageParse(message) {
|
|
145
|
+
// If the MQTT output type is set to attribute_and_json, the non-valid JSON must be checked here.
|
|
146
|
+
if (utils.isJson(message) == false) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
135
150
|
const messageObj = JSON.parse(message);
|
|
136
|
-
//this.log.debug(JSON.stringify(messageObj));
|
|
137
151
|
|
|
138
152
|
switch (messageObj.topic) {
|
|
139
153
|
case 'bridge/config':
|
|
@@ -214,6 +228,15 @@ class Zigbee2mqtt extends core.Adapter {
|
|
|
214
228
|
}
|
|
215
229
|
// States
|
|
216
230
|
} else {
|
|
231
|
+
// With the MQTT output type attribute_and_json, primitive payloads arrive here that must be discarded.
|
|
232
|
+
if (utils.isObject(messageObj.payload) == false) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// If MQTT is used, I have to filter the self-sent 'set' commands.
|
|
236
|
+
if (messageObj.topic.endsWith('/set')) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
217
240
|
statesController.processDeviceMessage(messageObj);
|
|
218
241
|
}
|
|
219
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.zigbee2mqtt",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Zigbee2MQTT adapter for ioBroker",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Dennis Rathjen",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"url": "https://github.com/o0shojo0o/ioBroker.zigbee2mqtt.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@iobroker/adapter-core": "^
|
|
23
|
-
"aedes": "^0.
|
|
22
|
+
"@iobroker/adapter-core": "^3.0.3",
|
|
23
|
+
"aedes": "^0.50.0",
|
|
24
24
|
"aedes-persistence-nedb": "^2.0.3",
|
|
25
|
-
"mqtt": "^
|
|
25
|
+
"mqtt": "^5.0.2",
|
|
26
26
|
"net": "^1.0.2",
|
|
27
27
|
"ws": "^8.13.0"
|
|
28
28
|
},
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"@types/chai": "^4.3.5",
|
|
38
38
|
"@types/chai-as-promised": "^7.1.5",
|
|
39
39
|
"@types/mocha": "^10.0.1",
|
|
40
|
-
"@types/node": "^20.4.
|
|
40
|
+
"@types/node": "^20.4.8",
|
|
41
41
|
"@types/proxyquire": "^1.3.28",
|
|
42
|
-
"@types/sinon": "^10.0.
|
|
42
|
+
"@types/sinon": "^10.0.16",
|
|
43
43
|
"@types/sinon-chai": "^3.2.9",
|
|
44
44
|
"chai": "^4.3.7",
|
|
45
45
|
"chai-as-promised": "^7.1.1",
|
|
46
|
-
"eslint": "^8.
|
|
47
|
-
"eslint-config-prettier": "^
|
|
46
|
+
"eslint": "^8.46.0",
|
|
47
|
+
"eslint-config-prettier": "^9.0.0",
|
|
48
48
|
"eslint-plugin-prettier": "^5.0.0",
|
|
49
49
|
"mocha": "^10.2.0",
|
|
50
|
-
"prettier": "^3.0.
|
|
50
|
+
"prettier": "^3.0.1",
|
|
51
51
|
"proxyquire": "^2.1.3",
|
|
52
52
|
"sinon": "^15.2.0",
|
|
53
53
|
"sinon-chai": "^3.7.0",
|