diff --git a/CHANGELOG.md b/CHANGELOG.md
index 619392d..a0c5df1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
+## [2.1.2] - 2024-06-21
+
+### Added
+
+- [dependencies]: Update dependencies.
+- [start]: Refactor start sequence.
+
+
+
+
+
## [2.1.1] - 2024-06-20
### Added
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..a77fd88
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+@Luligu
\ No newline at end of file
diff --git a/matterbridge-zigbee2mqtt.schema.json b/matterbridge-zigbee2mqtt.schema.json
index c736af3..bb972f3 100644
--- a/matterbridge-zigbee2mqtt.schema.json
+++ b/matterbridge-zigbee2mqtt.schema.json
@@ -2,7 +2,11 @@
"title": "Matterbridge zigbee2mqtt plugin",
"description": "matterbridge-zigbee2mqtt v. 2.0.17 by https://github.com/Luligu",
"type": "object",
- "required": ["host", "port", "topic"],
+ "required": [
+ "host",
+ "port",
+ "topic"
+ ],
"properties": {
"name": {
"description": "Plugin name",
@@ -88,11 +92,13 @@
},
"debug": {
"description": "Enable the debug for the plugin (development only)",
- "type": "boolean"
+ "type": "boolean",
+ "default": false
},
"unregisterOnShutdown": {
"description": "Unregister all devices on shutdown (development only)",
- "type": "boolean"
+ "type": "boolean",
+ "default": false
}
}
-}
+}
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 25c3a43..687ec7d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "matterbridge-zigbee2mqtt",
- "version": "2.1.0",
+ "version": "2.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "matterbridge-zigbee2mqtt",
- "version": "2.1.0",
+ "version": "2.1.1",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
@@ -18,7 +18,7 @@
"@eslint/js": "^9.5.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.12",
- "@types/node": "^20.14.6",
+ "@types/node": "^20.14.7",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-prettier": "^5.1.3",
@@ -26,7 +26,7 @@
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.5",
- "typescript": "^5.4.5",
+ "typescript": "^5.5.2",
"typescript-eslint": "^7.13.1"
},
"engines": {
@@ -1617,9 +1617,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
- "version": "20.14.6",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.6.tgz",
- "integrity": "sha512-JbA0XIJPL1IiNnU7PFxDXyfAwcwVVrOoqyzzyQTyMeVhBzkJVMSkC1LlVsRQ2lpqiY4n6Bb9oCS6lzDKVQxbZw==",
+ "version": "20.14.7",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.7.tgz",
+ "integrity": "sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==",
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
@@ -5796,9 +5796,9 @@
"license": "MIT"
},
"node_modules/typescript": {
- "version": "5.4.5",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz",
- "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==",
+ "version": "5.5.2",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz",
+ "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==",
"dev": true,
"license": "Apache-2.0",
"bin": {
diff --git a/package.json b/package.json
index 28da2d5..eb67d02 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "matterbridge-zigbee2mqtt",
- "version": "2.1.1",
+ "version": "2.1.2",
"description": "Matterbridge zigbee2mqtt plugin",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
@@ -92,7 +92,7 @@
"@eslint/js": "^9.5.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.12",
- "@types/node": "^20.14.6",
+ "@types/node": "^20.14.7",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-prettier": "^5.1.3",
@@ -100,7 +100,7 @@
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.5",
- "typescript": "^5.4.5",
+ "typescript": "^5.5.2",
"typescript-eslint": "^7.13.1"
}
}
\ No newline at end of file
diff --git a/src/platform.ts b/src/platform.ts
index 0b66978..7cd22c3 100644
--- a/src/platform.ts
+++ b/src/platform.ts
@@ -22,7 +22,7 @@
*/
import { BridgedDeviceBasicInformationCluster, DoorLock, DoorLockCluster, Matterbridge, MatterbridgeDevice, MatterbridgeDynamicPlatform, PlatformConfig, waiter } from 'matterbridge';
-import { AnsiLogger, dn, gn, db, wr, zb, payloadStringify, rs, debugStringify } from 'node-ansi-logger';
+import { AnsiLogger, dn, gn, db, wr, zb, payloadStringify, rs, debugStringify, CYAN } from 'node-ansi-logger';
import { ZigbeeDevice, ZigbeeEntity, ZigbeeGroup, BridgedBaseDevice } from './entity.js';
import { Zigbee2MQTT } from './zigbee2mqtt.js';
@@ -73,7 +73,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
constructor(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig) {
super(matterbridge, log, config);
- this.debugEnabled = matterbridge.debugEnabled;
+ this.debugEnabled = config.debug as boolean;
this.shouldStart = false;
this.shouldConfigure = false;
@@ -104,6 +104,8 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
this.log.debug('Created ZigbeePlatform as Matterbridge extension');
return;
}
+
+ this.log.info(`Initializing platform: ${this.config.name}${rs} v${CYAN}${this.version}`);
this.log.info(`Loaded zigbee2mqtt parameters from ${path.join(matterbridge.matterbridgeDirectory, 'matterbridge-zigbee2mqtt.config.json')}${rs}:`);
// this.log.debug(`Config:')}${rs}`, config);
@@ -272,6 +274,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
this.z2mDevicesRegistered = true;
}
}
+
if (this.shouldConfigure) {
this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`);
for (const bridgedEntity of this.zigbeeEntities) {
@@ -286,6 +289,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
this.z2m.on('bridge-groups', async (groups: BridgeGroup[]) => {
this.log.info(`zigbee2MQTT sent ${groups.length} groups ${this.z2mGroupsRegistered ? 'already registered' : ''}`);
this.z2mBridgeGroups = groups;
+
if (this.shouldStart) {
if (!this.z2mGroupsRegistered && this.z2mBridgeGroups) {
for (const group of this.z2mBridgeGroups) {
@@ -294,6 +298,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
this.z2mGroupsRegistered = true;
}
}
+
if (this.shouldConfigure) {
this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`);
for (const bridgedEntity of this.zigbeeEntities) {
@@ -318,14 +323,16 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
const hasDevices = await waiter('z2mBridgeDevices & z2mBridgeGroups', () => this.z2mBridgeDevices !== undefined || this.z2mBridgeGroups !== undefined);
if (!hasOnline || !hasInfo || !hasDevices) {
- this.log.error('Exiting due to missing zigbee2mqtt bridge state or info or devices/groups. Check if zigbee2mqtt is running and connected to the MQTT broker.');
+ this.log.error('The plugin did not receive zigbee2mqtt bridge state or info or devices/groups. Check if zigbee2mqtt is running and connected to the MQTT broker.');
return;
}
+ /*
if (!this.z2mDevicesRegistered || !this.z2mGroupsRegistered) {
this.shouldStart = true;
this.log.debug('Setting flag to start when zigbee2mqtt sends devices: ', reason);
}
+ */
if (!this.z2mDevicesRegistered && this.z2mBridgeDevices) {
this.log.info(`Registering ${this.z2mBridgeDevices.length} devices`);
@@ -347,10 +354,12 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
}
override async onConfigure() {
+ /*
if (!this.z2mDevicesRegistered || !this.z2mGroupsRegistered) {
this.shouldConfigure = true;
this.log.debug('Setting flag to configure when zigbee2mqtt sends devices');
}
+ */
this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`);
for (const bridgedEntity of this.zigbeeEntities) {
@@ -404,10 +413,16 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
this.publishCallBack = undefined;
}
+ /**
+ * @deprecated
+ */
public setPublishCallBack(onPublish: (entityName: string, topic: string, message: string) => Promise): void {
this.publishCallBack = onPublish;
}
+ /**
+ * @deprecated
+ */
public setPermitJoinCallBack(onPermitJoin: (entityName: string, permit: boolean) => Promise): void {
this.permitJoinCallBack = onPermitJoin;
}
@@ -422,6 +437,9 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
}
}
+ /**
+ * @deprecated
+ */
public emit(eventName: string, data: Payload) {
this.z2m.emit(eventName, data);
}