@matterbridge/core 3.11.3-dev-20261107-92e4713 → 3.11.3-dev-20261113-e1fbc0d

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.
Files changed (35) hide show
  1. package/dist/backend.d.ts +1 -0
  2. package/dist/backend.js +7 -6
  3. package/dist/backendExpress.d.ts +0 -1
  4. package/dist/backendExpress.js +11 -1
  5. package/dist/backendWsServer.d.ts +2 -1
  6. package/dist/backendWsServer.js +113 -6
  7. package/dist/behaviors/export.d.ts +3 -0
  8. package/dist/behaviors/export.js +3 -0
  9. package/dist/behaviors/snapshot.js +0 -19
  10. package/dist/behaviors/timeSynchronizationServer.d.ts +34 -0
  11. package/dist/behaviors/timeSynchronizationServer.js +202 -0
  12. package/dist/behaviors/tlsCertificateManagementServer.d.ts +58 -0
  13. package/dist/behaviors/tlsCertificateManagementServer.js +352 -0
  14. package/dist/behaviors/tlsClientManagementServer.d.ts +21 -0
  15. package/dist/behaviors/tlsClientManagementServer.js +110 -0
  16. package/dist/behaviors/windowCoveringServer.d.ts +63 -0
  17. package/dist/behaviors/windowCoveringServer.js +3 -0
  18. package/dist/cli.js +1 -1
  19. package/dist/clusters/closure-control.js +1 -1
  20. package/dist/clusters/closure-dimension.js +1 -1
  21. package/dist/clusters/soil-measurement.js +1 -1
  22. package/dist/frontend.d.ts +2 -2
  23. package/dist/frontend.js +36 -36
  24. package/dist/matterNode.d.ts +4 -1
  25. package/dist/matterNode.js +58 -20
  26. package/dist/matterNodeHelpers.d.ts +102 -0
  27. package/dist/matterNodeHelpers.js +44 -0
  28. package/dist/matterbridge.js +15 -19
  29. package/dist/matterbridgeEndpoint.js +5 -63
  30. package/dist/matterbridgeEndpointCommandHandler.d.ts +0 -25
  31. package/dist/matterbridgeEndpointHelpers.d.ts +5 -0
  32. package/dist/matterbridgeEndpointHelpers.js +82 -3
  33. package/dist/matterbridgePlatform.js +52 -0
  34. package/dist/pluginManager.js +24 -1
  35. package/package.json +5 -5
@@ -8,11 +8,9 @@ import { inspect } from 'node:util';
8
8
  import { Crypto, Environment, LogFormat as MatterLogFormat, Logger, LogLevel as MatterLogLevel, StorageService, UINT16_MAX, UINT32_MAX, } from '@matter/general';
9
9
  import { Endpoint, ServerNode } from '@matter/node';
10
10
  import { BasicInformationServer } from '@matter/node/behaviors/basic-information';
11
- import { PowerSourceServer } from '@matter/node/behaviors/power-source';
12
11
  import { AggregatorEndpoint } from '@matter/node/endpoints/aggregator';
13
12
  import { PaseClient } from '@matter/protocol';
14
- import { PowerSource } from '@matter/types/clusters/power-source';
15
- import { DeviceTypeId, EndpointNumber, VendorId } from '@matter/types/datatype';
13
+ import { DeviceTypeId, VendorId } from '@matter/types/datatype';
16
14
  import { ManualPairingCodeCodec } from '@matter/types/schema';
17
15
  import { BroadcastServer } from '@matterbridge/thread/server';
18
16
  import { dev, MATTER_LOGGER_FILE, MATTER_STORAGE_DIR, MATTERBRIDGE_LOGGER_FILE, NODE_STORAGE_DIR, plg, typ } from '@matterbridge/types';
@@ -35,7 +33,7 @@ import { bridge } from './matterbridgeDeviceTypes.js';
35
33
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
36
34
  import { startController } from './matterController.js';
37
35
  import { matterToAnsiLogLevel } from './matterLogger.js';
38
- import { clearAdvertisingNodes, deleteAdvertisingNode, getServerNodeData, setAdvertisingNode } from './matterNodeHelpers.js';
36
+ import { clearAdvertisingNodes, deleteAdvertisingNode, getServerNodeData, rootCameraEndpoint, rootCameraOptions, setAdvertisingNode } from './matterNodeHelpers.js';
39
37
  import { PluginManager } from './pluginManager.js';
40
38
  logModuleLoaded('Matterbridge');
41
39
  export class Matterbridge extends EventEmitter {
@@ -373,6 +371,8 @@ export class Matterbridge extends EventEmitter {
373
371
  this.restartRequired = msg.params.restartRequired;
374
372
  if (msg.params?.updateRequired !== undefined)
375
373
  this.updateRequired = msg.params.updateRequired;
374
+ if (msg.params?.bridgeStatus !== undefined)
375
+ this.bridgeStatus = msg.params.bridgeStatus;
376
376
  this.server.respond({ ...msg, result: { data: this.getApiSettings(), success: true } });
377
377
  break;
378
378
  case 'matterbridge_start_plugin_server':
@@ -1084,6 +1084,7 @@ export class Matterbridge extends EventEmitter {
1084
1084
  this.log.debug(`Starting matterbridge in mode ${this.bridgeMode}`);
1085
1085
  if (hasParameter('experimental-node')) {
1086
1086
  this.log.notice(`***Starting experimental MatterNode threads in ${this.bridgeMode} mode...`);
1087
+ this.server.request({ type: 'frontend_matterbridgestatusupdate', src: 'matterbridge', dst: 'frontend', params: { status: (this.bridgeStatus = 'starting') } });
1087
1088
  for (const plugin of this.plugins.array().filter((p) => p.enabled)) {
1088
1089
  this.server.request({
1089
1090
  type: 'manager_run',
@@ -1092,6 +1093,7 @@ export class Matterbridge extends EventEmitter {
1092
1093
  params: { name: 'RootNode', workerData: { threadName: 'RootNode', sharedMatterbridge: this.getSharedMatterbridge(), pluginName: plugin.name } },
1093
1094
  });
1094
1095
  }
1096
+ this.server.request({ type: 'frontend_matterbridgestatusupdate', src: 'matterbridge', dst: 'frontend', params: { status: (this.bridgeStatus = 'started') } });
1095
1097
  this.log.notice(`***Started experimental MatterNode threads in ${this.bridgeMode} mode`);
1096
1098
  return;
1097
1099
  }
@@ -1514,7 +1516,9 @@ export class Matterbridge extends EventEmitter {
1514
1516
  }
1515
1517
  this.log.info('Matter storage reset done!');
1516
1518
  }
1517
- await this.stopMatterStorage();
1519
+ if (!hasParameter('experimental-node')) {
1520
+ await this.stopMatterStorage();
1521
+ }
1518
1522
  clearAdvertisingNodes();
1519
1523
  function unlinkSafe(path, log) {
1520
1524
  try {
@@ -2009,12 +2013,14 @@ export class Matterbridge extends EventEmitter {
2009
2013
  this.log.warn(`Invalid discriminator ${discriminator} for server node ${storeId}. Discriminator must be between 0 and 4095 (0xFFF). Generating a random discriminator...`);
2010
2014
  discriminator = PaseClient.generateRandomDiscriminator(this.environment.get(Crypto));
2011
2015
  }
2016
+ const rootCamera = hasParameter('root-camera') || Boolean(process.env.MATTERBRIDGE_CHIP_TEST);
2012
2017
  let rootEndpoint;
2013
- if (hasParameter('root-power-source') || process.env.MATTERBRIDGE_CHIP_TEST) {
2018
+ if (rootCamera) {
2014
2019
  this.log.warn(' ****************************************************************************************');
2015
- this.log.warn(' * Adding the PowerSource cluster server to the root endpoint. *');
2020
+ this.log.warn(' * Adding the PowerSource, TimeSynchronization, TlsCertificateManagement and *');
2021
+ this.log.warn(' * TlsClientManagement cluster servers to the root endpoint (root camera). *');
2016
2022
  this.log.warn(' ****************************************************************************************');
2017
- rootEndpoint = ServerNode.RootEndpoint.with(PowerSourceServer.with(PowerSource.Feature.Wired));
2023
+ rootEndpoint = rootCameraEndpoint();
2018
2024
  }
2019
2025
  else {
2020
2026
  rootEndpoint = ServerNode.RootEndpoint;
@@ -2064,17 +2070,7 @@ export class Matterbridge extends EventEmitter {
2064
2070
  configurationVersion: await storageContext.get('configurationVersion'),
2065
2071
  reachable: true,
2066
2072
  },
2067
- ...(hasParameter('root-power-source') || process.env.MATTERBRIDGE_CHIP_TEST
2068
- ? {
2069
- powerSource: {
2070
- status: PowerSource.PowerSourceStatus.Active,
2071
- order: 0,
2072
- description: 'AC Power',
2073
- endpointList: [EndpointNumber(0)],
2074
- wiredCurrentType: PowerSource.WiredCurrentType.Ac,
2075
- },
2076
- }
2077
- : {}),
2073
+ ...(rootCamera ? rootCameraOptions() : {}),
2078
2074
  });
2079
2075
  serverNode.lifecycle.commissioned.on(() => {
2080
2076
  this.log.notice(`Server node for ${storeId} commissioned successfully!`);
@@ -83,10 +83,10 @@ import { MatterbridgeTemperatureAlarmServer } from './behaviors/temperatureAlarm
83
83
  import { MatterbridgeThermostatServer } from './behaviors/thermostatServer.js';
84
84
  import { MatterbridgeValveConfigurationAndControlServer } from './behaviors/valveConfigurationAndControlServer.js';
85
85
  import { MatterbridgeWaterTankLevelMonitoringServer } from './behaviors/waterTankLevelMonitoringServer.js';
86
- import { MatterbridgeWindowCoveringServer } from './behaviors/windowCoveringServer.js';
86
+ import { MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeTiltWindowCoveringServer } from './behaviors/windowCoveringServer.js';
87
87
  import { DeviceClasses } from './matterbridgeDeviceTypes.js';
88
88
  import { CommandHandler, } from './matterbridgeEndpointCommandHandler.js';
89
- import { addClusterClients, addClusterServers, addFixedLabel, addOptionalClusterClients, addOptionalClusterServers, addRequiredClusterClients, addRequiredClusterServers, addUserLabel, checkNotLatinCharacters, createUniqueId, defaultFor, emitCommand, featuresFor, generateUniqueId, getApparentElectricalPowerMeasurementClusterServer, getAttribute, getAttributeId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getCluster, getClusterId, getDefaultDeviceEnergyManagementClusterServer, getDefaultDeviceEnergyManagementModeClusterServer, getDefaultElectricalEnergyMeasurementClusterServer, getDefaultElectricalPowerMeasurementClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultOccupancySensingClusterServer, getDefaultOperationalStateClusterServer, getDefaultPowerSourceBatteryClusterServer, getDefaultPowerSourceRechargeableBatteryClusterServer, getDefaultPowerSourceReplaceableBatteryClusterServer, getDefaultPowerSourceWiredClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultSoilMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getExportedElectricalEnergyMeasurementClusterServer, getImportedElectricalEnergyMeasurementClusterServer, invokeBehaviorCommand, lowercaseFirstLetter, setAttribute, setCluster, subscribeAttribute, subscribeCommand, triggerEvent, updateAttribute, } from './matterbridgeEndpointHelpers.js';
89
+ import { addClusterClients, addClusterServers, addFixedLabel, addOptionalClusterClients, addOptionalClusterServers, addRequiredClusterClients, addRequiredClusterServers, addUserLabel, checkNotLatinCharacters, createUniqueId, defaultFor, emitCommand, featuresFor, generateUniqueId, getApparentElectricalPowerMeasurementClusterServer, getAttribute, getAttributeId, getBehavior, getBehaviourTypesFromClusterClientIds, getBehaviourTypesFromClusterServerIds, getCluster, getClusterId, getDefaultDeviceEnergyManagementClusterServer, getDefaultDeviceEnergyManagementModeClusterServer, getDefaultElectricalEnergyMeasurementClusterServer, getDefaultElectricalPowerMeasurementClusterServer, getDefaultFlowMeasurementClusterServer, getDefaultIlluminanceMeasurementClusterServer, getDefaultLiftTiltWindowCoveringClusterServer, getDefaultOccupancySensingClusterServer, getDefaultOperationalStateClusterServer, getDefaultPowerSourceBatteryClusterServer, getDefaultPowerSourceRechargeableBatteryClusterServer, getDefaultPowerSourceReplaceableBatteryClusterServer, getDefaultPowerSourceWiredClusterServer, getDefaultPressureMeasurementClusterServer, getDefaultRelativeHumidityMeasurementClusterServer, getDefaultSoilMeasurementClusterServer, getDefaultTemperatureMeasurementClusterServer, getDefaultTiltWindowCoveringClusterServer, getDefaultWindowCoveringClusterServer, getExportedElectricalEnergyMeasurementClusterServer, getImportedElectricalEnergyMeasurementClusterServer, invokeBehaviorCommand, lowercaseFirstLetter, setAttribute, setCluster, subscribeAttribute, subscribeCommand, triggerEvent, updateAttribute, } from './matterbridgeEndpointHelpers.js';
90
90
  logModuleLoaded('MatterbridgeEndpoint');
91
91
  const deviceClassifications = {
92
92
  [DeviceClasses.Node]: DeviceClassification.Node,
@@ -844,73 +844,15 @@ export class MatterbridgeEndpoint extends Endpoint {
844
844
  }
845
845
  }
846
846
  createDefaultWindowCoveringClusterServer(positionPercent100ths = 0, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade, movementDuration = 0) {
847
- this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift), {
848
- type,
849
- numberOfActuationsLift: 0,
850
- configStatus: {
851
- operational: true,
852
- liftMovementReversed: false,
853
- liftPositionAware: true,
854
- tiltPositionAware: false,
855
- liftEncoderControlled: false,
856
- tiltEncoderControlled: false,
857
- },
858
- operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped },
859
- endProductType,
860
- mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
861
- targetPositionLiftPercent100ths: positionPercent100ths,
862
- currentPositionLiftPercent100ths: positionPercent100ths,
863
- currentPositionLiftPercentage: positionPercent100ths === null ? null : Math.floor(positionPercent100ths / 100),
864
- movementDuration,
865
- });
847
+ this.behaviors.require(MatterbridgeLiftWindowCoveringServer, getDefaultWindowCoveringClusterServer(positionPercent100ths, type, endProductType, movementDuration));
866
848
  return this;
867
849
  }
868
850
  createDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths = 0, positionTiltPercent100ths = 0, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind, movementDuration = 0) {
869
- this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift, WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
870
- type,
871
- numberOfActuationsLift: 0,
872
- numberOfActuationsTilt: 0,
873
- configStatus: {
874
- operational: true,
875
- liftMovementReversed: false,
876
- liftPositionAware: true,
877
- tiltPositionAware: true,
878
- liftEncoderControlled: false,
879
- tiltEncoderControlled: false,
880
- },
881
- operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
882
- endProductType,
883
- mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
884
- targetPositionLiftPercent100ths: positionLiftPercent100ths,
885
- currentPositionLiftPercent100ths: positionLiftPercent100ths,
886
- currentPositionLiftPercentage: positionLiftPercent100ths === null ? null : Math.floor(positionLiftPercent100ths / 100),
887
- targetPositionTiltPercent100ths: positionTiltPercent100ths,
888
- currentPositionTiltPercent100ths: positionTiltPercent100ths,
889
- currentPositionTiltPercentage: positionTiltPercent100ths === null ? null : Math.floor(positionTiltPercent100ths / 100),
890
- movementDuration,
891
- });
851
+ this.behaviors.require(MatterbridgeLiftTiltWindowCoveringServer, getDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths, positionTiltPercent100ths, type, endProductType, movementDuration));
892
852
  return this;
893
853
  }
894
854
  createDefaultTiltWindowCoveringClusterServer(positionTiltPercent100ths = 0, type = WindowCovering.WindowCoveringType.TiltBlindTiltOnly, endProductType = WindowCovering.EndProductType.TiltOnlyInteriorBlind, movementDuration = 0) {
895
- this.behaviors.require(MatterbridgeWindowCoveringServer.with(WindowCovering.Feature.Tilt, WindowCovering.Feature.PositionAwareTilt), {
896
- type,
897
- numberOfActuationsTilt: 0,
898
- configStatus: {
899
- operational: true,
900
- liftMovementReversed: false,
901
- liftPositionAware: false,
902
- tiltPositionAware: true,
903
- liftEncoderControlled: false,
904
- tiltEncoderControlled: false,
905
- },
906
- operationalStatus: { global: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
907
- endProductType,
908
- mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
909
- targetPositionTiltPercent100ths: positionTiltPercent100ths,
910
- currentPositionTiltPercent100ths: positionTiltPercent100ths,
911
- currentPositionTiltPercentage: positionTiltPercent100ths === null ? null : Math.floor(positionTiltPercent100ths / 100),
912
- movementDuration,
913
- });
855
+ this.behaviors.require(MatterbridgeTiltWindowCoveringServer, getDefaultTiltWindowCoveringClusterServer(positionTiltPercent100ths, type, endProductType, movementDuration));
914
856
  return this;
915
857
  }
916
858
  async setWindowCoveringTargetAsCurrentAndStopped() {
@@ -38,7 +38,6 @@ import type { TemperatureAlarm } from '@matter/types/clusters/temperature-alarm'
38
38
  import type { TemperatureControl } from '@matter/types/clusters/temperature-control';
39
39
  import type { Thermostat } from '@matter/types/clusters/thermostat';
40
40
  import type { ThreadNetworkDiagnostics } from '@matter/types/clusters/thread-network-diagnostics';
41
- import type { TimeSynchronization } from '@matter/types/clusters/time-synchronization';
42
41
  import type { ValveConfigurationAndControl } from '@matter/types/clusters/valve-configuration-and-control';
43
42
  import type { WaterHeaterManagement } from '@matter/types/clusters/water-heater-management';
44
43
  import type { WaterHeaterMode } from '@matter/types/clusters/water-heater-mode';
@@ -729,30 +728,6 @@ export type CommandHandlerDataMap = {
729
728
  attributes: ClusterAttributeValues<(typeof ThreadNetworkDiagnostics)['attributes']>;
730
729
  endpoint: MatterbridgeEndpoint;
731
730
  };
732
- 'setUtcTime': CommandHandlerData<'TimeSynchronization.setUtcTime'>;
733
- 'setTimeZone': CommandHandlerData<'TimeSynchronization.setTimeZone'>;
734
- 'setDstOffset': CommandHandlerData<'TimeSynchronization.setDstOffset'>;
735
- 'TimeSynchronization.setUtcTime': {
736
- command: 'setUtcTime';
737
- request: TimeSynchronization.SetUtcTimeRequest;
738
- cluster: 'timeSynchronization';
739
- attributes: ClusterAttributeValues<(typeof TimeSynchronization)['attributes']>;
740
- endpoint: MatterbridgeEndpoint;
741
- };
742
- 'TimeSynchronization.setTimeZone': {
743
- command: 'setTimeZone';
744
- request: TimeSynchronization.SetTimeZoneRequest;
745
- cluster: 'timeSynchronization';
746
- attributes: ClusterAttributeValues<(typeof TimeSynchronization)['attributes']>;
747
- endpoint: MatterbridgeEndpoint;
748
- };
749
- 'TimeSynchronization.setDstOffset': {
750
- command: 'setDstOffset';
751
- request: TimeSynchronization.SetDstOffsetRequest;
752
- cluster: 'timeSynchronization';
753
- attributes: ClusterAttributeValues<(typeof TimeSynchronization)['attributes']>;
754
- endpoint: MatterbridgeEndpoint;
755
- };
756
731
  'pauseRequest': CommandHandlerData<'DeviceEnergyManagement.pauseRequest'>;
757
732
  'resumeRequest': CommandHandlerData<'DeviceEnergyManagement.resumeRequest'>;
758
733
  'powerAdjustRequest': CommandHandlerData<'DeviceEnergyManagement.powerAdjustRequest'>;
@@ -15,6 +15,7 @@ import { PressureMeasurement } from '@matter/types/clusters/pressure-measurement
15
15
  import { RelativeHumidityMeasurement } from '@matter/types/clusters/relative-humidity-measurement';
16
16
  import { SoilMeasurement } from '@matter/types/clusters/soil-measurement';
17
17
  import { TemperatureMeasurement } from '@matter/types/clusters/temperature-measurement';
18
+ import { WindowCovering } from '@matter/types/clusters/window-covering';
18
19
  import { type ClusterId, type VendorId } from '@matter/types/datatype';
19
20
  import { type MeasurementAccuracy, type Semtag } from '@matter/types/globals';
20
21
  import { type AnsiLogger } from 'node-ansi-logger';
@@ -22,6 +23,7 @@ import { MatterbridgeDeviceEnergyManagementModeServer } from './behaviors/device
22
23
  import { MatterbridgeDeviceEnergyManagementServer } from './behaviors/deviceEnergyManagementServer.js';
23
24
  import { MatterbridgeOperationalStateServer } from './behaviors/operationalStateServer.js';
24
25
  import { MatterbridgePowerSourceServer } from './behaviors/powerSourceServer.js';
26
+ import { MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeTiltWindowCoveringServer } from './behaviors/windowCoveringServer.js';
25
27
  import type { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
26
28
  import type { CommandHandlers } from './matterbridgeEndpointCommandHandler.js';
27
29
  import type { SubscribeCommandListener } from './matterbridgeEndpointTypes.js';
@@ -227,6 +229,9 @@ export declare function getDefaultDeviceEnergyManagementClusterServer(esaType?:
227
229
  export declare function getDefaultDeviceEnergyManagementModeClusterServer(currentMode?: number, supportedModes?: DeviceEnergyManagementMode.ModeOption[]): Partial<import("@matter/node").ClusterState.Type<ClusterType.WithSupportedFeatures<DeviceEnergyManagementMode, {
228
230
  onOff: false;
229
231
  }>, typeof MatterbridgeDeviceEnergyManagementModeServer>>;
232
+ export declare function getDefaultWindowCoveringClusterServer(positionPercent100ths?: number | null, type?: WindowCovering.WindowCoveringType, endProductType?: WindowCovering.EndProductType, movementDuration?: number): Behavior.Options<typeof MatterbridgeLiftWindowCoveringServer>;
233
+ export declare function getDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths?: number | null, positionTiltPercent100ths?: number | null, type?: WindowCovering.WindowCoveringType, endProductType?: WindowCovering.EndProductType, movementDuration?: number): Behavior.Options<typeof MatterbridgeLiftTiltWindowCoveringServer>;
234
+ export declare function getDefaultTiltWindowCoveringClusterServer(positionTiltPercent100ths?: number | null, type?: WindowCovering.WindowCoveringType, endProductType?: WindowCovering.EndProductType, movementDuration?: number): Behavior.Options<typeof MatterbridgeTiltWindowCoveringServer>;
230
235
  export declare function getDefaultOperationalStateClusterServer(operationalState?: OperationalState.OperationalStateEnum, operationalStateList?: OperationalState.OperationalStateStruct[], operationalError?: OperationalState.ErrorStateStruct, phaseList?: string[] | null, currentPhase?: number | null): Partial<import("@matter/node").ClusterState.Type<ClusterType.WithSupportedFeatures<ClusterType.WithEnabledAttributes<ClusterType.WithEnabledEvents<OperationalState, "operationCompletion">, never>, {}>, typeof MatterbridgeOperationalStateServer>>;
231
236
  export declare function getDefaultTemperatureMeasurementClusterServer(measuredValue?: number | null, minMeasuredValue?: number | null, maxMeasuredValue?: number | null, tolerance?: number): Partial<import("@matter/node").ClusterState.Type<TemperatureMeasurement, typeof ClusterBehavior>>;
232
237
  export declare function getDefaultRelativeHumidityMeasurementClusterServer(measuredValue?: number | null, minMeasuredValue?: number | null, maxMeasuredValue?: number | null, tolerance?: number): Partial<import("@matter/node").ClusterState.Type<RelativeHumidityMeasurement, typeof ClusterBehavior>>;
@@ -113,7 +113,7 @@ import { NodeId } from '@matter/types/datatype';
113
113
  import { MeasurementType } from '@matter/types/globals';
114
114
  import { deepEqual } from '@matterbridge/utils/deep-equal';
115
115
  import { logModuleLoaded } from '@matterbridge/utils/loader';
116
- import { isValidArray } from '@matterbridge/utils/validate';
116
+ import { isValidArray, isValidNumber } from '@matterbridge/utils/validate';
117
117
  import { waiter } from '@matterbridge/utils/wait';
118
118
  import { BLUE, CYAN, db, debugStringify, er, hk, nf, or, wr, YELLOW, zb } from 'node-ansi-logger';
119
119
  import { MatterbridgeBindingServer } from './behaviors/bindingServer.js';
@@ -135,7 +135,7 @@ import { MatterbridgeSmokeCoAlarmServer } from './behaviors/smokeCoAlarmServer.j
135
135
  import { MatterbridgeTemperatureAlarmServer } from './behaviors/temperatureAlarmServer.js';
136
136
  import { MatterbridgeThermostatServer } from './behaviors/thermostatServer.js';
137
137
  import { MatterbridgeValveConfigurationAndControlServer } from './behaviors/valveConfigurationAndControlServer.js';
138
- import { MatterbridgeWindowCoveringServer } from './behaviors/windowCoveringServer.js';
138
+ import { MatterbridgeLiftTiltWindowCoveringServer, MatterbridgeLiftWindowCoveringServer, MatterbridgeTiltWindowCoveringServer } from './behaviors/windowCoveringServer.js';
139
139
  logModuleLoaded('MatterbridgeEndpointHelpers');
140
140
  export function capitalizeFirstLetter(name) {
141
141
  if (!name)
@@ -288,7 +288,7 @@ export function getBehaviourTypeFromClusterServerId(clusterId) {
288
288
  if (clusterId === ColorControl.id)
289
289
  return MatterbridgeColorControlServer;
290
290
  if (clusterId === WindowCovering.id)
291
- return MatterbridgeWindowCoveringServer.with('Lift', 'PositionAwareLift');
291
+ return MatterbridgeLiftWindowCoveringServer;
292
292
  if (clusterId === Thermostat.id)
293
293
  return MatterbridgeThermostatServer.with('AutoMode', 'Heating', 'Cooling');
294
294
  if (clusterId === ThermostatUserInterfaceConfiguration.id)
@@ -1116,6 +1116,85 @@ export function getDefaultDeviceEnergyManagementModeClusterServer(currentMode, s
1116
1116
  currentMode: currentMode ?? 1,
1117
1117
  });
1118
1118
  }
1119
+ function windowCoveringPercentage(positionPercent100ths, name) {
1120
+ if (positionPercent100ths === null)
1121
+ return null;
1122
+ if (!isValidNumber(positionPercent100ths, 0, 10000) || !Number.isInteger(positionPercent100ths)) {
1123
+ throw new Error(`Invalid WindowCovering ${name} ${positionPercent100ths}: expected an integer from 0 to 10000 or null`);
1124
+ }
1125
+ return Math.floor(positionPercent100ths / 100);
1126
+ }
1127
+ export function getDefaultWindowCoveringClusterServer(positionPercent100ths = 0, type = WindowCovering.WindowCoveringType.Rollershade, endProductType = WindowCovering.EndProductType.RollerShade, movementDuration = 0) {
1128
+ const currentPositionLiftPercentage = windowCoveringPercentage(positionPercent100ths, 'positionPercent100ths');
1129
+ return optionsFor(MatterbridgeLiftWindowCoveringServer, {
1130
+ type,
1131
+ numberOfActuationsLift: 0,
1132
+ configStatus: {
1133
+ operational: true,
1134
+ liftMovementReversed: false,
1135
+ liftPositionAware: true,
1136
+ tiltPositionAware: false,
1137
+ liftEncoderControlled: false,
1138
+ tiltEncoderControlled: false,
1139
+ },
1140
+ operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped },
1141
+ endProductType,
1142
+ mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
1143
+ targetPositionLiftPercent100ths: positionPercent100ths,
1144
+ currentPositionLiftPercent100ths: positionPercent100ths,
1145
+ currentPositionLiftPercentage,
1146
+ movementDuration,
1147
+ });
1148
+ }
1149
+ export function getDefaultLiftTiltWindowCoveringClusterServer(positionLiftPercent100ths = 0, positionTiltPercent100ths = 0, type = WindowCovering.WindowCoveringType.TiltBlindLift, endProductType = WindowCovering.EndProductType.InteriorBlind, movementDuration = 0) {
1150
+ const currentPositionLiftPercentage = windowCoveringPercentage(positionLiftPercent100ths, 'positionLiftPercent100ths');
1151
+ const currentPositionTiltPercentage = windowCoveringPercentage(positionTiltPercent100ths, 'positionTiltPercent100ths');
1152
+ return optionsFor(MatterbridgeLiftTiltWindowCoveringServer, {
1153
+ type,
1154
+ numberOfActuationsLift: 0,
1155
+ numberOfActuationsTilt: 0,
1156
+ configStatus: {
1157
+ operational: true,
1158
+ liftMovementReversed: false,
1159
+ liftPositionAware: true,
1160
+ tiltPositionAware: true,
1161
+ liftEncoderControlled: false,
1162
+ tiltEncoderControlled: false,
1163
+ },
1164
+ operationalStatus: { global: WindowCovering.MovementStatus.Stopped, lift: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
1165
+ endProductType,
1166
+ mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
1167
+ targetPositionLiftPercent100ths: positionLiftPercent100ths,
1168
+ currentPositionLiftPercent100ths: positionLiftPercent100ths,
1169
+ currentPositionLiftPercentage,
1170
+ targetPositionTiltPercent100ths: positionTiltPercent100ths,
1171
+ currentPositionTiltPercent100ths: positionTiltPercent100ths,
1172
+ currentPositionTiltPercentage,
1173
+ movementDuration,
1174
+ });
1175
+ }
1176
+ export function getDefaultTiltWindowCoveringClusterServer(positionTiltPercent100ths = 0, type = WindowCovering.WindowCoveringType.TiltBlindTiltOnly, endProductType = WindowCovering.EndProductType.TiltOnlyInteriorBlind, movementDuration = 0) {
1177
+ const currentPositionTiltPercentage = windowCoveringPercentage(positionTiltPercent100ths, 'positionTiltPercent100ths');
1178
+ return optionsFor(MatterbridgeTiltWindowCoveringServer, {
1179
+ type,
1180
+ numberOfActuationsTilt: 0,
1181
+ configStatus: {
1182
+ operational: true,
1183
+ liftMovementReversed: false,
1184
+ liftPositionAware: false,
1185
+ tiltPositionAware: true,
1186
+ liftEncoderControlled: false,
1187
+ tiltEncoderControlled: false,
1188
+ },
1189
+ operationalStatus: { global: WindowCovering.MovementStatus.Stopped, tilt: WindowCovering.MovementStatus.Stopped },
1190
+ endProductType,
1191
+ mode: { motorDirectionReversed: false, calibrationMode: false, maintenanceMode: false, ledFeedback: false },
1192
+ targetPositionTiltPercent100ths: positionTiltPercent100ths,
1193
+ currentPositionTiltPercent100ths: positionTiltPercent100ths,
1194
+ currentPositionTiltPercentage,
1195
+ movementDuration,
1196
+ });
1197
+ }
1119
1198
  export function getDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped, operationalStateList = [
1120
1199
  { operationalStateId: OperationalState.OperationalStateEnum.Stopped },
1121
1200
  { operationalStateId: OperationalState.OperationalStateEnum.Running },
@@ -178,6 +178,58 @@ export class MatterbridgePlatform {
178
178
  return;
179
179
  this.#server.respond({ ...msg, result: { entities: this.getSelectEntities().toSorted((keyA, keyB) => keyA.name.localeCompare(keyB.name)) } });
180
180
  break;
181
+ case 'platform_select_device':
182
+ case 'platform_unselect_device': {
183
+ if (msg.params.pluginName !== this.name)
184
+ return;
185
+ const { serialNumber, deviceName } = msg.params;
186
+ fireAndForget((async () => {
187
+ try {
188
+ if (!isValidString(serialNumber, 1) || !isValidString(deviceName, 1)) {
189
+ throw new Error(`Wrong parameters in ${msg.type}`);
190
+ }
191
+ const schema = await this.getSchema();
192
+ const properties = schema?.properties;
193
+ const blackList = isValidObject(properties) && 'blackList' in properties ? properties.blackList : undefined;
194
+ const select = isValidObject(blackList) && 'selectFrom' in blackList ? blackList.selectFrom : undefined;
195
+ if (select !== 'serial' && select !== 'name') {
196
+ throw new Error(`SelectDevice: select ${String(select)} not supported`);
197
+ }
198
+ const selected = msg.type === 'platform_select_device';
199
+ this.log.info(`${selected ? 'Selected' : 'Unselected'} device ${select} ${select === 'serial' ? serialNumber : deviceName}`);
200
+ const config = this.config;
201
+ if (config.postfix && !isValidString(config.postfix))
202
+ throw new Error('SelectDevice: postfix must be a string');
203
+ const serial = config.postfix ? serialNumber.replace('-' + config.postfix, '') : serialNumber;
204
+ const value = select === 'serial' ? serial : deviceName;
205
+ if (selected) {
206
+ if (isValidArray(config.whiteList, 1) && !config.whiteList.includes(value))
207
+ config.whiteList.push(value);
208
+ if (isValidArray(config.blackList, 1) && config.blackList.includes(value)) {
209
+ config.blackList = config.blackList.filter((item) => item !== value);
210
+ }
211
+ }
212
+ else {
213
+ if (isValidArray(config.whiteList, 1) && config.whiteList.includes(value)) {
214
+ config.whiteList = config.whiteList.filter((item) => item !== value);
215
+ }
216
+ if (isValidArray(config.blackList) && !config.blackList.includes(value))
217
+ config.blackList.push(value);
218
+ }
219
+ this.#server.request({ type: 'plugins_saveconfigfromjson', src: 'platform', dst: 'plugins', params: { name: this.name, config, restartRequired: true } });
220
+ this.#server.request({ type: 'matterbridge_apisettings', src: 'platform', dst: 'matterbridge', params: { restartRequired: true } });
221
+ this.#server.request({ type: 'frontend_restartrequired', src: 'platform', dst: 'frontend', params: { snackbar: false, fixed: false } });
222
+ this.#server.request({ type: 'frontend_refreshrequired', src: 'platform', dst: 'frontend', params: { changed: 'plugins' } });
223
+ this.#server.respond({ ...msg, result: { success: true } });
224
+ }
225
+ catch (error) {
226
+ const message = error instanceof Error ? error.message : String(error);
227
+ this.log.error(`${msg.type}: ${message}`);
228
+ this.#server.respond({ ...msg, error: message });
229
+ }
230
+ })(), this.log, `${msg.type} ${serialNumber}`);
231
+ break;
232
+ }
181
233
  case 'platform_unregister_device':
182
234
  if (msg.params.pluginName === this.name) {
183
235
  this.#server.respond({ ...msg, result: { success: true } });
@@ -217,6 +217,29 @@ export class PluginManager extends EventEmitter {
217
217
  }
218
218
  }
219
219
  break;
220
+ case 'plugins_getconfig':
221
+ {
222
+ const plugin = this.get(msg.params.name);
223
+ if (plugin) {
224
+ this.server.respond({ ...msg, result: { config: plugin.configJson } });
225
+ }
226
+ else {
227
+ this.server.respond({ ...msg, result: { config: undefined } });
228
+ }
229
+ }
230
+ break;
231
+ case 'plugins_setconfig':
232
+ {
233
+ const plugin = this.get(msg.params.name);
234
+ if (plugin) {
235
+ plugin.configJson = msg.params.config;
236
+ this.server.respond({ ...msg, result: { success: true } });
237
+ }
238
+ else {
239
+ this.server.respond({ ...msg, error: `Plugin ${msg.params.name} not found` });
240
+ }
241
+ }
242
+ break;
220
243
  case 'plugins_getschema':
221
244
  {
222
245
  const plugin = this.get(msg.params.name);
@@ -400,7 +423,7 @@ export class PluginManager extends EventEmitter {
400
423
  frontendPath: plugin.frontendPath,
401
424
  hasWhiteList: plugin.configJson?.whiteList !== undefined,
402
425
  hasBlackList: plugin.configJson?.blackList !== undefined,
403
- matter: plugin.serverNode ? getServerNodeData(plugin.serverNode) : undefined,
426
+ matter: plugin.serverNode ? getServerNodeData(plugin.serverNode) : plugin.matter,
404
427
  };
405
428
  }
406
429
  array() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.11.3-dev-20261107-92e4713",
3
+ "version": "3.11.3-dev-20261113-e1fbc0d",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -136,10 +136,10 @@
136
136
  },
137
137
  "dependencies": {
138
138
  "@matter/main": "0.18.0",
139
- "@matterbridge/dgram": "3.11.3-dev-20261107-92e4713",
140
- "@matterbridge/thread": "3.11.3-dev-20261107-92e4713",
141
- "@matterbridge/types": "3.11.3-dev-20261107-92e4713",
142
- "@matterbridge/utils": "3.11.3-dev-20261107-92e4713",
139
+ "@matterbridge/dgram": "3.11.3-dev-20261113-e1fbc0d",
140
+ "@matterbridge/thread": "3.11.3-dev-20261113-e1fbc0d",
141
+ "@matterbridge/types": "3.11.3-dev-20261113-e1fbc0d",
142
+ "@matterbridge/utils": "3.11.3-dev-20261113-e1fbc0d",
143
143
  "escape-html": "1.0.3",
144
144
  "express": "5.3.0",
145
145
  "express-rate-limit": "8.7.3",