@matterbridge/core 3.8.1-dev-20260606-d6bb335 → 3.8.1-dev-20260607-08cd4da

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.
@@ -10,26 +10,26 @@ export class ExtractorHood extends MatterbridgeEndpoint {
10
10
  this.createBaseFanControlClusterServer();
11
11
  this.createDefaultHepaFilterMonitoringClusterServer(hepaCondition, hepaChangeIndication, hepaInPlaceIndicator, hepaLastChangedTime, hepaReplacementProductList);
12
12
  this.createDefaultActivatedCarbonFilterMonitoringClusterServer(activatedCarbonCondition, activatedCarbonChangeIndication, activatedCarbonInPlaceIndicator, activatedCarbonLastChangedTime, activatedCarbonReplacementProductList);
13
- void this.subscribeAttribute('fanControl', 'fanMode', (newValue, oldValue, context) => {
13
+ this.subscribeAttribute('fanControl', 'fanMode', (newValue, oldValue, context) => {
14
14
  if (context.offline === true)
15
15
  return;
16
16
  this.log.info(`Fan control fanMode attribute changed: ${newValue}`);
17
- }).catch(() => { });
18
- void this.subscribeAttribute('fanControl', 'percentSetting', (newValue, oldValue, context) => {
17
+ });
18
+ this.subscribeAttribute('fanControl', 'percentSetting', (newValue, oldValue, context) => {
19
19
  if (context.offline === true)
20
20
  return;
21
21
  this.log.info(`Fan control percentSetting attribute changed: ${newValue}`);
22
22
  void this.setAttribute('fanControl', 'percentCurrent', newValue, this.log).catch(() => { });
23
- }).catch(() => { });
24
- void this.subscribeAttribute('hepaFilterMonitoring', 'lastChangedTime', (newValue, oldValue, context) => {
23
+ });
24
+ this.subscribeAttribute('hepaFilterMonitoring', 'lastChangedTime', (newValue, oldValue, context) => {
25
25
  if (context.offline === true)
26
26
  return;
27
27
  this.log.info(`Hepa filter monitoring lastChangedTime attribute changed: ${newValue}`);
28
- }).catch(() => { });
29
- void this.subscribeAttribute('activatedCarbonFilterMonitoring', 'lastChangedTime', (newValue, oldValue, context) => {
28
+ });
29
+ this.subscribeAttribute('activatedCarbonFilterMonitoring', 'lastChangedTime', (newValue, oldValue, context) => {
30
30
  if (context.offline === true)
31
31
  return;
32
32
  this.log.info(`Activated carbon filter monitoring lastChangedTime attribute changed: ${newValue}`);
33
- }).catch(() => { });
33
+ });
34
34
  }
35
35
  }
@@ -1,8 +1,9 @@
1
+ import { MatterbridgeEndpoint } from '../matterbridgeEndpoint.js';
1
2
  export declare const setClusterMatterbridgeEndpointSpy: import("jest-mock").SpiedFunction<{
2
3
  <T extends import("@matter/node").Behavior.Type>(cluster: T, value: import("@matter/node").Behavior.StateOf<T>, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
3
- <T extends import("@matter/types").ClusterType>(cluster: T, value: T["Typing"] extends {
4
+ <T extends import("@matter/types").ClusterType>(cluster: T, value: Partial<T["Typing"] extends {
4
5
  Attributes: infer Attributes;
5
- } ? Attributes : {}, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
6
+ } ? Attributes : {}>, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
6
7
  (cluster: import("@matter/types").ClusterId | string, value: Record<string, boolean | number | bigint | string | object | undefined | null>, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
7
8
  }>;
8
9
  export declare const setAttributeMatterbridgeEndpointSpy: import("jest-mock").SpiedFunction<{
@@ -24,15 +25,15 @@ export declare const updateAttributeMatterbridgeEndpointSpy: import("jest-mock")
24
25
  (cluster: import("@matter/types").ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
25
26
  }>;
26
27
  export declare const subscribeAttributeMatterbridgeEndpointSpy: import("jest-mock").SpiedFunction<{
27
- <T extends import("@matter/node").Behavior.Type, A extends keyof import("@matter/node").Behavior.StateOf<T>>(cluster: T, attribute: A, listener: (newValue: import("@matter/node").Behavior.StateOf<T>[A], oldValue: import("@matter/node").Behavior.StateOf<T>[A], context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
28
+ <T extends import("@matter/node").Behavior.Type, A extends keyof import("@matter/node").Behavior.StateOf<T>>(cluster: T, attribute: A, listener: (newValue: import("@matter/node").Behavior.StateOf<T>[A], oldValue: import("@matter/node").Behavior.StateOf<T>[A], context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): MatterbridgeEndpoint;
28
29
  <T extends import("@matter/types").ClusterType, A extends keyof (T["Typing"] extends {
29
30
  Attributes: infer Attributes;
30
31
  } ? Attributes : {})>(cluster: T, attribute: A, listener: (newValue: (T["Typing"] extends {
31
32
  Attributes: infer Attributes;
32
33
  } ? Attributes : {})[A], oldValue: (T["Typing"] extends {
33
34
  Attributes: infer Attributes;
34
- } ? Attributes : {})[A], context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
35
- (cluster: import("@matter/types").ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): Promise<boolean>;
35
+ } ? Attributes : {})[A], context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): MatterbridgeEndpoint;
36
+ (cluster: import("@matter/types").ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: import("@matter/node").ActionContext) => void, log?: import("node-ansi-logger").AnsiLogger): MatterbridgeEndpoint;
36
37
  }>;
37
38
  export declare const triggerEventMatterbridgeEndpointSpy: import("jest-mock").SpiedFunction<{
38
39
  <T extends import("@matter/node").Behavior.Type, E extends keyof ((T extends {
@@ -13,7 +13,7 @@ import { BroadcastServer } from '@matterbridge/thread/server';
13
13
  import { dev, MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg } from '@matterbridge/types';
14
14
  import { getIntParameter, getParameter, hasParameter } from '@matterbridge/utils/cli';
15
15
  import { copyDirectory } from '@matterbridge/utils/copy-dir';
16
- import { inspectError } from '@matterbridge/utils/error';
16
+ import { getErrorMessage, inspectError } from '@matterbridge/utils/error';
17
17
  import { isValidNumber, isValidString, parseVersionString } from '@matterbridge/utils/validate';
18
18
  import { wait, withTimeout } from '@matterbridge/utils/wait';
19
19
  import { AnsiLogger, BLUE, CYAN, db, debugStringify, er, nf, or, zb } from 'node-ansi-logger';
@@ -22,7 +22,6 @@ import { toBaseDevice } from './deviceManager.js';
22
22
  import { addVirtualDevice } from './helpers.js';
23
23
  import { bridge } from './matterbridgeDeviceTypes.js';
24
24
  import { PluginManager } from './pluginManager.js';
25
- import { getErrorMessage } from './utils/export.js';
26
25
  export class MatterNode extends EventEmitter {
27
26
  matterbridge;
28
27
  pluginName;
@@ -852,7 +851,7 @@ export class MatterNode extends EventEmitter {
852
851
  for (const sub of subscriptions) {
853
852
  if (device.hasAttributeServer(sub.cluster, sub.attribute)) {
854
853
  this.log.debug(`Subscribing to endpoint ${plg}${plugin.name}${db}:${dev}${device.deviceName}${db}:${or}${device.id}${db}:${or}${device.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changes...`);
855
- await device.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
854
+ device.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
856
855
  if (!device.plugin || !device.serialNumber || !device.uniqueId)
857
856
  return;
858
857
  this.log.debug(`Bridged endpoint ${plg}${plugin.name}${db}:${dev}${device.deviceName}${db}:${or}${device.id}${db}:${or}${device.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changed to ${CYAN}${value}${db}`);
@@ -876,7 +875,7 @@ export class MatterNode extends EventEmitter {
876
875
  for (const child of device.getChildEndpoints()) {
877
876
  if (child.hasAttributeServer(sub.cluster, sub.attribute)) {
878
877
  this.log.debug(`Subscribing to child endpoint ${plg}${plugin.name}${db}:${dev}${device.deviceName}${db}:${or}${child.id}${db}:${or}${child.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changes...`);
879
- await child.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
878
+ child.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
880
879
  if (!device.plugin || !device.serialNumber || !device.uniqueId)
881
880
  return;
882
881
  this.log.debug(`Bridged child endpoint ${plg}${plugin.name}${db}:${dev}${device.deviceName}${db}:${or}${child.id}${db}:${or}${child.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changed to ${CYAN}${value}${db}`);
@@ -2105,7 +2105,7 @@ export class Matterbridge extends EventEmitter {
2105
2105
  for (const sub of subscriptions) {
2106
2106
  if (device.hasAttributeServer(sub.cluster, sub.attribute)) {
2107
2107
  this.log.debug(`Subscribing to endpoint ${or}${device.id}${db}:${or}${device.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changes...`);
2108
- await device.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
2108
+ device.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
2109
2109
  this.log.debug(`Bridged endpoint ${or}${device.id}${db}:${or}${device.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changed to ${CYAN}${isValidObject(value) ? debugStringify(value) : value}${db}`);
2110
2110
  this.frontend.wssSendAttributeChangedMessage(device.plugin, device.serialNumber, device.uniqueId, device.number, device.id, sub.cluster, sub.attribute, value);
2111
2111
  });
@@ -2113,7 +2113,7 @@ export class Matterbridge extends EventEmitter {
2113
2113
  for (const child of device.getChildEndpoints()) {
2114
2114
  if (child.hasAttributeServer(sub.cluster, sub.attribute)) {
2115
2115
  this.log.debug(`Subscribing to child endpoint ${or}${child.id}${db}:${or}${child.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changes...`);
2116
- await child.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
2116
+ child.subscribeAttribute(sub.cluster, sub.attribute, (value) => {
2117
2117
  this.log.debug(`Bridged child endpoint ${or}${child.id}${db}:${or}${child.number}${db} attribute ${dev}${sub.cluster}${db}.${dev}${sub.attribute}${db} changed to ${CYAN}${isValidObject(value) ? debugStringify(value) : value}${db}`);
2118
2118
  this.frontend.wssSendAttributeChangedMessage(device.plugin, device.serialNumber, device.uniqueId, child.number, child.id, sub.cluster, sub.attribute, value);
2119
2119
  });
@@ -96,11 +96,11 @@ export declare class MatterbridgeEndpoint extends Endpoint {
96
96
  updateAttribute<T extends Behavior.Type, A extends keyof Behavior.StateOf<T>>(cluster: T, attribute: A, value: Behavior.StateOf<T>[A], log?: AnsiLogger): Promise<boolean>;
97
97
  updateAttribute<T extends ClusterType, A extends keyof ClusterAttributesOf<T>>(cluster: T, attribute: A, value: ClusterAttributesOf<T>[A], log?: AnsiLogger): Promise<boolean>;
98
98
  updateAttribute(cluster: ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: AnsiLogger): Promise<boolean>;
99
- subscribeAttribute<T extends Behavior.Type, A extends keyof Behavior.StateOf<T>>(cluster: T, attribute: A, listener: (newValue: Behavior.StateOf<T>[A], oldValue: Behavior.StateOf<T>[A], context: ActionContext) => void, log?: AnsiLogger): Promise<boolean>;
100
- subscribeAttribute<T extends ClusterType, A extends keyof ClusterAttributesOf<T>>(cluster: T, attribute: A, listener: (newValue: ClusterAttributesOf<T>[A], oldValue: ClusterAttributesOf<T>[A], context: ActionContext) => void, log?: AnsiLogger): Promise<boolean>;
101
- subscribeAttribute(cluster: ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: ActionContext) => void, log?: AnsiLogger): Promise<boolean>;
99
+ subscribeAttribute<T extends Behavior.Type, A extends keyof Behavior.StateOf<T>>(cluster: T, attribute: A, listener: (newValue: Behavior.StateOf<T>[A], oldValue: Behavior.StateOf<T>[A], context: ActionContext) => void, log?: AnsiLogger): MatterbridgeEndpoint;
100
+ subscribeAttribute<T extends ClusterType, A extends keyof ClusterAttributesOf<T>>(cluster: T, attribute: A, listener: (newValue: ClusterAttributesOf<T>[A], oldValue: ClusterAttributesOf<T>[A], context: ActionContext) => void, log?: AnsiLogger): MatterbridgeEndpoint;
101
+ subscribeAttribute(cluster: ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: ActionContext) => void, log?: AnsiLogger): MatterbridgeEndpoint;
102
102
  setCluster<T extends Behavior.Type>(cluster: T, value: Behavior.StateOf<T>, log?: AnsiLogger): Promise<boolean>;
103
- setCluster<T extends ClusterType>(cluster: T, value: ClusterAttributesOf<T>, log?: AnsiLogger): Promise<boolean>;
103
+ setCluster<T extends ClusterType>(cluster: T, value: Partial<ClusterAttributesOf<T>>, log?: AnsiLogger): Promise<boolean>;
104
104
  setCluster(cluster: ClusterId | string, value: Record<string, boolean | number | bigint | string | object | undefined | null>, log?: AnsiLogger): Promise<boolean>;
105
105
  getCluster<T extends Behavior.Type>(cluster: T, log?: AnsiLogger): Behavior.StateOf<T> | undefined;
106
106
  getCluster<T extends ClusterType>(cluster: T, log?: AnsiLogger): ClusterAttributesOf<T> | undefined;
@@ -240,8 +240,8 @@ export class MatterbridgeEndpoint extends Endpoint {
240
240
  async updateAttribute(cluster, attribute, value, log) {
241
241
  return await updateAttribute(this, cluster, attribute, value, log);
242
242
  }
243
- async subscribeAttribute(cluster, attribute, listener, log) {
244
- return await subscribeAttribute(this, cluster, attribute, listener, log);
243
+ subscribeAttribute(cluster, attribute, listener, log) {
244
+ return subscribeAttribute(this, cluster, attribute, listener, log);
245
245
  }
246
246
  async setCluster(cluster, value, log) {
247
247
  return await setCluster(this, cluster, value, log);
@@ -56,7 +56,7 @@ export declare function getAttributeId(endpoint: Endpoint, cluster: string, attr
56
56
  export declare function getAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, log?: AnsiLogger): any;
57
57
  export declare function setAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: AnsiLogger): Promise<boolean>;
58
58
  export declare function updateAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, value: boolean | number | bigint | string | object | null, log?: AnsiLogger): Promise<boolean>;
59
- export declare function subscribeAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: ActionContext) => void, log?: AnsiLogger): Promise<boolean>;
59
+ export declare function subscribeAttribute(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, attribute: string, listener: (newValue: any, oldValue: any, context: ActionContext) => void, log?: AnsiLogger): MatterbridgeEndpoint;
60
60
  export declare function setCluster(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, value: Record<string, boolean | number | bigint | string | object | undefined | null>, log?: AnsiLogger): Promise<boolean>;
61
61
  export declare function getCluster(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, log?: AnsiLogger): Record<string, boolean | number | bigint | string | object | undefined | null> | undefined;
62
62
  export declare function triggerEvent(endpoint: MatterbridgeEndpoint, cluster: Behavior.Type | ClusterType | ClusterId | string, event: string, payload: Record<string, boolean | number | bigint | string | object | undefined | null>, log?: AnsiLogger): Promise<boolean>;
@@ -719,25 +719,21 @@ export async function updateAttribute(endpoint, cluster, attribute, value, log)
719
719
  `to ${YELLOW}${value !== null && typeof value === 'object' ? debugStringify(value) : value}${db}`);
720
720
  return true;
721
721
  }
722
- export async function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
722
+ export function subscribeAttribute(endpoint, cluster, attribute, listener, log) {
723
723
  const clusterName = getBehavior(endpoint, cluster)?.id;
724
724
  if (!clusterName) {
725
725
  endpoint.log.error(`subscribeAttribute ${hk}${attribute}${er} error: cluster not found on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
726
- return false;
727
- }
728
- if (endpoint.construction.status !== Lifecycle.Status.Active) {
729
- endpoint.log.debug(`subscribeAttribute ${hk}${clusterName}.${attribute}${db}: Endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} is in the ${BLUE}${endpoint.construction.status}${db} state`);
730
- await endpoint.construction.ready;
726
+ return endpoint;
731
727
  }
732
728
  const events = endpoint.events;
733
729
  attribute = lowercaseFirstLetter(attribute) + '$Changed';
734
730
  if (!(clusterName in events) || !(attribute in events[clusterName])) {
735
731
  endpoint.log.error(`subscribeAttribute error: Attribute ${hk}${attribute.replace('$Changed', '')}${er} not found on Cluster ${'0x' + getClusterId(endpoint, clusterName)?.toString(16).padStart(4, '0')}:${clusterName} on endpoint ${or}${endpoint.maybeId}${er}:${or}${endpoint.maybeNumber}${er}`);
736
- return false;
732
+ return endpoint;
737
733
  }
738
734
  events[clusterName][attribute].on(listener);
739
- log?.info(`${db}Subscribed endpoint ${or}${endpoint.id}${db}:${or}${endpoint.number}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
740
- return true;
735
+ log?.info(`${db}Subscribed endpoint ${or}${endpoint.maybeId}${db}:${or}${endpoint.maybeNumber}${db} attribute ${hk}${capitalizeFirstLetter(clusterName)}${db}.${hk}${attribute}${db}`);
736
+ return endpoint;
741
737
  }
742
738
  export async function setCluster(endpoint, cluster, value, log) {
743
739
  const clusterName = getBehavior(endpoint, cluster)?.id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.8.1-dev-20260606-d6bb335",
3
+ "version": "3.8.1-dev-20260607-08cd4da",
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.17.1",
133
- "@matterbridge/dgram": "3.8.1-dev-20260606-d6bb335",
134
- "@matterbridge/thread": "3.8.1-dev-20260606-d6bb335",
135
- "@matterbridge/types": "3.8.1-dev-20260606-d6bb335",
136
- "@matterbridge/utils": "3.8.1-dev-20260606-d6bb335",
133
+ "@matterbridge/dgram": "3.8.1-dev-20260607-08cd4da",
134
+ "@matterbridge/thread": "3.8.1-dev-20260607-08cd4da",
135
+ "@matterbridge/types": "3.8.1-dev-20260607-08cd4da",
136
+ "@matterbridge/utils": "3.8.1-dev-20260607-08cd4da",
137
137
  "escape-html": "1.0.3",
138
138
  "express": "5.2.1",
139
139
  "express-rate-limit": "8.5.2",