Skip to content

Commit

Permalink
Merge pull request #220 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 2.1.4
  • Loading branch information
Luligu authored Feb 7, 2025
2 parents bac12da + 892efc8 commit bf3f9be
Show file tree
Hide file tree
Showing 22 changed files with 554 additions and 152 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,35 @@ Starting from v. 2.1.0, the legacy old api of matter.js have been completely rem

For this reason there is no compatibility with the old versions of the plugins.

You need to update all plugins you use and Matterbridge in the same moment.
You need to update all plugins you use and Matterbridge in the same moment.

I suggest to first update all plugins without restarting and then to update Matterbridge so when it restarts, all versions will be the latest.

If you use docker, all plugins are already installed in the image so you just need to pull the new image.

Compatibility list:
matterbridge-shelly v. 1.1.5
matterbridge-zigbee2mqtt v. 2.4.4
matterbridge-somfy-tahoma v. 1.2.3
matterbridge-hass v. 0.0.8

## [2.1.4] - 2025-02-07

### Added

- [frontend]: Added memorycheck before cleanup.
- [platform]: Added a check for not latin characters.
- [platform]: Added a check for already registered device names.

### Changed

- [package]: Update matter.js to 0.12.3.
- [matter.js]: Since matter.js storage cannot properly encode non latin names, they are encoded before passing them to matter.js.

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

## [2.1.3] - 2025-02-04

### Added
Expand Down
18 changes: 11 additions & 7 deletions README-DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ The container must have full access to the host network (needed for mdns).

```
sudo docker run --name matterbridge \
-v ${HOME}/Matterbridge:/root/Matterbridge \
-v ${HOME}/.matterbridge:/root/.matterbridge \
-v /home/<USER>/Matterbridge:/root/Matterbridge \
-v /home/<USER>/.matterbridge:/root/.matterbridge \
--network host --restart always -d luligu/matterbridge:latest
```

Replace USER with your user name (i.e. ubuntu or pi).

You may need to adapt the script to your setup.

### Run with docker compose
Expand All @@ -63,14 +65,16 @@ The docker-compose.yml file is available in the docker directory of the package
services:
matterbridge:
container_name: matterbridge
image: luligu/matterbridge:latest # Matterbridge image with the latest tag
network_mode: host # Ensures the Matter mdns works
restart: always # Ensures the container always restarts automatically
image: luligu/matterbridge:latest # Matterbridge image with the tag latest
network_mode: host # Ensures the Matter mdns works
restart: always # Ensures the container always restarts automatically
volumes:
- "${HOME}/Matterbridge:/root/Matterbridge" # Mounts the Matterbridge plugin directory
- "${HOME}/.matterbridge:/root/.matterbridge" # Mounts the Matterbridge storage directory
- "/home/<USER>/Matterbridge:/root/Matterbridge" # Mounts the Matterbridge plugin directory
- "/home/<USER>/.matterbridge:/root/.matterbridge" # Mounts the Matterbridge storage directory
```

Replace USER with your user name (i.e. ubuntu or pi).

copy it in the home directory or edit the existing one to add the matterbridge service.

Then start docker compose with:
Expand Down
106 changes: 53 additions & 53 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge",
"version": "2.1.3",
"version": "2.1.4",
"description": "Matterbridge plugin manager for Matter",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -147,7 +147,7 @@
"install:jest": "npm install --save-dev jest ts-jest @types/jest eslint-plugin-jest && npm run test"
},
"dependencies": {
"@matter/main": "0.12.2",
"@matter/main": "0.12.3",
"archiver": "7.0.1",
"express": "4.21.2",
"glob": "11.0.1",
Expand Down
4 changes: 0 additions & 4 deletions src/deviceManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
import { DeviceManager } from './deviceManager.js';
import { PluginManager } from './pluginManager.js';
import { contactSensor, occupancySensor } from './matterbridgeDeviceTypes.js';
import { MdnsService } from '@matter/main/protocol';

// Default colors
const plg = '\u001B[38;5;33m';
Expand Down Expand Up @@ -38,9 +37,7 @@ describe('DeviceManager with mocked devices', () => {

afterAll(async () => {
// Close the Matterbridge instance
const server = matterbridge.serverNode;
await matterbridge.destroyInstance();
await server?.env.get(MdnsService)[Symbol.asyncDispose]();
// Restore the mocked AnsiLogger.log method
loggerLogSpy.mockRestore();
// Restore the mocked console.log
Expand Down Expand Up @@ -195,7 +192,6 @@ describe('DeviceManager with real devices', () => {
// Close the Matterbridge instance
const server = matterbridge.serverNode;
await matterbridge.destroyInstance();
await server?.env.get(MdnsService)[Symbol.asyncDispose]();
// Restore the mocked AnsiLogger.log method
loggerLogSpy.mockRestore();
// Restore the mocked console.log
Expand Down
2 changes: 0 additions & 2 deletions src/frontend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1166,9 +1166,7 @@ describe('Matterbridge frontend', () => {
expect((matterbridge as any).plugins.size).toBe(0);

// Close the Matterbridge instance
const server = matterbridge.serverNode;
await matterbridge.destroyInstance();
await server?.env.get(MdnsService)[Symbol.asyncDispose]();

expect(loggerLogSpy).toHaveBeenCalledWith(LogLevel.DEBUG, `WebSocket server closed successfully`);
expect(loggerLogSpy).toHaveBeenCalledWith(LogLevel.NOTICE, `Cleanup completed. Shutting down...`);
Expand Down
18 changes: 16 additions & 2 deletions src/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,20 @@ export class Frontend {
}

async stop() {
// Start the memory check. This will not allow the process to exit but will log the memory usage for 5 minutes.
if (hasParameter('memorycheck')) {
await new Promise<void>((resolve) => {
this.log.debug(`***Memory check started for ${getIntParameter('memorycheck') ?? 5 * 60 * 1000} ms`);
setTimeout(
() => {
this.log.debug(`***Memory check stopped after ${getIntParameter('memorycheck') ?? 5 * 60 * 1000} ms`);
resolve();
},
getIntParameter('memorycheck') ?? 5 * 60 * 1000,
);
});
}

// Close the http server
if (this.httpServer) {
this.httpServer.close();
Expand Down Expand Up @@ -1015,7 +1029,7 @@ export class Frontend {
};

this.log.debug(
`***Cpu usage ${CYAN}${cpuUsage.padStart(6, ' ')} %${db} - Memory usage rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}`,
`***Cpu usage: ${CYAN}${cpuUsage.padStart(6, ' ')} %${db} - Memory usage: rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}`,
);
};
interval();
Expand Down Expand Up @@ -1045,7 +1059,7 @@ export class Frontend {
};
// eslint-disable-next-line no-console
console.log(
`${YELLOW}Cpu usage${db} ${CYAN}${memory.cpu.padStart(6, ' ')} %${db} - ${YELLOW}Memory usage${db} rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}${rs}`,
`${YELLOW}Cpu usage:${db} ${CYAN}${memory.cpu.padStart(6, ' ')} %${db} - ${YELLOW}Memory usage:${db} rss ${CYAN}${memoryUsage.rss}${db} heapTotal ${CYAN}${memoryUsage.heapTotal}${db} heapUsed ${CYAN}${memoryUsage.heapUsed}${db} external ${memoryUsage.external} arrayBuffers ${memoryUsage.arrayBuffers}${rs}`,
);
}
this.memoryData = [];
Expand Down
4 changes: 0 additions & 4 deletions src/matterbridge.bridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { jest } from '@jest/globals';
import { AnsiLogger, db, LogLevel, nf, rs, UNDERLINE, UNDERLINEOFF } from 'node-ansi-logger';
import { Matterbridge } from './matterbridge.js';
import { wait, waiter } from './utils/utils.js';
import { MdnsService } from '@matter/main/protocol';
import { Environment, StorageService } from '@matter/main';
import path from 'path';
import os from 'os';
Expand Down Expand Up @@ -83,7 +82,6 @@ describe('Matterbridge loadInstance() and cleanup() -bridge mode', () => {
afterAll(async () => {
// Restore all mocks
jest.restoreAllMocks();
// console.log('Matterbridge test -bridge mode');
}, 30000);

test('Matterbridge.loadInstance(true) -bridge mode', async () => {
Expand Down Expand Up @@ -160,9 +158,7 @@ describe('Matterbridge loadInstance() and cleanup() -bridge mode', () => {

test('Matterbridge.destroyInstance() -bridge mode', async () => {
// Close the Matterbridge instance
const server = matterbridge.serverNode;
await matterbridge.destroyInstance();
await server?.env.get(MdnsService)[Symbol.asyncDispose]();

expect((matterbridge as any).log.log).toHaveBeenCalledWith(LogLevel.NOTICE, `Cleanup completed. Shutting down...`);
}, 60000);
Expand Down
2 changes: 0 additions & 2 deletions src/matterbridge.childbridge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { jest } from '@jest/globals';
import { AnsiLogger, db, LogLevel, nf, rs, UNDERLINE, UNDERLINEOFF } from 'node-ansi-logger';
import { Matterbridge } from './matterbridge.js';
import { wait, waiter } from './utils/utils.js';
import { MdnsService } from '@matter/main/protocol';
import { Environment, StorageService } from '@matter/main';
import path from 'path';
import os from 'os';
Expand Down Expand Up @@ -82,7 +81,6 @@ describe('Matterbridge loadInstance() and cleanup() -childbridge mode', () => {
afterAll(async () => {
// Restore all mocks
jest.restoreAllMocks();
// console.log('Matterbridge test -childbridge mode');
});

test('Matterbridge.loadInstance(true) -childbridge mode', async () => {
Expand Down
Loading

0 comments on commit bf3f9be

Please sign in to comment.