matterbridge 3.3.4-dev-20251021-7651f57 → 3.3.4-dev-20251022-681420c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -37,8 +37,9 @@ Advantages:
37
37
 
38
38
  - [frontend]: Added debounce to MatterSettings.
39
39
  - [cli]: Bumped `cli` version to 3.0.0 with backport of Traker and Inspector from thread module.
40
- - [powerSource]: Added MatterbridgePowerSourceServer that initialize the enpointList of the PowerSource cluster.
40
+ - [powerSource]: Added MatterbridgePowerSourceServer. It initializes the enpointList of the PowerSource cluster.
41
41
  - [thread]: Added BroadcastServer to Matterbridge.
42
+ - [service]: Added configuration [guide](README-SERVICE-LOCAL.md) to run matterbridge as a daemon with systemctl (Linux only) and with local global node_modules (no sudo required).
42
43
 
43
44
  ### Changed
44
45
 
@@ -0,0 +1,226 @@
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge systemd configuration with local global node_modules
2
+
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
5
+ [![Docker Version](https://img.shields.io/docker/v/luligu/matterbridge?label=docker%20version&sort=semver)](https://hub.docker.com/r/luligu/matterbridge)
6
+ [![Docker Pulls](https://img.shields.io/docker/pulls/luligu/matterbridge.svg)](https://hub.docker.com/r/luligu/matterbridge)
7
+ ![Node.js CI](https://github.com/Luligu/matterbridge/actions/workflows/build.yml/badge.svg)
8
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
10
+
11
+ [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
12
+ [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
13
+ [![power by](https://img.shields.io/badge/powered%20by-node--persist--manager-blue)](https://www.npmjs.com/package/node-persist-manager)
14
+
15
+ ---
16
+
17
+ # Advanced configuration
18
+
19
+ ## Run matterbridge as a daemon with systemctl (Linux only) with local global node_modules
20
+
21
+ The easiest way to add systemctl is to use [Matterbridge service cli for linux](https://github.com/Luligu/mb-service-linux).
22
+
23
+ If your setup is too complex or you prefer to do it manually follow this method. You can still use mb-service to manage systemd after.
24
+
25
+ ### First create the Matterbridge directories and set the correct permissions
26
+
27
+ This will create the required directories if they don't exist
28
+
29
+ ```bash
30
+ cd ~
31
+ sudo systemctl stop matterbridge # ✅ Safe precaution
32
+ mkdir -p ~/Matterbridge ~/.matterbridge ~/.mattercert ~/.npm-global # ✅ Creates all needed dirs
33
+ chown -R $USER:$USER ~/Matterbridge ~/.matterbridge ~/.mattercert ~/.npm-global # ✅ Ensures ownership
34
+ chmod -R 755 ~/Matterbridge ~/.matterbridge ~/.mattercert ~/.npm-global # ✅ Secure permissions
35
+ NPM_CONFIG_PREFIX=~/.npm-global npm install matterbridge --omit=dev --verbose --global # ✅ Install, no sudo
36
+ ```
37
+
38
+ ### Then create a system-wide symlink
39
+
40
+ ```bash
41
+ sudo ln -sf /home/$USER/.npm-global/bin/matterbridge /usr/local/bin/matterbridge
42
+ which matterbridge
43
+ matterbridge --version
44
+ ```
45
+
46
+ ### Then create a systemctl configuration file for Matterbridge
47
+
48
+ Create a systemctl configuration file for Matterbridge
49
+
50
+ ```bash
51
+ sudo nano /etc/systemd/system/matterbridge.service
52
+ ```
53
+
54
+ Add the following to this file, replacing 5 times (!) USER with your user name (e.g. WorkingDirectory=/home/pi/Matterbridge, User=pi and Group=pi and Environment="NPM_CONFIG_PREFIX=/home/pi/.npm-global"):
55
+
56
+ ```
57
+ [Unit]
58
+ Description=matterbridge
59
+ After=network.target
60
+ Wants=network.target
61
+
62
+ [Service]
63
+ Type=simple
64
+ Environment="NPM_CONFIG_PREFIX=/home/<USER>/.npm-global"
65
+ ExecStart=matterbridge --service --nosudo
66
+ WorkingDirectory=/home/<USER>/Matterbridge
67
+ StandardOutput=inherit
68
+ StandardError=inherit
69
+ Restart=always
70
+ User=<USER>
71
+ Group=<USER>
72
+
73
+ [Install]
74
+ WantedBy=multi-user.target
75
+ ```
76
+
77
+ If you use the frontend with **-ssl** -frontend 443 and get an error message: "Port 443 requires elevated privileges",
78
+ add this:
79
+
80
+ ```
81
+ [Service]
82
+ AmbientCapabilities=CAP_NET_BIND_SERVICE
83
+ ```
84
+
85
+ If you use the **matterbridge-bthome** plugin add this:
86
+
87
+ ```
88
+ [Service]
89
+ AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_NET_ADMIN
90
+ ```
91
+
92
+ Now and if you modify matterbridge.service after, run:
93
+
94
+ ```bash
95
+ sudo systemctl daemon-reload
96
+ sudo systemctl restart matterbridge.service
97
+ ```
98
+
99
+ ### Start Matterbridge
100
+
101
+ ```bash
102
+ sudo systemctl start matterbridge
103
+ ```
104
+
105
+ ### Stop Matterbridge
106
+
107
+ ```bash
108
+ sudo systemctl stop matterbridge
109
+ ```
110
+
111
+ ### Show Matterbridge status
112
+
113
+ ```bash
114
+ sudo systemctl status matterbridge.service
115
+ ```
116
+
117
+ ### Enable Matterbridge to start automatically on boot
118
+
119
+ ```bash
120
+ sudo systemctl enable matterbridge.service
121
+ ```
122
+
123
+ ### Disable Matterbridge from starting automatically on boot
124
+
125
+ ```bash
126
+ sudo systemctl disable matterbridge.service
127
+ ```
128
+
129
+ ### View the log of Matterbridge in real time (this will show the log with colors)
130
+
131
+ ```bash
132
+ sudo journalctl -u matterbridge.service -n 1000 -f --output cat
133
+ ```
134
+
135
+ ### Delete the logs older then 3 days (all of them not only the ones of Matterbridge!)
136
+
137
+ Check the space used
138
+
139
+ ```bash
140
+ sudo journalctl --disk-usage
141
+ ```
142
+
143
+ remove all log older then 3 days
144
+
145
+ ```bash
146
+ sudo journalctl --rotate
147
+ sudo journalctl --vacuum-time=3d
148
+ ```
149
+
150
+ ## Prevent the journal logs to grow
151
+
152
+ If you want to make the setting permanent to prevent the journal logs to grow too much, run
153
+
154
+ ```bash
155
+ sudo nano /etc/systemd/journald.conf
156
+ ```
157
+
158
+ add
159
+
160
+ ```bash
161
+ Compress=yes # Compress logs
162
+ MaxRetentionSec=3days # Keep logs for a maximum of 3 days.
163
+ MaxFileSec=1day # Rotate logs daily within the 3-day retention period.
164
+ ForwardToSyslog=no # Disable forwarding to syslog to prevent duplicate logging.
165
+ SystemMaxUse=100M # Limit persistent logs in /var/log/journal to 100 MB.
166
+ RuntimeMaxUse=100M # Limit runtime logs in /run/log/journal to 100 MB.
167
+ ```
168
+
169
+ save it and run
170
+
171
+ ```bash
172
+ sudo systemctl restart systemd-journald
173
+ ```
174
+
175
+ ## Verify that with your distro you can run sudo npm install -g matterbridge without the password
176
+
177
+ Run the following command to verify if you can install Matterbridge globally without being prompted for a password:
178
+
179
+ ```bash
180
+ sudo npm install -g matterbridge --omit=dev
181
+ ```
182
+
183
+ If you are not prompted for a password, no further action is required.
184
+
185
+ If that is not the case, open the sudoers file for editing using visudo
186
+
187
+ ```bash
188
+ sudo visudo
189
+ ```
190
+
191
+ verify the presence of of a line
192
+
193
+ ```
194
+ @includedir /etc/sudoers.d
195
+ ```
196
+
197
+ exit and create a configuration file for sudoers
198
+
199
+ ```bash
200
+ sudo nano /etc/sudoers.d/matterbridge
201
+ ```
202
+
203
+ add this line replacing USER with your user name (e.g. radxa ALL=(ALL) NOPASSWD: ALL)
204
+
205
+ ```
206
+ <USER> ALL=(ALL) NOPASSWD: ALL
207
+ ```
208
+
209
+ or if you prefers to only give access to npm without password try with (e.g. radxa ALL=(ALL) NOPASSWD: /usr/bin/npm)
210
+
211
+ ```
212
+ <USER> ALL=(ALL) NOPASSWD: /usr/bin/npm
213
+ ```
214
+
215
+ save the file and reload the settings with:
216
+
217
+ ```bash
218
+ sudo chmod 0440 /etc/sudoers.d/matterbridge
219
+ sudo visudo -c
220
+ ```
221
+
222
+ Verify if you can install Matterbridge globally without being prompted for a password:
223
+
224
+ ```bash
225
+ sudo npm install -g matterbridge --omit=dev
226
+ ```
@@ -34,6 +34,9 @@ export class BroadcastServer extends EventEmitter {
34
34
  this.log.debug(`*Received broadcast message: ${debugStringify(data)}`);
35
35
  this.emit('broadcast_message', data);
36
36
  }
37
+ broadcast(message) {
38
+ this.broadcastChannel.postMessage(message);
39
+ }
37
40
  request(message) {
38
41
  if (message.id === undefined) {
39
42
  message.id = this.getUniqueId();
package/dist/cli.js CHANGED
@@ -2,7 +2,6 @@ if (process.argv.includes('--loader') || process.argv.includes('-loader'))
2
2
  console.log('\u001B[32mCli loaded.\u001B[40;0m');
3
3
  import { AnsiLogger } from 'node-ansi-logger';
4
4
  import { cliEmitter } from './cliEmitter.js';
5
- import { Matterbridge } from './matterbridge.js';
6
5
  import { hasParameter, hasAnyParameter } from './utils/commandLine.js';
7
6
  import { inspectError } from './utils/error.js';
8
7
  import { Tracker } from './utils/tracker.js';
@@ -67,11 +66,13 @@ async function shutdown() {
67
66
  }
68
67
  async function restart() {
69
68
  log.debug('Received restart event, loading...');
69
+ const { Matterbridge } = await import('./matterbridge.js');
70
70
  instance = await Matterbridge.loadInstance(true);
71
71
  registerHandlers();
72
72
  }
73
73
  async function update() {
74
74
  log.debug('Received update event, updating...');
75
+ const { Matterbridge } = await import('./matterbridge.js');
75
76
  instance = await Matterbridge.loadInstance(true);
76
77
  registerHandlers();
77
78
  }
@@ -89,6 +90,7 @@ async function main() {
89
90
  if (hasParameter('inspect'))
90
91
  await startInspector();
91
92
  log.debug(`***Matterbridge.loadInstance(true) called`);
93
+ const { Matterbridge } = await import('./matterbridge.js');
92
94
  instance = await Matterbridge.loadInstance(true);
93
95
  log.debug(`***Matterbridge.loadInstance(true) exited`);
94
96
  if (!instance || instance.shutdown) {
@@ -130,11 +130,11 @@ export class Matterbridge extends EventEmitter {
130
130
  this.log.debug(`**Received broadcast request ${CYAN}${msg.type}${db} from ${CYAN}${msg.src}${db}: ${debugStringify(msg)}${db}`);
131
131
  switch (msg.type) {
132
132
  case 'get_log_level':
133
- this.server.respond({ ...msg, response: { success: true, level: this.log.logLevel } });
133
+ this.server.respond({ ...msg, response: { success: true, logLevel: this.log.logLevel } });
134
134
  break;
135
135
  case 'set_log_level':
136
- this.log.logLevel = msg.params.level;
137
- this.server.respond({ ...msg, response: { success: true, level: this.log.logLevel } });
136
+ this.log.logLevel = msg.params.logLevel;
137
+ this.server.respond({ ...msg, response: { success: true, logLevel: this.log.logLevel } });
138
138
  break;
139
139
  default:
140
140
  this.log.warn(`Unknown broadcast request ${CYAN}${msg.type}${wr} from ${CYAN}${msg.src}${wr}`);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.3.4-dev-20251021-7651f57",
3
+ "version": "3.3.4-dev-20251022-681420c",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge",
9
- "version": "3.3.4-dev-20251021-7651f57",
9
+ "version": "3.3.4-dev-20251022-681420c",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@matter/main": "0.15.6",
@@ -367,9 +367,9 @@
367
367
  "license": "MIT"
368
368
  },
369
369
  "node_modules/bare-events": {
370
- "version": "2.8.0",
371
- "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.8.0.tgz",
372
- "integrity": "sha512-AOhh6Bg5QmFIXdViHbMc2tLDsBIRxdkIaIddPslJF9Z5De3APBScuqGP2uThXnIpqFrgoxMNC6km7uXNIMLHXA==",
370
+ "version": "2.8.1",
371
+ "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.8.1.tgz",
372
+ "integrity": "sha512-oxSAxTS1hRfnyit2CL5QpAOS5ixfBjj6ex3yTNvXyY/kE719jQ/IjuESJBK2w5v4wwQRAHGseVJXx9QBYOtFGQ==",
373
373
  "license": "Apache-2.0",
374
374
  "peerDependencies": {
375
375
  "bare-abort-controller": "*"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge",
3
- "version": "3.3.4-dev-20251021-7651f57",
3
+ "version": "3.3.4-dev-20251022-681420c",
4
4
  "description": "Matterbridge plugin manager for Matter",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",