diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d67edc..2716402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,20 @@ -# Changelog +# Matterbridge Logo   Matterbridge zigbee2mqtt plugin changelog + +If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-zigbee2mqtt and sponsoring it. All notable changes to this project will be documented in this file. +## [2.1.4] - 2024-06-30 + +### Changed + +- [dependencies]: Update dependencies. +- [dependencies]: Update eslint to 9.6.0. + + + Buy me a coffee + + ## [2.1.3] - 2024-06-23 ### Added diff --git a/README.md b/README.md index 20848e8..cac29ff 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ Matterbridge zigbee2mqtt is a matterbridge production-level plugin that expose a No hub or dedicated hardware needed. +If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-zigbee2mqtt and sponsoring it. + ## Prerequisites ### Matterbridge @@ -238,7 +240,7 @@ For general controller issues check the Matterbridge Known issues section ## Alexa -In the plugin config add each switch device to the lightList or outletList cause they don't show up like switch (Matterbridge uses a modified switch device type without client cluster that Alexa doesn't recognize). +In the plugin config add each switch device to the lightList or outletList if they don't show up like switch (Matterbridge uses a modified switch device type without client cluster that Alexa doesn't recognize). ## SmartThings diff --git a/matterbridge-zigbee2mqtt.schema.json b/matterbridge-zigbee2mqtt.schema.json index bb972f3..d56b803 100644 --- a/matterbridge-zigbee2mqtt.schema.json +++ b/matterbridge-zigbee2mqtt.schema.json @@ -53,7 +53,7 @@ } }, "switchList": { - "description": "The devices in the list will be exposed like switches.", + "description": "The devices in the list will be exposed like switches. (don't use it for Alexa, use lightList or outletList instead)", "type": "array", "items": { "type": "string" diff --git a/package-lock.json b/package-lock.json index 04e8b6a..5c0852b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,24 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.1.2", + "version": "2.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "matterbridge-zigbee2mqtt", - "version": "2.1.2", + "version": "2.1.4", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "moment": "^2.30.1", - "mqtt": "^5.7.2", + "mqtt": "^5.7.3", "node-ansi-logger": "^1.9.5" }, "devDependencies": { - "@eslint/js": "^9.5.0", + "@eslint/js": "^9.6.0", "@types/eslint__js": "^8.42.3", "@types/jest": "^29.5.12", - "@types/node": "^20.14.8", + "@types/node": "^20.14.9", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.1.3", @@ -28,7 +28,7 @@ "rimraf": "^5.0.7", "ts-jest": "^29.1.5", "typescript": "^5.5.2", - "typescript-eslint": "^7.13.1" + "typescript-eslint": "^7.14.1" }, "engines": { "node": ">=18.0.0" @@ -39,13 +39,14 @@ } }, "../matterbridge": { - "version": "1.3.2", + "version": "1.3.6", "dev": true, "license": "Apache-2.0", "dependencies": { "@project-chip/matter-node.js": "^0.9.2", "body-parser": "^1.20.2", "express": "^4.19.2", + "https": "^1.0.0", "matter-history": "^1.1.2", "node-ansi-logger": "^1.9.5", "node-persist-manager": "^1.0.7", @@ -55,16 +56,21 @@ "matterbridge": "dist/cli.js" }, "devDependencies": { - "@tsconfig/node-lts": "^20.1.3", + "@eslint/js": "^9.5.0", + "@types/eslint__js": "^8.42.3", "@types/express": "^4.17.21", - "@types/node": "^20.14.8", + "@types/jest": "^29.5.12", + "@types/node": "^20.14.9", "@types/ws": "^8.5.10", - "@typescript-eslint/eslint-plugin": "^7.13.1", - "@typescript-eslint/parser": "^7.13.1", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.1.3", + "jest": "^29.7.0", "prettier": "^3.3.2", - "typescript": "^5.5.2" + "rimraf": "^5.0.7", + "ts-jest": "^29.1.5", + "typescript": "^5.5.2", + "typescript-eslint": "^7.14.1" }, "engines": { "node": ">=18.0.0" @@ -821,9 +827,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.5.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.5.0.tgz", - "integrity": "sha512-A7+AOT2ICkodvtsWnxZP4Xxk3NbZ3VMHd8oihydLRGrJgqqdEz1qSeEgXYyT/Cu8h1TWWsQRejIx48mtjZ5y1w==", + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.6.0.tgz", + "integrity": "sha512-D9B0/3vNg44ZeWbYMpBoXqNP4j6eQD5vNwIlGAuFRRzK/WtT/jvDQW3Bi9kkf3PMDMlM7Yi+73VLUsn5bJcl8A==", "dev": true, "license": "MIT", "engines": { @@ -1654,9 +1660,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", - "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "license": "MIT", "dependencies": { "undici-types": "~5.26.4" @@ -1706,17 +1712,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.13.1.tgz", - "integrity": "sha512-kZqi+WZQaZfPKnsflLJQCz6Ze9FFSMfXrrIOcyargekQxG37ES7DJNpJUE9Q/X5n3yTIP/WPutVNzgknQ7biLg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.14.1.tgz", + "integrity": "sha512-aAJd6bIf2vvQRjUG3ZkNXkmBpN+J7Wd0mfQiiVCJMu9Z5GcZZdcc0j8XwN/BM97Fl7e3SkTXODSk4VehUv7CGw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "7.13.1", - "@typescript-eslint/type-utils": "7.13.1", - "@typescript-eslint/utils": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1", + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/type-utils": "7.14.1", + "@typescript-eslint/utils": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -1740,16 +1746,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.13.1.tgz", - "integrity": "sha512-1ELDPlnLvDQ5ybTSrMhRTFDfOQEOXNM+eP+3HT/Yq7ruWpciQw+Avi73pdEbA4SooCawEWo3dtYbF68gN7Ed1A==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.14.1.tgz", + "integrity": "sha512-8lKUOebNLcR0D7RvlcloOacTOWzOqemWEWkKSVpMZVF/XVcwjPR+3MD08QzbW9TCGJ+DwIc6zUSGZ9vd8cO1IA==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "7.13.1", - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/typescript-estree": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1", + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/typescript-estree": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "debug": "^4.3.4" }, "engines": { @@ -1769,14 +1775,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.13.1.tgz", - "integrity": "sha512-adbXNVEs6GmbzaCpymHQ0MB6E4TqoiVbC0iqG3uijR8ZYfpAXMGttouQzF4Oat3P2GxDVIrg7bMI/P65LiQZdg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.14.1.tgz", + "integrity": "sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1" + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -1787,14 +1793,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.13.1.tgz", - "integrity": "sha512-aWDbLu1s9bmgPGXSzNCxELu+0+HQOapV/y+60gPXafR8e2g1Bifxzevaa+4L2ytCWm+CHqpELq4CSoN9ELiwCg==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.14.1.tgz", + "integrity": "sha512-/MzmgNd3nnbDbOi3LfasXWWe292+iuo+umJ0bCCMCPc1jLO/z2BQmWUUUXvXLbrQey/JgzdF/OV+I5bzEGwJkQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "7.13.1", - "@typescript-eslint/utils": "7.13.1", + "@typescript-eslint/typescript-estree": "7.14.1", + "@typescript-eslint/utils": "7.14.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -1815,9 +1821,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.13.1.tgz", - "integrity": "sha512-7K7HMcSQIAND6RBL4kDl24sG/xKM13cA85dc7JnmQXw2cBDngg7c19B++JzvJHRG3zG36n9j1i451GBzRuHchw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.14.1.tgz", + "integrity": "sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==", "dev": true, "license": "MIT", "engines": { @@ -1829,14 +1835,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.13.1.tgz", - "integrity": "sha512-uxNr51CMV7npU1BxZzYjoVz9iyjckBduFBP0S5sLlh1tXYzHzgZ3BR9SVsNed+LmwKrmnqN3Kdl5t7eZ5TS1Yw==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.14.1.tgz", + "integrity": "sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/visitor-keys": "7.13.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/visitor-keys": "7.14.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -1868,9 +1874,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "license": "ISC", "dependencies": { @@ -1884,16 +1890,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.13.1.tgz", - "integrity": "sha512-h5MzFBD5a/Gh/fvNdp9pTfqJAbuQC4sCN2WzuXme71lqFJsZtLbjxfSk4r3p02WIArOF9N94pdsLiGutpDbrXQ==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.14.1.tgz", + "integrity": "sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.13.1", - "@typescript-eslint/types": "7.13.1", - "@typescript-eslint/typescript-estree": "7.13.1" + "@typescript-eslint/scope-manager": "7.14.1", + "@typescript-eslint/types": "7.14.1", + "@typescript-eslint/typescript-estree": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -1907,13 +1913,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.13.1.tgz", - "integrity": "sha512-k/Bfne7lrP7hcb7m9zSsgcBmo+8eicqqfNAJ7uUY+jkTFpKeH2FSkWpFRtimBxgkyvqfu9jTPRbYOvud6isdXA==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.14.1.tgz", + "integrity": "sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "7.13.1", + "@typescript-eslint/types": "7.14.1", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -4608,9 +4614,9 @@ } }, "node_modules/mqtt": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-5.7.2.tgz", - "integrity": "sha512-b5xIA9J/K1LTubSWKaNYYLxYIusQdip6o9/8bRWad2TelRr8xLifjQt+SnamDAwMp3O6NdvR9E8ae7VMuN02kg==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/mqtt/-/mqtt-5.7.3.tgz", + "integrity": "sha512-v+5la6Q6zjl0AWsI7ICDA/K3hclkNj7CMa0khMugCC+LKPLrQF+sSQb/9ckezZLMvcBC1tXhRzqmcagQoDl9fQ==", "license": "MIT", "dependencies": { "@types/readable-stream": "^4.0.5", @@ -5851,15 +5857,15 @@ } }, "node_modules/typescript-eslint": { - "version": "7.13.1", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.13.1.tgz", - "integrity": "sha512-pvLEuRs8iS9s3Cnp/Wt//hpK8nKc8hVa3cLljHqzaJJQYP8oys8GUyIFqtlev+2lT/fqMPcyQko+HJ6iYK3nFA==", + "version": "7.14.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.14.1.tgz", + "integrity": "sha512-Eo1X+Y0JgGPspcANKjeR6nIqXl4VL5ldXLc15k4m9upq+eY5fhU2IueiEZL6jmHrKH8aCfbIvM/v3IrX5Hg99w==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "7.13.1", - "@typescript-eslint/parser": "7.13.1", - "@typescript-eslint/utils": "7.13.1" + "@typescript-eslint/eslint-plugin": "7.14.1", + "@typescript-eslint/parser": "7.14.1", + "@typescript-eslint/utils": "7.14.1" }, "engines": { "node": "^18.18.0 || >=20.0.0" diff --git a/package.json b/package.json index 2ebe350..a8f03fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.1.3", + "version": "2.1.4", "description": "Matterbridge zigbee2mqtt plugin", "author": "https://github.com/Luligu", "license": "Apache-2.0", @@ -37,7 +37,7 @@ ], "type": "module", "main": "dist/index.js", - "types": "dist/index.d.js", + "types": "dist/index.d.ts", "engines": { "node": ">=18.0.0" }, @@ -85,14 +85,14 @@ }, "dependencies": { "moment": "^2.30.1", - "mqtt": "^5.7.2", + "mqtt": "^5.7.3", "node-ansi-logger": "^1.9.5" }, "devDependencies": { - "@eslint/js": "^9.5.0", + "@eslint/js": "^9.6.0", "@types/eslint__js": "^8.42.3", "@types/jest": "^29.5.12", - "@types/node": "^20.14.8", + "@types/node": "^20.14.9", "eslint-config-prettier": "^9.1.0", "eslint-plugin-jest": "^28.6.0", "eslint-plugin-prettier": "^5.1.3", @@ -102,6 +102,6 @@ "rimraf": "^5.0.7", "ts-jest": "^29.1.5", "typescript": "^5.5.2", - "typescript-eslint": "^7.13.1" + "typescript-eslint": "^7.14.1" } -} +} \ No newline at end of file diff --git a/src/entity.ts b/src/entity.ts index d86a01a..5717e4a 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -901,7 +901,6 @@ export class ZigbeeDevice extends ZigbeeEntity { } export class BridgedBaseDevice extends MatterbridgeDevice { - // public log: AnsiLogger; public hasEndpoints = false; public isRouter = false; public noUpdate = false; @@ -1043,24 +1042,14 @@ export class BridgedBaseDevice extends MatterbridgeDevice { configure() { if (this.getClusterServerById(WindowCovering.Cluster.id)) { - this.log.debug(`Configuring ${this.deviceName} WindowCovering`); + this.log.info(`Configuring ${this.deviceName} WindowCovering cluster`); this.setWindowCoveringTargetAsCurrentAndStopped(); } if (this.getClusterServerById(DoorLock.Cluster.id)) { - this.log.debug(`Configuring ${this.deviceName} DoorLock`); + this.log.info(`Configuring ${this.deviceName} DoorLock cluster`); const state = this.getClusterServerById(DoorLock.Cluster.id)?.getLockStateAttribute(); if (state === DoorLock.LockState.Locked) this.getClusterServer(DoorLockCluster)?.triggerLockOperationEvent({ lockOperationType: DoorLock.LockOperationType.Lock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }); if (state === DoorLock.LockState.Unlocked) this.getClusterServer(DoorLockCluster)?.triggerLockOperationEvent({ lockOperationType: DoorLock.LockOperationType.Unlock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }); } - /* - if (this.getClusterServerById(DoorLock.Cluster.id)) { - this.log.debug(`Configuring ${this.deviceName}`); - this.getClusterServerById(DoorLock.Cluster.id)?.setLockStateAttribute(DoorLock.LockState.Locked); - } - if (this.getClusterServerById(Switch.Cluster.id)) { - this.log.debug(`Configuring ${this.deviceName}`); - this.getClusterServerById(Switch.Cluster.id)?.setCurrentPositionAttribute(0); - } - */ } } diff --git a/src/platform.ts b/src/platform.ts index c8ad89b..28d2a79 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -151,6 +151,66 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { this.updateAvailability(false); }); + this.z2m.on('bridge-info', async (bridgeInfo: BridgeInfo) => { + this.z2mBridgeInfo = bridgeInfo; + this.log.info(`zigbee2MQTT version ${this.z2mBridgeInfo.version} zh version ${this.z2mBridgeInfo.zigbee_herdsman.version} zhc version ${this.z2mBridgeInfo.zigbee_herdsman_converters.version}`); + if (this.z2mBridgeInfo.config.advanced.output === 'attribute') this.log.error(`zigbee2MQTT advanced.output must be 'json' or 'attribute_and_json'. Now is ${this.z2mBridgeInfo.config.advanced.output}`); + if (this.z2mBridgeInfo.config.advanced.legacy_api === true) this.log.info(`zigbee2MQTT advanced.legacy_api is ${this.z2mBridgeInfo.config.advanced.legacy_api}`); + if (this.z2mBridgeInfo.config.advanced.legacy_availability_payload === true) this.log.info(`zigbee2MQTT advanced.legacy_availability_payload is ${this.z2mBridgeInfo.config.advanced.legacy_availability_payload}`); + }); + + this.z2m.on('bridge-devices', async (devices: BridgeDevice[]) => { + this.log.info(`zigbee2MQTT sent ${devices.length} devices ${this.z2mDevicesRegistered ? 'already registered' : ''}`); + if (config.injectDevices) { + const data = this.z2m.readConfig(path.join(matterbridge.matterbridgeDirectory, config.injectDevices as string)); + this.log.warn(`***Injecting ${data.devices.length} devices from ${config.injectDevices}`); + this.z2mBridgeDevices = [devices, data.devices].flat(); + } else this.z2mBridgeDevices = devices; + + if (this.shouldStart) { + if (!this.z2mDevicesRegistered && this.z2mBridgeDevices) { + for (const device of this.z2mBridgeDevices) { + await this.registerZigbeeDevice(device); + } + this.z2mDevicesRegistered = true; + } + } + + if (this.shouldConfigure) { + this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`); + for (const bridgedEntity of this.zigbeeEntities) { + if (bridgedEntity.isDevice && bridgedEntity.device) await this.requestDeviceUpdate(bridgedEntity.device); + } + for (const device of this.bridgedDevices) { + device.configure(); + } + } + }); + + 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) { + await this.registerZigbeeGroup(group); + } + this.z2mGroupsRegistered = true; + } + } + + if (this.shouldConfigure) { + this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`); + for (const bridgedEntity of this.zigbeeEntities) { + if (bridgedEntity.isGroup && bridgedEntity.group) await this.requestGroupUpdate(bridgedEntity.group); + } + for (const device of this.bridgedDevices) { + device.configure(); + } + } + }); + this.z2m.on('availability', (device: string, available: boolean) => { this.z2mDeviceAvailability.set(device, available); if (available) this.log.info(`zigbee2MQTT device ${device} is ${available ? 'online' : 'offline'}`); @@ -257,66 +317,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } }); - this.z2m.on('bridge-info', async (bridgeInfo: BridgeInfo) => { - this.z2mBridgeInfo = bridgeInfo; - this.log.info(`zigbee2MQTT version ${this.z2mBridgeInfo.version} zh version ${this.z2mBridgeInfo.zigbee_herdsman.version} zhc version ${this.z2mBridgeInfo.zigbee_herdsman_converters.version}`); - if (this.z2mBridgeInfo.config.advanced.output === 'attribute') this.log.error(`zigbee2MQTT advanced.output must be 'json' or 'attribute_and_json'. Now is ${this.z2mBridgeInfo.config.advanced.output}`); - if (this.z2mBridgeInfo.config.advanced.legacy_api === true) this.log.info(`zigbee2MQTT advanced.legacy_api is ${this.z2mBridgeInfo.config.advanced.legacy_api}`); - if (this.z2mBridgeInfo.config.advanced.legacy_availability_payload === true) this.log.info(`zigbee2MQTT advanced.legacy_availability_payload is ${this.z2mBridgeInfo.config.advanced.legacy_availability_payload}`); - }); - - this.z2m.on('bridge-devices', async (devices: BridgeDevice[]) => { - this.log.info(`zigbee2MQTT sent ${devices.length} devices ${this.z2mDevicesRegistered ? 'already registered' : ''}`); - if (config.injectDevices) { - const data = this.z2m.readConfig(path.join(matterbridge.matterbridgeDirectory, config.injectDevices as string)); - this.log.warn(`***Injecting ${data.devices.length} devices from ${config.injectDevices}`); - this.z2mBridgeDevices = [devices, data.devices].flat(); - } else this.z2mBridgeDevices = devices; - - if (this.shouldStart) { - if (!this.z2mDevicesRegistered && this.z2mBridgeDevices) { - for (const device of this.z2mBridgeDevices) { - await this.registerZigbeeDevice(device); - } - this.z2mDevicesRegistered = true; - } - } - - if (this.shouldConfigure) { - this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`); - for (const bridgedEntity of this.zigbeeEntities) { - if (bridgedEntity.isDevice && bridgedEntity.device) await this.requestDeviceUpdate(bridgedEntity.device); - } - for (const device of this.bridgedDevices) { - device.configure(); - } - } - }); - - 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) { - await this.registerZigbeeGroup(group); - } - this.z2mGroupsRegistered = true; - } - } - - if (this.shouldConfigure) { - this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`); - for (const bridgedEntity of this.zigbeeEntities) { - if (bridgedEntity.isGroup && bridgedEntity.group) await this.requestGroupUpdate(bridgedEntity.group); - } - for (const device of this.bridgedDevices) { - device.configure(); - } - } - }); - this.log.debug('Created zigbee2mqtt dynamic platform'); } @@ -329,10 +329,11 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { const hasDevices = await waiter('z2mBridgeDevices & z2mBridgeGroups', () => this.z2mBridgeDevices !== undefined || this.z2mBridgeGroups !== undefined); + if (!hasOnline) this.log.error('The plugin did not receive zigbee2mqtt bridge state. Check if zigbee2mqtt is running and connected to the MQTT broker.'); + if (!hasInfo) this.log.error('The plugin did not receive zigbee2mqtt bridge info. Check if zigbee2mqtt is running and connected to the MQTT broker.'); + if (!hasDevices) this.log.error('The plugin did not receive zigbee2mqtt bridge devices/groups. Check if zigbee2mqtt is running and connected to the MQTT broker.'); if (!hasOnline || !hasInfo || !hasDevices) { throw new 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.'); - // 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; } /* @@ -369,7 +370,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } */ - this.log.info(`Configuring ${this.zigbeeEntities.length} zigbee entities.`); + this.log.info(`Requesting update for ${this.zigbeeEntities.length} zigbee entities.`); for (const bridgedEntity of this.zigbeeEntities) { if (bridgedEntity.isDevice && bridgedEntity.device) await this.requestDeviceUpdate(bridgedEntity.device); if (bridgedEntity.isGroup && bridgedEntity.group) await this.requestGroupUpdate(bridgedEntity.group);