From 7fa1665665a800e43f886f7f06fbf92f3dfa227e Mon Sep 17 00:00:00 2001 From: Luligu Date: Tue, 24 Dec 2024 10:50:44 +0100 Subject: [PATCH] Update .gitignore, .npmignore, and workflows; modify CHANGELOG and README for version 2.3.2 --- .../workflows/build-matterbridge-plugin.yml | 3 - .../workflows/publish-matterbridge-plugin.yml | 3 - .gitignore | 1 + .npmignore | 1 + CHANGELOG.md | 13 ++ README.md | 13 +- package-lock.json | 185 +++++++++--------- package.json | 16 +- src/index.test.ts | 33 +++- src/platform.test.ts | 26 +-- src/platform.ts | 18 +- 11 files changed, 171 insertions(+), 141 deletions(-) diff --git a/.github/workflows/build-matterbridge-plugin.yml b/.github/workflows/build-matterbridge-plugin.yml index c2bc2a9..ea4a65d 100644 --- a/.github/workflows/build-matterbridge-plugin.yml +++ b/.github/workflows/build-matterbridge-plugin.yml @@ -24,9 +24,6 @@ jobs: - name: Clean cache run: npm cache clean --force - - name: Install latest npm - run: npm install -g npm@latest - - name: Verify Node.js version run: node -v diff --git a/.github/workflows/publish-matterbridge-plugin.yml b/.github/workflows/publish-matterbridge-plugin.yml index dcdd5e5..ac4c71f 100644 --- a/.github/workflows/publish-matterbridge-plugin.yml +++ b/.github/workflows/publish-matterbridge-plugin.yml @@ -21,9 +21,6 @@ jobs: - name: Clean cache run: npm cache clean --force - - name: Install latest npm - run: npm install -g npm@latest - - name: Verify Node.js version run: node -v diff --git a/.gitignore b/.gitignore index 416c2a7..38f6e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ replay_pid* # zigbee2mqtt temp/ +jest/ TODO.md \ No newline at end of file diff --git a/.npmignore b/.npmignore index 0e5ca3c..901facd 100644 --- a/.npmignore +++ b/.npmignore @@ -165,5 +165,6 @@ screenshot tsconfig.production.json temp/ mock/ +jest/ TODO.md yellow-button.png \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6086189..02caf0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ If you like this project and find it useful, please consider giving it a star on All notable changes to this project will be documented in this file. +## [2.3.2] - 2024-12-24 + +### Changed + +- [package]: Updated package. +- [package]: Updated dependencies. +- [plugin]: Use platform white and black list. +- [platform]: Use platform endpoint number check. + + + Buy me a coffee + + ## [2.3.1] - 2024-12-12 ### Added diff --git a/README.md b/README.md index 476fa5c..0e7b933 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ matterbridge -add ./ Then start Matterbridge ``` -matterbridge -bridge +matterbridge ``` # Config file @@ -174,7 +174,7 @@ If you want to exclude "temperature" and "humidity" for the device "My motion se } ``` -By default matterbridge uses hostname in order to make entities unique, however in some cases +By default matterbridge-zigbee2mqtt uses hostname in order to make entities unique, however in some cases you may not want this behavior. You can use "postfixHostname" boolean flag to disable this behavior: ```json @@ -217,8 +217,6 @@ The latest release also supports all clusters in the multi endpoints devices (e. Since the Matter support in the available ecosystems (controllers) is sometimes limited and, when available, only covers Matter 1.1 specifications, some z2m devices cannot be exposed properly or cannot be exposed at all. -We discoverd that Matter support in Home Assistant includes some clusters not supported by other ecosystems. These clusters like EveHistory have been added so with HA you can see Voltage, Current, Consumption and TotalConsumption (screenshot https://github.com/Luligu/matterbridge/blob/main/screenshot/Screenshot%20HA%20sm-dc-power-m.png). - ## Unsupported devices If one of your devices is not supported out of the box, open an issue and we will try to support it if possible. @@ -254,16 +252,13 @@ For general controller issues check the Matterbridge Known issues section ## Apple Home -## Home Assistant (Matter Server is still in Beta) +## Home Assistant ## Google Home ## Alexa -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). +In the plugin config add each switch device to the lightList or outletList. Matterbridge uses a modified switch device type without client cluster that Alexa doesn't recognize. ## SmartThings -## eWeLink - -## Tuya/Smart Life diff --git a/package-lock.json b/package-lock.json index 5035ab7..52931ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.3.1", + "version": "2.3.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "matterbridge-zigbee2mqtt", - "version": "2.3.1", + "version": "2.3.2", "license": "Apache-2.0", "dependencies": { "moment": "2.30.1", @@ -15,19 +15,19 @@ "node-persist-manager": "1.0.8" }, "devDependencies": { - "@eslint/js": "9.16.0", + "@eslint/js": "9.17.0", "@types/eslint__js": "8.42.3", "@types/jest": "29.5.14", "@types/node": "22.10.2", - "eslint": "9.16.0", + "eslint": "9.17.0", "eslint-config-prettier": "9.1.0", - "eslint-plugin-jest": "28.9.0", + "eslint-plugin-jest": "28.10.0", "eslint-plugin-prettier": "5.2.1", "jest": "29.7.0", "prettier": "3.4.2", "ts-jest": "29.2.5", "typescript": "5.7.2", - "typescript-eslint": "8.18.0" + "typescript-eslint": "8.18.2" }, "engines": { "node": ">=18.0.0 <19.0.0 || >=20.0.0 <21.0.0 || >=22.0.0 <23.0.0" @@ -674,9 +674,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.16.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.16.0.tgz", - "integrity": "sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg==", + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", + "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", "dev": true, "license": "MIT", "engines": { @@ -1493,17 +1493,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.0.tgz", - "integrity": "sha512-NR2yS7qUqCL7AIxdJUQf2MKKNDVNaig/dEB0GBLU7D+ZdHgK1NoH/3wsgO3OnPVipn51tG3MAwaODEGil70WEw==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.2.tgz", + "integrity": "sha512-adig4SzPLjeQ0Tm+jvsozSGiCliI2ajeURDGHjZ2llnA+A67HihCQ+a3amtPhUakd1GlwHxSRvzOZktbEvhPPg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.18.0", - "@typescript-eslint/type-utils": "8.18.0", - "@typescript-eslint/utils": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0", + "@typescript-eslint/scope-manager": "8.18.2", + "@typescript-eslint/type-utils": "8.18.2", + "@typescript-eslint/utils": "8.18.2", + "@typescript-eslint/visitor-keys": "8.18.2", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -1523,16 +1523,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.0.tgz", - "integrity": "sha512-hgUZ3kTEpVzKaK3uNibExUYm6SKKOmTU2BOxBSvOYwtJEPdVQ70kZJpPjstlnhCHcuc2WGfSbpKlb/69ttyN5Q==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.2.tgz", + "integrity": "sha512-y7tcq4StgxQD4mDr9+Jb26dZ+HTZ/SkfqpXSiqeUXZHxOUyjWDKsmwKhJ0/tApR08DgOhrFAoAhyB80/p3ViuA==", "dev": true, - "license": "MITClause", + "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.18.0", - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/typescript-estree": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0", + "@typescript-eslint/scope-manager": "8.18.2", + "@typescript-eslint/types": "8.18.2", + "@typescript-eslint/typescript-estree": "8.18.2", + "@typescript-eslint/visitor-keys": "8.18.2", "debug": "^4.3.4" }, "engines": { @@ -1548,14 +1548,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.0.tgz", - "integrity": "sha512-PNGcHop0jkK2WVYGotk/hxj+UFLhXtGPiGtiaWgVBVP1jhMoMCHlTyJA+hEj4rszoSdLTK3fN4oOatrL0Cp+Xw==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.2.tgz", + "integrity": "sha512-YJFSfbd0CJjy14r/EvWapYgV4R5CHzptssoag2M7y3Ra7XNta6GPAJPPP5KGB9j14viYXyrzRO5GkX7CRfo8/g==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0" + "@typescript-eslint/types": "8.18.2", + "@typescript-eslint/visitor-keys": "8.18.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1566,14 +1566,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.0.tgz", - "integrity": "sha512-er224jRepVAVLnMF2Q7MZJCq5CsdH2oqjP4dT7K6ij09Kyd+R21r7UVJrF0buMVdZS5QRhDzpvzAxHxabQadow==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.2.tgz", + "integrity": "sha512-AB/Wr1Lz31bzHfGm/jgbFR0VB0SML/hd2P1yxzKDM48YmP7vbyJNHRExUE/wZsQj2wUCvbWH8poNHFuxLqCTnA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.18.0", - "@typescript-eslint/utils": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.2", + "@typescript-eslint/utils": "8.18.2", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -1590,9 +1590,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.0.tgz", - "integrity": "sha512-FNYxgyTCAnFwTrzpBGq+zrnoTO4x0c1CKYY5MuUTzpScqmY5fmsh2o3+57lqdI3NZucBDCzDgdEbIaNfAjAHQA==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.2.tgz", + "integrity": "sha512-Z/zblEPp8cIvmEn6+tPDIHUbRu/0z5lqZ+NvolL5SvXWT5rQy7+Nch83M0++XzO0XrWRFWECgOAyE8bsJTl1GQ==", "dev": true, "license": "MIT", "engines": { @@ -1604,14 +1604,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.0.tgz", - "integrity": "sha512-rqQgFRu6yPkauz+ms3nQpohwejS8bvgbPyIDq13cgEDbkXt4LH4OkDMT0/fN1RUtzG8e8AKJyDBoocuQh8qNeg==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.2.tgz", + "integrity": "sha512-WXAVt595HjpmlfH4crSdM/1bcsqh+1weFRWIa9XMTx/XHZ9TCKMcr725tLYqWOgzKdeDrqVHxFotrvWcEsk2Tg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0", + "@typescript-eslint/types": "8.18.2", + "@typescript-eslint/visitor-keys": "8.18.2", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -1657,16 +1657,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.0.tgz", - "integrity": "sha512-p6GLdY383i7h5b0Qrfbix3Vc3+J2k6QWw6UMUeY5JGfm3C5LbZ4QIZzJNoNOfgyRe0uuYKjvVOsO/jD4SJO+xg==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.2.tgz", + "integrity": "sha512-Cr4A0H7DtVIPkauj4sTSXVl+VBWewE9/o40KcF3TV9aqDEOWoXF3/+oRXNby3DYzZeCATvbdksYsGZzplwnK/Q==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.18.0", - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/typescript-estree": "8.18.0" + "@typescript-eslint/scope-manager": "8.18.2", + "@typescript-eslint/types": "8.18.2", + "@typescript-eslint/typescript-estree": "8.18.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1681,13 +1681,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.0.tgz", - "integrity": "sha512-pCh/qEA8Lb1wVIqNvBke8UaRjJ6wrAWkJO5yyIbs8Yx6TNGYyfNjOo61tLv+WwLvoLPp4BQ8B7AHKijl8NGUfw==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.2.tgz", + "integrity": "sha512-zORcwn4C3trOWiCqFQP1x6G3xTRyZ1LYydnj51cRnJ6hxBlr/cKPckk+PKPUw/fXmvfKTcw7bwY3w9izgx5jZw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/types": "8.18.2", "eslint-visitor-keys": "^4.2.0" }, "engines": { @@ -2010,9 +2010,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.2.tgz", - "integrity": "sha512-ZIc+Q62revdMcqC6aChtW4jz3My3klmCO1fEmINZY/8J3EpBg5/A/D0AKmBveUh6pgoeycoMkVMko84tuYS+Gg==", + "version": "4.24.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.3.tgz", + "integrity": "sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA==", "dev": true, "funding": [ { @@ -2030,9 +2030,9 @@ ], "license": "MIT", "dependencies": { - "caniuse-lite": "^1.0.30001669", - "electron-to-chromium": "^1.5.41", - "node-releases": "^2.0.18", + "caniuse-lite": "^1.0.30001688", + "electron-to-chromium": "^1.5.73", + "node-releases": "^2.0.19", "update-browserslist-db": "^1.1.1" }, "bin": { @@ -2116,9 +2116,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001688", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz", - "integrity": "sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA==", + "version": "1.0.30001690", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", + "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", "dev": true, "funding": [ { @@ -2411,9 +2411,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.73", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.73.tgz", - "integrity": "sha512-8wGNxG9tAG5KhGd3eeA0o6ixhiNdgr0DcHWm85XPCphwZgD1lIEoi6t3VERayWao7SF7AAZTw6oARGJeVjH8Kg==", + "version": "1.5.76", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.76.tgz", + "integrity": "sha512-CjVQyG7n7Sr+eBXE86HIulnL5N8xZY1sgmOPGuq/F0Rr0FJq63lg0kEtOIDfZBk44FnDLf6FUJ+dsJcuiUDdDQ==", "dev": true, "license": "ISC" }, @@ -2471,9 +2471,9 @@ } }, "node_modules/eslint": { - "version": "9.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.16.0.tgz", - "integrity": "sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA==", + "version": "9.17.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.17.0.tgz", + "integrity": "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA==", "dev": true, "license": "MIT", "dependencies": { @@ -2482,7 +2482,7 @@ "@eslint/config-array": "^0.19.0", "@eslint/core": "^0.9.0", "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "9.16.0", + "@eslint/js": "9.17.0", "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", @@ -2491,7 +2491,7 @@ "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.5", + "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", @@ -2544,9 +2544,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "28.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.9.0.tgz", - "integrity": "sha512-rLu1s1Wf96TgUUxSw6loVIkNtUjq1Re7A9QdCCHSohnvXEBAjuL420h0T/fMmkQlNsQP2GhQzEUpYHPfxBkvYQ==", + "version": "28.10.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.10.0.tgz", + "integrity": "sha512-hyMWUxkBH99HpXT3p8hc7REbEZK3D+nk8vHXGgpB+XXsi0gO4PxMSP+pjfUzb67GnV9yawV9a53eUmcde1CCZA==", "dev": true, "license": "MIT", "dependencies": { @@ -2848,9 +2848,9 @@ } }, "node_modules/fastq": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", - "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.18.0.tgz", + "integrity": "sha512-QKHXPW0hD8g4UET03SdOdunzSouc9N4AuHdsX8XNcTsuz+yYFILVNIX4l9yHABMhiEI9Db0JTTIpu0wB+Y1QQw==", "dev": true, "license": "ISC", "dependencies": { @@ -3250,9 +3250,9 @@ "license": "MIT" }, "node_modules/is-core-module": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", - "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, "license": "MIT", "dependencies": { @@ -4844,9 +4844,9 @@ "license": "MIT" }, "node_modules/readable-stream": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", - "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.6.0.tgz", + "integrity": "sha512-cbAdYt0VcnpN2Bekq7PU+k363ZRsPwJoEEJOEtSJQlJXzwaxt3FIo/uL+KeDSGIjJqtkwyge4KQgD2S2kd+CQw==", "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", @@ -4882,19 +4882,22 @@ } }, "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", "dev": true, "license": "MIT", "dependencies": { - "is-core-module": "^2.13.0", + "is-core-module": "^2.16.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, "bin": { "resolve": "bin/resolve" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5416,15 +5419,15 @@ } }, "node_modules/typescript-eslint": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.0.tgz", - "integrity": "sha512-Xq2rRjn6tzVpAyHr3+nmSg1/9k9aIHnJ2iZeOH7cfGOWqTkXTm3kwpQglEuLGdNrYvPF+2gtAs+/KF5rjVo+WQ==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.2.tgz", + "integrity": "sha512-KuXezG6jHkvC3MvizeXgupZzaG5wjhU3yE8E7e6viOvAvD9xAWYp8/vy0WULTGe9DYDWcQu7aW03YIV3mSitrQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.18.0", - "@typescript-eslint/parser": "8.18.0", - "@typescript-eslint/utils": "8.18.0" + "@typescript-eslint/eslint-plugin": "8.18.2", + "@typescript-eslint/parser": "8.18.2", + "@typescript-eslint/utils": "8.18.2" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index 77e4017..c18b23a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.3.1", + "version": "2.3.2", "description": "Matterbridge zigbee2mqtt plugin", "author": "https://github.com/Luligu", "license": "Apache-2.0", @@ -62,10 +62,10 @@ "checkDependencies": "npx npm-check-updates", "updateDependencies": "npx npm-check-updates -u && npm install && npm link matterbridge && npm run build", "prepublishOnly": "npm pkg delete devDependencies && npm pkg delete scripts && npm install --omit=dev && npm shrinkwrap", - "npmPack": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm pack && copy package.log package.json && npm run deepCleanBuild && npm run deepCleanBuild", + "npmPack": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npm pkg delete types && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm pack && copy package.log package.json && npm run deepCleanBuild", "buildProduction": "npm run clean && tsc --project tsconfig.production.json", - "npmPublishTagDev": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm publish --tag dev && copy package.log package.json && npm run deepCleanBuild", - "npmPublishTagLatest": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm publish --tag latest && copy package.log package.json && npm run deepCleanBuild", + "npmPublishTagDev": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npm pkg delete types && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm publish --tag dev && copy package.log package.json && npm run deepCleanBuild", + "npmPublishTagLatest": "copy package.json package.log && npm run buildProduction && npm pkg delete devDependencies && npm pkg delete scripts && npm pkg delete types && npx rimraf ./node_modules && npm install --omit=dev && npm shrinkwrap && npm publish --tag latest && copy package.log package.json && npm run deepCleanBuild", "matterbridge:add": "matterbridge -add .\\", "matterbridge:remove": "matterbridge -remove .\\", "matterbridge:enable": "matterbridge -enable .\\", @@ -86,18 +86,18 @@ "node-persist-manager": "1.0.8" }, "devDependencies": { - "@eslint/js": "9.16.0", + "@eslint/js": "9.17.0", "@types/eslint__js": "8.42.3", "@types/jest": "29.5.14", "@types/node": "22.10.2", - "eslint": "9.16.0", + "eslint": "9.17.0", "eslint-config-prettier": "9.1.0", - "eslint-plugin-jest": "28.9.0", + "eslint-plugin-jest": "28.10.0", "eslint-plugin-prettier": "5.2.1", "jest": "29.7.0", "prettier": "3.4.2", "ts-jest": "29.2.5", "typescript": "5.7.2", - "typescript-eslint": "8.18.0" + "typescript-eslint": "8.18.2" } } \ No newline at end of file diff --git a/src/index.test.ts b/src/index.test.ts index 4f98a4e..6421c6d 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-console */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unused-vars */ -import { Matterbridge, PlatformConfig } from 'matterbridge'; +import { Matterbridge, MatterbridgeDevice, MatterbridgeEndpoint, PlatformConfig } from 'matterbridge'; import { AnsiLogger, LogLevel } from 'matterbridge/logger'; import { ZigbeePlatform } from './platform.js'; import initializePlugin from './index'; @@ -23,12 +23,33 @@ describe('initializePlugin', () => { beforeEach(() => { mockMatterbridge = { - addBridgedDevice: jest.fn(), - matterbridgeDirectory: '', - matterbridgePluginDirectory: 'temp', + matterbridgeDirectory: './jest/matterbridge', + matterbridgePluginDirectory: './jest/plugins', systemInformation: { ipv4Address: undefined }, - matterbridgeVersion: '1.6.6', - removeAllBridgedDevices: jest.fn(), + matterbridgeVersion: '1.6.7', + getDevices: jest.fn(() => { + // console.log('getDevices called'); + return []; + }), + addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { + // console.log('addBridgedDevice called'); + }), + addBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { + // console.log('addBridgedEndpoint called'); + // await aggregator.add(device); + }), + removeBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { + // console.log('removeBridgedDevice called'); + }), + removeBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { + // console.log('removeBridgedEndpoint called'); + }), + removeAllBridgedDevices: jest.fn(async (pluginName: string) => { + // console.log('removeAllBridgedDevices called'); + }), + removeAllBridgedEndpoints: jest.fn(async (pluginName: string) => { + // console.log('removeAllBridgedEndpoints called'); + }), } as unknown as Matterbridge; mockLog = { fatal: jest.fn((message) => { diff --git a/src/platform.test.ts b/src/platform.test.ts index 023c36d..d9b6039 100644 --- a/src/platform.test.ts +++ b/src/platform.test.ts @@ -31,29 +31,33 @@ describe('TestPlatform', () => { beforeAll(() => { mockMatterbridge = { + matterbridgeDirectory: './jest/matterbridge', + matterbridgePluginDirectory: './jest/plugins', + systemInformation: { ipv4Address: undefined }, + matterbridgeVersion: '1.6.7', + getDevices: jest.fn(() => { + // console.log('getDevices called'); + return []; + }), addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { - // console.error('addBridgedDevice called'); + // console.log('addBridgedDevice called'); }), addBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { - device.number = 100; - // console.error('addBridgedEndpoint called'); + // console.log('addBridgedEndpoint called'); + // await aggregator.add(device); }), removeBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { - // console.error('removeBridgedDevice called'); + // console.log('removeBridgedDevice called'); }), removeBridgedEndpoint: jest.fn(async (pluginName: string, device: MatterbridgeEndpoint) => { - // console.error('removeBridgedEndpoint called'); + // console.log('removeBridgedEndpoint called'); }), removeAllBridgedDevices: jest.fn(async (pluginName: string) => { - // console.error('removeAllBridgedDevices called'); + // console.log('removeAllBridgedDevices called'); }), removeAllBridgedEndpoints: jest.fn(async (pluginName: string) => { - // console.error('removeAllBridgedEndpoints called'); + // console.log('removeAllBridgedEndpoints called'); }), - matterbridgeDirectory: '', - matterbridgePluginDirectory: 'temp', - systemInformation: { ipv4Address: undefined }, - matterbridgeVersion: '1.6.6', } as unknown as Matterbridge; mockConfig = { 'name': 'matterbridge-zigbee2mqtt', diff --git a/src/platform.ts b/src/platform.ts index 76dfd7b..5a0d487 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -51,8 +51,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { private mqttUsername: string | undefined = undefined; private mqttPassword: string | undefined = undefined; private mqttProtocol: 4 | 5 | 3 = 5; - private whiteList: string[] = []; - private blackList: string[] = []; public lightList: string[] = []; public outletList: string[] = []; public switchList: string[] = []; @@ -93,8 +91,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { if (config.username) this.mqttUsername = config.username as string; if (config.password) this.mqttPassword = config.password as string; if (config.protocolVersion && typeof config.protocolVersion === 'number' && config.protocolVersion >= 3 && config.protocolVersion <= 5) this.mqttProtocol = config.protocolVersion as 4 | 5 | 3; - if (config.whiteList) this.whiteList = config.whiteList as string[]; - if (config.blackList) this.blackList = config.blackList as string[]; if (config.switchList) this.switchList = config.switchList as string[]; if (config.lightList) this.lightList = config.lightList as string[]; if (config.outletList) this.outletList = config.outletList as string[]; @@ -109,8 +105,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { config.topic = this.mqttTopic; config.username = this.mqttUsername; config.password = this.mqttPassword; - config.whiteList = this.whiteList; - config.blackList = this.blackList; config.postfixHostname = this.postfixHostname; if (config.type === 'MatterbridgeExtension') { @@ -289,7 +283,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { this.z2m.on('device_interview', async (friendly_name: string, ieee_address: string, status: string, supported: boolean) => { this.log.info(`zigbee2MQTT sent device_interview device: ${friendly_name} ieee_address: ${ieee_address} status: ${status} supported: ${supported}`); if (status === 'successful' && supported) { - if (!this.validateWhiteBlackList(friendly_name)) return; + if (!this.validateDeviceWhiteBlackList(friendly_name)) return; this.log.info(`Registering device: ${friendly_name}`); const bridgedDevice = this.z2mBridgeDevices?.find((device) => device.friendly_name === friendly_name); if (bridgedDevice) await this.registerZigbeeDevice(bridgedDevice); @@ -309,7 +303,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { this.z2m.on('group_add', async (friendly_name: string, id: number, status: string) => { this.log.info(`zigbee2MQTT sent group_add friendly_name: ${friendly_name} id ${id} status ${status}`); - if (!this.validateWhiteBlackList(friendly_name)) return; + if (!this.validateDeviceWhiteBlackList(friendly_name)) return; this.log.info(`Registering group: ${friendly_name}`); const bridgedGroup = this.z2mBridgeGroups?.find((group) => group.friendly_name === friendly_name); if (bridgedGroup) await this.registerZigbeeGroup(bridgedGroup); @@ -386,6 +380,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } override async onConfigure() { + await super.onConfigure(); 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); @@ -435,6 +430,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } override async onShutdown(reason?: string) { + await super.onShutdown(reason); this.log.debug('Shutting down zigbee2mqtt platform: ' + reason); for (const entity of this.zigbeeEntities) { entity.destroy(); @@ -514,6 +510,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } } + /* public validateWhiteBlackList(entityName: string) { if (this.whiteList.length > 0 && !this.whiteList.find((name) => name === entityName)) { this.log.warn(`Skipping ${dn}${entityName}${wr} because not in whitelist`); @@ -525,9 +522,10 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } return true; } + */ private async registerZigbeeDevice(device: BridgeDevice): Promise { - if (!this.validateWhiteBlackList(device.friendly_name)) { + if (!this.validateDeviceWhiteBlackList(device.friendly_name)) { return undefined; } this.log.debug(`Registering device ${dn}${device.friendly_name}${db} ID: ${zb}${device.ieee_address}${db}`); @@ -547,7 +545,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } public async registerZigbeeGroup(group: BridgeGroup): Promise { - if (!this.validateWhiteBlackList(group.friendly_name)) { + if (!this.validateDeviceWhiteBlackList(group.friendly_name)) { return undefined; } this.log.debug(`Registering group ${gn}${group.friendly_name}${db} ID: ${zb}${group.id}${db}`);