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 325a873..6c458ee 100644 --- a/.gitignore +++ b/.gitignore @@ -42,7 +42,4 @@ coverage/ hs_err_pid* replay_pid* -# zigbee2mqtt -bridge-info.json -bridge-devices.json -bridge-groups.json \ No newline at end of file +jest/ \ No newline at end of file diff --git a/.npmignore b/.npmignore index bd48beb..c557137 100644 --- a/.npmignore +++ b/.npmignore @@ -165,4 +165,5 @@ screenshot TODO.md yellow-button.png create-release.js -tsconfig.production.json \ No newline at end of file +tsconfig.production.json +jest/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b1e0dcc..0fd6bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-example-dynamic-platform and sponsoring it. + +## [1.1.3] - 2024-12-21 + +### Added + +- [platform]: Added call to super.OnConfigure() and super.OnShutDown() to check endpoints numbers. + +### Changed + +- [package]: Updated dependencies. +- [package]: Updated package. + + + Buy me a coffee + + ## [1.1.2] - 2024-12-12 - [package]: Require matterbridge 1.6.6 diff --git a/package-lock.json b/package-lock.json index 5b76c24..2f07737 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,31 +1,31 @@ { "name": "matterbridge-example-accessory-platform", - "version": "1.1.1", + "version": "1.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "matterbridge-example-accessory-platform", - "version": "1.1.1", + "version": "1.1.3", "license": "MIT", "dependencies": { "node-ansi-logger": "3.0.0", "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.1" }, "engines": { "node": ">=18.0.0 <19.0.0 || >=20.0.0 <21.0.0 || >=22.0.0 <23.0.0" @@ -660,9 +660,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": { @@ -1461,17 +1461,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.18.1.tgz", + "integrity": "sha512-Ncvsq5CT3Gvh+uJG0Lwlho6suwDfUXH0HztslDf5I+F2wAFAZMRwYLEorumpKLzmO2suAXZ/td1tBg4NZIi9CQ==", "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.1", + "@typescript-eslint/type-utils": "8.18.1", + "@typescript-eslint/utils": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -1491,16 +1491,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.18.1.tgz", + "integrity": "sha512-rBnTWHCdbYM2lh7hjyXqxk70wvon3p2FyaniZuey5TrcGBpfhVp0OxOa6gxr9Q9YhZFKyfbEnxc24ZnVbbUkCA==", "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.1", + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/typescript-estree": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", "debug": "^4.3.4" }, "engines": { @@ -1516,14 +1516,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.18.1.tgz", + "integrity": "sha512-HxfHo2b090M5s2+/9Z3gkBhI6xBH8OJCFjH9MhQ+nnoZqxU3wNxkLT+VWXWSFWc3UF3Z+CfPAyqdCTdoXtDPCQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0" + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1534,14 +1534,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.18.1.tgz", + "integrity": "sha512-jAhTdK/Qx2NJPNOTxXpMwlOiSymtR2j283TtPqXkKBdH8OAMmhiUfP0kJjc/qSE51Xrq02Gj9NY7MwK+UxVwHQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.18.0", - "@typescript-eslint/utils": "8.18.0", + "@typescript-eslint/typescript-estree": "8.18.1", + "@typescript-eslint/utils": "8.18.1", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -1558,9 +1558,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.18.1.tgz", + "integrity": "sha512-7uoAUsCj66qdNQNpH2G8MyTFlgerum8ubf21s3TSM3XmKXuIn+H2Sifh/ES2nPOPiYSRJWAk0fDkW0APBWcpfw==", "dev": true, "license": "MIT", "engines": { @@ -1572,14 +1572,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.18.1.tgz", + "integrity": "sha512-z8U21WI5txzl2XYOW7i9hJhxoKKNG1kcU4RzyNvKrdZDmbjkmLBo8bgeiOJmA06kizLI76/CCBAAGlTlEeUfyg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", - "@typescript-eslint/visitor-keys": "8.18.0", + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/visitor-keys": "8.18.1", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -1625,16 +1625,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.18.1.tgz", + "integrity": "sha512-8vikiIj2ebrC4WRdcAdDcmnu9Q/MXXwg+STf40BVfT8exDqBCUPdypvzcUPxEqRGKg9ALagZ0UWcYCtn+4W2iQ==", "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.1", + "@typescript-eslint/types": "8.18.1", + "@typescript-eslint/typescript-estree": "8.18.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1649,13 +1649,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.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.18.1.tgz", + "integrity": "sha512-Vj0WLm5/ZsD013YeUKn+K0y8p1M0jPpxOkKdbD1wB0ns53a5piVY02zjf072TblEweAbcYiFiPoSMF3kp+VhhQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.18.0", + "@typescript-eslint/types": "8.18.1", "eslint-visitor-keys": "^4.2.0" }, "engines": { @@ -1934,9 +1934,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": [ { @@ -1954,9 +1954,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": { @@ -2017,9 +2017,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": [ { @@ -2278,9 +2278,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.75", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.75.tgz", + "integrity": "sha512-Lf3++DumRE/QmweGjU+ZcKqQ+3bKkU/qjaKYhIJKEOhgIO9Xs6IiAQFkfFoj+RhgDk4LUeNsLo6plExHqSyu6Q==", "dev": true, "license": "ISC" }, @@ -2338,9 +2338,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": { @@ -2349,7 +2349,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", @@ -2358,7 +2358,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", @@ -2411,9 +2411,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": { @@ -3061,9 +3061,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.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.0.tgz", + "integrity": "sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g==", "dev": true, "license": "MIT", "dependencies": { @@ -4564,19 +4564,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" } @@ -5043,15 +5046,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.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.18.1.tgz", + "integrity": "sha512-Mlaw6yxuaDEPQvb/2Qwu3/TfgeBHy9iTJ3mTwe7OvpPmF6KPQjVOfGyEJpPv6Ez2C34OODChhXrzYw/9phI0MQ==", "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.1", + "@typescript-eslint/parser": "8.18.1", + "@typescript-eslint/utils": "8.18.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" diff --git a/package.json b/package.json index 4b574d7..02a3011 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matterbridge-example-accessory-platform", - "version": "1.1.2", + "version": "1.1.3", "description": "Matterbridge accessory plugin", "author": "https://github.com/Luligu", "license": "MIT", @@ -51,9 +51,9 @@ "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", "buildProduction": "npm run clean && tsc --project tsconfig.production.json", - "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", - "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", + "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", + "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 .\\", @@ -63,19 +63,19 @@ "dev:unlink": "npm unlink matterbridge" }, "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.1" }, "dependencies": { "node-ansi-logger": "3.0.0", diff --git a/src/index.test.ts b/src/index.test.ts index 56ea646..1b1aa85 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -13,29 +13,33 @@ describe('initializePlugin', () => { 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; mockLog = { fatal: jest.fn((message: string, ...parameters: any[]) => { diff --git a/src/platform.test.ts b/src/platform.test.ts index e5a1233..251606c 100644 --- a/src/platform.test.ts +++ b/src/platform.test.ts @@ -33,29 +33,33 @@ describe('TestPlatform', () => { beforeAll(async () => { 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; mockLog = { fatal: jest.fn((message: string, ...parameters: any[]) => { diff --git a/src/platform.ts b/src/platform.ts index ba4bb38..1627ffd 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -2,7 +2,6 @@ import { Matterbridge, MatterbridgeDevice, MatterbridgeAccessoryPlatform, - DeviceTypes, PlatformConfig, WindowCovering, powerSource, @@ -13,6 +12,7 @@ import { AtLeastOne, EndpointOptions, MatterbridgeEndpoint, + coverDevice, } from 'matterbridge'; import { isValidNumber } from 'matterbridge/utils'; import { AnsiLogger } from 'matterbridge/logger'; @@ -44,7 +44,8 @@ export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryP override async onStart(reason?: string) { this.log.info('onStart called with reason:', reason ?? 'none'); - this.cover = await this.createMutableDevice(DeviceTypes.WINDOW_COVERING, { uniqueStorageKey: 'Cover example device' }, this.config.debug as boolean); + this.cover = await this.createMutableDevice(coverDevice, { uniqueStorageKey: 'Cover example device' }, this.config.debug as boolean); + this.cover.log.logName = 'Cover example device'; this.cover.createDefaultIdentifyClusterServer(); this.cover.createDefaultBasicInformationClusterServer( 'Cover example device', @@ -115,6 +116,7 @@ export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryP } override async onConfigure() { + await super.onConfigure(); this.log.info('onConfigure called'); await this.cover?.setWindowCoveringTargetAsCurrentAndStopped(); @@ -133,6 +135,7 @@ export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryP } override async onShutdown(reason?: string) { + await super.onShutdown(reason); this.log.info('onShutdown called with reason:', reason ?? 'none'); clearInterval(this.coverInterval); this.coverInterval = undefined;