matterbridge-example-dynamic-platform 1.3.8 → 1.3.9-dev-20250831-3f93c3f
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 +24 -0
- package/README.md +14 -1
- package/dist/platform.js +156 -10
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -23,6 +23,30 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
23
23
|
<img src="bmc-button.svg" alt="Buy me a coffee" width="120">
|
|
24
24
|
</a>
|
|
25
25
|
|
|
26
|
+
## [1.3.9] - 2025-08-30
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- [platform]: Added a door contact sensor
|
|
31
|
+
- [platform]: Added a motion sensor
|
|
32
|
+
- [platform]: Added an illuminance sensor
|
|
33
|
+
- [platform]: Added a temperature sensor
|
|
34
|
+
- [platform]: Added an humidity sensor
|
|
35
|
+
- [platform]: Added a pressure sensor
|
|
36
|
+
- [platform]: Added a flow sensor
|
|
37
|
+
- [platform]: Added a climate sensor with temperature, humidity and pressure
|
|
38
|
+
- [platform]: Added a mode select device
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- [package]: Updated dependencies.
|
|
43
|
+
- [package]: Updated to Automator v. 2.0.5.
|
|
44
|
+
- [devContainer]: Updated devContainer with repository name for the container and shallow clone matterbridge for speed and memory optimization.
|
|
45
|
+
|
|
46
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
47
|
+
<img src="bmc-button.svg" alt="Buy me a coffee" width="80">
|
|
48
|
+
</a>
|
|
49
|
+
|
|
26
50
|
## [1.3.8] - 2025-08-20
|
|
27
51
|
|
|
28
52
|
### Added
|
package/README.md
CHANGED
|
@@ -17,8 +17,17 @@
|
|
|
17
17
|
|
|
18
18
|
Matterbridge dynamic platform example plugin is a template to develop your own plugin using the dynamic platform.
|
|
19
19
|
|
|
20
|
-
It exposes
|
|
20
|
+
It exposes 56 virtual devices:
|
|
21
21
|
|
|
22
|
+
- a door contact sensor
|
|
23
|
+
- a motion sensor
|
|
24
|
+
- an illuminance sensor
|
|
25
|
+
- a temperature sensor
|
|
26
|
+
- an humidity sensor
|
|
27
|
+
- a pressure sensor
|
|
28
|
+
- a flow sensor
|
|
29
|
+
- a climate sensor with temperature, humidity and pressure
|
|
30
|
+
- a mode select device
|
|
22
31
|
- a switch with onOff cluster
|
|
23
32
|
- a light with onOff
|
|
24
33
|
- a light with onOff and levelControl (dimmer)
|
|
@@ -83,3 +92,7 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
83
92
|
### Matterbridge
|
|
84
93
|
|
|
85
94
|
See the guidelines on [Matterbridge](https://github.com/Luligu/matterbridge/blob/main/README.md) for more information.
|
|
95
|
+
|
|
96
|
+
## Style guide
|
|
97
|
+
|
|
98
|
+
See also the [Style Guide](./STYLE_GUIDE.md) for JSDoc, naming and logging conventions used in this repository.
|
package/dist/platform.js
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
|
-
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, genericSwitch, airConditioner, onOffMountedSwitch, dimmableMountedSwitch, extendedColorLight, } from 'matterbridge';
|
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform, airQualitySensor, bridgedNode, colorTemperatureLight, coverDevice, dimmableLight, doorLockDevice, fanDevice, flowSensor, humiditySensor, onOffLight, onOffOutlet, onOffSwitch, powerSource, rainSensor, smokeCoAlarm, temperatureSensor, thermostatDevice, waterFreezeDetector, waterLeakDetector, airPurifier, pumpDevice, waterValve, genericSwitch, airConditioner, onOffMountedSwitch, dimmableMountedSwitch, extendedColorLight, pressureSensor, contactSensor, occupancySensor, lightSensor, modeSelect, } from 'matterbridge';
|
|
2
2
|
import { RoboticVacuumCleaner, LaundryWasher, WaterHeater, Evse, SolarPower, BatteryStorage, LaundryDryer, HeatPump, Dishwasher, ExtractorHood, MicrowaveOven, Oven, Cooktop, Refrigerator, } from 'matterbridge/devices';
|
|
3
|
-
import { isValidBoolean, isValidNumber, isValidString } from 'matterbridge/utils';
|
|
3
|
+
import { isValidBoolean, isValidNumber, isValidObject, isValidString } from 'matterbridge/utils';
|
|
4
4
|
import { debugStringify } from 'matterbridge/logger';
|
|
5
5
|
import { AreaNamespaceTag, LocationTag, NumberTag, PositionTag, RefrigeratorTag, SwitchesTag, UINT16_MAX, UINT32_MAX } from 'matterbridge/matter';
|
|
6
|
-
import { PowerSource, BooleanState, OnOff, LevelControl, AirQuality, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, FlowMeasurement, ColorControl, DoorLock, FanControl, FormaldehydeConcentrationMeasurement, NitrogenDioxideConcentrationMeasurement, OzoneConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, TemperatureMeasurement, Thermostat, ThermostatCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, EnergyEvseMode, EnergyEvse, RvcRunMode, RvcCleanMode, ConcentrationMeasurement, Descriptor, BridgedDeviceBasicInformation, OvenMode, OperationalState, } from 'matterbridge/matter/clusters';
|
|
6
|
+
import { PowerSource, BooleanState, OnOff, LevelControl, AirQuality, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, FlowMeasurement, ColorControl, DoorLock, FanControl, FormaldehydeConcentrationMeasurement, NitrogenDioxideConcentrationMeasurement, OzoneConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm25ConcentrationMeasurement, RadonConcentrationMeasurement, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, SmokeCoAlarm, TemperatureMeasurement, Thermostat, ThermostatCluster, TotalVolatileOrganicCompoundsConcentrationMeasurement, WindowCovering, EnergyEvseMode, EnergyEvse, RvcRunMode, RvcCleanMode, ConcentrationMeasurement, Descriptor, BridgedDeviceBasicInformation, OvenMode, OperationalState, OccupancySensing, IlluminanceMeasurement, PressureMeasurement, } from 'matterbridge/matter/clusters';
|
|
7
|
+
function luxToMatter(lux) {
|
|
8
|
+
if (!Number.isFinite(lux) || lux <= 0)
|
|
9
|
+
return 0;
|
|
10
|
+
const encoded = 10000 * Math.log10(lux);
|
|
11
|
+
if (!Number.isFinite(encoded) || encoded < 0)
|
|
12
|
+
return 0;
|
|
13
|
+
return Math.round(Math.min(encoded, 0xfffe));
|
|
14
|
+
}
|
|
15
|
+
function matterToLux(value) {
|
|
16
|
+
if (!Number.isFinite(value) || value <= 0)
|
|
17
|
+
return 0;
|
|
18
|
+
const v = Math.min(value, 0xfffe);
|
|
19
|
+
const lux = Math.pow(10, v / 10000);
|
|
20
|
+
return Math.round(lux < 0 ? 0 : lux);
|
|
21
|
+
}
|
|
7
22
|
export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
|
|
23
|
+
door;
|
|
24
|
+
occupancy;
|
|
25
|
+
illuminance;
|
|
26
|
+
temperature;
|
|
27
|
+
humidity;
|
|
28
|
+
pressure;
|
|
29
|
+
flow;
|
|
30
|
+
select;
|
|
31
|
+
climate;
|
|
8
32
|
switch;
|
|
9
33
|
mountedOnOffSwitch;
|
|
10
34
|
mountedDimmerSwitch;
|
|
@@ -53,6 +77,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
53
77
|
oven;
|
|
54
78
|
cooktop;
|
|
55
79
|
refrigerator;
|
|
80
|
+
sensorInterval;
|
|
56
81
|
switchInterval;
|
|
57
82
|
lightInterval;
|
|
58
83
|
outletInterval;
|
|
@@ -93,12 +118,82 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
93
118
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
|
94
119
|
await this.ready;
|
|
95
120
|
await this.clearSelect();
|
|
121
|
+
this.door = new MatterbridgeEndpoint([contactSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Door' }, this.config.debug)
|
|
122
|
+
.createDefaultIdentifyClusterServer()
|
|
123
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Door', 'DOOR23452164', 0xfff1, 'Matterbridge', 'Matterbridge Door')
|
|
124
|
+
.createDefaultBooleanStateClusterServer(true)
|
|
125
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(90, PowerSource.BatChargeLevel.Ok, 2990, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
126
|
+
.addRequiredClusterServers();
|
|
127
|
+
this.door = await this.addDevice(this.door);
|
|
128
|
+
this.occupancy = new MatterbridgeEndpoint([occupancySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Occupancy' }, this.config.debug)
|
|
129
|
+
.createDefaultIdentifyClusterServer()
|
|
130
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Occupancy', 'OCCUPANCY23452164', 0xfff1, 'Matterbridge', 'Matterbridge Occupancy')
|
|
131
|
+
.createDefaultOccupancySensingClusterServer(false)
|
|
132
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(70, PowerSource.BatChargeLevel.Ok, 2950, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
133
|
+
.addRequiredClusterServers();
|
|
134
|
+
this.occupancy = await this.addDevice(this.occupancy);
|
|
135
|
+
this.illuminance = new MatterbridgeEndpoint([lightSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Illuminance' }, this.config.debug)
|
|
136
|
+
.createDefaultIdentifyClusterServer()
|
|
137
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Illuminance', 'ILLUMINANCE23452164', 0xfff1, 'Matterbridge', 'Matterbridge Illuminance')
|
|
138
|
+
.createDefaultIlluminanceMeasurementClusterServer(luxToMatter(1))
|
|
139
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 3100, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
140
|
+
.addRequiredClusterServers();
|
|
141
|
+
this.illuminance = await this.addDevice(this.illuminance);
|
|
142
|
+
this.temperature = new MatterbridgeEndpoint([temperatureSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Temperature' }, this.config.debug)
|
|
143
|
+
.createDefaultIdentifyClusterServer()
|
|
144
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Temperature', 'TEMPERATURE23452164', 0xfff1, 'Matterbridge', 'Matterbridge Temperature')
|
|
145
|
+
.createDefaultTemperatureMeasurementClusterServer(1000)
|
|
146
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 3100, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
147
|
+
.addRequiredClusterServers();
|
|
148
|
+
this.temperature = await this.addDevice(this.temperature);
|
|
149
|
+
this.humidity = new MatterbridgeEndpoint([humiditySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Humidity' }, this.config.debug)
|
|
150
|
+
.createDefaultIdentifyClusterServer()
|
|
151
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Humidity', 'HUMIDITY23452164', 0xfff1, 'Matterbridge', 'Matterbridge Humidity')
|
|
152
|
+
.createDefaultRelativeHumidityMeasurementClusterServer(1000)
|
|
153
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 3100, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
154
|
+
.addRequiredClusterServers();
|
|
155
|
+
this.humidity = await this.addDevice(this.humidity);
|
|
156
|
+
this.pressure = new MatterbridgeEndpoint([pressureSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Pressure' }, this.config.debug)
|
|
157
|
+
.createDefaultIdentifyClusterServer()
|
|
158
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Pressure', 'PRESSURE23452164', 0xfff1, 'Matterbridge', 'Matterbridge Pressure')
|
|
159
|
+
.createDefaultPressureMeasurementClusterServer(9000)
|
|
160
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 3050, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
161
|
+
.addRequiredClusterServers();
|
|
162
|
+
this.pressure = await this.addDevice(this.pressure);
|
|
163
|
+
this.flow = new MatterbridgeEndpoint([flowSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Flow' }, this.config.debug)
|
|
164
|
+
.createDefaultIdentifyClusterServer()
|
|
165
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Flow', 'FLOW23452164', 0xfff1, 'Matterbridge', 'Matterbridge Flow')
|
|
166
|
+
.createDefaultFlowMeasurementClusterServer(10)
|
|
167
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 3050, 'AA', 1, PowerSource.BatReplaceability.UserReplaceable)
|
|
168
|
+
.addRequiredClusterServers();
|
|
169
|
+
this.flow = await this.addDevice(this.flow);
|
|
170
|
+
this.climate = new MatterbridgeEndpoint([temperatureSensor, humiditySensor, pressureSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Climate' }, this.config.debug)
|
|
171
|
+
.createDefaultIdentifyClusterServer()
|
|
172
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Climate', 'CLIMATE23452164', 0xfff1, 'Matterbridge', 'Matterbridge Climate')
|
|
173
|
+
.createDefaultTemperatureMeasurementClusterServer(1000)
|
|
174
|
+
.createDefaultRelativeHumidityMeasurementClusterServer(1000)
|
|
175
|
+
.createDefaultPressureMeasurementClusterServer(9000)
|
|
176
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(90, PowerSource.BatChargeLevel.Ok, 2990, '2 x AA', 2, PowerSource.BatReplaceability.UserReplaceable)
|
|
177
|
+
.addRequiredClusterServers();
|
|
178
|
+
this.climate = await this.addDevice(this.climate);
|
|
179
|
+
this.select = new MatterbridgeEndpoint([modeSelect, bridgedNode, powerSource], { uniqueStorageKey: 'Select' }, this.config.debug)
|
|
180
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Select', 'SELECT23452164', 0xfff1, 'Matterbridge', 'Matterbridge Select')
|
|
181
|
+
.createDefaultModeSelectClusterServer('Night mode', [
|
|
182
|
+
{ label: 'Led ON', mode: 1, semanticTags: [] },
|
|
183
|
+
{ label: 'Led OFF', mode: 2, semanticTags: [] },
|
|
184
|
+
], 1, 1)
|
|
185
|
+
.createDefaultPowerSourceWiredClusterServer()
|
|
186
|
+
.addRequiredClusterServers();
|
|
187
|
+
this.select = await this.addDevice(this.select);
|
|
188
|
+
this.select?.addCommandHandler('changeToMode', async ({ request: { newMode } }) => {
|
|
189
|
+
this.log.info(`Command changeToMode called newMode:${newMode}`);
|
|
190
|
+
});
|
|
96
191
|
this.switch = new MatterbridgeEndpoint([onOffSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'Switch' }, this.config.debug)
|
|
97
192
|
.createDefaultIdentifyClusterServer()
|
|
98
193
|
.createDefaultGroupsClusterServer()
|
|
99
194
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Switch', '0x23452164', 0xfff1, 'Matterbridge', 'Matterbridge Switch')
|
|
100
195
|
.createDefaultOnOffClusterServer()
|
|
101
|
-
.
|
|
196
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
102
197
|
this.switch = await this.addDevice(this.switch);
|
|
103
198
|
this.switch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
104
199
|
this.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -116,7 +211,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
116
211
|
.createDefaultGroupsClusterServer()
|
|
117
212
|
.createDefaultBridgedDeviceBasicInformationClusterServer('OnOff Mounted Switch', '0x298242164', 0xfff1, 'Matterbridge', 'Matterbridge OnOff Mounted Switch')
|
|
118
213
|
.createDefaultOnOffClusterServer()
|
|
119
|
-
.
|
|
214
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
120
215
|
this.mountedOnOffSwitch = await this.addDevice(this.mountedOnOffSwitch);
|
|
121
216
|
this.mountedOnOffSwitch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
122
217
|
this.mountedOnOffSwitch?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -181,7 +276,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
181
276
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer', '0x234554564', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer')
|
|
182
277
|
.createDefaultOnOffClusterServer()
|
|
183
278
|
.createDefaultLevelControlClusterServer()
|
|
184
|
-
.
|
|
279
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
185
280
|
this.dimmer = await this.addDevice(this.dimmer);
|
|
186
281
|
this.dimmer?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
187
282
|
this.dimmer?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -209,7 +304,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
209
304
|
.createDefaultOnOffClusterServer()
|
|
210
305
|
.createDefaultLevelControlClusterServer()
|
|
211
306
|
.createDefaultColorControlClusterServer()
|
|
212
|
-
.
|
|
307
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
213
308
|
this.light = await this.addDevice(this.light);
|
|
214
309
|
this.light?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
215
310
|
this.light?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -341,7 +436,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
341
436
|
.createDefaultOnOffClusterServer()
|
|
342
437
|
.createDefaultLevelControlClusterServer()
|
|
343
438
|
.createCtColorControlClusterServer()
|
|
344
|
-
.
|
|
439
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
345
440
|
this.lightCT = await this.addDevice(this.lightCT);
|
|
346
441
|
this.lightCT?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
347
442
|
this.lightCT?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -389,7 +484,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
389
484
|
.createDefaultGroupsClusterServer()
|
|
390
485
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift', 'CL01020564', 0xfff1, 'Matterbridge', 'Matterbridge Cover')
|
|
391
486
|
.createDefaultWindowCoveringClusterServer()
|
|
392
|
-
.
|
|
487
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
393
488
|
this.coverLift = await this.addDevice(this.coverLift);
|
|
394
489
|
this.coverLift?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
395
490
|
this.coverLift?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -415,7 +510,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
415
510
|
.createDefaultGroupsClusterServer()
|
|
416
511
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Cover lift and tilt', 'CLT01020554', 0xfff1, 'Matterbridge', 'Matterbridge Cover')
|
|
417
512
|
.createDefaultLiftTiltWindowCoveringClusterServer()
|
|
418
|
-
.
|
|
513
|
+
.createDefaultPowerSourceWiredClusterServer();
|
|
419
514
|
this.coverLiftTilt = await this.addDevice(this.coverLiftTilt);
|
|
420
515
|
this.coverLiftTilt?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
421
516
|
this.coverLiftTilt?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
|
@@ -1089,6 +1184,56 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1089
1184
|
async onConfigure() {
|
|
1090
1185
|
await super.onConfigure();
|
|
1091
1186
|
this.log.info('onConfigure called');
|
|
1187
|
+
if (this.config.useInterval) {
|
|
1188
|
+
this.sensorInterval = setInterval(async () => {
|
|
1189
|
+
let value = this.door?.getAttribute(BooleanState.Cluster.id, 'stateValue', this.door.log);
|
|
1190
|
+
if (isValidBoolean(value)) {
|
|
1191
|
+
value = !value;
|
|
1192
|
+
await this.door?.setAttribute(BooleanState.Cluster.id, 'stateValue', value, this.door.log);
|
|
1193
|
+
this.door?.log.info(`Set door stateValue to ${value}`);
|
|
1194
|
+
}
|
|
1195
|
+
const occupancyValue = this.occupancy?.getAttribute(OccupancySensing.Cluster.id, 'occupancy', this.occupancy.log);
|
|
1196
|
+
if (isValidObject(occupancyValue, 1)) {
|
|
1197
|
+
occupancyValue.occupied = !occupancyValue.occupied;
|
|
1198
|
+
await this.occupancy?.setAttribute(OccupancySensing.Cluster.id, 'occupancy', occupancyValue, this.occupancy.log);
|
|
1199
|
+
this.occupancy?.log.info(`Set occupancy to ${occupancyValue.occupied}`);
|
|
1200
|
+
}
|
|
1201
|
+
value = this.illuminance?.getAttribute(IlluminanceMeasurement.Cluster.id, 'measuredValue', this.illuminance.log);
|
|
1202
|
+
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1203
|
+
value = matterToLux(value);
|
|
1204
|
+
value = value + 10 < 500 ? value + 10 : 1;
|
|
1205
|
+
await this.illuminance?.setAttribute(IlluminanceMeasurement.Cluster.id, 'measuredValue', luxToMatter(value), this.illuminance.log);
|
|
1206
|
+
this.illuminance?.log.info(`Set illuminance measuredValue to ${value}`);
|
|
1207
|
+
}
|
|
1208
|
+
value = this.temperature?.getAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', this.temperature.log);
|
|
1209
|
+
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1210
|
+
value = value + 100 < 3000 ? value + 100 : 1000;
|
|
1211
|
+
await this.temperature?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', value, this.temperature.log);
|
|
1212
|
+
await this.climate?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', value, this.climate.log);
|
|
1213
|
+
this.temperature?.log.info(`Set temperature measuredValue to ${value}`);
|
|
1214
|
+
}
|
|
1215
|
+
value = this.humidity?.getAttribute(RelativeHumidityMeasurement.Cluster.id, 'measuredValue', this.humidity.log);
|
|
1216
|
+
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1217
|
+
value = value + 100 < 10000 ? value + 100 : 100;
|
|
1218
|
+
await this.humidity?.setAttribute(RelativeHumidityMeasurement.Cluster.id, 'measuredValue', value, this.humidity.log);
|
|
1219
|
+
await this.climate?.setAttribute(RelativeHumidityMeasurement.Cluster.id, 'measuredValue', value, this.climate.log);
|
|
1220
|
+
this.humidity?.log.info(`Set humidity measuredValue to ${value}`);
|
|
1221
|
+
}
|
|
1222
|
+
value = this.pressure?.getAttribute(PressureMeasurement.Cluster.id, 'measuredValue', this.pressure.log);
|
|
1223
|
+
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1224
|
+
value = value + 10 < 9900 ? value + 10 : 8600;
|
|
1225
|
+
await this.pressure?.setAttribute(PressureMeasurement.Cluster.id, 'measuredValue', value, this.pressure.log);
|
|
1226
|
+
await this.climate?.setAttribute(PressureMeasurement.Cluster.id, 'measuredValue', value, this.climate.log);
|
|
1227
|
+
this.pressure?.log.info(`Set pressure measuredValue to ${value}`);
|
|
1228
|
+
}
|
|
1229
|
+
value = this.flow?.getAttribute(FlowMeasurement.Cluster.id, 'measuredValue', this.flow.log);
|
|
1230
|
+
if (isValidNumber(value, 0, 0xfffe)) {
|
|
1231
|
+
value = value + 1 < 50 ? value + 1 : 1;
|
|
1232
|
+
await this.flow?.setAttribute(FlowMeasurement.Cluster.id, 'measuredValue', value, this.flow.log);
|
|
1233
|
+
this.flow?.log.info(`Set flow measuredValue to ${value}`);
|
|
1234
|
+
}
|
|
1235
|
+
}, 60 * 1000 + 900);
|
|
1236
|
+
}
|
|
1092
1237
|
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.switch.log);
|
|
1093
1238
|
await this.mountedOnOffSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitch.log);
|
|
1094
1239
|
this.switch?.log.info(`Set switch initial onOff to ${this.intervalOnOff}`);
|
|
@@ -1412,6 +1557,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
|
1412
1557
|
}
|
|
1413
1558
|
}
|
|
1414
1559
|
async onShutdown(reason) {
|
|
1560
|
+
clearInterval(this.sensorInterval);
|
|
1415
1561
|
clearInterval(this.switchInterval);
|
|
1416
1562
|
clearInterval(this.lightInterval);
|
|
1417
1563
|
clearInterval(this.outletInterval);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-example-dynamic-platform",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9-dev-20250831-3f93c3f",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge-example-dynamic-platform",
|
|
9
|
-
"version": "1.3.
|
|
9
|
+
"version": "1.3.9-dev-20250831-3f93c3f",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"node-ansi-logger": "3.1.1",
|