iobroker.zigbee2mqtt 3.0.9 → 3.0.13
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/LICENSE +1 -1
- package/README.md +20 -245
- package/io-package.json +54 -55
- package/lib/check.js +6 -0
- package/lib/colors.js +26 -6
- package/lib/deviceController.js +69 -17
- package/lib/exposes.js +123 -157
- package/lib/imageController.js +52 -3
- package/lib/messages.js +10 -0
- package/lib/mqttServerController.js +21 -5
- package/lib/nonGenericDevicesExtension.js +6 -2
- package/lib/rgb.js +81 -27
- package/lib/statesController.js +62 -11
- package/lib/utils.js +54 -7
- package/lib/websocketController.js +29 -0
- package/lib/z2mController.js +19 -0
- package/main.js +8 -10
- package/package.json +16 -31
package/lib/deviceController.js
CHANGED
|
@@ -5,7 +5,19 @@ const colors = require('./colors.js');
|
|
|
5
5
|
const rgb = require('./rgb.js');
|
|
6
6
|
const ImageController = require('./imageController').ImageController;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
8
11
|
class DeviceController {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param adapter
|
|
15
|
+
* @param deviceCache
|
|
16
|
+
* @param groupCache
|
|
17
|
+
* @param config
|
|
18
|
+
* @param logCustomizations
|
|
19
|
+
* @param createCache
|
|
20
|
+
*/
|
|
9
21
|
constructor(adapter, deviceCache, groupCache, config, logCustomizations, createCache) {
|
|
10
22
|
this.adapter = adapter;
|
|
11
23
|
this.groupCache = groupCache;
|
|
@@ -16,6 +28,10 @@ class DeviceController {
|
|
|
16
28
|
this.imageController = new ImageController(adapter);
|
|
17
29
|
}
|
|
18
30
|
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param devicesMessage
|
|
34
|
+
*/
|
|
19
35
|
async createDeviceDefinitions(devicesMessage) {
|
|
20
36
|
utils.clearArray(this.deviceCache);
|
|
21
37
|
for (const devicesMessag of devicesMessage) {
|
|
@@ -44,6 +60,12 @@ class DeviceController {
|
|
|
44
60
|
}
|
|
45
61
|
}
|
|
46
62
|
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param groupID
|
|
66
|
+
* @param ieee_address
|
|
67
|
+
* @param scenes
|
|
68
|
+
*/
|
|
47
69
|
async defineGroupDevice(groupID, ieee_address, scenes) {
|
|
48
70
|
const brmPropName =
|
|
49
71
|
this.adapter.config.brightnessMoveOnOff == true ? 'brightness_move_onoff' : 'brightness_move';
|
|
@@ -126,14 +148,14 @@ class DeviceController {
|
|
|
126
148
|
if (payload.color && payload.color.x && payload.color.y) {
|
|
127
149
|
const colorval = rgb.cie_to_rgb(payload.color.x, payload.color.y);
|
|
128
150
|
return (
|
|
129
|
-
|
|
130
|
-
utils.decimalToHex(colorval[0])
|
|
131
|
-
utils.decimalToHex(colorval[1])
|
|
132
|
-
utils.decimalToHex(colorval[2])
|
|
151
|
+
`#${
|
|
152
|
+
utils.decimalToHex(colorval[0])
|
|
153
|
+
}${utils.decimalToHex(colorval[1])
|
|
154
|
+
}${utils.decimalToHex(colorval[2])}`
|
|
133
155
|
);
|
|
134
|
-
}
|
|
156
|
+
}
|
|
135
157
|
return undefined;
|
|
136
|
-
|
|
158
|
+
|
|
137
159
|
},
|
|
138
160
|
},
|
|
139
161
|
{
|
|
@@ -159,9 +181,9 @@ class DeviceController {
|
|
|
159
181
|
}
|
|
160
182
|
if (this.config.useKelvin == true) {
|
|
161
183
|
return utils.miredKelvinConversion(payload.color_temp);
|
|
162
|
-
}
|
|
184
|
+
}
|
|
163
185
|
return payload.color_temp;
|
|
164
|
-
|
|
186
|
+
|
|
165
187
|
},
|
|
166
188
|
},
|
|
167
189
|
{
|
|
@@ -213,7 +235,7 @@ class DeviceController {
|
|
|
213
235
|
type: 'boolean',
|
|
214
236
|
setter: (value) => (value ? scene.id : undefined),
|
|
215
237
|
};
|
|
216
|
-
|
|
238
|
+
|
|
217
239
|
newDevice.states.push(sceneSate);
|
|
218
240
|
}
|
|
219
241
|
|
|
@@ -222,6 +244,10 @@ class DeviceController {
|
|
|
222
244
|
this.groupCache.push(newDevice);
|
|
223
245
|
}
|
|
224
246
|
|
|
247
|
+
/**
|
|
248
|
+
*
|
|
249
|
+
* @param groupsMessage
|
|
250
|
+
*/
|
|
225
251
|
async createGroupDefinitions(groupsMessage) {
|
|
226
252
|
utils.clearArray(this.groupCache);
|
|
227
253
|
for (const groupMessage of groupsMessage) {
|
|
@@ -232,6 +258,9 @@ class DeviceController {
|
|
|
232
258
|
}
|
|
233
259
|
}
|
|
234
260
|
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
235
264
|
async createOrUpdateDevices() {
|
|
236
265
|
for (const device of this.groupCache.concat(this.deviceCache)) {
|
|
237
266
|
let deviceName = await this.getDeviceName(device);
|
|
@@ -270,17 +299,12 @@ class DeviceController {
|
|
|
270
299
|
if (device.ieee_address.includes('group_')) {
|
|
271
300
|
deviceObj.native.groupDevice = true;
|
|
272
301
|
deviceObj.common.statusStates.onlineId = `${this.adapter.name}.${this.adapter.instance}.${device.ieee_address}.available`;
|
|
273
|
-
}
|
|
274
|
-
// Disabled Device
|
|
275
|
-
else if (device.disabled || device.disabled == true) {
|
|
302
|
+
} else if (device.disabled || device.disabled == true) { // // Disabled Device
|
|
276
303
|
// Placeholder for possible later logic
|
|
277
|
-
}
|
|
278
|
-
// Only the onlineId is set if the device is not disabled
|
|
279
|
-
else {
|
|
304
|
+
} else { // Only the onlineId is set if the device is not disabled
|
|
280
305
|
deviceObj.common.statusStates.onlineId = `${this.adapter.name}.${this.adapter.instance}.${device.ieee_address}.available`;
|
|
281
306
|
}
|
|
282
|
-
|
|
283
|
-
//@ts-ignore
|
|
307
|
+
|
|
284
308
|
await this.adapter.extendObjectAsync(device.ieee_address, deviceObj);
|
|
285
309
|
this.createCache[device.ieee_address] = { name: deviceName, description: description };
|
|
286
310
|
}
|
|
@@ -313,6 +337,10 @@ class DeviceController {
|
|
|
313
337
|
}
|
|
314
338
|
}
|
|
315
339
|
|
|
340
|
+
/**
|
|
341
|
+
*
|
|
342
|
+
* @param messageObj
|
|
343
|
+
*/
|
|
316
344
|
async renameDeviceInCache(messageObj) {
|
|
317
345
|
const renamedDevice = this.groupCache
|
|
318
346
|
.concat(this.deviceCache)
|
|
@@ -322,6 +350,9 @@ class DeviceController {
|
|
|
322
350
|
}
|
|
323
351
|
}
|
|
324
352
|
|
|
353
|
+
/**
|
|
354
|
+
*
|
|
355
|
+
*/
|
|
325
356
|
async checkAndProgressDeviceRemove() {
|
|
326
357
|
let description = '';
|
|
327
358
|
let deviceName = '';
|
|
@@ -359,6 +390,11 @@ class DeviceController {
|
|
|
359
390
|
}
|
|
360
391
|
}
|
|
361
392
|
|
|
393
|
+
/**
|
|
394
|
+
*
|
|
395
|
+
* @param devices
|
|
396
|
+
* @param ieee_address
|
|
397
|
+
*/
|
|
362
398
|
removeDeviceByIeee(devices, ieee_address) {
|
|
363
399
|
const idx = devices.findIndex((x) => x.ieee_address == ieee_address);
|
|
364
400
|
if (idx > -1) {
|
|
@@ -366,6 +402,10 @@ class DeviceController {
|
|
|
366
402
|
}
|
|
367
403
|
}
|
|
368
404
|
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* @param state
|
|
408
|
+
*/
|
|
369
409
|
async copyAndCleanStateObj(state) {
|
|
370
410
|
const iobState = { ...state };
|
|
371
411
|
const blacklistedKeys = [
|
|
@@ -387,14 +427,26 @@ class DeviceController {
|
|
|
387
427
|
return iobState;
|
|
388
428
|
}
|
|
389
429
|
|
|
430
|
+
/**
|
|
431
|
+
*
|
|
432
|
+
* @param device
|
|
433
|
+
*/
|
|
390
434
|
getDeviceName(device) {
|
|
391
435
|
return device.id == device.ieee_address ? '' : device.id;
|
|
392
436
|
}
|
|
393
437
|
|
|
438
|
+
/**
|
|
439
|
+
*
|
|
440
|
+
* @param device
|
|
441
|
+
*/
|
|
394
442
|
getDeviceDescription(device) {
|
|
395
443
|
return device.description ? device.description : '';
|
|
396
444
|
}
|
|
397
445
|
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
* @param payload
|
|
449
|
+
*/
|
|
398
450
|
processCoordinatorCheck(payload) {
|
|
399
451
|
if (payload && payload.data && payload.data.missing_routers) {
|
|
400
452
|
const missingRoutersCount = payload.data.missing_routers.length;
|