matterbridge-zigbee2mqtt 3.0.3-dev-20251211-d87d63c → 3.0.3-dev-20251211-ab441ae

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
@@ -8,9 +8,20 @@ If you like this project and find it useful, please consider giving it a star on
8
8
 
9
9
  ## [3.0.3] - 2025-12-12
10
10
 
11
+ ### Added
12
+
13
+ - [mqtt]: Added a guide to setup Unix socket on the host.
14
+ - [mqtt]: Added a guide to setup Unix socket with docker.
15
+
11
16
  ### Changed
12
17
 
13
18
  - [package]: Updated dependencies.
19
+ - [mqtt]: Clarified in the schema that the mqtt port is not used with Unix socket.
20
+ - [mqtt]: Removed options.protocol.
21
+
22
+ ### Fixed
23
+
24
+ - [mqtt]: Fixed wrong log messages with Unix socket.
14
25
 
15
26
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
16
27
 
package/README.md CHANGED
@@ -23,43 +23,25 @@ No cloud: all is local and fast.
23
23
 
24
24
  Interested in super fast and autonomous **[automations for zigbee2mqtt](https://github.com/Luligu/zigbee2mqtt-automations)**? Try this: https://github.com/Luligu/zigbee2mqtt-automations.
25
25
 
26
- If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-zigbee2mqtt and sponsoring it.
26
+ If you like this project and find it useful, please consider giving it a star on [GitHub](https://github.com/Luligu/matterbridge-zigbee2mqtt) and sponsoring it.
27
27
 
28
- <a href="https://www.buymeacoffee.com/luligugithub">
29
- <img src="bmc-button.svg" alt="Buy me a coffee" width="120">
30
- </a>
28
+ <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/bmc-button.svg" alt="Buy me a coffee" width="120"></a>
31
29
 
32
30
  ## Introduction
33
31
 
34
32
  Matterbridge enables non-Matter devices (Zigbee devices) to integrate with the Matter communication protocol. Bridges allow platforms that use other protocol standards to interoperate with the Matter ecosystem by integrating a Matter server into, or between, existing smart gateways, controllers, and hubs. Many commercial smart gateways provide a built-in Matter bridge that translates Matter to Zigbee or other protocols, making it possible for other ecosystems to communicate with them.
35
33
 
36
- The Matterbridge zigbee2mqtt plugin acts as a Matter Bridge, exposing all Zigbee devices and groups from [Zigbee2MQTT](https://github.com/Koenkk/zigbee2mqtt/blob/master/README.md) as Matter devices to third-party Matter controllers like Apple Home, Google Home, Amazon Alexa, and SmartThings, all while remaining local on the user's network. This allows fast, secure, and cloud-free control of Zigbee2MQTT-connected Zigbee devices from all major voice assistants as well as other third-party Matter clients.
34
+ The Matterbridge zigbee2mqtt plugin acts as a Matter Bridge, exposing all Zigbee devices, groups and scenes from [Zigbee2MQTT](https://github.com/Koenkk/zigbee2mqtt/blob/master/README.md) as Matter devices to third-party Matter controllers like Apple Home, Google Home, Amazon Alexa, and SmartThings, all while remaining local on the user's network. This allows fast, secure, and cloud-free control of Zigbee2MQTT-connected Zigbee devices from all major voice assistants as well as other third-party Matter clients.
37
35
 
38
36
  ## Prerequisites
39
37
 
40
38
  ### Matterbridge
41
39
 
42
- Follow these steps to install or update Matterbridge if it is not already installed and up to date:
43
-
44
- on Windows:
45
-
46
- ```
47
- npm install -g matterbridge --omit=dev
48
- ```
49
-
50
- on Linux and macOS (you need the necessary permissions):
51
-
52
- ```
53
- sudo npm install -g matterbridge --omit=dev
54
- ```
55
-
56
- See the complete guidelines on [Matterbridge](https://github.com/Luligu/matterbridge/blob/main/README.md) for more information.
40
+ See the guidelines on [Matterbridge](https://matterbridge.io/README.html) for more information.
57
41
 
58
42
  ### Zigbee2mqtt
59
43
 
60
- A fully working installation of zigbee2MQTT is required.
61
-
62
- See the guidelines on [zigbee2mqtt](https://github.com/Koenkk/zigbee2mqtt/blob/master/README.md) for more information.
44
+ See the guidelines on [zigbee2mqtt](https://www.zigbee2mqtt.io/) for more information.
63
45
 
64
46
  ## How to install the plugin
65
47
 
@@ -300,6 +282,69 @@ If one of your devices is not supported out of the box, open an issue and we wil
300
282
 
301
283
  ![See the screenshot here](https://github.com/Luligu/matterbridge-zigbee2mqtt/blob/main/screenshot/Smart%20button.png)
302
284
 
285
+ ## Unix socket (Linux only)
286
+
287
+ ### Create the directory for the Unix socket on the host
288
+
289
+ ```bash
290
+ # Create the directory for the Unix socket if it doesn't exist
291
+ sudo mkdir -p /var/run/mosquitto
292
+
293
+ # Make sure the mosquitto user can access the socket
294
+ sudo chown mosquitto:mosquitto /var/run/mosquitto
295
+
296
+ # Allow group users (e.g. matterbridge) to access the socket
297
+ sudo chmod 750 /var/run/mosquitto
298
+
299
+ # Optional: Add your user to the mosquitto group to access the socket without sudo
300
+ # sudo usermod -aG mosquitto $USER
301
+
302
+ # If matterbridge runs like user matterbridge, add the matterbridge user to the mosquitto group to access the socket without sudo
303
+ # sudo usermod -aG mosquitto matterbridge
304
+ ```
305
+
306
+ Log out and back in after running usermod -aG for the group changes to take effect.
307
+
308
+ ```bash
309
+ # Check the appropriate permissions for the directory
310
+ sudo -u mosquitto ls -ld /var/run/mosquitto
311
+ sudo -u mosquitto ls -l /var/run/mosquitto/mqtt.sock
312
+ ```
313
+
314
+ ### Configure mosquitto to use Unix socket on the host
315
+
316
+ Add this to your mosquitto.conf
317
+
318
+ ```
319
+ # Unix socket listener
320
+ listener 0 /var/run/mosquitto/mqtt.sock
321
+ protocol mqtt
322
+ allow_anonymous false
323
+ ```
324
+
325
+ Restart mosquitto.
326
+
327
+ ```bash
328
+ sudo systemctl restart mosquitto
329
+ ```
330
+
331
+ ### Configure docker to use Unix socket
332
+
333
+ Create the directory on the host
334
+
335
+ ```bash
336
+ mkdir -p "$HOME/mosquitto/run"
337
+ sudo chown 1883:1883 "$HOME/mosquitto/run"
338
+ sudo chmod 770 "$HOME/mosquitto/run"
339
+ ```
340
+
341
+ Add the unix socket volume for each service using it (i.e. mosquitto, zigbee2mqtt and matterbridge).
342
+
343
+ ```
344
+ volumes:
345
+ - "${HOME}/mosquitto/run:/var/run/mosquitto"
346
+ ```
347
+
303
348
  # Known issues
304
349
 
305
350
  For general controller issues check the Matterbridge Known issues section
package/dist/module.js CHANGED
@@ -12,7 +12,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
12
12
  config;
13
13
  bridgedDevices = [];
14
14
  zigbeeEntities = [];
15
- connectTimeout = 30000;
15
+ connectTimeout = 90000;
16
16
  availabilityTimeout = 10000;
17
17
  injectTimer;
18
18
  mqttHost = 'mqtt://localhost';
@@ -49,7 +49,7 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
49
49
  if (config.host && typeof config.host === 'string') {
50
50
  this.mqttHost = config.host;
51
51
  this.mqttHost =
52
- !this.mqttHost.startsWith('mqtt://') && !this.mqttHost.startsWith('mqtts://') && !this.mqttHost.startsWith('unix://') ? 'mqtt://' + this.mqttHost : this.mqttHost;
52
+ !this.mqttHost.startsWith('mqtt://') && !this.mqttHost.startsWith('mqtts://') && !this.mqttHost.startsWith('mqtt+unix://') ? 'mqtt://' + this.mqttHost : this.mqttHost;
53
53
  }
54
54
  if (config.port)
55
55
  this.mqttPort = config.port;
@@ -97,27 +97,27 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
97
97
  this.z2m.setLogDebug(config.debug);
98
98
  this.z2m.setDataPath(path.join(matterbridge.matterbridgePluginDirectory, 'matterbridge-zigbee2mqtt'));
99
99
  if (isValidString(this.mqttHost) && isValidNumber(this.mqttPort, 1, 65535)) {
100
- this.log.info(`Connecting to MQTT broker: ${this.mqttHost + ':' + this.mqttPort.toString()}`);
100
+ this.log.info(`Connecting to MQTT broker: ${this.z2m.getUrl()}`);
101
101
  this.z2m.start();
102
102
  }
103
103
  else {
104
104
  this.log.error(`Invalid MQTT broker host: ${this.mqttHost} or port: ${this.mqttPort}`);
105
105
  }
106
106
  this.z2m.on('mqtt_connect', () => {
107
- this.log.info(`MQTT broker at ${this.z2m.mqttHost}:${this.z2m.mqttPort} connected`);
107
+ this.log.info(`MQTT broker at ${this.z2m.getUrl()} connected`);
108
108
  this.z2m.subscribe(this.z2m.mqttTopic + '/#');
109
109
  });
110
110
  this.z2m.on('mqtt_subscribed', () => {
111
- this.log.info(`MQTT broker at ${this.z2m.mqttHost}:${this.z2m.mqttPort} subscribed to: ${this.z2m.mqttTopic + '/#'}`);
111
+ this.log.info(`MQTT broker at ${this.z2m.getUrl()} subscribed to: ${this.z2m.mqttTopic + '/#'}`);
112
112
  });
113
113
  this.z2m.on('close', () => {
114
- this.log.warn(`MQTT broker at ${this.z2m.mqttHost}:${this.z2m.mqttPort} closed the connection`);
114
+ this.log.warn(`MQTT broker at ${this.z2m.getUrl()} closed the connection`);
115
115
  });
116
116
  this.z2m.on('end', () => {
117
- this.log.warn(`MQTT broker at ${this.z2m.mqttHost}:${this.z2m.mqttPort} ended the connection`);
117
+ this.log.warn(`MQTT broker at ${this.z2m.getUrl()} ended the connection`);
118
118
  });
119
119
  this.z2m.on('mqtt_error', (error) => {
120
- this.log.error(`MQTT broker at ${this.z2m.mqttHost}:${this.z2m.mqttPort} error:`, error);
120
+ this.log.error(`MQTT broker at ${this.z2m.getUrl()} error:`, error);
121
121
  });
122
122
  this.z2m.on('online', () => {
123
123
  this.log.info('zigbee2MQTT is online');
@@ -33,7 +33,6 @@ export class Zigbee2MQTT extends EventEmitter {
33
33
  options = {
34
34
  clientId: 'matterbridge_' + crypto.randomBytes(8).toString('hex'),
35
35
  keepalive: 60,
36
- protocol: 'mqtt',
37
36
  protocolVersion: 5,
38
37
  reconnectPeriod: 5000,
39
38
  connectTimeout: 60 * 1000,
@@ -99,20 +98,20 @@ export class Zigbee2MQTT extends EventEmitter {
99
98
  this.log.warn('You are using mqtt:// protocol, but you provided a key. It will be ignored.');
100
99
  }
101
100
  }
102
- else if (mqttHost.startsWith('unix://')) {
103
- this.log.debug('Using unix:// protocol for MQTT connection over Unix socket');
101
+ else if (mqttHost.startsWith('mqtt+unix://')) {
102
+ this.log.debug('Using mqtt+unix:// protocol for MQTT connection over Unix socket');
104
103
  if (ca) {
105
- this.log.warn('You are using unix:// protocol, but you provided a CA certificate. It will be ignored.');
104
+ this.log.warn('You are using mqtt+unix:// protocol, but you provided a CA certificate. It will be ignored.');
106
105
  }
107
106
  if (cert) {
108
- this.log.warn('You are using unix:// protocol, but you provided a certificate. It will be ignored.');
107
+ this.log.warn('You are using mqtt+unix:// protocol, but you provided a certificate. It will be ignored.');
109
108
  }
110
109
  if (key) {
111
- this.log.warn('You are using unix:// protocol, but you provided a key. It will be ignored.');
110
+ this.log.warn('You are using mqtt+unix:// protocol, but you provided a key. It will be ignored.');
112
111
  }
113
112
  }
114
113
  else {
115
- this.log.warn('You are using an unsupported MQTT protocol. Please use mqtt:// or mqtts://.');
114
+ this.log.warn('You are using an unsupported MQTT protocol. Please use mqtt:// or mqtts:// or mqtt+unix://.');
116
115
  }
117
116
  this.z2mIsAvailabilityEnabled = false;
118
117
  this.z2mIsOnline = false;
@@ -168,7 +167,7 @@ export class Zigbee2MQTT extends EventEmitter {
168
167
  }
169
168
  }
170
169
  getUrl() {
171
- return this.mqttHost.startsWith('unix://') ? this.mqttHost : this.mqttHost + ':' + this.mqttPort.toString();
170
+ return this.mqttHost.includes('unix://') ? this.mqttHost : this.mqttHost + ':' + this.mqttPort.toString();
172
171
  }
173
172
  async start() {
174
173
  this.log.debug(`Starting connection to ${this.getUrl()}...`);
@@ -17,12 +17,12 @@
17
17
  "ui:widget": "hidden"
18
18
  },
19
19
  "host": {
20
- "description": "MQTT server host (IP address or hostname with mqtt:// or mqtts:// prefix) or unix://<SOCKET_PATH> for Unix socket on Linux (e.g. unix:///var/run/mqtt.sock). For secure connections, use the mqtts:// prefix and ensure your certificates are configured. If you use a hostname, make sure that the hostname is resolvable by the system running matterbridge.",
20
+ "description": "MQTT server host (IP address or hostname with mqtt:// or mqtts:// prefix) or unix://<SOCKET_PATH> for Unix socket on Linux (e.g. unix:///var/run/mosquitto/mqtt.sock). For secure connections, use the mqtts:// prefix and ensure your certificates are configured. If you use a hostname, make sure that the hostname is resolvable by the system running matterbridge.",
21
21
  "type": "string",
22
22
  "default": "mqtt://localhost"
23
23
  },
24
24
  "port": {
25
- "description": "MQTT server port (i.e. 1883 for mqtt:// and 8883 for mqtts://).",
25
+ "description": "MQTT server port (i.e. 1883 for mqtt:// and 8883 for mqtts://). For Unix socket, this value is ignored.",
26
26
  "type": "number",
27
27
  "default": 1883
28
28
  },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-zigbee2mqtt",
3
- "version": "3.0.3-dev-20251211-d87d63c",
3
+ "version": "3.0.3-dev-20251211-ab441ae",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-zigbee2mqtt",
9
- "version": "3.0.3-dev-20251211-d87d63c",
9
+ "version": "3.0.3-dev-20251211-ab441ae",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "moment": "2.30.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-zigbee2mqtt",
3
- "version": "3.0.3-dev-20251211-d87d63c",
3
+ "version": "3.0.3-dev-20251211-ab441ae",
4
4
  "description": "Matterbridge zigbee2mqtt plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",