matterbridge-zigbee2mqtt 2.5.0-dev.2 → 2.5.0-dev.4

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
@@ -17,9 +17,9 @@ New device types:
17
17
  - rainSensor
18
18
  - smokeSensor
19
19
 
20
- If your controller has issues detecting the new device type, blacklist these devices, restart, wait 5 minutes, remove the blacklist and restart again. This will create a new endpoint on the controller.
20
+ If your controller has issues detecting the new device type, blacklist these devices, restart, wait 5 minutes that the controller removes them, remove the blacklist and restart again. This will create a new endpoint on the controller.
21
21
 
22
- ## [2.5.0] - 2025-05-21
22
+ ## [2.5.0] - 2025-05-23
23
23
 
24
24
  ### Added
25
25
 
@@ -27,7 +27,11 @@ If your controller has issues detecting the new device type, blacklist these dev
27
27
  - [waterLeak]: Added waterLeakDetector device type for zigbee property "water_leak". Default to false (i.e. no alarm) since is not possible to get the property.
28
28
  - [rainSensor]: Added rainSensor device type for zigbee property "rain". Default to false (i.e. no alarm) since is not possible to get the property.
29
29
  - [smokeSensor]: Added smokeSensor device type for zigbee property "smoke". Default to false (i.e. no alarm) since is not possible to get the property.
30
- - [colorTemp]: Added conversion from color temperature to rgb for the devices that doesn't support color temperature.
30
+ - [colorTemp]: Added conversion from color temperature to rgb for the rgb devices that don't support color temperature.
31
+ - [battery]: Set batChargeLevel to warning if battery is less than 40% and the device doesn't expose battery_low.
32
+ - [battery]: Set batChargeLevel to critical if battery is less than 20% and the device doesn't expose battery_low.
33
+ - [retain]: Send retained mqtt states at startup if z2m has retain enabled.
34
+ - [logger]: Added onChangeLoggerLevel() to the platform.
31
35
 
32
36
  ### Changed
33
37
 
@@ -36,6 +40,7 @@ If your controller has issues detecting the new device type, blacklist these dev
36
40
  - [plugin]: Requires Matterbridge 3.0.3.
37
41
  - [config]: As anticipated in the previous release, the parameter postfixHostname has been removed. Use postfix if needed.
38
42
  - [colorRgb]: Changed the default device type from colorTemperatureLight to extendedColorLight to solve the SmartThings issue with colors.
43
+ - [colorTemp]: The min and max mired values are now set in the cluster.
39
44
 
40
45
  <a href="https://www.buymeacoffee.com/luligugithub">
41
46
  <img src="bmc-button.svg" alt="Buy me a coffee" width="80">
package/README.md CHANGED
@@ -151,7 +151,7 @@ These are the default vules:
151
151
  "featureBlackList": [],
152
152
  "deviceFeatureBlackList": {},
153
153
  "scenesType": "outlet",
154
- "scenesPrefix: true,
154
+ "scenesPrefix": true,
155
155
  "postfix": ""
156
156
  }
157
157
  ```
@@ -180,19 +180,7 @@ If you want to exclude "temperature" and "humidity" for the device "My motion se
180
180
  }
181
181
  ```
182
182
 
183
- The parameter postfixHostname is deprecated and will be removed in the next release. Use postfix instead if needed.
184
- By default matterbridge-zigbee2mqtt uses hostname in order to make entities unique, however in some cases
185
- you may not want this behavior. You can use "postfixHostname" boolean flag to disable this behavior:
186
-
187
- ```json
188
- {
189
- ...
190
- "postfixHostname": false
191
- ...
192
- }
193
- ```
194
-
195
- From the release 1.2.14 of Matterbridge you can edit the config file directly in the frontend.
183
+ From the release 1.2.14 of Matterbridge you can edit the config file directly in the frontend. I strongly suggest you use the integrated config editor.
196
184
 
197
185
  You can edit the config file manually if you prefer:
198
186
 
@@ -218,11 +206,46 @@ nano matterbridge-zigbee2mqtt.config.json
218
206
 
219
207
  ## What is supported?
220
208
 
221
- Out of the box, this plugin supports all possible conversion from zigbee2mqtt to Matter 1.1.
209
+ Out of the box, this plugin supports all possible conversion from zigbee2mqtt to Matter 1.4.
210
+
211
+ It also supports all clusters in the multi endpoints devices (e.g. DIY devices or the double channel switches/dimmers).
212
+
213
+ Since the Matter support in the available ecosystems (controllers) is sometimes limited and, when available, only covers Matter 1.2 specifications, some z2m devices cannot be exposed properly or cannot be exposed at all.
214
+
215
+ ## Scenes in groups and devices
216
+
217
+ With release 2.5.0 has been added support for scenes in groups and devices.
218
+
219
+ In the config select what device type you want to use to expose the command that runs the scene: 'light' | 'outlet' | 'switch' | 'mounted_switch'.
220
+
221
+ Switch is not supported by Alexa. Mounted Switch is not supported by Apple Home.
222
+
223
+ The virtual device takes the name of the group or device it belongs to, with added the name of scene. If scenesPrefix is disabled, it takes only the name of the scene. Consider that in Matter the node name is 32 characters long. Consider also that each scene name must by unique if scenesPrefix is disabled.
224
+
225
+ The state of the virtual device is always reverted to off in a few seconds.
226
+
227
+ It is possibile to disable the feature globally with featureBlackList (add "scenes" to the list) and on a per device/group base with deviceFeatureBlackList (add "scenes" to the list).
228
+
229
+ ## Availability
222
230
 
223
- The latest release also supports all clusters in the multi endpoints devices (e.g. DIY devices or the double channel switches/dimmers).
231
+ If the availability is enabled in zigbee2mqtt settings, it is used to set the corresponding device/group reachable or not.
224
232
 
225
- Since the Matter support in the available ecosystems (controllers) is sometimes limited and, when available, only covers Matter 1.1 specifications, some z2m devices cannot be exposed properly or cannot be exposed at all.
233
+ [Screenshot](https://github.com/user-attachments/assets/7e0d395f-19e4-4e7f-b263-0cae3df70be4)
234
+
235
+ ## Retain
236
+
237
+ If the retain option is enabled in zigbee2mqtt settings or device setting, at restart all retained states are updated. I suggest to use this option expecially for battery powered devices.
238
+
239
+ To enable retain globally, stop zigbee2mqtt, add retain: true to device_options and restart zigbee2mqtt.
240
+
241
+ ```
242
+ device_options:
243
+ retain: true
244
+ ```
245
+
246
+ To enable retain for a single device set it in the device settings.
247
+
248
+ [Screenshot](https://github.com/user-attachments/assets/5ae09f2a-6cff-4623-92f4-87f7721ee443)
226
249
 
227
250
  ## Unsupported devices
228
251
 
@@ -251,20 +274,6 @@ If one of your devices is not supported out of the box, open an issue and we wil
251
274
 
252
275
  ![See the screenshot here](https://github.com/Luligu/matterbridge-zigbee2mqtt/blob/main/screenshot/Smart%20button.png)
253
276
 
254
- ## Scenes in groups and devices
255
-
256
- With release 2.5.0 has been added support for scenes in groups and devices.
257
-
258
- In the config select what device type you want to use to expose the command that runs the scene: 'light' | 'outlet' | 'switch' | 'mounted_switch'.
259
-
260
- Switch is not supported by Alexa. Mounted Switch is not supported by Apple Home.
261
-
262
- The virtual device takes the name of the group or device it belongs to, with added the name of scene. If scenesPrefix is disabled, it takes only the name of the scene. Consider that in Matter the node name is 32 characters long.
263
-
264
- The state of the virtual device is always reverted to off in a few seconds.
265
-
266
- It is possibile to disable the feature globally with featureBlackList and on a per device/group base with deviceFeatureBlackList.
267
-
268
277
  # Known issues
269
278
 
270
279
  For general controller issues check the Matterbridge Known issues section
@@ -279,6 +288,6 @@ For general controller issues check the Matterbridge Known issues section
279
288
 
280
289
  ## Alexa
281
290
 
282
- In the plugin config add each switch device to the lightList or outletList. Matterbridge uses a modified switch device type without client cluster that Alexa doesn't recognize.
291
+ In the plugin config add each switch device to the lightList or outletList. Matterbridge uses a switch device type without client cluster that Alexa doesn't recognize.
283
292
 
284
293
  ## SmartThings
package/dist/entity.js CHANGED
@@ -86,6 +86,17 @@ export class ZigbeeEntity extends EventEmitter {
86
86
  return;
87
87
  if (key === 'voltage' && this.isDevice && this.device?.power_source === 'Battery')
88
88
  key = 'battery_voltage';
89
+ if (key === 'battery' && !('battery_low' in payload) && isValidNumber(value, 0, 100) && this.isDevice && this.device?.power_source === 'Battery') {
90
+ if (value < 20) {
91
+ this.updateAttributeIfChanged(this.bridgedDevice, undefined, PowerSource.Cluster.id, 'batChargeLevel', PowerSource.BatChargeLevel.Critical);
92
+ }
93
+ else if (value < 40) {
94
+ this.updateAttributeIfChanged(this.bridgedDevice, undefined, PowerSource.Cluster.id, 'batChargeLevel', PowerSource.BatChargeLevel.Warning);
95
+ }
96
+ else {
97
+ this.updateAttributeIfChanged(this.bridgedDevice, undefined, PowerSource.Cluster.id, 'batChargeLevel', PowerSource.BatChargeLevel.Ok);
98
+ }
99
+ }
89
100
  const propertyMap = this.propertyMap.get(key);
90
101
  if (propertyMap) {
91
102
  this.log.debug(`Payload entry ${CYAN}${key}${db} => name: ${CYAN}${propertyMap.name}${db} type: ${CYAN}${propertyMap.type === '' ? 'generic' : propertyMap.type}${db} ` +
@@ -143,7 +154,8 @@ export class ZigbeeEntity extends EventEmitter {
143
154
  }
144
155
  if (key === 'color_temp' && 'color_mode' in payload && payload['color_mode'] === 'color_temp') {
145
156
  this.updateAttributeIfChanged(this.bridgedDevice, undefined, ColorControl.Cluster.id, 'colorMode', ColorControl.ColorMode.ColorTemperatureMireds);
146
- this.updateAttributeIfChanged(this.bridgedDevice, undefined, ColorControl.Cluster.id, 'colorTemperatureMireds', Math.max(147, Math.min(500, typeof value === 'number' ? value : 0)));
157
+ const colorTemp = this.propertyMap.get('color_temp');
158
+ this.updateAttributeIfChanged(this.bridgedDevice, undefined, ColorControl.Cluster.id, 'colorTemperatureMireds', Math.max(colorTemp?.value_min ?? 147, Math.min(colorTemp?.value_max ?? 500, typeof value === 'number' ? value : 0)));
147
159
  }
148
160
  if (key === 'color' && 'color_mode' in payload && payload['color_mode'] === 'hs') {
149
161
  const { hue, saturation } = value;
@@ -201,15 +213,13 @@ export class ZigbeeEntity extends EventEmitter {
201
213
  const hardwareVersionString = this.platform.matterbridge.matterbridgeVersion || 'unknown';
202
214
  if (this.isDevice && this.device && this.device.friendly_name === 'Coordinator') {
203
215
  this.bridgedDevice.createDefaultBridgedDeviceBasicInformationClusterServer(this.device.friendly_name, this.serial, 0xfff1, 'zigbee2MQTT', 'Coordinator', softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
204
- return this.bridgedDevice;
205
216
  }
206
217
  else if (this.isDevice && this.device) {
207
218
  this.bridgedDevice.createDefaultBridgedDeviceBasicInformationClusterServer(this.device.friendly_name, this.serial, 0xfff1, this.device.definition ? this.device.definition.vendor : this.device.manufacturer, this.device.definition ? this.device.definition.model : this.device.model_id, softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
208
- return this.bridgedDevice;
209
219
  }
210
- if (!this.group)
211
- throw new Error('No group found');
212
- this.bridgedDevice.createDefaultBridgedDeviceBasicInformationClusterServer(this.group.friendly_name, this.serial, 0xfff1, 'zigbee2MQTT', 'Group', softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
220
+ else if (this.isGroup && this.group) {
221
+ this.bridgedDevice.createDefaultBridgedDeviceBasicInformationClusterServer(this.group.friendly_name, this.serial, 0xfff1, 'zigbee2MQTT', 'Group', softwareVersion, softwareVersionString, hardwareVersion, hardwareVersionString);
222
+ }
213
223
  return this.bridgedDevice;
214
224
  }
215
225
  addPowerSource() {
@@ -266,6 +276,12 @@ export class ZigbeeEntity extends EventEmitter {
266
276
  this.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Unlock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
267
277
  }
268
278
  }
279
+ if (this.bridgedDevice?.hasClusterServer(ColorControl.Cluster.id)) {
280
+ this.log.info(`Configuring ${this.bridgedDevice?.deviceName} ColorControl cluster`);
281
+ const colorTemp = this.propertyMap.get('color_temp');
282
+ this.bridgedDevice?.setAttribute(ColorControl.Cluster.id, 'colorTempPhysicalMinMireds', colorTemp?.value_min ?? 147, this.log);
283
+ this.bridgedDevice?.setAttribute(ColorControl.Cluster.id, 'colorTempPhysicalMaxMireds', colorTemp?.value_max ?? 500, this.log);
284
+ }
269
285
  }
270
286
  updateAttributeIfChanged(deviceEndpoint, childEndpointName, clusterId, attributeName, value, lookup) {
271
287
  if (value === undefined)
@@ -976,11 +992,11 @@ export class ZigbeeDevice extends ZigbeeEntity {
976
992
  if (mainEndpoint.clusterServersIds.includes(ColorControl.Cluster.id)) {
977
993
  if (!names.includes('color_hs') && !names.includes('color_xy')) {
978
994
  zigbeeDevice.log.debug(`Configuring device ${zigbeeDevice.ien}${device.friendly_name}${rs}${db} ColorControlCluster cluster with CT: ${names.includes('color_temp')} min: ${zigbeeDevice.propertyMap.get('color_temp')?.value_min} max: ${zigbeeDevice.propertyMap.get('color_temp')?.value_max}`);
979
- zigbeeDevice.bridgedDevice.createCtColorControlClusterServer(zigbeeDevice.propertyMap.get('color_temp')?.value_max, zigbeeDevice.propertyMap.get('color_temp')?.value_min, zigbeeDevice.propertyMap.get('color_temp')?.value_max);
995
+ zigbeeDevice.bridgedDevice.createCtColorControlClusterServer();
980
996
  }
981
997
  else {
982
998
  zigbeeDevice.log.debug(`Configuring device ${zigbeeDevice.ien}${device.friendly_name}${rs}${db} ColorControlCluster cluster with HS: ${names.includes('color_hs')} XY: ${names.includes('color_xy')} CT: ${names.includes('color_temp')} min: ${zigbeeDevice.propertyMap.get('color_temp')?.value_min} max: ${zigbeeDevice.propertyMap.get('color_temp')?.value_max}`);
983
- zigbeeDevice.bridgedDevice.createDefaultColorControlClusterServer(undefined, undefined, undefined, undefined, zigbeeDevice.propertyMap.get('color_temp')?.value_max, zigbeeDevice.propertyMap.get('color_temp')?.value_min, zigbeeDevice.propertyMap.get('color_temp')?.value_max);
999
+ zigbeeDevice.bridgedDevice.createDefaultColorControlClusterServer();
984
1000
  }
985
1001
  mainEndpoint.clusterServersIds.splice(mainEndpoint.clusterServersIds.indexOf(ColorControl.Cluster.id), 1);
986
1002
  }
package/dist/platform.js CHANGED
@@ -34,7 +34,8 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
34
34
  z2mBridgeInfo;
35
35
  z2mBridgeDevices;
36
36
  z2mBridgeGroups;
37
- z2mDeviceAvailability = new Map();
37
+ z2mEntityAvailability = new Map();
38
+ z2mEntityPayload = new Map();
38
39
  availabilityTimer;
39
40
  constructor(matterbridge, log, config) {
40
41
  super(matterbridge, log, config);
@@ -194,11 +195,14 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
194
195
  }
195
196
  });
196
197
  this.z2m.on('availability', (device, available) => {
197
- this.z2mDeviceAvailability.set(device, available);
198
+ this.z2mEntityAvailability.set(device, available);
198
199
  if (available)
199
- this.log.info(`zigbee2MQTT device ${device} is ${available ? 'online' : 'offline'}`);
200
+ this.log.info(`zigbee2MQTT entity ${device} is ${available ? 'online' : 'offline'}`);
200
201
  else
201
- this.log.warn(`zigbee2MQTT device ${device} is ${available ? 'online' : 'offline'}`);
202
+ this.log.warn(`zigbee2MQTT entity ${device} is ${available ? 'online' : 'offline'}`);
203
+ });
204
+ this.z2m.on('message', (device, payload) => {
205
+ this.z2mEntityPayload.set(device, payload);
202
206
  });
203
207
  this.z2m.on('permit_join', async (device, time, status) => {
204
208
  this.log.info(`zigbee2MQTT sent permit_join device: ${device} time: ${time} status: ${status}`);
@@ -334,10 +338,6 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
334
338
  await super.onConfigure();
335
339
  this.log.info(`Requesting update for ${this.zigbeeEntities.length} zigbee entities.`);
336
340
  for (const bridgedEntity of this.zigbeeEntities) {
337
- if (bridgedEntity.isDevice && bridgedEntity.device)
338
- await this.requestDeviceUpdate(bridgedEntity.device);
339
- if (bridgedEntity.isGroup && bridgedEntity.group)
340
- await this.requestGroupUpdate(bridgedEntity.group);
341
341
  await bridgedEntity.configure();
342
342
  if (bridgedEntity.isRouter && bridgedEntity.bridgedDevice) {
343
343
  this.log.info(`Configuring router ${bridgedEntity.bridgedDevice?.deviceName}.`);
@@ -352,15 +352,24 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
352
352
  bridgedEntity.bridgedDevice?.triggerEvent(DoorLock.Cluster.id, 'lockOperation', { lockOperationType: DoorLock.LockOperationType.Lock, operationSource: DoorLock.OperationSource.Manual, userIndex: null, fabricIndex: null, sourceNode: null }, this.log);
353
353
  }
354
354
  }
355
+ if (bridgedEntity.isDevice && bridgedEntity.device)
356
+ await this.requestDeviceUpdate(bridgedEntity.device);
357
+ if (bridgedEntity.isGroup && bridgedEntity.group)
358
+ await this.requestGroupUpdate(bridgedEntity.group);
355
359
  }
356
360
  this.availabilityTimer = setTimeout(() => {
357
- for (const [device, available] of this.z2mDeviceAvailability) {
361
+ this.log.info(`Setting availability for ${this.z2mEntityAvailability.size} entities`);
362
+ for (const [entity, available] of this.z2mEntityAvailability) {
358
363
  if (available)
359
- this.z2m.emit('ONLINE-' + device);
364
+ this.z2m.emit('ONLINE-' + entity);
360
365
  else
361
- this.z2m.emit('OFFLINE-' + device);
366
+ this.z2m.emit('OFFLINE-' + entity);
367
+ }
368
+ this.log.info(`Setting retained values for ${this.z2mEntityPayload.size} entities`);
369
+ for (const [entity, payload] of this.z2mEntityPayload) {
370
+ this.z2m.emit('MESSAGE-' + entity, payload);
362
371
  }
363
- }, 60 * 1000);
372
+ }, 10 * 1000).unref();
364
373
  if (this.config.injectPayloads) {
365
374
  this.injectTimer = setInterval(() => {
366
375
  const data = this.z2m.readConfig(path.join(this.matterbridge.matterbridgeDirectory, this.config.injectPayloads));
@@ -372,6 +381,18 @@ export class ZigbeePlatform extends MatterbridgeDynamicPlatform {
372
381
  }
373
382
  this.log.info(`Configured zigbee2mqtt dynamic platform v${this.version}`);
374
383
  }
384
+ async onChangeLoggerLevel(logLevel) {
385
+ this.log.info(`Configuring zigbee2mqtt platform logger level to ${CYAN}${logLevel}${nf}`);
386
+ this.log.logLevel = logLevel;
387
+ this.z2m.setLogLevel(logLevel);
388
+ for (const bridgedDevice of this.bridgedDevices) {
389
+ bridgedDevice.log.logLevel = logLevel;
390
+ }
391
+ for (const entity of this.zigbeeEntities) {
392
+ entity.log.logLevel = logLevel;
393
+ }
394
+ this.log.debug('Changed logger level to ' + logLevel);
395
+ }
375
396
  async onShutdown(reason) {
376
397
  await super.onShutdown(reason);
377
398
  this.z2m.removeAllListeners();
@@ -65,6 +65,9 @@ export class Zigbee2MQTT extends EventEmitter {
65
65
  setLogDebug(logDebug) {
66
66
  this.log.logLevel = logDebug ? "debug" : "info";
67
67
  }
68
+ setLogLevel(logLevel) {
69
+ this.log.logLevel = logLevel;
70
+ }
68
71
  async setDataPath(dataPath) {
69
72
  try {
70
73
  await mkdir(dataPath, { recursive: true });
@@ -80,6 +83,13 @@ export class Zigbee2MQTT extends EventEmitter {
80
83
  this.log.error('Error creating data directory:', error);
81
84
  }
82
85
  }
86
+ try {
87
+ const filePath = path.join(this.mqttDataPath, 'bridge-payloads.txt');
88
+ fs.unlinkSync(filePath);
89
+ }
90
+ catch (error) {
91
+ this.log.debug(`Error deleting bridge-payloads.txt: ${error}`);
92
+ }
83
93
  }
84
94
  getUrl() {
85
95
  return 'mqtt://' + this.mqttHost + ':' + this.mqttPort.toString();
@@ -613,6 +623,7 @@ export class Zigbee2MQTT extends EventEmitter {
613
623
  else if (service === 'set') {
614
624
  }
615
625
  else if (service === undefined) {
626
+ this.emit('message', entity, data);
616
627
  this.emit('MESSAGE-' + entity, data);
617
628
  }
618
629
  else {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-zigbee2mqtt",
3
- "version": "2.5.0-dev.2",
3
+ "version": "2.5.0-dev.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-zigbee2mqtt",
9
- "version": "2.5.0-dev.2",
9
+ "version": "2.5.0-dev.4",
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": "2.5.0-dev.2",
3
+ "version": "2.5.0-dev.4",
4
4
  "description": "Matterbridge zigbee2mqtt plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",