Skip to content

Commit

Permalink
Merge pull request #58 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 1.3.3
  • Loading branch information
Luligu authored Jun 22, 2024
2 parents ac38eb9 + 06c9fe5 commit c843e53
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-buildx-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ node_storage
Eve door_history.json

# Dockerfile

migrationV8.txt
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<a href="https://www.buymeacoffee.com/luligugithub">
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
</a>

## [1.3.2] - 2024-06-22

New plugin
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -94,7 +94,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"
Expand Down
27 changes: 23 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
53 changes: 38 additions & 15 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,26 +1758,37 @@ export class Matterbridge extends EventEmitter {
*/
private async startMatterbridge(): Promise<void> {
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');
Expand Down Expand Up @@ -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;
Expand All @@ -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');
Expand Down

0 comments on commit c843e53

Please sign in to comment.