matterbridge 2.1.0-dev.1 → 2.1.0-dev.10

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
@@ -16,24 +16,26 @@ Tamer (https://github.com/tammeryousef1006) has created the Matterbridge Discord
16
16
  ### Breaking Changes
17
17
 
18
18
  Starting from v. 2.0.0 Matterbridge is running only in mode edge (no parameter needed and no badge in the frontend).
19
- The legacy old api have been removed.
19
+ With this release v. 2.1.0, the legacy old api of matter.js have been completely removed from Matterbridge and from all plugins.
20
+ For this reason there is no compatibility for old versions of the plugins.
21
+ You need to update all plugins you use and Matterbridge in the same moment.
22
+ I suggest to first update all plugins without restarting and then to update Matterbridge so when it restarts, all versions will be the latest.
20
23
 
21
- The frontend has a new dark and light mode. The dark mode is now the default mode.
22
- It is possible to change the mode (Classic, Dark or Light) in Settings, Matterbridge settings.
23
-
24
- ## [2.1.0.dev.1] - 2025-01-26
24
+ ## [2.1.0.dev.10] - 2025-01-31
25
25
 
26
26
  ### Added
27
27
 
28
28
  - [matterbridge]: Add MatterbridgeModeSelectServer.
29
+ - [matterbridge]: Add MatterbridgeSwitchServer.
29
30
  - [frontend]: Add api/advertise to turn on matter advertising in bridge mode.
30
31
  - [frontend]: Frontend v.2.4.0.
31
32
 
32
33
  ### Changed
33
34
 
35
+ - [package]: Removed legacy imports.
34
36
  - [package]: Update dependencies.
35
37
  - [package]: Update matter.js to 0.12.0.
36
- - [package]: Removed legacy imports.
38
+ - [package]: Update matter.js to 0.12.1.
37
39
 
38
40
  ### Fixed
39
41
 
package/dist/frontend.js CHANGED
@@ -226,7 +226,13 @@ export class Frontend {
226
226
  });
227
227
  this.expressApp.get('/api/advertise', express.json(), async (req, res) => {
228
228
  const pairingCodes = await this.matterbridge.advertiseServerNode(this.matterbridge.serverNode);
229
- res.json(pairingCodes);
229
+ if (pairingCodes) {
230
+ const { manualPairingCode, qrPairingCode } = pairingCodes;
231
+ res.json({ manualPairingCode, qrPairingCode: 'https://project-chip.github.io/connectedhomeip/qrcode.html?data=' + qrPairingCode });
232
+ }
233
+ else {
234
+ res.status(500).json({ error: 'Failed to generate pairing codes' });
235
+ }
230
236
  });
231
237
  this.expressApp.get('/api/settings', express.json(), async (req, res) => {
232
238
  this.log.debug('The frontend sent /api/settings');
@@ -830,77 +836,83 @@ export class Frontend {
830
836
  return '';
831
837
  };
832
838
  let attributes = '';
833
- Object.entries(device.state).forEach(([clusterName, clusterAttributes]) => {
834
- Object.entries(clusterAttributes).forEach(([attributeName, attributeValue]) => {
835
- if (typeof attributeValue === 'undefined')
836
- return;
837
- if (clusterName === 'onOff' && attributeName === 'onOff')
838
- attributes += `OnOff: ${attributeValue} `;
839
- if (clusterName === 'switch' && attributeName === 'currentPosition')
840
- attributes += `Position: ${attributeValue} `;
841
- if (clusterName === 'windowCovering' && attributeName === 'currentPositionLiftPercent100ths')
842
- attributes += `Cover position: ${attributeValue / 100}% `;
843
- if (clusterName === 'doorLock' && attributeName === 'lockState')
844
- attributes += `State: ${attributeValue === 1 ? 'Locked' : 'Not locked'} `;
845
- if (clusterName === 'thermostat' && attributeName === 'localTemperature')
846
- attributes += `Temperature: ${attributeValue / 100}°C `;
847
- if (clusterName === 'thermostat' && attributeName === 'occupiedHeatingSetpoint')
848
- attributes += `Heat to: ${attributeValue / 100}°C `;
849
- if (clusterName === 'thermostat' && attributeName === 'occupiedCoolingSetpoint')
850
- attributes += `Cool to: ${attributeValue / 100}°C `;
851
- if (clusterName === 'pumpConfigurationAndControl' && attributeName === 'operationMode')
852
- attributes += `Mode: ${attributeValue} `;
853
- if (clusterName === 'valveConfigurationAndControl' && attributeName === 'currentState')
854
- attributes += `State: ${attributeValue} `;
855
- if (clusterName === 'levelControl' && attributeName === 'currentLevel')
856
- attributes += `Level: ${attributeValue}% `;
857
- if (clusterName === 'colorControl' && attributeName === 'colorMode')
858
- attributes += `Mode: ${['HS', 'XY', 'CT'][attributeValue]} `;
859
- if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 0 && attributeName === 'currentHue')
860
- attributes += `Hue: ${Math.round(attributeValue)} `;
861
- if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 0 && attributeName === 'currentSaturation')
862
- attributes += `Saturation: ${Math.round(attributeValue)} `;
863
- if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 1 && attributeName === 'currentX')
864
- attributes += `X: ${Math.round(attributeValue)} `;
865
- if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 1 && attributeName === 'currentY')
866
- attributes += `Y: ${Math.round(attributeValue)} `;
867
- if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 2 && attributeName === 'colorTemperatureMireds')
868
- attributes += `ColorTemp: ${Math.round(attributeValue)} `;
869
- if (clusterName === 'booleanState' && attributeName === 'stateValue')
870
- attributes += `Contact: ${attributeValue} `;
871
- if (clusterName === 'booleanStateConfiguration' && attributeName === 'alarmsActive')
872
- attributes += `Active alarms: ${stringify(attributeValue)} `;
873
- if (clusterName === 'smokeCoAlarm' && attributeName === 'smokeState')
874
- attributes += `Smoke: ${attributeValue} `;
875
- if (clusterName === 'smokeCoAlarm' && attributeName === 'coState')
876
- attributes += `Co: ${attributeValue} `;
877
- if (clusterName === 'fanControl' && attributeName === 'fanMode')
878
- attributes += `Mode: ${attributeValue} `;
879
- if (clusterName === 'fanControl' && attributeName === 'percentCurrent')
880
- attributes += `Percent: ${attributeValue} `;
881
- if (clusterName === 'fanControl' && attributeName === 'speedCurrent')
882
- attributes += `Speed: ${attributeValue} `;
883
- if (clusterName === 'occupancySensing' && attributeName === 'occupancy')
884
- attributes += `Occupancy: ${attributeValue.occupied} `;
885
- if (clusterName === 'illuminanceMeasurement' && attributeName === 'measuredValue')
886
- attributes += `Illuminance: ${attributeValue} `;
887
- if (clusterName === 'airQuality' && attributeName === 'airQuality')
888
- attributes += `Air quality: ${attributeValue} `;
889
- if (clusterName === 'tvocMeasurement' && attributeName === 'measuredValue')
890
- attributes += `Voc: ${attributeValue} `;
891
- if (clusterName === 'temperatureMeasurement' && attributeName === 'measuredValue')
892
- attributes += `Temperature: ${attributeValue / 100}°C `;
893
- if (clusterName === 'relativeHumidityMeasurement' && attributeName === 'measuredValue')
894
- attributes += `Humidity: ${attributeValue / 100}% `;
895
- if (clusterName === 'pressureMeasurement' && attributeName === 'measuredValue')
896
- attributes += `Pressure: ${attributeValue} `;
897
- if (clusterName === 'flowMeasurement' && attributeName === 'measuredValue')
898
- attributes += `Flow: ${attributeValue} `;
899
- if (clusterName === 'fixedLabel' && attributeName === 'labelList')
900
- attributes += `${getFixedLabel(device)} `;
901
- if (clusterName === 'userLabel' && attributeName === 'labelList')
902
- attributes += `${getUserLabel(device)} `;
903
- });
839
+ device.forEachAttribute((clusterName, clusterId, attributeName, attributeId, attributeValue) => {
840
+ if (typeof attributeValue === 'undefined')
841
+ return;
842
+ if (clusterName === 'onOff' && attributeName === 'onOff')
843
+ attributes += `OnOff: ${attributeValue} `;
844
+ if (clusterName === 'switch' && attributeName === 'currentPosition')
845
+ attributes += `Position: ${attributeValue} `;
846
+ if (clusterName === 'windowCovering' && attributeName === 'currentPositionLiftPercent100ths' && isValidNumber(attributeValue, 0, 10000))
847
+ attributes += `Cover position: ${attributeValue / 100}% `;
848
+ if (clusterName === 'doorLock' && attributeName === 'lockState')
849
+ attributes += `State: ${attributeValue === 1 ? 'Locked' : 'Not locked'} `;
850
+ if (clusterName === 'thermostat' && attributeName === 'localTemperature' && isValidNumber(attributeValue))
851
+ attributes += `Temperature: ${attributeValue / 100}°C `;
852
+ if (clusterName === 'thermostat' && attributeName === 'occupiedHeatingSetpoint' && isValidNumber(attributeValue))
853
+ attributes += `Heat to: ${attributeValue / 100}°C `;
854
+ if (clusterName === 'thermostat' && attributeName === 'occupiedCoolingSetpoint' && isValidNumber(attributeValue))
855
+ attributes += `Cool to: ${attributeValue / 100}°C `;
856
+ if (clusterName === 'pumpConfigurationAndControl' && attributeName === 'operationMode')
857
+ attributes += `Mode: ${attributeValue} `;
858
+ if (clusterName === 'valveConfigurationAndControl' && attributeName === 'currentState')
859
+ attributes += `State: ${attributeValue} `;
860
+ if (clusterName === 'levelControl' && attributeName === 'currentLevel')
861
+ attributes += `Level: ${attributeValue} `;
862
+ if (clusterName === 'colorControl' && attributeName === 'colorMode' && isValidNumber(attributeValue, 0, 2))
863
+ attributes += `Mode: ${['HS', 'XY', 'CT'][attributeValue]} `;
864
+ if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 0 && attributeName === 'currentHue' && isValidNumber(attributeValue))
865
+ attributes += `Hue: ${Math.round(attributeValue)} `;
866
+ if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 0 && attributeName === 'currentSaturation' && isValidNumber(attributeValue))
867
+ attributes += `Saturation: ${Math.round(attributeValue)} `;
868
+ if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 1 && attributeName === 'currentX' && isValidNumber(attributeValue))
869
+ attributes += `X: ${Math.round(attributeValue / 655.36) / 100} `;
870
+ if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 1 && attributeName === 'currentY' && isValidNumber(attributeValue))
871
+ attributes += `Y: ${Math.round(attributeValue / 655.36) / 100} `;
872
+ if (clusterName === 'colorControl' && getAttribute(device, 'colorControl', 'colorMode') === 2 && attributeName === 'colorTemperatureMireds' && isValidNumber(attributeValue))
873
+ attributes += `ColorTemp: ${Math.round(attributeValue)} `;
874
+ if (clusterName === 'booleanState' && attributeName === 'stateValue')
875
+ attributes += `Contact: ${attributeValue} `;
876
+ if (clusterName === 'booleanStateConfiguration' && attributeName === 'alarmsActive' && isValidObject(attributeValue))
877
+ attributes += `Active alarms: ${stringify(attributeValue)} `;
878
+ if (clusterName === 'smokeCoAlarm' && attributeName === 'smokeState')
879
+ attributes += `Smoke: ${attributeValue} `;
880
+ if (clusterName === 'smokeCoAlarm' && attributeName === 'coState')
881
+ attributes += `Co: ${attributeValue} `;
882
+ if (clusterName === 'fanControl' && attributeName === 'fanMode')
883
+ attributes += `Mode: ${attributeValue} `;
884
+ if (clusterName === 'fanControl' && attributeName === 'percentCurrent')
885
+ attributes += `Percent: ${attributeValue} `;
886
+ if (clusterName === 'fanControl' && attributeName === 'speedCurrent')
887
+ attributes += `Speed: ${attributeValue} `;
888
+ if (clusterName === 'occupancySensing' && attributeName === 'occupancy' && isValidObject(attributeValue, 1))
889
+ attributes += `Occupancy: ${attributeValue.occupied} `;
890
+ if (clusterName === 'illuminanceMeasurement' && attributeName === 'measuredValue' && isValidNumber(attributeValue))
891
+ attributes += `Illuminance: ${Math.round(Math.max(Math.pow(10, attributeValue / 10000), 0))} `;
892
+ if (clusterName === 'airQuality' && attributeName === 'airQuality')
893
+ attributes += `Air quality: ${attributeValue} `;
894
+ if (clusterName === 'totalVolatileOrganicCompoundsConcentrationMeasurement' && attributeName === 'measuredValue')
895
+ attributes += `Voc: ${attributeValue} `;
896
+ if (clusterName === 'pm1ConcentrationMeasurement' && attributeName === 'measuredValue')
897
+ attributes += `Pm1: ${attributeValue} `;
898
+ if (clusterName === 'pm25ConcentrationMeasurement' && attributeName === 'measuredValue')
899
+ attributes += `Pm2.5: ${attributeValue} `;
900
+ if (clusterName === 'pm10ConcentrationMeasurement' && attributeName === 'measuredValue')
901
+ attributes += `Pm10: ${attributeValue} `;
902
+ if (clusterName === 'formaldehydeConcentrationMeasurement' && attributeName === 'measuredValue')
903
+ attributes += `CH₂O: ${attributeValue} `;
904
+ if (clusterName === 'temperatureMeasurement' && attributeName === 'measuredValue' && isValidNumber(attributeValue))
905
+ attributes += `Temperature: ${attributeValue / 100}°C `;
906
+ if (clusterName === 'relativeHumidityMeasurement' && attributeName === 'measuredValue' && isValidNumber(attributeValue))
907
+ attributes += `Humidity: ${attributeValue / 100}% `;
908
+ if (clusterName === 'pressureMeasurement' && attributeName === 'measuredValue')
909
+ attributes += `Pressure: ${attributeValue} `;
910
+ if (clusterName === 'flowMeasurement' && attributeName === 'measuredValue')
911
+ attributes += `Flow: ${attributeValue} `;
912
+ if (clusterName === 'fixedLabel' && attributeName === 'labelList')
913
+ attributes += `${getFixedLabel(device)} `;
914
+ if (clusterName === 'userLabel' && attributeName === 'labelList')
915
+ attributes += `${getUserLabel(device)} `;
904
916
  });
905
917
  return attributes.trimStart().trimEnd();
906
918
  }
@@ -1066,8 +1078,11 @@ export class Frontend {
1066
1078
  const clusterServers = endpointServer.getAllClusterServers();
1067
1079
  clusterServers.forEach((clusterServer) => {
1068
1080
  Object.entries(clusterServer.attributes).forEach(([key, value]) => {
1069
- if (clusterServer.name === 'EveHistory')
1070
- return;
1081
+ if (clusterServer.name === 'EveHistory') {
1082
+ if (['configDataGet', 'configDataSet', 'historyStatus', 'historyEntries', 'historyRequest', 'historySetTime', 'rLoc'].includes(key)) {
1083
+ return;
1084
+ }
1085
+ }
1071
1086
  if (clusterServer.name === 'Descriptor' && key === 'deviceTypeList') {
1072
1087
  value.getLocal().forEach((deviceType) => {
1073
1088
  deviceTypes.push(deviceType.deviceType);
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export * from '@matter/main/types';
5
5
  export * from './matterbridge.js';
6
6
  export * from './matterbridgeTypes.js';
7
7
  export * from './matterbridgeEndpoint.js';
8
+ export * from './matterbridgeEndpointHelpers.js';
8
9
  export * from './matterbridgeBehaviors.js';
9
10
  export * from './matterbridgeDeviceTypes.js';
10
11
  export * from './matterbridgePlatform.js';
@@ -0,0 +1 @@
1
+ export * from '@matter/node/behaviors';
@@ -0,0 +1 @@
1
+ export * from '@matter/types/clusters';
@@ -0,0 +1 @@
1
+ export * from '@matter/node/devices';
@@ -0,0 +1 @@
1
+ export { AggregatorEndpoint, ElectricalSensorEndpoint, PowerSourceEndpoint, BridgedNodeEndpoint, RootEndpoint, DeviceEnergyManagementEndpoint, OtaProviderEndpoint, OtaRequestorEndpoint } from '@matter/node/endpoints';
@@ -1,6 +1,3 @@
1
1
  export * from '@matter/main';
2
- export { AggregatorEndpoint } from '@matter/main/endpoints';
3
- export * from '@matter/main/devices';
4
- export * from '@matter/main/behaviors';
5
- export { FabricAction, MdnsService, PaseClient } from '@matter/main/protocol';
2
+ export { SemanticNamespace, ClosureTag, CompassDirectionTag, CompassLocationTag, DirectionTag, ElectricalMeasurementTag, LaundryTag, LevelTag, LocationTag, NumberTag, PositionTag, PowerSourceTag, RefrigeratorTag, RoomAirConditionerTag, SwitchesTag, } from '@matter/main';
6
3
  export { AttributeElement, ClusterElement, ClusterModel, CommandElement, EventElement, FieldElement } from '@matter/main/model';
@@ -0,0 +1,2 @@
1
+ export * from '@matter/types';
2
+ export { ClusterRegistry } from '@matter/types';
@@ -7,7 +7,7 @@ import path from 'path';
7
7
  import { randomBytes } from 'crypto';
8
8
  import { NodeStorageManager } from './storage/export.js';
9
9
  import { AnsiLogger, UNDERLINE, UNDERLINEOFF, YELLOW, db, debugStringify, BRIGHT, RESET, er, nf, rs, wr, RED, GREEN, zb, CYAN, nt } from './logger/export.js';
10
- import { logInterfaces, wait, waiter, copyDirectory, getParameter, getIntParameter, hasParameter } from './utils/utils.js';
10
+ import { logInterfaces, copyDirectory, getParameter, getIntParameter, hasParameter } from './utils/utils.js';
11
11
  import { PluginManager } from './pluginManager.js';
12
12
  import { DeviceManager } from './deviceManager.js';
13
13
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
@@ -140,10 +140,6 @@ export class Matterbridge extends EventEmitter {
140
140
  }
141
141
  async destroyInstance() {
142
142
  await this.cleanup('destroying instance...', false);
143
- await waiter('destroying instance...', () => {
144
- return this.initialized === false && this.execRunningCount <= 0 ? true : false;
145
- }, false, 60000, 100, false);
146
- await wait(1000, 'Wait for the global node_modules and matterbridge version', false);
147
143
  }
148
144
  async initialize() {
149
145
  if (hasParameter('service'))
@@ -1021,15 +1017,6 @@ export class Matterbridge extends EventEmitter {
1021
1017
  catch (error) {
1022
1018
  }
1023
1019
  if (this.nodeStorage && this.nodeContext) {
1024
- this.log.info('Saving registered devices...');
1025
- const serializedRegisteredDevices = [];
1026
- this.devices.forEach(async (device) => {
1027
- const serializedMatterbridgeDevice = MatterbridgeEndpoint.serialize(device);
1028
- if (serializedMatterbridgeDevice)
1029
- serializedRegisteredDevices.push(serializedMatterbridgeDevice);
1030
- });
1031
- await this.nodeContext.set('devices', serializedRegisteredDevices);
1032
- this.log.info(`Saved registered devices (${serializedRegisteredDevices?.length})`);
1033
1020
  this.log.debug(`Closing node storage context for ${plg}Matterbridge${db}...`);
1034
1021
  await this.nodeContext.close();
1035
1022
  this.nodeContext = undefined;
@@ -18,6 +18,7 @@ import { ThermostatServer } from '@matter/main/behaviors/thermostat';
18
18
  import { ValveConfigurationAndControlServer } from '@matter/main/behaviors/valve-configuration-and-control';
19
19
  import { ModeSelectServer } from '@matter/main/behaviors/mode-select';
20
20
  import { SmokeCoAlarmServer } from '@matter/main/behaviors/smoke-co-alarm';
21
+ import { SwitchServer } from '@matter/main/behaviors/switch';
21
22
  export class MatterbridgeBehaviorDevice {
22
23
  log;
23
24
  commandHandler;
@@ -338,3 +339,7 @@ export class MatterbridgeBooleanStateConfigurationServer extends BooleanStateCon
338
339
  super.enableDisableAlarm({ alarmsToEnableDisable });
339
340
  }
340
341
  }
342
+ export class MatterbridgeSwitchServer extends SwitchServer {
343
+ initialize() {
344
+ }
345
+ }