From f6fd0a8840b37120d04aabd328a59ceadaeed9cd Mon Sep 17 00:00:00 2001 From: Luligu <132135057+Luligu@users.noreply.github.com> Date: Sat, 22 Jun 2024 11:14:50 +0200 Subject: [PATCH 1/4] chore: Update matter-history to latest version --- package-lock.json | 18 +++++++++--------- package.json | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0601d3bd..9f57cdfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@project-chip/matter-node.js": "^0.9.2", "body-parser": "^1.20.2", "express": "^4.19.2", - "matter-history": "^1.1.1", + "matter-history": "^1.1.2", "node-ansi-logger": "^1.9.5", "node-persist-manager": "^1.0.7", "ws": "^8.17.1" @@ -23,7 +23,7 @@ "devDependencies": { "@tsconfig/node-lts": "^20.1.3", "@types/express": "^4.17.21", - "@types/node": "^20.14.7", + "@types/node": "^20.14.8", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^7.13.1", "@typescript-eslint/parser": "^7.13.1", @@ -362,9 +362,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.7.tgz", - "integrity": "sha512-uTr2m2IbJJucF3KUxgnGOZvYbN0QgkGyWxG6973HCpMYFy2KfcgYuIwkJQMQkt1VbBMlvWRbpshFTLxnxCZjKQ==", + "version": "20.14.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.8.tgz", + "integrity": "sha512-DO+2/jZinXfROG7j7WKFn/3C6nFwxy2lLpgLjEXJz+0XKphZlTLJ14mo8Vfg8X5BWN6XjyESXq+LcYdT7tR3bA==", "dev": true, "license": "MIT", "dependencies": { @@ -2014,12 +2014,12 @@ "peer": true }, "node_modules/matter-history": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/matter-history/-/matter-history-1.1.1.tgz", - "integrity": "sha512-qFnt4T+GVK2Epa+3MeQ5FXmt+kVwX6+ukc+M0WUfVvuFPrfCsDD/RurP/JZwUahI1J1wOQE+/yvFEwUp8TJO7Q==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/matter-history/-/matter-history-1.1.2.tgz", + "integrity": "sha512-6oJIjK8KIt24sS+T+ywaVwBJhaz8Sid17q1RkSyP1PSqDzMRPvos2F5jBzgqTA++Ijq/AXoVfu8WlG/s/YhBlw==", "license": "Apache-2.0", "dependencies": { - "@project-chip/matter-node.js": "^0.9.1", + "@project-chip/matter-node.js": "^0.9.2", "moment": "^2.30.1", "node-ansi-logger": "^1.9.5" }, diff --git a/package.json b/package.json index 423f8bf2..3ca02764 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "devDependencies": { "@tsconfig/node-lts": "^20.1.3", "@types/express": "^4.17.21", - "@types/node": "^20.14.7", + "@types/node": "^20.14.8", "@types/ws": "^8.5.10", "@typescript-eslint/eslint-plugin": "^7.13.1", "@typescript-eslint/parser": "^7.13.1", @@ -94,9 +94,9 @@ "@project-chip/matter-node.js": "^0.9.2", "body-parser": "^1.20.2", "express": "^4.19.2", - "matter-history": "^1.1.1", + "matter-history": "^1.1.2", "node-ansi-logger": "^1.9.5", "node-persist-manager": "^1.0.7", "ws": "^8.17.1" } -} \ No newline at end of file +} From 3d87ffb8ef296bc83c3032280dcf21f14ef6e9d4 Mon Sep 17 00:00:00 2001 From: Luligu <132135057+Luligu@users.noreply.github.com> Date: Sat, 22 Jun 2024 17:35:32 +0200 Subject: [PATCH 2/4] chore: Add migrationV8.txt to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d53607d1..eb8c6ef5 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ node_storage Eve door_history.json # Dockerfile + +migrationV8.txt \ No newline at end of file From c2d93b10d6c030290d7a8ff525a8319e454dcf48 Mon Sep 17 00:00:00 2001 From: Luligu <132135057+Luligu@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:16:18 +0200 Subject: [PATCH 3/4] Changed error mode plugin behaviour --- src/index.ts | 27 +++++++++++++++++++---- src/matterbridge.ts | 53 ++++++++++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/index.ts b/src/index.ts index 3de88a77..09d64f61 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,14 +39,33 @@ export * from './matterbridgeDevice.js'; export * from './matterbridgePlatform.js'; export * from './matterbridgeAccessoryPlatform.js'; export * from './matterbridgeDynamicPlatform.js'; + export * from './cluster/AirQualityCluster.js'; -export * from './cluster/TvocCluster.js'; -export * from './cluster/CarbonMonoxideConcentrationMeasurementCluster.js'; export * from './cluster/BooleanStateConfigurationCluster.js'; -export * from './cluster/PowerTopologyCluster.js'; -// export * from './cluster/FanControlCluster.js'; // Already defined in matter.js like rev. 2 +export * from './cluster/CarbonDioxideConcentrationMeasurementCluster.js'; +export * from './cluster/CarbonMonoxideConcentrationMeasurementCluster.js'; +export * from './cluster/ConcentrationMeasurementCluster.js'; +export * from './cluster/DeviceEnergyManagementCluster.js'; +export * from './cluster/DeviceEnergyManagementModeCluster.js'; export * from './cluster/ElectricalEnergyMeasurementCluster.js'; export * from './cluster/ElectricalPowerMeasurementCluster.js'; +export * from './cluster/FormaldehydeConcentrationMeasurementCluster.js'; +export * from './cluster/MeasurementAccuracy.js'; +export * from './cluster/MeasurementAccuracyRange.js'; +export * from './cluster/MeasurementType.js'; +export * from './cluster/NitrogenDioxideConcentrationMeasurementCluster.js'; +export * from './cluster/OzoneConcentrationMeasurementCluster.js'; +export * from './cluster/Pm10ConcentrationMeasurementCluster.js'; +export * from './cluster/Pm1ConcentrationMeasurementCluster.js'; +export * from './cluster/Pm25ConcentrationMeasurementCluster.js'; +export * from './cluster/PowerTopologyCluster.js'; +export * from './cluster/RadonConcentrationMeasurementCluster.js'; +export * from './cluster/SmokeCoAlarmCluster.js'; +export * from './cluster/TvocCluster.js'; + +// export * from './cluster/BridgedDeviceBasicInformationCluster.js'; // Already defined in matter.js like rev. 2 +// export * from './cluster/FanControlCluster.js'; // Already defined in matter.js like rev. 2 + export * from './utils.js'; async function main() { diff --git a/src/matterbridge.ts b/src/matterbridge.ts index 6095c7e8..c3d78b2b 100644 --- a/src/matterbridge.ts +++ b/src/matterbridge.ts @@ -1758,26 +1758,37 @@ export class Matterbridge extends EventEmitter { */ private async startMatterbridge(): Promise { if (this.bridgeMode === 'bridge') { - // Plugins are loaded and started by loadPlugin on startup and plugin.loaded is set to true - // Plugins configured by callback when Matterbridge is commissioned + // Plugins are loaded and started by loadPlugin on startup and plugin.loaded and plugin.loaded are set to true + // Plugins are configured by callback when Matterbridge is commissioned and plugin.configured is set to true this.log.debug('***Starting startMatterbridge interval for Matterbridge'); let failCount = 0; - const startInterval = setInterval(async () => { + const startMatterInterval = setInterval(async () => { for (const plugin of this.registeredPlugins) { - if (!plugin.enabled || plugin.error) continue; + // if (!plugin.enabled || plugin.error) continue; + + // new code to not start the bridge if one plugin is in error cause the controllers will delete the devices loosing all the configuration + if (!plugin.enabled) continue; + if (plugin.error) { + clearInterval(startMatterInterval); + this.log.debug('***Cleared startMatterInterval interval for Matterbridge for plugin in error state'); + this.log.error(`The plugin ${plg}${plugin.name}${er} is in error state.`); + this.log.error('The bridge will not start until the problem is solved to prevent the controllers from deleting all registered devices.'); + this.log.error('If you want to start the bridge disable the plugin in error state and restart.'); + return; + } + if (!plugin.loaded || !plugin.started) { - this.log.debug(`***Waiting (failSafeCount=${failCount}/30) in startMatterbridge interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded} started: ${plugin.started}...`); + this.log.debug(`***Waiting (failSafeCount=${failCount}/30) in startMatterInterval interval for plugin ${plg}${plugin.name}${db} loaded: ${plugin.loaded} started: ${plugin.started}...`); failCount++; if (failCount > 30) { - this.log.error(`Error waiting for plugin ${plg}${plugin.name}${er} to load and start. Plugin is in error mode.`); + this.log.error(`Error waiting for plugin ${plg}${plugin.name}${er} to load and start. Plugin is in error state.`); plugin.error = true; - } else { - return; } + return; } } - clearInterval(startInterval); - this.log.debug('***Cleared startMatterbridge interval for Matterbridge'); + clearInterval(startMatterInterval); + this.log.debug('***Cleared startMatterInterval interval for Matterbridge'); await this.startMatterServer(); this.log.info('Matter server started'); @@ -1850,8 +1861,21 @@ export class Matterbridge extends EventEmitter { let failCount = 0; const startMatterInterval = setInterval(async () => { let allStarted = true; - this.registeredPlugins.forEach((plugin) => { - if (!plugin.enabled || plugin.error) return; + // this.registeredPlugins.forEach((plugin) => { + for (const plugin of this.registeredPlugins) { + // if (!plugin.enabled || plugin.error) return; + + // new code to not start the bridge if one plugin is in error cause the controllers will delete the devices loosing all the configuration + if (!plugin.enabled) continue; + if (plugin.error) { + clearInterval(startMatterInterval); + this.log.debug('***Cleared startMatterInterval interval for Matterbridge for plugin in error state'); + this.log.error(`The plugin ${plg}${plugin.name}${er} is in error state.`); + this.log.error('The bridge will not start until the problem is solved to prevent the controllers from deleting all registered devices.'); + this.log.error('If you want to start the bridge disable the plugin in error state and restart.'); + return; + } + this.log.debug(`***Checking plugin ${plg}${plugin.name}${db} to start matter in childbridge mode...`); if (!plugin.loaded || !plugin.started) { allStarted = false; @@ -1860,13 +1884,12 @@ export class Matterbridge extends EventEmitter { if (failCount > 30) { this.log.error(`Error waiting for plugin ${plg}${plugin.name}${er} to load and start. Plugin is in error mode.`); plugin.error = true; - return; } } - }); + } if (!allStarted) return; clearInterval(startMatterInterval); - this.log.debug('***Cleared startMatterbridge interval in childbridge mode'); + this.log.debug('***Cleared startMatterInterval interval in childbridge mode'); await this.startMatterServer(); this.log.info('Matter server started'); From 06c9fe57ab91d2482947fb3f70e21c000b40fcaa Mon Sep 17 00:00:00 2001 From: Luligu <132135057+Luligu@users.noreply.github.com> Date: Sat, 22 Jun 2024 21:32:19 +0200 Subject: [PATCH 4/4] Release 1.3.3 --- .github/workflows/docker-buildx-main.yml | 2 +- CHANGELOG.md | 10 ++++++++++ package.json | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-buildx-main.yml b/.github/workflows/docker-buildx-main.yml index 149df9fc..4a238cbc 100644 --- a/.github/workflows/docker-buildx-main.yml +++ b/.github/workflows/docker-buildx-main.yml @@ -39,7 +39,7 @@ jobs: --platform linux/amd64,linux/arm64,linux/arm/v7 \ -f docker/Dockerfile.main \ -t luligu/matterbridge:latest \ - -t luligu/matterbridge:1.3.2 \ + -t luligu/matterbridge:1.3.3 \ --push . docker manifest inspect luligu/matterbridge:latest timeout-minutes: 60 diff --git a/CHANGELOG.md b/CHANGELOG.md index 65497218..ef8aade2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. +## [1.3.3] - 2024-06-22 + +### Changed +- [matterbridge]: Updated dependencies +- [matterbridge]: When a plugin is in an error state, the bridge does not start to avoid causing the controllers to delete the registered devices and lose the configuration (e.g. room and automations). + + + Buy me a coffee + + ## [1.3.2] - 2024-06-22 New plugin diff --git a/package.json b/package.json index 3ca02764..58a603af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "matterbridge", - "version": "1.3.2", + "version": "1.3.3", "description": "Matterbridge plugin manager for Matter", "author": "https://github.com/Luligu", "license": "Apache-2.0", @@ -99,4 +99,4 @@ "node-persist-manager": "^1.0.7", "ws": "^8.17.1" } -} +} \ No newline at end of file