Skip to content

Commit

Permalink
Dev 1.6.0-dev.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Oct 13, 2024
1 parent 522a2b4 commit 98170cb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
3 changes: 1 addition & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
- Add test for triggerSwitchEvent configureColorControlCluster configureColorControlMode
- bug on sessions
- when change mode update QR immediately

The following actions use a deprecated Node.js version and will be forced to run on node20: docker/login-action@v2. For more info: https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
- discord on readme
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge",
"version": "1.6.0-dev.2",
"version": "1.6.0-dev.3",
"description": "Matterbridge plugin manager for Matter",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down
61 changes: 37 additions & 24 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,43 @@ export class Matterbridge extends EventEmitter {
return;
}

// Check if the bridge mode is set and start matterbridge in bridge mode if not set
if (!hasParameter('bridge') && !hasParameter('childbridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === '') {
this.log.info('Setting default matterbridge start mode to bridge');
await this.nodeContext?.set<string>('bridgeMode', 'bridge');
}

// Start matterbridge in bridge mode
if (hasParameter('bridge') || (!hasParameter('childbridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === 'bridge')) {
this.bridgeMode = 'bridge';
MatterbridgeDevice.bridgeMode = 'bridge';
await this.loadStartConfigurePlugins();
this.log.debug(`Starting matterbridge in mode ${this.bridgeMode}`);
await this.startBridge();
return;
}

// Start matterbridge in childbridge mode
if (hasParameter('childbridge') || (!hasParameter('bridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === 'childbridge')) {
this.bridgeMode = 'childbridge';
MatterbridgeDevice.bridgeMode = 'childbridge';
await this.loadStartConfigurePlugins();
this.log.debug(`Starting matterbridge in mode ${this.bridgeMode}`);
await this.startChildbridge();
return;
}
}

/**
* Asynchronously loads, starts the configures the registered plugins.
*
* This method is responsible for initializing and configuring all necessary plugins
* required by the application. It ensures that each plugin is properly loaded and
* configured before the application starts using them.
*
* @returns {Promise<void>} A promise that resolves when all plugins have been loaded and configured.
*/
private async loadStartConfigurePlugins() {
// Check, load and start the plugins
for (const plugin of this.plugins) {
plugin.configJson = await this.plugins.loadConfig(plugin);
Expand Down Expand Up @@ -647,30 +684,6 @@ export class Matterbridge extends EventEmitter {
plugin.manualPairingCode = undefined;
this.plugins.load(plugin, true, 'Matterbridge is starting'); // No await do it asyncronously
}

// Check if the bridge mode is set and start matterbridge in bridge mode if not set
if (!hasParameter('bridge') && !hasParameter('childbridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === '') {
this.log.info('Setting default matterbridge start mode to bridge');
await this.nodeContext?.set<string>('bridgeMode', 'bridge');
}

// Start matterbridge in bridge mode
if (hasParameter('bridge') || (!hasParameter('childbridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === 'bridge')) {
this.bridgeMode = 'bridge';
MatterbridgeDevice.bridgeMode = 'bridge';
this.log.debug(`Starting matterbridge in mode ${this.bridgeMode}`);
await this.startBridge();
return;
}

// Start matterbridge in childbridge mode
if (hasParameter('childbridge') || (!hasParameter('bridge') && (await this.nodeContext?.get<string>('bridgeMode', '')) === 'childbridge')) {
this.bridgeMode = 'childbridge';
MatterbridgeDevice.bridgeMode = 'childbridge';
this.log.debug(`Starting matterbridge in mode ${this.bridgeMode}`);
await this.startChildbridge();
return;
}
}

/**
Expand Down

0 comments on commit 98170cb

Please sign in to comment.