matterbridge 3.0.0-edge.1 → 3.0.0-edge.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.
@@ -1,10 +1,10 @@
1
1
  import { AnsiLogger, BLUE, CYAN, YELLOW, db, debugStringify, er, hk, or, zb } from './logger/export.js';
2
2
  import { bridgedNode } from './matterbridgeDeviceTypes.js';
3
3
  import { isValidNumber, isValidObject } from './utils/export.js';
4
- import { MatterbridgeBehavior, MatterbridgeBehaviorDevice, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, } from './matterbridgeBehaviors.js';
4
+ import { MatterbridgeServer, MatterbridgeServerDevice, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer, MatterbridgeWindowCoveringServer, MatterbridgeThermostatServer, MatterbridgeFanControlServer, MatterbridgeDoorLockServer, MatterbridgeModeSelectServer, MatterbridgeValveConfigurationAndControlServer, MatterbridgeSmokeCoAlarmServer, MatterbridgeBooleanStateConfigurationServer, MatterbridgeSwitchServer, } from './matterbridgeBehaviors.js';
5
5
  import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, capitalizeFirstLetter, createUniqueId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultOccupancySensingClusterServer, lowercaseFirstLetter, updateAttribute, getClusterId, getAttributeId, setAttribute, getAttribute, checkNotLatinCharacters, generateUniqueId, subscribeAttribute, } from './matterbridgeEndpointHelpers.js';
6
6
  import { Endpoint, Lifecycle, MutableEndpoint, NamedHandler, SupportedBehaviors, VendorId } from '@matter/main';
7
- import { ClusterType, getClusterNameById, MeasurementType } from '@matter/main/types';
7
+ import { getClusterNameById, MeasurementType } from '@matter/main/types';
8
8
  import { Descriptor } from '@matter/main/clusters/descriptor';
9
9
  import { PowerSource } from '@matter/main/clusters/power-source';
10
10
  import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
@@ -26,8 +26,6 @@ import { ElectricalPowerMeasurement } from '@matter/main/clusters/electrical-pow
26
26
  import { ElectricalEnergyMeasurement } from '@matter/main/clusters/electrical-energy-measurement';
27
27
  import { AirQuality } from '@matter/main/clusters/air-quality';
28
28
  import { ConcentrationMeasurement } from '@matter/main/clusters/concentration-measurement';
29
- import { RvcRunMode } from '@matter/main/clusters/rvc-run-mode';
30
- import { RvcOperationalState } from '@matter/main/clusters/rvc-operational-state';
31
29
  import { OccupancySensing } from '@matter/main/clusters/occupancy-sensing';
32
30
  import { DescriptorServer } from '@matter/main/behaviors/descriptor';
33
31
  import { PowerSourceServer } from '@matter/main/behaviors/power-source';
@@ -57,9 +55,10 @@ import { Pm25ConcentrationMeasurementServer } from '@matter/main/behaviors/pm25-
57
55
  import { Pm10ConcentrationMeasurementServer } from '@matter/main/behaviors/pm10-concentration-measurement';
58
56
  import { RadonConcentrationMeasurementServer } from '@matter/main/behaviors/radon-concentration-measurement';
59
57
  import { TotalVolatileOrganicCompoundsConcentrationMeasurementServer } from '@matter/main/behaviors/total-volatile-organic-compounds-concentration-measurement';
60
- import { RvcRunModeServer } from '@matter/main/behaviors/rvc-run-mode';
61
- import { RvcOperationalStateServer } from '@matter/main/behaviors/rvc-operational-state';
62
- import { RvcCleanModeServer } from '@matter/main/behaviors/rvc-clean-mode';
58
+ import { FanControlServer } from '@matter/main/behaviors/fan-control';
59
+ import { ResourceMonitoring } from '@matter/main/clusters/resource-monitoring';
60
+ import { HepaFilterMonitoringServer } from '@matter/main/behaviors/hepa-filter-monitoring';
61
+ import { ActivatedCarbonFilterMonitoringServer } from '@matter/main/behaviors/activated-carbon-filter-monitoring';
63
62
  export class MatterbridgeEndpoint extends Endpoint {
64
63
  static bridgeMode = '';
65
64
  static logLevel = "info";
@@ -139,7 +138,7 @@ export class MatterbridgeEndpoint extends Endpoint {
139
138
  this.log = new AnsiLogger({ logName: options.uniqueStorageKey ?? 'MatterbridgeEndpoint', logTimestampFormat: 4, logLevel: debug === true ? "debug" : MatterbridgeEndpoint.logLevel });
140
139
  this.log.debug(`${YELLOW}new${db} MatterbridgeEndpoint: ${zb}${'0x' + firstDefinition.code.toString(16).padStart(4, '0')}${db}-${zb}${firstDefinition.name}${db} ` +
141
140
  `id: ${CYAN}${options.uniqueStorageKey}${db} number: ${CYAN}${options.endpointId}${db} taglist: ${CYAN}${options.tagList ? debugStringify(options.tagList) : 'undefined'}${db}`);
142
- this.behaviors.require(MatterbridgeBehavior, { deviceCommand: new MatterbridgeBehaviorDevice(this.log, this.commandHandler, undefined) });
141
+ this.behaviors.require(MatterbridgeServer, { deviceCommand: new MatterbridgeServerDevice(this.log, this.commandHandler, undefined) });
143
142
  }
144
143
  static async loadInstance(definition, options = {}, debug = false) {
145
144
  return new MatterbridgeEndpoint(definition, options, debug);
@@ -524,7 +523,7 @@ export class MatterbridgeEndpoint extends Endpoint {
524
523
  return this;
525
524
  }
526
525
  createOnOffClusterServer(onOff = false) {
527
- this.behaviors.require(MatterbridgeOnOffServer.for(ClusterType(OnOff.Base)), {
526
+ this.behaviors.require(MatterbridgeOnOffServer, {
528
527
  onOff,
529
528
  });
530
529
  return this;
@@ -535,6 +534,12 @@ export class MatterbridgeEndpoint extends Endpoint {
535
534
  });
536
535
  return this;
537
536
  }
537
+ createOffOnlyOnOffClusterServer(onOff = false) {
538
+ this.behaviors.require(MatterbridgeOnOffServer.with(OnOff.Feature.OffOnly), {
539
+ onOff,
540
+ });
541
+ return this;
542
+ }
538
543
  createDefaultLevelControlClusterServer(currentLevel = 254, minLevel = 1, maxLevel = 254, onLevel = null, startUpCurrentLevel = null) {
539
544
  this.behaviors.require(MatterbridgeLevelControlServer.with(LevelControl.Feature.OnOff, LevelControl.Feature.Lighting), {
540
545
  currentLevel,
@@ -550,6 +555,17 @@ export class MatterbridgeEndpoint extends Endpoint {
550
555
  });
551
556
  return this;
552
557
  }
558
+ createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
559
+ this.behaviors.require(MatterbridgeLevelControlServer, {
560
+ currentLevel,
561
+ onLevel,
562
+ options: {
563
+ executeIfOff: false,
564
+ coupleColorTempToLevel: false,
565
+ },
566
+ });
567
+ return this;
568
+ }
553
569
  createDefaultColorControlClusterServer(currentX = 0, currentY = 0, currentHue = 0, currentSaturation = 0, colorTemperatureMireds = 500, colorTempPhysicalMinMireds = 147, colorTempPhysicalMaxMireds = 500) {
554
570
  this.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.Xy, ColorControl.Feature.HueSaturation, ColorControl.Feature.ColorTemperature), {
555
571
  colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
@@ -756,6 +772,31 @@ export class MatterbridgeEndpoint extends Endpoint {
756
772
  });
757
773
  return this;
758
774
  }
775
+ createBaseFanControlClusterServer(fanMode = FanControl.FanMode.Off) {
776
+ this.behaviors.require(FanControlServer, {
777
+ fanMode,
778
+ fanModeSequence: FanControl.FanModeSequence.OffLowMedHigh,
779
+ percentSetting: 0,
780
+ percentCurrent: 0,
781
+ });
782
+ return this;
783
+ }
784
+ createDefaultHepaFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
785
+ this.behaviors.require(HepaFilterMonitoringServer, {
786
+ changeIndication,
787
+ inPlaceIndicator,
788
+ lastChangedTime,
789
+ });
790
+ return this;
791
+ }
792
+ createDefaultActivatedCarbonFilterMonitoringClusterServer(changeIndication = ResourceMonitoring.ChangeIndication.Ok, inPlaceIndicator = undefined, lastChangedTime = undefined) {
793
+ this.behaviors.require(ActivatedCarbonFilterMonitoringServer, {
794
+ changeIndication,
795
+ inPlaceIndicator,
796
+ lastChangedTime,
797
+ });
798
+ return this;
799
+ }
759
800
  createDefaultDoorLockClusterServer(lockState = DoorLock.LockState.Locked, lockType = DoorLock.LockType.DeadBolt) {
760
801
  this.behaviors.require(MatterbridgeDoorLockServer.enable({ events: { doorLockAlarm: true, lockOperation: true, lockOperationError: true } }), {
761
802
  lockState,
@@ -1156,43 +1197,4 @@ export class MatterbridgeEndpoint extends Endpoint {
1156
1197
  });
1157
1198
  return this;
1158
1199
  }
1159
- createDefaultRvcRunModeClusterServer() {
1160
- this.behaviors.require(RvcRunModeServer, {
1161
- supportedModes: [
1162
- { label: 'Idle', mode: 1, modeTags: [{ value: RvcRunMode.ModeTag.Idle }] },
1163
- { label: 'Cleaning', mode: 2, modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }] },
1164
- ],
1165
- currentMode: 1,
1166
- });
1167
- return this;
1168
- }
1169
- createDefaultRvcOperationalStateClusterServer() {
1170
- this.behaviors.require(RvcOperationalStateServer, {
1171
- phaseList: [],
1172
- currentPhase: null,
1173
- operationalStateList: [
1174
- { operationalStateId: RvcOperationalState.OperationalState.Stopped, operationalStateLabel: 'Stopped' },
1175
- { operationalStateId: RvcOperationalState.OperationalState.Running, operationalStateLabel: 'Running' },
1176
- { operationalStateId: RvcOperationalState.OperationalState.Paused, operationalStateLabel: 'Paused' },
1177
- { operationalStateId: RvcOperationalState.OperationalState.Error, operationalStateLabel: 'Error' },
1178
- { operationalStateId: RvcOperationalState.OperationalState.SeekingCharger, operationalStateLabel: 'SeekingCharger' },
1179
- { operationalStateId: RvcOperationalState.OperationalState.Charging, operationalStateLabel: 'Charging' },
1180
- { operationalStateId: RvcOperationalState.OperationalState.Docked, operationalStateLabel: 'Docked' },
1181
- ],
1182
- operationalState: RvcOperationalState.OperationalState.Stopped,
1183
- operationalError: { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error' },
1184
- });
1185
- return this;
1186
- }
1187
- createDefaultRvcCleanModeClusterServer() {
1188
- this.behaviors.require(RvcCleanModeServer, {
1189
- supportedModes: [
1190
- { label: 'Idle', mode: 1, modeTags: [] },
1191
- { label: 'Cleaning', mode: 2, modeTags: [] },
1192
- { label: 'SpotCleaning', mode: 3, modeTags: [] },
1193
- ],
1194
- currentMode: 1,
1195
- });
1196
- return this;
1197
- }
1198
1200
  }
@@ -115,8 +115,8 @@ export class MatterbridgePlatform {
115
115
  if (device.deviceName)
116
116
  this._registeredEndpointsByName.delete(device.deviceName);
117
117
  }
118
- async unregisterAllDevices() {
119
- await this.matterbridge.removeAllBridgedEndpoints(this.name);
118
+ async unregisterAllDevices(delay = 0) {
119
+ await this.matterbridge.removeAllBridgedEndpoints(this.name, delay);
120
120
  this._registeredEndpoints.clear();
121
121
  this._registeredEndpointsByName.clear();
122
122
  }
@@ -226,7 +226,7 @@ export class PluginManager {
226
226
  if (!packageJson.author)
227
227
  this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no author in package.json`);
228
228
  if (!packageJson.homepage)
229
- this.log.warn(`Plugin ${plg}${plugin.name}${wr} has no homepage in package.json`);
229
+ this.log.info(`Plugin ${plg}${plugin.name}${nf} has no homepage in package.json`);
230
230
  if (!packageJson.type || packageJson.type !== 'module')
231
231
  this.log.error(`Plugin ${plg}${plugin.name}${er} is not a module`);
232
232
  if (!packageJson.main)
@@ -748,7 +748,13 @@ export class PluginManager {
748
748
  return schema;
749
749
  }
750
750
  catch (err) {
751
- this.log.debug(`Schema file ${schemaFile} for plugin ${plg}${plugin.name}${db} not found. Loading default schema. Error: ${err instanceof Error ? err.message + '\n' + err.stack : err}`);
751
+ const nodeErr = err;
752
+ if (nodeErr.code === 'ENOENT') {
753
+ this.log.debug(`Schema file ${schemaFile} for plugin ${plg}${plugin.name}${db} not found. Loading default schema.`);
754
+ }
755
+ else {
756
+ this.log.debug(`Schema file ${schemaFile} for plugin ${plg}${plugin.name}${db} not found. Loading default schema. Error: ${err instanceof Error ? err.message + '\n' + err.stack : err}`);
757
+ }
752
758
  return this.getDefaultSchema(plugin);
753
759
  }
754
760
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.ea7910e9.css",
4
- "main.js": "./static/js/main.1fa50342.js",
4
+ "main.js": "./static/js/main.ff47208e.js",
5
5
  "static/js/453.d855a71b.chunk.js": "./static/js/453.d855a71b.chunk.js",
6
6
  "static/media/roboto-latin-700-normal.woff2": "./static/media/roboto-latin-700-normal.c4d6cab43bec89049809.woff2",
7
7
  "static/media/roboto-latin-500-normal.woff2": "./static/media/roboto-latin-500-normal.599f66a60bdf974e578e.woff2",
@@ -77,11 +77,11 @@
77
77
  "static/media/roboto-greek-ext-300-normal.woff": "./static/media/roboto-greek-ext-300-normal.60729cafbded24073dfb.woff",
78
78
  "index.html": "./index.html",
79
79
  "main.ea7910e9.css.map": "./static/css/main.ea7910e9.css.map",
80
- "main.1fa50342.js.map": "./static/js/main.1fa50342.js.map",
80
+ "main.ff47208e.js.map": "./static/js/main.ff47208e.js.map",
81
81
  "453.d855a71b.chunk.js.map": "./static/js/453.d855a71b.chunk.js.map"
82
82
  },
83
83
  "entrypoints": [
84
84
  "static/css/main.ea7910e9.css",
85
- "static/js/main.1fa50342.js"
85
+ "static/js/main.ff47208e.js"
86
86
  ]
87
87
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.1fa50342.js"></script><link href="./static/css/main.ea7910e9.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.ff47208e.js"></script><link href="./static/css/main.ea7910e9.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>