From b7bea34a70785f444b2b799c6d13d8478c1ed577 Mon Sep 17 00:00:00 2001 From: Luligu Date: Sat, 11 Jan 2025 17:26:52 +0100 Subject: [PATCH] Release 2.4.1 --- .../workflows/publish-matterbridge-plugin.yml | 2 +- CHANGELOG.md | 18 ++- matterbridge-zigbee2mqtt.schema.json | 26 +++- package-lock.json | 129 +++++++++--------- package.json | 8 +- src/entity.ts | 37 ++--- src/index.test.ts | 6 +- src/platform.test.ts | 6 +- src/platform.ts | 16 +-- 9 files changed, 147 insertions(+), 101 deletions(-) diff --git a/.github/workflows/publish-matterbridge-plugin.yml b/.github/workflows/publish-matterbridge-plugin.yml index ac4c71f..1f88c8f 100644 --- a/.github/workflows/publish-matterbridge-plugin.yml +++ b/.github/workflows/publish-matterbridge-plugin.yml @@ -15,7 +15,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: '22.x' registry-url: 'https://registry.npmjs.org' - name: Clean cache diff --git a/CHANGELOG.md b/CHANGELOG.md index ba710db..4684dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,16 +4,32 @@ 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.4.1] - 2025-01-11 + +### Added + +- [selectEntity]: Added selectEntity to get the components names from a list in the config editor. +- [configUrl]: Added zigbeeFrontend in the config to prefix configUrl to get a link to the zigbee2mqtt frontend from the Matterbridge frontend Devices page. This allows to open the device configuration from the frontend. + +### Changed + +- [plugin]: Requires Matterbridge 1.7.2. +- [package]: Updated dependencies. + + + Buy me a coffee + + ## [2.4.0] - 2025-01-08 ### Added - [selectDevice]: Added selectDevice to get the device names from a list in the config editor. -- [configUrl]: Added configUrl to get a link to the zigbee2mqtt frontend from the Matterbridge frontend Devices page. ### Changed - [illuminace_lux]: Follow removal of illuminace_lux https://github.com/Koenkk/zigbee-herdsman-converters/pull/8304 +- [plugin]: Requires Matterbridge 1.7.1. - [package]: Updated dependencies. diff --git a/matterbridge-zigbee2mqtt.schema.json b/matterbridge-zigbee2mqtt.schema.json index 0acaaab..a648f93 100644 --- a/matterbridge-zigbee2mqtt.schema.json +++ b/matterbridge-zigbee2mqtt.schema.json @@ -46,6 +46,11 @@ "type": "string", "default": "zigbee2mqtt" }, + "zigbeeFrontend": { + "description": "Zigbee frontend host to prefix the configUrl", + "type": "string", + "default": "http://localhost:8080" + }, "blackList": { "description": "The devices in the list will not be exposed.", "type": "array", @@ -53,14 +58,17 @@ "type": "string", "default": "device or group name" }, + "uniqueItems": true, "selectFrom": "name" }, "whiteList": { "description": "Only the devices in the list will be exposed.", "type": "array", "items": { - "type": "string" + "type": "string", + "default": "device or group name" }, + "uniqueItems": true, "selectFrom": "name" }, "switchList": { @@ -69,6 +77,7 @@ "items": { "type": "string" }, + "uniqueItems": true, "selectFrom": "name" }, "lightList": { @@ -77,6 +86,7 @@ "items": { "type": "string" }, + "uniqueItems": true, "selectFrom": "name" }, "outletList": { @@ -85,6 +95,7 @@ "items": { "type": "string" }, + "uniqueItems": true, "selectFrom": "name" }, "featureBlackList": { @@ -92,16 +103,23 @@ "type": "array", "items": { "type": "string" - } + }, + "uniqueItems": true, + "selectEntityFrom": "name" }, "deviceFeatureBlackList": { - "description": "List of features not to be exposed for a single device. Enter in the first field the name of the device and in the second field add all the features to exclude.", + "description": "List of features not to be exposed for a single device. Enter in the first field the name of the device and in the list add all the features to exclude.", "type": "object", + "uniqueItems": true, + "selectFrom": "name", "additionalProperties": { + "description": "List of features not to be exposed for this device. Enter the feature (i.e. device_temperature) to exclude.", "type": "array", "items": { "type": "string" - } + }, + "uniqueItems": true, + "selectDeviceEntityFrom": "name" } }, "postfixHostname": { diff --git a/package-lock.json b/package-lock.json index 600f20d..14be7a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.4.0", + "version": "2.4.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "matterbridge-zigbee2mqtt", - "version": "2.4.0", + "version": "2.4.1", "license": "Apache-2.0", "dependencies": { "moment": "2.30.1", @@ -15,18 +15,18 @@ "node-persist-manager": "1.0.8" }, "devDependencies": { - "@eslint/js": "9.17.0", + "@eslint/js": "9.18.0", "@types/eslint__js": "8.42.3", "@types/jest": "29.5.14", "@types/node": "22.10.5", - "eslint": "9.17.0", + "eslint": "9.18.0", "eslint-config-prettier": "9.1.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": "5.7.3", "typescript-eslint": "8.19.1" }, "engines": { @@ -67,9 +67,9 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.3.tgz", - "integrity": "sha512-nHIxvKPniQXpmQLb0vhY3VaFb3S0YrTAwpOWJZh1wn3oJPjJk9Asva204PsBdmAE8vpzfHudT8DB0scYvy9q0g==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.26.5.tgz", + "integrity": "sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==", "dev": true, "license": "MIT", "engines": { @@ -118,14 +118,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.3.tgz", - "integrity": "sha512-6FF/urZvD0sTeO7k6/B15pMLC4CHUv1426lzr3N01aHJTl046uCAh9LXW/fzeXXjPNCJ6iABW5XaWOsIZB93aQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.26.5.tgz", + "integrity": "sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.26.3", - "@babel/types": "^7.26.3", + "@babel/parser": "^7.26.5", + "@babel/types": "^7.26.5", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^3.0.2" @@ -135,13 +135,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.9.tgz", - "integrity": "sha512-j9Db8Suy6yV/VHa4qzrj9yZfZxhLWQdVnRlXxmKLYlhWUVB1sB2G5sxuWYXk/whHD9iW76PmNzxZ4UCnTQTVEQ==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz", + "integrity": "sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.25.9", + "@babel/compat-data": "^7.26.5", "@babel/helper-validator-option": "^7.25.9", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", @@ -194,9 +194,9 @@ } }, "node_modules/@babel/helper-plugin-utils": { - "version": "7.25.9", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.25.9.tgz", - "integrity": "sha512-kSMlyUVdWe25rEsRGviIgOWnoT/nfABVWlqt9N19/dIPWViAOW2s9wznP5tURbs/IDuNk4gPy3YdYRgH3uxhBw==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.26.5.tgz", + "integrity": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==", "dev": true, "license": "MIT", "engines": { @@ -248,13 +248,13 @@ } }, "node_modules/@babel/parser": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.3.tgz", - "integrity": "sha512-WJ/CvmY8Mea8iDXo6a7RK2wbmJITT5fN3BEkRuFlxVyNx8jOKIIhmC4fSkTcPcf8JyavbBwIe6OpiCOBXt/IcA==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.5.tgz", + "integrity": "sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.26.3" + "@babel/types": "^7.26.5" }, "bin": { "parser": "bin/babel-parser.js" @@ -530,17 +530,17 @@ } }, "node_modules/@babel/traverse": { - "version": "7.26.4", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.4.tgz", - "integrity": "sha512-fH+b7Y4p3yqvApJALCPJcwb0/XaOSgtK4pzV6WVjPR5GLFQBRI7pfoX2V2iM48NXvX07NUxxm1Vw98YjqTcU5w==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.26.5.tgz", + "integrity": "sha512-rkOSPOw+AXbgtwUga3U4u8RpoK9FEFWBNAlTpcnkLFjL5CT+oyHNuUUC/xx6XefEJ16r38r8Bc/lfp6rYuHeJQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.26.2", - "@babel/generator": "^7.26.3", - "@babel/parser": "^7.26.3", + "@babel/generator": "^7.26.5", + "@babel/parser": "^7.26.5", "@babel/template": "^7.25.9", - "@babel/types": "^7.26.3", + "@babel/types": "^7.26.5", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -559,9 +559,9 @@ } }, "node_modules/@babel/types": { - "version": "7.26.3", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.3.tgz", - "integrity": "sha512-vN5p+1kl59GVKMvTHt55NzzmYVxprfJD+ql7U9NFIfKCBkYE55LYtS+WtPlaYOyzydrKI8Nezd+aZextrd+FMA==", + "version": "7.26.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.5.tgz", + "integrity": "sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==", "dev": true, "license": "MIT", "dependencies": { @@ -637,9 +637,9 @@ } }, "node_modules/@eslint/core": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.9.1.tgz", - "integrity": "sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q==", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.10.0.tgz", + "integrity": "sha512-gFHJ+xBOo4G3WRlR1e/3G8A6/KZAH6zcE/hkLRCZTi/B9avAG365QhFA8uOGzTMqgTghpn7/fSnscW++dpMSAw==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -674,9 +674,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.17.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.17.0.tgz", - "integrity": "sha512-Sxc4hqcs1kTu0iID3kcZDW3JHq2a77HO9P8CP6YEA/FpH3Ll8UXE2r/86Rz9YJLKme39S9vU5OWNjC6Xl0Cr3w==", + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.18.0.tgz", + "integrity": "sha512-fK6L7rxcq6/z+AaQMtiFTkvbHkBLNlwyRxHpKawP0x3u9+NC6MQTnFW+AdpwC6gfHTW0051cokQgtTN2FqlxQA==", "dev": true, "license": "MIT", "engines": { @@ -694,12 +694,13 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz", - "integrity": "sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.5.tgz", + "integrity": "sha512-lB05FkqEdUg2AA0xEbUz0SnkXT1LcCTa438W4IWTUh4hdOnVbQyOJ81OrDXsJk/LSiJHubgGEFoR5EHq1NsH1A==", "dev": true, "license": "Apache-2.0", "dependencies": { + "@eslint/core": "^0.10.0", "levn": "^0.4.1" }, "engines": { @@ -2010,9 +2011,9 @@ } }, "node_modules/browserslist": { - "version": "4.24.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.3.tgz", - "integrity": "sha512-1CPmv8iobE2fyRMV97dAcMVegvvWKxmq94hkLiAkUGwKVTyDLw33K+ZxiFrREKmmps4rIw6grcCFCnTMSZ/YiA==", + "version": "4.24.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.24.4.tgz", + "integrity": "sha512-KDi1Ny1gSePi1vm0q4oxSF8b4DR44GF4BbmS2YdhPLOEqd8pDviZOGH/GsmRwoWJ2+5Lr085X7naowMwKHDG1A==", "dev": true, "funding": [ { @@ -2116,9 +2117,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001690", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz", - "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==", + "version": "1.0.30001692", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz", + "integrity": "sha512-A95VKan0kdtrsnMubMKxEKUKImOPSuCpYgxSQBo036P5YYgVIcOYJEgt/txJWqObiRQeISNCfef9nvlQ0vbV7A==", "dev": true, "funding": [ { @@ -2411,9 +2412,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.79", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.79.tgz", - "integrity": "sha512-nYOxJNxQ9Om4EC88BE4pPoNI8xwSFf8pU/BAeOl4Hh/b/i6V4biTAzwV7pXi3ARKeoYO5JZKMIXTryXSVer5RA==", + "version": "1.5.80", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.80.tgz", + "integrity": "sha512-LTrKpW0AqIuHwmlVNV+cjFYTnXtM9K37OGhpe0ZI10ScPSxqVSryZHIY3WnCS5NSYbBODRTZyhRMS2h5FAEqAw==", "dev": true, "license": "ISC" }, @@ -2471,19 +2472,19 @@ } }, "node_modules/eslint": { - "version": "9.17.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.17.0.tgz", - "integrity": "sha512-evtlNcpJg+cZLcnVKwsai8fExnqjGPicK7gnUtlNuzu+Fv9bI0aLpND5T44VLQtoMEnI57LoXO9XAkIXwohKrA==", + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.18.0.tgz", + "integrity": "sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", "@eslint/config-array": "^0.19.0", - "@eslint/core": "^0.9.0", + "@eslint/core": "^0.10.0", "@eslint/eslintrc": "^3.2.0", - "@eslint/js": "9.17.0", - "@eslint/plugin-kit": "^0.2.3", + "@eslint/js": "9.18.0", + "@eslint/plugin-kit": "^0.2.5", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.1", @@ -5405,9 +5406,9 @@ "license": "MIT" }, "node_modules/typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "dev": true, "license": "Apache-2.0", "bin": { @@ -5448,9 +5449,9 @@ "license": "MIT" }, "node_modules/update-browserslist-db": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz", - "integrity": "sha512-R8UzCaa9Az+38REPiJ1tXlImTJXlVfgHZsglwBD/k6nj76ctsH1E3q4doGrukiLQd3sGQYu56r5+lo5r94l29A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.2.tgz", + "integrity": "sha512-PPypAm5qvlD7XMZC3BujecnaOxwhrtoFR+Dqkk5Aa/6DssiH0ibKoketaj9w8LP7Bont1rYeoV5plxD7RTEPRg==", "dev": true, "funding": [ { @@ -5469,7 +5470,7 @@ "license": "MIT", "dependencies": { "escalade": "^3.2.0", - "picocolors": "^1.1.0" + "picocolors": "^1.1.1" }, "bin": { "update-browserslist-db": "cli.js" diff --git a/package.json b/package.json index bf9cfdb..e3d28c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matterbridge-zigbee2mqtt", - "version": "2.4.0", + "version": "2.4.1", "description": "Matterbridge zigbee2mqtt plugin", "author": "https://github.com/Luligu", "license": "Apache-2.0", @@ -86,18 +86,18 @@ "node-persist-manager": "1.0.8" }, "devDependencies": { - "@eslint/js": "9.17.0", + "@eslint/js": "9.18.0", "@types/eslint__js": "8.42.3", "@types/jest": "29.5.14", "@types/node": "22.10.5", - "eslint": "9.17.0", + "eslint": "9.18.0", "eslint-config-prettier": "9.1.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": "5.7.3", "typescript-eslint": "8.19.1" } } \ No newline at end of file diff --git a/src/entity.ts b/src/entity.ts index d60401b..31366aa 100644 --- a/src/entity.ts +++ b/src/entity.ts @@ -618,6 +618,12 @@ export class ZigbeeGroup extends ZigbeeEntity { zigbeeGroup.serial = `group-${group.id}`.slice(0, 32); } + // Set the device entity select + zigbeeGroup.log.warn(`***Group ${zigbeeGroup.en}${group.friendly_name}${db} adds select device ${group.id} (${group.friendly_name})`); + if (!platform.selectDevice.get(`group-${group.id}`)) { + platform.selectDevice.set(`group-${group.id}`, { serial: `group-${group.id}`, name: group.friendly_name, icon: 'wifi', entities: [] }); + } + let useState = false; let useBrightness = false; let useColor = false; @@ -1048,23 +1054,6 @@ export class ZigbeeDevice extends ZigbeeEntity { if (device.power_source === 'Battery' && expose.name === 'voltage') expose.name = 'battery_voltage'; if (device.power_source === 'Battery' && expose.property === 'voltage') expose.property = 'battery_voltage'; - // Fix illuminance and illuminance_lux for light sensors: - // illuminance is raw value (use like it is) - // illuminance_lux is in lux (convert with log10) - // illuminance has description "Raw measured illuminance" - // illuminance_lux has description "Measured illuminance in lux" - if (expose.description === 'Raw measured illuminance') { - expose.name = 'illuminance'; - expose.property = 'illuminance'; - expose.label = 'Illuminance'; - expose.unit = ''; - } - if (expose.description === 'Measured illuminance in lux') { - expose.name = 'illuminance_lux'; - expose.property = 'illuminance_lux'; - expose.label = 'Illuminance (lux)'; - expose.unit = 'lx'; - } types.push(''); endpoints.push(expose.endpoint || ''); names.push(expose.name || ''); @@ -1110,6 +1099,20 @@ export class ZigbeeDevice extends ZigbeeEntity { }); } + // Set the device entity select + platform.selectEntity.set('last_seen', { name: 'last_seen', description: 'Last seen', icon: 'hub' }); + for (const [index, property] of properties.entries()) { + zigbeeDevice.log.warn(`***Device ${zigbeeDevice.en}${device.friendly_name}${db} adds select device ${device.ieee_address} (${device.friendly_name})`); + if (!platform.selectDevice.get(device.ieee_address)) { + platform.selectDevice.set(device.ieee_address, { serial: device.ieee_address, name: device.friendly_name, icon: 'wifi', entities: [] }); + } + + zigbeeDevice.log.warn(`***Device ${zigbeeDevice.en}${device.friendly_name}${db} adds select entity ${property} (${descriptions[index]})`); + if (endpoints[index] === '') platform.selectEntity.set(property, { name: property, description: descriptions[index], icon: 'hub' }); + platform.selectDevice.get(device.ieee_address)?.entities?.push({ name: property, description: descriptions[index], icon: 'hub' }); + } + + // Set the global and devic based feature blacklist if (platform.featureBlackList) zigbeeDevice.ignoreFeatures = [...zigbeeDevice.ignoreFeatures, ...platform.featureBlackList]; if (platform.deviceFeatureBlackList[device.friendly_name]) zigbeeDevice.ignoreFeatures = [...zigbeeDevice.ignoreFeatures, ...platform.deviceFeatureBlackList[device.friendly_name]]; diff --git a/src/index.test.ts b/src/index.test.ts index 5d2880a..f9c508f 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -26,11 +26,15 @@ describe('initializePlugin', () => { matterbridgeDirectory: './jest/matterbridge', matterbridgePluginDirectory: './jest/plugins', systemInformation: { ipv4Address: undefined }, - matterbridgeVersion: '1.7.1', + matterbridgeVersion: '1.7.2', getDevices: jest.fn(() => { // console.log('getDevices called'); return []; }), + getPlugins: jest.fn(() => { + // console.log('getDevices called'); + return []; + }), addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { // console.log('addBridgedDevice called'); }), diff --git a/src/platform.test.ts b/src/platform.test.ts index f2c6c91..c150500 100644 --- a/src/platform.test.ts +++ b/src/platform.test.ts @@ -34,11 +34,15 @@ describe('TestPlatform', () => { matterbridgeDirectory: './jest/matterbridge', matterbridgePluginDirectory: './jest/plugins', systemInformation: { ipv4Address: undefined }, - matterbridgeVersion: '1.7.1', + matterbridgeVersion: '1.7.2', getDevices: jest.fn(() => { // console.log('getDevices called'); return []; }), + getPlugins: jest.fn(() => { + // console.log('getDevices called'); + return []; + }), addBridgedDevice: jest.fn(async (pluginName: string, device: MatterbridgeDevice) => { // console.log('addBridgedDevice called'); }), diff --git a/src/platform.ts b/src/platform.ts index 2a44b95..586d83e 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -76,8 +76,8 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { super(matterbridge, log, config); // Verify that Matterbridge is the correct version - if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.7.1')) { - throw new Error(`This plugin requires Matterbridge version >= "1.7.1". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`); + if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.7.2')) { + throw new Error(`This plugin requires Matterbridge version >= "1.7.2". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend."`); } // this.log.debug(`Config:')}${rs}`, config); @@ -511,8 +511,8 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } private async registerZigbeeDevice(device: BridgeDevice): Promise { - this.selectDevice.set(device.ieee_address, { serial: device.ieee_address, name: device.friendly_name }); - if (!this.validateDeviceWhiteBlackList(device.friendly_name)) { + this.selectDevice.set(device.ieee_address, { serial: device.ieee_address, name: device.friendly_name, icon: 'wifi', entities: [] }); + if (!this.validateDevice(device.friendly_name)) { return undefined; } this.log.debug(`Registering device ${dn}${device.friendly_name}${db} ID: ${zb}${device.ieee_address}${db}`); @@ -520,7 +520,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { try { matterDevice = await ZigbeeDevice.create(this, device); if (matterDevice.bridgedDevice) { - matterDevice.bridgedDevice.configUrl = `http://${this.mqttHost}:8080/#/device/${device.ieee_address}/info`; + matterDevice.bridgedDevice.configUrl = `${this.config.zigbeeFrontend}/#/device/${device.ieee_address}/info`; await this.registerDevice(matterDevice.bridgedDevice); this.bridgedDevices.push(matterDevice.bridgedDevice); this.zigbeeEntities.push(matterDevice); @@ -533,8 +533,8 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { } public async registerZigbeeGroup(group: BridgeGroup): Promise { - this.selectDevice.set(`group-${group.id}`, { serial: `group-${group.id}`, name: group.friendly_name }); - if (!this.validateDeviceWhiteBlackList(group.friendly_name)) { + this.selectDevice.set(`group-${group.id}`, { serial: `group-${group.id}`, name: group.friendly_name, icon: 'wifi' }); + if (!this.validateDevice(group.friendly_name)) { return undefined; } this.log.debug(`Registering group ${gn}${group.friendly_name}${db} ID: ${zb}${group.id}${db}`); @@ -542,7 +542,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform { try { matterGroup = await ZigbeeGroup.create(this, group); if (matterGroup.bridgedDevice) { - matterGroup.bridgedDevice.configUrl = `http://${this.mqttHost}:8080/#/group/${group.id}`; + matterGroup.bridgedDevice.configUrl = `${this.config.zigbeeFrontend}/#/group/${group.id}`; await this.registerDevice(matterGroup.bridgedDevice); this.bridgedDevices.push(matterGroup.bridgedDevice); this.zigbeeEntities.push(matterGroup);