matterbridge-example-dynamic-platform 3.0.3-dev-20260829-d83e6fe → 3.0.3-dev-20260830-a347a26

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
@@ -57,6 +57,7 @@ If you like this project and find it useful, please consider giving it a star on
57
57
  - [devices]: Update `RoboticVacuumCleaner`, `Oven.addCabinet`, `Cooktop.addSurface`, and `Refrigerator.addCabinet` to the options object form, removing the last `typescript/no-deprecated` oxlint suppressions in the platform.
58
58
  - [platform]: Make the local `addDevice` helper generic (`addDevice<T extends MatterbridgeEndpoint>`) so it returns the same subclass it was given, removing 9 `typescript/no-unsafe-type-assertion` oxlint suppressions at its call sites.
59
59
  - [platform]: Type `initializePlugin`'s `config` parameter directly as `DynamicPlatformConfig`, matching the pattern used in production plugins, removing the last `typescript/no-unsafe-type-assertion` cast on plugin startup.
60
+ - [illuminance]: `luxToMatter`/`matterToLux` were missing the `+ 1` offset required by the Matter spec's `MeasuredValue = 10,000 x log10(illuminance) + 1` formula (Matter 1.6.0 § 2.2.5.1); every encoded illuminance value was off by 1. Fixed and aligned with the corrected implementation in matterbridge's `packages/utils`.
60
61
 
61
62
  <a href="https://www.buymeacoffee.com/luligugithub"><img src="https://matterbridge.io/assets/bmc-button.svg" alt="Buy me a coffee" width="80"></a>
62
63
 
package/dist/module.js CHANGED
@@ -2,26 +2,20 @@ import { aggregator, airPurifier, airQualitySensor, bridgedNode, closure, colorT
2
2
  import { AirConditioner, BasicVideoPlayer, BatteryStorage, Closure, Cooktop, Dishwasher, Evse, ExtractorHood, HeatPump, IrrigationSystem, LaundryDryer, LaundryWasher, MatterbridgeClosureControlServer, MicrowaveOven, Oven, Refrigerator, RoboticVacuumCleaner, SoilSensor, SolarPower, Speaker, WaterHeater, } from 'matterbridge/devices';
3
3
  import { debugStringify } from 'matterbridge/logger';
4
4
  import { ClosureCoveringTag, ClosurePanelTag, ClosureTag, ClosureWindowTag, CommonAreaNamespaceTag, CommonLocationTag, CommonNumberTag, CommonPositionTag, RefrigeratorTag, SwitchesTag, UINT16_MAX, UINT32_MAX, } from 'matterbridge/matter';
5
- import { AirQuality, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, ClosureControl, ClosureDimension, ColorControl, Descriptor, DeviceEnergyManagement, DoorLock, ElectricalEnergyMeasurement, ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, FanControl, FlowMeasurement, FormaldehydeConcentrationMeasurement, Identify, IlluminanceMeasurement, LevelControl, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OperationalState, OvenMode, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PressureMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RvcCleanMode, RvcOperationalState, RvcRunMode, SmokeCoAlarm, TemperatureMeasurement, Thermostat, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, } from 'matterbridge/matter/clusters';
5
+ import { AirQuality, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, ClosureControl, ClosureDimension, ColorControl, DeviceEnergyManagement, DoorLock, ElectricalEnergyMeasurement, ElectricalPowerMeasurement, EnergyEvse, EnergyEvseMode, FanControl, FlowMeasurement, FormaldehydeConcentrationMeasurement, Identify, IlluminanceMeasurement, LevelControl, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OperationalState, OvenMode, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PressureMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RvcCleanMode, RvcOperationalState, RvcRunMode, SmokeCoAlarm, TemperatureMeasurement, Thermostat, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, } from 'matterbridge/matter/clusters';
6
6
  import { ThreeLevelAuto } from 'matterbridge/matter/types';
7
- import { fireAndForget, getEnumDescription, isValidBoolean, isValidNumber, isValidObject, isValidString } from 'matterbridge/utils';
7
+ import { fireAndForget, getEnumDescription, isValidBoolean, isValidNumber, isValidObject, isValidString, parseVersionString } from 'matterbridge/utils';
8
8
  function luxToMatter(lux) {
9
- if (!Number.isFinite(lux) || lux <= 0)
9
+ if (!Number.isFinite(lux) || lux < 1)
10
10
  return 0;
11
- const encoded = 10000 * Math.log10(lux);
12
- if (!Number.isFinite(encoded) || encoded < 0)
13
- return 0;
14
- return Math.round(Math.min(encoded, 0xfffe));
11
+ const encoded = Math.round(10000 * Math.log10(lux) + 1);
12
+ return Math.min(encoded, 0xfffe);
15
13
  }
16
14
  function matterToLux(value) {
17
15
  if (!Number.isFinite(value) || value <= 0)
18
16
  return 0;
19
17
  const v = Math.min(value, 0xfffe);
20
- const lux = Math.pow(10, v / 10000);
21
- return Math.round(lux < 0 ? 0 : lux);
22
- }
23
- function isDeviceTypeList(value) {
24
- return Array.isArray(value);
18
+ return Math.round(Math.pow(10, (v - 1) / 10000));
25
19
  }
26
20
  export default function initializePlugin(matterbridge, log, config) {
27
21
  return new ExampleMatterbridgeDynamicPlatform(matterbridge, log, config);
@@ -2699,14 +2693,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
2699
2693
  return undefined;
2700
2694
  this.setSelectDevice(device.serialNumber, device.deviceName, undefined, 'hub');
2701
2695
  if (this.validateDevice(device.deviceName)) {
2702
- device.softwareVersion = Number.parseInt(this.version.replace(/\D/g, ''));
2696
+ device.softwareVersion = parseVersionString(this.version);
2703
2697
  device.softwareVersionString = this.version === '' ? 'Unknown' : this.version;
2704
- device.hardwareVersion = Number.parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, ''));
2698
+ device.hardwareVersion = parseVersionString(this.matterbridge.matterbridgeVersion);
2705
2699
  device.hardwareVersionString = this.matterbridge.matterbridgeVersion;
2706
2700
  device.softwareVersion = isValidNumber(device.softwareVersion, 0, UINT32_MAX) ? device.softwareVersion : undefined;
2707
- device.softwareVersionString = isValidString(device.softwareVersionString) ? device.softwareVersionString.slice(0, 64) : undefined;
2701
+ device.softwareVersionString = isValidString(device.softwareVersionString, 1) ? device.softwareVersionString.slice(0, 64) : undefined;
2708
2702
  device.hardwareVersion = isValidNumber(device.hardwareVersion, 0, UINT16_MAX) ? device.hardwareVersion : undefined;
2709
- device.hardwareVersionString = isValidString(device.hardwareVersionString) ? device.hardwareVersionString.slice(0, 64) : undefined;
2703
+ device.hardwareVersionString = isValidString(device.hardwareVersionString, 1) ? device.hardwareVersionString.slice(0, 64) : undefined;
2710
2704
  const options = device.getClusterServerOptions(BridgedDeviceBasicInformation.id);
2711
2705
  if (options) {
2712
2706
  options.softwareVersion = device.softwareVersion ?? 1;
@@ -2714,17 +2708,6 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
2714
2708
  options.hardwareVersion = device.hardwareVersion ?? 1;
2715
2709
  options.hardwareVersionString = device.hardwareVersionString ?? '1.0.0';
2716
2710
  }
2717
- if (device.mode === undefined && !device.deviceTypes.has(bridgedNode.code)) {
2718
- device.deviceTypes.set(bridgedNode.code, bridgedNode);
2719
- const options = device.getClusterServerOptions(Descriptor);
2720
- const deviceTypeList = options?.deviceTypeList;
2721
- if (isDeviceTypeList(deviceTypeList)) {
2722
- if (!deviceTypeList.find((dt) => dt.deviceType === bridgedNode.code)) {
2723
- deviceTypeList.push({ deviceType: bridgedNode.code, revision: bridgedNode.revision });
2724
- }
2725
- }
2726
- device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
2727
- }
2728
2711
  await this.registerDevice(device);
2729
2712
  return device;
2730
2713
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-example-dynamic-platform",
3
- "version": "3.0.3-dev-20260829-d83e6fe",
3
+ "version": "3.0.3-dev-20260830-a347a26",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-example-dynamic-platform",
9
- "version": "3.0.3-dev-20260829-d83e6fe",
9
+ "version": "3.0.3-dev-20260830-a347a26",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "node-ansi-logger": "3.3.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-example-dynamic-platform",
3
- "version": "3.0.3-dev-20260829-d83e6fe",
3
+ "version": "3.0.3-dev-20260830-a347a26",
4
4
  "description": "Matterbridge dynamic plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",