@matterbridge/core 3.7.4 → 3.7.5-dev-20260419-96eefd1

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.
@@ -141,7 +141,7 @@ export class MatterbridgeKeypadInputServer extends KeypadInputServer {
141
141
  command: 'sendKey',
142
142
  request,
143
143
  cluster: KeypadInputServer.id,
144
- attributes: this.state,
144
+ attributes: {},
145
145
  endpoint: this.endpoint,
146
146
  });
147
147
  return { status: KeypadInput.Status.Success };
@@ -189,7 +189,7 @@ export async function createMatterbridgeEnvironment(name, createOnly = false) {
189
189
  matterbridge = await Matterbridge.loadInstance(false);
190
190
  expect(matterbridge).toBeDefined();
191
191
  expect(matterbridge).toBeInstanceOf(Matterbridge);
192
- matterbridge.matterbridgeVersion = '3.7.4';
192
+ matterbridge.matterbridgeVersion = '3.7.5';
193
193
  matterbridge.bridgeMode = 'bridge';
194
194
  matterbridge.rootDirectory = path.join(HOMEDIR);
195
195
  matterbridge.homeDirectory = path.join(HOMEDIR);
@@ -83,7 +83,7 @@ import { MatterbridgeThermostatServer } from './behaviors/thermostatServer.js';
83
83
  import { MatterbridgeValveConfigurationAndControlServer } from './behaviors/valveConfigurationAndControlServer.js';
84
84
  import { MatterbridgeWindowCoveringServer } from './behaviors/windowCoveringServer.js';
85
85
  import { CommandHandler } from './matterbridgeEndpointCommandHandler.js';
86
- import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, checkNotLatinCharacters, createUniqueId, featuresFor, generateUniqueId, getApparentElectricalPowerMeasurementClusterServer, getAttribute, getAttributeId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getCluster, getClusterId, getDefaultDeviceEnergyManagementClusterServer, getDefaultDeviceEnergyManagementModeClusterServer, getDefaultElectricalEnergyMeasurementClusterServer, getDefaultElectricalPowerMeasurementClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultOccupancySensingClusterServer, getDefaultOperationalStateClusterServer, getDefaultPowerSourceBatteryClusterServer, getDefaultPowerSourceRechargeableBatteryClusterServer, getDefaultPowerSourceReplaceableBatteryClusterServer, getDefaultPowerSourceWiredClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, invokeBehaviorCommand, lowercaseFirstLetter, setAttribute, setCluster, subscribeAttribute, triggerEvent, updateAttribute, } from './matterbridgeEndpointHelpers.js';
86
+ import { addClusterServers, addFixedLabel, addOptionalClusterServers, addRequiredClusterServers, addUserLabel, checkNotLatinCharacters, createUniqueId, defaultFor, featuresFor, generateUniqueId, getApparentElectricalPowerMeasurementClusterServer, getAttribute, getAttributeId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getCluster, getClusterId, getDefaultDeviceEnergyManagementClusterServer, getDefaultDeviceEnergyManagementModeClusterServer, getDefaultElectricalEnergyMeasurementClusterServer, getDefaultElectricalPowerMeasurementClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultOccupancySensingClusterServer, getDefaultOperationalStateClusterServer, getDefaultPowerSourceBatteryClusterServer, getDefaultPowerSourceRechargeableBatteryClusterServer, getDefaultPowerSourceReplaceableBatteryClusterServer, getDefaultPowerSourceWiredClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, invokeBehaviorCommand, lowercaseFirstLetter, setAttribute, setCluster, subscribeAttribute, triggerEvent, updateAttribute, } from './matterbridgeEndpointHelpers.js';
87
87
  const MATTERBRIDGE_ENDPOINT_BRAND = Symbol('MatterbridgeEndpoint.brand');
88
88
  export function isMatterbridgeEndpoint(value) {
89
89
  if (!value || typeof value !== 'object')
@@ -210,9 +210,10 @@ export class MatterbridgeEndpoint extends Endpoint {
210
210
  const behavior = getBehavior(this, cluster);
211
211
  if (!behavior || !this.behaviors.supported[behavior.id])
212
212
  return false;
213
+ const normalizedAttribute = lowercaseFirstLetter(attribute);
213
214
  const options = this.behaviors.optionsFor(behavior);
214
- const defaults = this.behaviors.defaultsFor(behavior);
215
- return lowercaseFirstLetter(attribute) in options || lowercaseFirstLetter(attribute) in defaults;
215
+ const defaults = defaultFor(behavior, options);
216
+ return (options !== undefined && normalizedAttribute in options) || (defaults !== undefined && normalizedAttribute in defaults);
216
217
  }
217
218
  getClusterServerOptions(cluster) {
218
219
  const behavior = getBehavior(this, cluster);
@@ -296,6 +297,9 @@ export class MatterbridgeEndpoint extends Endpoint {
296
297
  if (attributeId === undefined) {
297
298
  continue;
298
299
  }
300
+ if (attributeValue === undefined) {
301
+ continue;
302
+ }
299
303
  callback(clusterName, clusterId, attributeName, attributeId, attributeValue);
300
304
  }
301
305
  }
@@ -625,7 +629,7 @@ export class MatterbridgeEndpoint extends Endpoint {
625
629
  return this;
626
630
  }
627
631
  createLevelControlClusterServer(currentLevel = 254, onLevel = null) {
628
- this.behaviors.require(MatterbridgeLevelControlServer, {
632
+ this.behaviors.require(MatterbridgeLevelControlServer.with(), {
629
633
  currentLevel,
630
634
  onLevel,
631
635
  options: {
@@ -895,7 +895,7 @@ export type CommandHandlerDataMap = {
895
895
  command: 'sendKey';
896
896
  request: KeypadInput.SendKeyRequest;
897
897
  cluster: 'keypadInput';
898
- attributes: ClusterAttributeValues<(typeof KeypadInput.Complete)['attributes']>;
898
+ attributes: {};
899
899
  endpoint: MatterbridgeEndpoint;
900
900
  };
901
901
  'resetCondition': CommandHandlerData<'ResourceMonitoring.resetCondition'>;
@@ -31,8 +31,11 @@ export declare function checkNotLatinCharacters(deviceName: string): boolean;
31
31
  export declare function generateUniqueId(deviceName: string): string;
32
32
  export declare function createUniqueId(param1: string, param2: string, param3: string, param4: string): string;
33
33
  export declare function getSemtag(semtag: Semtag, label?: string | null | undefined, mfgCode?: VendorId | null): Semtag;
34
- export declare function featuresFor(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string): Record<string, boolean | undefined>;
35
- export declare function internalFor<T extends object = Record<string, unknown>>(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string): Promise<T | undefined>;
34
+ export declare function featuresFor(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string): Partial<Record<string, boolean>>;
35
+ export declare function internalFor<T extends Behavior.Type>(endpoint: MatterbridgeEndpoint, cluster: T): Promise<InstanceType<T['Internal']> | undefined>;
36
+ export declare function internalFor<T extends object = Record<string, unknown>>(endpoint: MatterbridgeEndpoint, cluster: ClusterType | ClusterId | string): Promise<T | undefined>;
37
+ export declare function optionsFor<T extends Behavior.Type>(type: T, options: Behavior.Options<T>): Behavior.Options<T>;
38
+ export declare function defaultFor<T extends Behavior.Type>(type: T, options?: Behavior.Options<T>): Partial<Behavior.Options<T>> | undefined;
36
39
  export declare function getBehaviourTypesFromClusterServerIds(clusterServerList: ClusterId[]): Behavior.Type[];
37
40
  export declare function getBehaviourTypesFromClusterClientIds(clusterClientList: ClusterId[]): Behavior.Type[];
38
41
  export declare function getBehaviourTypeFromClusterServerId(clusterId: ClusterId): Behavior.Type;
@@ -45,7 +48,6 @@ export declare function addOptionalClusterServers(endpoint: MatterbridgeEndpoint
45
48
  export declare function addClusterServers(endpoint: MatterbridgeEndpoint, serverList: ClusterId[]): void;
46
49
  export declare function addFixedLabel(endpoint: MatterbridgeEndpoint, label: string, value: string): Promise<void>;
47
50
  export declare function addUserLabel(endpoint: MatterbridgeEndpoint, label: string, value: string): Promise<void>;
48
- export declare function optionsFor<T extends Behavior.Type>(type: T, options: Behavior.Options<T>): Behavior.Options<T>;
49
51
  export declare function getClusterId(endpoint: Endpoint, cluster: string): number | undefined;
50
52
  export declare function getAttributeId(endpoint: Endpoint, cluster: string, attribute: string): number | undefined;
51
53
  export declare function getAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, log?: AnsiLogger): any;
@@ -172,7 +172,8 @@ export function featuresFor(endpoint, cluster) {
172
172
  endpoint.log?.error(`featuresFor error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
173
173
  return {};
174
174
  }
175
- return endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)]['cluster']['supportedFeatures'];
175
+ const supportedBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)];
176
+ return supportedBehavior?.cluster.supportedFeatures ?? {};
176
177
  }
177
178
  export async function internalFor(endpoint, cluster) {
178
179
  const behaviorId = getBehavior(endpoint, cluster)?.id;
@@ -180,7 +181,28 @@ export async function internalFor(endpoint, cluster) {
180
181
  endpoint.log?.error(`internalFor error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
181
182
  return undefined;
182
183
  }
183
- return endpoint.act((agent) => agent[behaviorId]?.internal);
184
+ const supportedBehavior = endpoint.behaviors.supported[lowercaseFirstLetter(behaviorId)];
185
+ if (!supportedBehavior) {
186
+ return undefined;
187
+ }
188
+ return endpoint.act(() => endpoint.behaviors.internalsOf(supportedBehavior));
189
+ }
190
+ export function optionsFor(type, options) {
191
+ return options;
192
+ }
193
+ export function defaultFor(type, options) {
194
+ let defaults;
195
+ if (options) {
196
+ for (const key in type.defaults) {
197
+ if (key in options) {
198
+ if (!defaults) {
199
+ defaults = {};
200
+ }
201
+ defaults[key] = options[key];
202
+ }
203
+ }
204
+ }
205
+ return defaults;
184
206
  }
185
207
  export function getBehaviourTypesFromClusterServerIds(clusterServerList) {
186
208
  const behaviorTypes = [];
@@ -488,9 +510,6 @@ export async function addUserLabel(endpoint, label, value) {
488
510
  await endpoint.setAttribute(UserLabel.Cluster.id, 'labelList', labelList, endpoint.log);
489
511
  }
490
512
  }
491
- export function optionsFor(type, options) {
492
- return options;
493
- }
494
513
  export function getClusterId(endpoint, cluster) {
495
514
  return endpoint.behaviors.supported[lowercaseFirstLetter(cluster)]?.schema?.id;
496
515
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.7.4",
3
+ "version": "3.7.5-dev-20260419-96eefd1",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -130,10 +130,10 @@
130
130
  ],
131
131
  "dependencies": {
132
132
  "@matter/main": "0.16.11",
133
- "@matterbridge/dgram": "3.7.4",
134
- "@matterbridge/thread": "3.7.4",
135
- "@matterbridge/types": "3.7.4",
136
- "@matterbridge/utils": "3.7.4",
133
+ "@matterbridge/dgram": "3.7.5-dev-20260419-96eefd1",
134
+ "@matterbridge/thread": "3.7.5-dev-20260419-96eefd1",
135
+ "@matterbridge/types": "3.7.5-dev-20260419-96eefd1",
136
+ "@matterbridge/utils": "3.7.5-dev-20260419-96eefd1",
137
137
  "escape-html": "1.0.3",
138
138
  "express": "5.2.1",
139
139
  "express-rate-limit": "8.3.2",