matterbridge-zigbee2mqtt 2.3.0 → 2.3.1-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/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
@@ -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,15 @@
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
1
  import { BridgedDeviceBasicInformation, DoorLock, DoorLockCluster, 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';
26
4
  import path from 'path';
27
- import { ZigbeeDevice, ZigbeeGroup /* , BridgedBaseDevice*/ } from './entity.js';
5
+ import { ZigbeeDevice, ZigbeeGroup } from './entity.js';
28
6
  import { Zigbee2MQTT } from './zigbee2mqtt.js';
29
7
  export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
30
- // extension
31
8
  publishCallBack = undefined;
32
9
  permitJoinCallBack = undefined;
33
- // platform
34
10
  bridgedDevices = [];
35
11
  zigbeeEntities = [];
36
12
  injectTimer;
37
- // z2m
38
13
  mqttHost = 'localhost';
39
14
  mqttPort = 1883;
40
15
  mqttTopic = 'zigbee2mqtt';
@@ -49,7 +24,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
49
24
  featureBlackList = [];
50
25
  deviceFeatureBlackList = {};
51
26
  postfixHostname = true;
52
- // zigbee2Mqtt
53
27
  debugEnabled;
54
28
  shouldStart;
55
29
  shouldConfigure;
@@ -64,11 +38,9 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
64
38
  availabilityTimer;
65
39
  constructor(matterbridge, log, config) {
66
40
  super(matterbridge, log, config);
67
- // Verify that Matterbridge is the correct version
68
- if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.6.5')) {
69
- throw new Error(`This plugin requires Matterbridge version >= "1.6.5". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`);
41
+ if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.6.6')) {
42
+ throw new Error(`This plugin requires Matterbridge version >= "1.6.6". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`);
70
43
  }
71
- // this.log.debug(`Config:')}${rs}`, config);
72
44
  this.debugEnabled = config.debug;
73
45
  this.shouldStart = false;
74
46
  this.shouldConfigure = false;
@@ -99,7 +71,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
99
71
  if (config.deviceFeatureBlackList)
100
72
  this.deviceFeatureBlackList = config.deviceFeatureBlackList;
101
73
  this.postfixHostname = config.postfixHostname ?? true;
102
- // Save back to create a default plugin config.json
103
74
  config.host = this.mqttHost;
104
75
  config.port = this.mqttPort;
105
76
  config.protocolVersion = this.mqttProtocol;
@@ -117,7 +88,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
117
88
  }
118
89
  this.log.info(`Initializing platform: ${CYAN}${this.config.name}${nf} version: ${CYAN}${this.config.version}${rs}`);
119
90
  this.log.info(`Loaded zigbee2mqtt parameters from ${CYAN}${path.join(matterbridge.matterbridgeDirectory, 'matterbridge-zigbee2mqtt.config.json')}${rs}`);
120
- // this.log.debug(`Config:')}${rs}`, config);
121
91
  this.z2m = new Zigbee2MQTT(this.mqttHost, this.mqttPort, this.mqttTopic, this.mqttUsername, this.mqttPassword, this.mqttProtocol, this.debugEnabled);
122
92
  this.z2m.setLogDebug(this.debugEnabled);
123
93
  this.z2m.setDataPath(path.join(matterbridge.matterbridgePluginDirectory, 'matterbridge-zigbee2mqtt'));
@@ -147,13 +117,11 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
147
117
  this.z2m.on('online', () => {
148
118
  this.log.info('zigbee2MQTT is online');
149
119
  this.z2mBridgeOnline = true;
150
- // TODO check single availability
151
120
  this.updateAvailability(true);
152
121
  });
153
122
  this.z2m.on('offline', () => {
154
123
  this.log.warn('zigbee2MQTT is offline');
155
124
  this.z2mBridgeOnline = false;
156
- // TODO check single availability
157
125
  this.updateAvailability(false);
158
126
  });
159
127
  this.z2m.on('bridge-info', async (bridgeInfo) => {
@@ -230,7 +198,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
230
198
  this.log.info(`zigbee2MQTT sent permit_join device: ${device} time: ${time} status: ${status}`);
231
199
  for (const zigbeeEntity of this.zigbeeEntities) {
232
200
  if (zigbeeEntity.isRouter && (device === undefined || device === zigbeeEntity.bridgedDevice?.deviceName)) {
233
- // Coordinator or dedicated routers
234
201
  this.log.info(`*- ${zigbeeEntity.bridgedDevice?.deviceName} ${zigbeeEntity.bridgedDevice?.number} (${zigbeeEntity.bridgedDevice?.name})`);
235
202
  if (zigbeeEntity.device && status) {
236
203
  zigbeeEntity.bridgedDevice?.setAttribute(DoorLockCluster.id, 'lockState', DoorLock.LockState.Unlocked, this.log);
@@ -247,11 +214,9 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
247
214
  });
248
215
  this.z2m.on('device_joined', async (friendly_name, ieee_address) => {
249
216
  this.log.info(`zigbee2MQTT sent device_joined device: ${friendly_name} ieee_address: ${ieee_address}`);
250
- // Here nothing to do, we wait eventually device_interview
251
217
  });
252
218
  this.z2m.on('device_announce', async (friendly_name, ieee_address) => {
253
219
  this.log.info(`zigbee2MQTT sent device_announce device: ${friendly_name} ieee_address: ${ieee_address}`);
254
- // Here nothing to do, we wait device_interview
255
220
  });
256
221
  this.z2m.on('device_leave', async (friendly_name, ieee_address) => {
257
222
  this.log.info(`zigbee2MQTT sent device_leave device: ${friendly_name} ieee_address: ${ieee_address}`);
@@ -408,22 +373,15 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
408
373
  if (this.availabilityTimer)
409
374
  clearInterval(this.availabilityTimer);
410
375
  this.availabilityTimer = undefined;
411
- // this.updateAvailability(false);
412
376
  if (this.config.unregisterOnShutdown === true)
413
377
  await this.unregisterAllDevices();
414
378
  this.z2m.stop();
415
379
  this.publishCallBack = undefined;
416
380
  this.log.info(`Shutdown zigbee2mqtt dynamic platform v${this.version}`);
417
381
  }
418
- /**
419
- * @deprecated
420
- */
421
382
  setPublishCallBack(onPublish) {
422
383
  this.publishCallBack = onPublish;
423
384
  }
424
- /**
425
- * @deprecated
426
- */
427
385
  setPermitJoinCallBack(onPermitJoin) {
428
386
  this.permitJoinCallBack = onPermitJoin;
429
387
  }
@@ -439,9 +397,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
439
397
  this.log.info(`MQTT publish topic: ${CYAN}${this.z2m.mqttTopic + '/' + topic + (subTopic === '' ? '' : '/' + subTopic)}${nf} payload: ${CYAN}${message}${nf}`);
440
398
  }
441
399
  }
442
- /**
443
- * @deprecated
444
- */
445
400
  emit(eventName, data) {
446
401
  this.z2m.emit(eventName, data);
447
402
  }
@@ -519,7 +474,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
519
474
  matterGroup = await ZigbeeGroup.create(this, group);
520
475
  if (matterGroup.bridgedDevice) {
521
476
  await this.registerDevice(matterGroup.bridgedDevice);
522
- // console.error('Plugin:', matterGroup.bridgedDevice.plugin);
523
477
  this.bridgedDevices.push(matterGroup.bridgedDevice);
524
478
  this.zigbeeEntities.push(matterGroup);
525
479
  this.log.debug(`Registered group ${gn}${group.friendly_name}${db} ID: ${zb}${group.id}${db}`);
@@ -552,4 +506,3 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
552
506
  }
553
507
  }
554
508
  }
555
- //# sourceMappingURL=platform.js.map