matterbridge-zigbee2mqtt 2.4.3 → 2.4.4-dev.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/CHANGELOG.md +11 -0
- package/dist/entity.js +124 -373
- package/dist/index.js +0 -35
- package/dist/payloadTypes.js +0 -23
- package/dist/platform.js +11 -56
- package/dist/zigbee2mqtt.js +22 -272
- package/dist/zigbee2mqttTypes.js +0 -23
- package/npm-shrinkwrap.json +47 -17
- package/package.json +1 -2
- package/dist/entity.d.ts +0 -492
- package/dist/entity.d.ts.map +0 -1
- package/dist/entity.js.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/payloadTypes.d.ts +0 -25
- package/dist/payloadTypes.d.ts.map +0 -1
- package/dist/payloadTypes.js.map +0 -1
- package/dist/platform.d.ts +0 -85
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js.map +0 -1
- package/dist/zigbee2mqtt.d.ts +0 -182
- package/dist/zigbee2mqtt.d.ts.map +0 -1
- package/dist/zigbee2mqtt.js.map +0 -1
- package/dist/zigbee2mqttTypes.d.ts +0 -350
- package/dist/zigbee2mqttTypes.d.ts.map +0 -1
- package/dist/zigbee2mqttTypes.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,40 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the entry point of Matterbridge.
|
|
3
|
-
*
|
|
4
|
-
* @file index.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2023-12-29
|
|
7
|
-
* @version 2.0.3
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2023, 2024 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
1
|
import { ZigbeePlatform } from './platform.js';
|
|
24
2
|
export * from './entity.js';
|
|
25
|
-
/**
|
|
26
|
-
* This is the standard interface for Matterbridge plugins.
|
|
27
|
-
* Each plugin should export a default function that follows this signature.
|
|
28
|
-
* Each plugin should return the platform.
|
|
29
|
-
*
|
|
30
|
-
* Initializes the Zigbee2mqtt plugin.
|
|
31
|
-
*
|
|
32
|
-
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
33
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
34
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
35
|
-
* @returns {ZigbeePlatform} The initialized Zigbee platform.
|
|
36
|
-
*/
|
|
37
3
|
export default function initializePlugin(matterbridge, log, config) {
|
|
38
4
|
return new ZigbeePlatform(matterbridge, log, config);
|
|
39
5
|
}
|
|
40
|
-
//# sourceMappingURL=index.js.map
|
package/dist/payloadTypes.js
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the types for Payload.
|
|
3
|
-
*
|
|
4
|
-
* @file payloadTypes.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2023-12-29
|
|
7
|
-
* @version 1.0.1
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2023, 2024 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
1
|
export {};
|
|
24
|
-
//# sourceMappingURL=payloadTypes.js.map
|
package/dist/platform.js
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* This file contains the class ZigbeePlatform.
|
|
3
|
-
*
|
|
4
|
-
* @file platform.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2023-12-29
|
|
7
|
-
* @version 2.2.2
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2023, 2024, 2025 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
|
-
import { BridgedDeviceBasicInformation, DoorLock, DoorLockCluster, MatterbridgeDynamicPlatform } from 'matterbridge';
|
|
1
|
+
import { MatterbridgeDynamicPlatform } from 'matterbridge';
|
|
24
2
|
import { dn, gn, db, wr, zb, payloadStringify, rs, debugStringify, CYAN, er, nf } from 'matterbridge/logger';
|
|
25
3
|
import { isValidNumber, isValidString, waiter } from 'matterbridge/utils';
|
|
4
|
+
import { BridgedDeviceBasicInformation, DoorLock } from 'matterbridge/matter/clusters';
|
|
26
5
|
import path from 'path';
|
|
27
|
-
import { ZigbeeDevice, ZigbeeGroup
|
|
6
|
+
import { ZigbeeDevice, ZigbeeGroup } from './entity.js';
|
|
28
7
|
import { Zigbee2MQTT } from './zigbee2mqtt.js';
|
|
29
8
|
export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
30
|
-
// extension
|
|
31
9
|
publishCallBack = undefined;
|
|
32
10
|
permitJoinCallBack = undefined;
|
|
33
|
-
// platform
|
|
34
11
|
bridgedDevices = [];
|
|
35
12
|
zigbeeEntities = [];
|
|
36
13
|
injectTimer;
|
|
37
|
-
// z2m
|
|
38
14
|
mqttHost = 'localhost';
|
|
39
15
|
mqttPort = 1883;
|
|
40
16
|
mqttTopic = 'zigbee2mqtt';
|
|
@@ -47,7 +23,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
47
23
|
featureBlackList = [];
|
|
48
24
|
deviceFeatureBlackList = {};
|
|
49
25
|
postfixHostname = true;
|
|
50
|
-
// zigbee2Mqtt
|
|
51
26
|
debugEnabled;
|
|
52
27
|
shouldStart;
|
|
53
28
|
shouldConfigure;
|
|
@@ -62,11 +37,9 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
62
37
|
availabilityTimer;
|
|
63
38
|
constructor(matterbridge, log, config) {
|
|
64
39
|
super(matterbridge, log, config);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
throw new Error(`This plugin requires Matterbridge version >= "1.7.3". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`);
|
|
40
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('2.1.0')) {
|
|
41
|
+
throw new Error(`This plugin requires Matterbridge version >= "2.1.0". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`);
|
|
68
42
|
}
|
|
69
|
-
// this.log.debug(`Config:')}${rs}`, config);
|
|
70
43
|
this.debugEnabled = config.debug;
|
|
71
44
|
this.shouldStart = false;
|
|
72
45
|
this.shouldConfigure = false;
|
|
@@ -93,7 +66,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
93
66
|
if (config.deviceFeatureBlackList)
|
|
94
67
|
this.deviceFeatureBlackList = config.deviceFeatureBlackList;
|
|
95
68
|
this.postfixHostname = config.postfixHostname ?? true;
|
|
96
|
-
// Save back to create a default plugin config.json
|
|
97
69
|
config.host = this.mqttHost;
|
|
98
70
|
config.port = this.mqttPort;
|
|
99
71
|
config.protocolVersion = this.mqttProtocol;
|
|
@@ -109,7 +81,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
109
81
|
}
|
|
110
82
|
this.log.info(`Initializing platform: ${CYAN}${this.config.name}${nf} version: ${CYAN}${this.config.version}${rs}`);
|
|
111
83
|
this.log.info(`Loaded zigbee2mqtt parameters from ${CYAN}${path.join(matterbridge.matterbridgeDirectory, 'matterbridge-zigbee2mqtt.config.json')}${rs}`);
|
|
112
|
-
// this.log.debug(`Config:')}${rs}`, config);
|
|
113
84
|
this.z2m = new Zigbee2MQTT(this.mqttHost, this.mqttPort, this.mqttTopic, this.mqttUsername, this.mqttPassword, this.mqttProtocol, this.debugEnabled);
|
|
114
85
|
this.z2m.setLogDebug(this.debugEnabled);
|
|
115
86
|
this.z2m.setDataPath(path.join(matterbridge.matterbridgePluginDirectory, 'matterbridge-zigbee2mqtt'));
|
|
@@ -139,13 +110,11 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
139
110
|
this.z2m.on('online', () => {
|
|
140
111
|
this.log.info('zigbee2MQTT is online');
|
|
141
112
|
this.z2mBridgeOnline = true;
|
|
142
|
-
// TODO check single availability
|
|
143
113
|
this.updateAvailability(true);
|
|
144
114
|
});
|
|
145
115
|
this.z2m.on('offline', () => {
|
|
146
116
|
this.log.warn('zigbee2MQTT is offline');
|
|
147
117
|
this.z2mBridgeOnline = false;
|
|
148
|
-
// TODO check single availability
|
|
149
118
|
this.updateAvailability(false);
|
|
150
119
|
});
|
|
151
120
|
this.z2m.on('bridge-info', async (bridgeInfo) => {
|
|
@@ -222,15 +191,14 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
222
191
|
this.log.info(`zigbee2MQTT sent permit_join device: ${device} time: ${time} status: ${status}`);
|
|
223
192
|
for (const zigbeeEntity of this.zigbeeEntities) {
|
|
224
193
|
if (zigbeeEntity.isRouter && (device === undefined || device === zigbeeEntity.bridgedDevice?.deviceName)) {
|
|
225
|
-
// Coordinator or dedicated routers
|
|
226
194
|
this.log.info(`*- ${zigbeeEntity.bridgedDevice?.deviceName} ${zigbeeEntity.bridgedDevice?.number} (${zigbeeEntity.bridgedDevice?.name})`);
|
|
227
195
|
if (zigbeeEntity.device && status) {
|
|
228
|
-
zigbeeEntity.bridgedDevice?.setAttribute(
|
|
196
|
+
zigbeeEntity.bridgedDevice?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Unlocked, this.log);
|
|
229
197
|
zigbeeEntity.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Unlock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
|
|
230
198
|
this.log.info(`Device ${zigbeeEntity.entityName} unlocked`);
|
|
231
199
|
}
|
|
232
200
|
if (zigbeeEntity.device && !status) {
|
|
233
|
-
zigbeeEntity.bridgedDevice?.setAttribute(
|
|
201
|
+
zigbeeEntity.bridgedDevice?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked, this.log);
|
|
234
202
|
zigbeeEntity.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Lock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
|
|
235
203
|
this.log.info(`Device ${zigbeeEntity.entityName} locked`);
|
|
236
204
|
}
|
|
@@ -239,11 +207,9 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
239
207
|
});
|
|
240
208
|
this.z2m.on('device_joined', async (friendly_name, ieee_address) => {
|
|
241
209
|
this.log.info(`zigbee2MQTT sent device_joined device: ${friendly_name} ieee_address: ${ieee_address}`);
|
|
242
|
-
// Here nothing to do, we wait eventually device_interview
|
|
243
210
|
});
|
|
244
211
|
this.z2m.on('device_announce', async (friendly_name, ieee_address) => {
|
|
245
212
|
this.log.info(`zigbee2MQTT sent device_announce device: ${friendly_name} ieee_address: ${ieee_address}`);
|
|
246
|
-
// Here nothing to do, we wait device_interview
|
|
247
213
|
});
|
|
248
214
|
this.z2m.on('device_leave', async (friendly_name, ieee_address) => {
|
|
249
215
|
this.log.info(`zigbee2MQTT sent device_leave device: ${friendly_name} ieee_address: ${ieee_address}`);
|
|
@@ -360,14 +326,14 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
360
326
|
if (bridgedEntity.isRouter && bridgedEntity.bridgedDevice) {
|
|
361
327
|
this.log.info(`Configuring router ${bridgedEntity.bridgedDevice?.deviceName}.`);
|
|
362
328
|
if (this.z2mBridgeInfo?.permit_join) {
|
|
363
|
-
bridgedEntity.bridgedDevice?.setAttribute(
|
|
329
|
+
bridgedEntity.bridgedDevice?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Unlocked, this.log);
|
|
364
330
|
if (bridgedEntity.bridgedDevice.number)
|
|
365
|
-
bridgedEntity.bridgedDevice?.triggerEvent(
|
|
331
|
+
bridgedEntity.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Unlock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
|
|
366
332
|
}
|
|
367
333
|
else {
|
|
368
|
-
bridgedEntity.bridgedDevice?.setAttribute(
|
|
334
|
+
bridgedEntity.bridgedDevice?.setAttribute(DoorLock.Cluster.id, 'lockState', DoorLock.LockState.Locked, this.log);
|
|
369
335
|
if (bridgedEntity.bridgedDevice.number)
|
|
370
|
-
bridgedEntity.bridgedDevice?.triggerEvent(
|
|
336
|
+
bridgedEntity.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Lock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
|
|
371
337
|
}
|
|
372
338
|
}
|
|
373
339
|
}
|
|
@@ -402,22 +368,15 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
402
368
|
if (this.availabilityTimer)
|
|
403
369
|
clearInterval(this.availabilityTimer);
|
|
404
370
|
this.availabilityTimer = undefined;
|
|
405
|
-
// this.updateAvailability(false);
|
|
406
371
|
if (this.config.unregisterOnShutdown === true)
|
|
407
372
|
await this.unregisterAllDevices();
|
|
408
373
|
this.z2m.stop();
|
|
409
374
|
this.publishCallBack = undefined;
|
|
410
375
|
this.log.info(`Shutdown zigbee2mqtt dynamic platform v${this.version}`);
|
|
411
376
|
}
|
|
412
|
-
/**
|
|
413
|
-
* @deprecated
|
|
414
|
-
*/
|
|
415
377
|
setPublishCallBack(onPublish) {
|
|
416
378
|
this.publishCallBack = onPublish;
|
|
417
379
|
}
|
|
418
|
-
/**
|
|
419
|
-
* @deprecated
|
|
420
|
-
*/
|
|
421
380
|
setPermitJoinCallBack(onPermitJoin) {
|
|
422
381
|
this.permitJoinCallBack = onPermitJoin;
|
|
423
382
|
}
|
|
@@ -433,9 +392,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
433
392
|
this.log.info(`MQTT publish topic: ${CYAN}${this.z2m.mqttTopic + '/' + topic + (subTopic === '' ? '' : '/' + subTopic)}${nf} payload: ${CYAN}${message}${nf}`);
|
|
434
393
|
}
|
|
435
394
|
}
|
|
436
|
-
/**
|
|
437
|
-
* @deprecated
|
|
438
|
-
*/
|
|
439
395
|
emit(eventName, data) {
|
|
440
396
|
this.z2m.emit(eventName, data);
|
|
441
397
|
}
|
|
@@ -538,4 +494,3 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
|
|
|
538
494
|
}
|
|
539
495
|
}
|
|
540
496
|
}
|
|
541
|
-
//# sourceMappingURL=platform.js.map
|