matterbridge-example-dynamic-platform 1.2.0-edge.9 → 1.2.1
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 -4
- package/README.md +13 -2
- package/dist/appliances.js +39 -73
- package/dist/platform.js +85 -42
- package/dist/robot.js +16 -40
- package/matterbridge-example-dynamic-platform.schema.json +3 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/tsconfig.jest.json +8 -0
package/CHANGELOG.md
CHANGED
@@ -8,18 +8,38 @@ If you like this project and find it useful, please consider giving it a star on
|
|
8
8
|
<img src="bmc-button.svg" alt="Buy me a coffee" width="120">
|
9
9
|
</a>
|
10
10
|
|
11
|
-
## [1.2.
|
11
|
+
## [1.2.1] - 2025-05-15
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
- [package]: Require matterbridge 3.0.1.
|
16
|
+
- [package]: Updated package.
|
17
|
+
- [package]: Updated dependencies.
|
18
|
+
|
19
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
20
|
+
<img src="bmc-button.svg" alt="Buy me a coffee" width="80">
|
21
|
+
</a>
|
22
|
+
|
23
|
+
## [1.2.0] - 2025-04-30
|
12
24
|
|
13
25
|
### Added
|
14
26
|
|
15
|
-
- [platform]: Added Robot Vacuum Cleaner device (supported by SmartThings, Alexa, Home Assistant and Apple Home).
|
27
|
+
- [platform]: Added Robot Vacuum Cleaner device (supported by SmartThings, Alexa, Home Assistant and partially by Apple Home). Read carefully the readme please and also https://github.com/Luligu/matterbridge/discussions/264.
|
28
|
+
- [platform]: Added OnOff Mounted Switch device (supported by SmartThings, Alexa, Home Assistant).
|
29
|
+
- [platform]: Added Dimmer Mounted Switch device (supported by SmartThings, Alexa, Home Assistant).
|
16
30
|
- [platform]: Added Laundry Washer device (supported by SmartThings, Alexa and Home Assistant).
|
31
|
+
- [platform]: Added Laundry Dryer device (supported by SmartThings, Alexa and Home Assistant).
|
17
32
|
- [platform]: Added Dishwasher device (supported by SmartThings, Alexa and Home Assistant).
|
18
|
-
- [platform]: Added
|
19
|
-
- [platform]: Added
|
33
|
+
- [platform]: Added Refrigerator device (supported by SmartThings, Alexa and Home Assistant).
|
34
|
+
- [platform]: Added Oven device (supported by SmartThings, Alexa and Home Assistant).
|
35
|
+
- [platform]: Added Microwave Oven device (supported by SmartThings, Alexa and Home Assistant).
|
36
|
+
- [platform]: Added Extractor Hood device (supported by SmartThings, Alexa and Home Assistant).
|
37
|
+
- [platform]: Added Cooktop device (supported by SmartThings, Alexa and Home Assistant).
|
20
38
|
|
21
39
|
### Changed
|
22
40
|
|
41
|
+
- [package]: Require matterbridge 3.0.0.
|
42
|
+
- [package]: Updated package.
|
23
43
|
- [package]: Updated dependencies.
|
24
44
|
|
25
45
|
<a href="https://www.buymeacoffee.com/luligugithub">
|
package/README.md
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
Matterbridge dynamic platform example plugin is a template to develop your own plugin using the dynamic platform.
|
18
18
|
|
19
|
-
It exposes:
|
19
|
+
It exposes 38 devices:
|
20
20
|
|
21
21
|
- a switch with onOff cluster
|
22
22
|
- a light with onOff
|
@@ -43,9 +43,20 @@ It exposes:
|
|
43
43
|
- an airPurifier device with temperature and humidity sensor (supported by Apple Home)
|
44
44
|
- a pumpDevice device
|
45
45
|
- a waterValve device
|
46
|
-
- an airQuality device with all concentration measurements clusters (supported by Apple Home
|
46
|
+
- an airQuality device with all concentration measurements clusters (supported by Apple Home with the concentration measurements from version 18.5)
|
47
47
|
- a momentary switch
|
48
48
|
- a latching switch
|
49
|
+
- a Robot Vacuum Cleaner device (supported by SmartThings, Alexa, Home Assistant and partially by Apple Home). Read also https://github.com/Luligu/matterbridge/discussions/264.
|
50
|
+
- a onOff Mounted Switch device (supported by SmartThings, Alexa, Home Assistant)
|
51
|
+
- a dimmer Mounted Switch device (supported by SmartThings, Alexa, Home Assistant)
|
52
|
+
- a laundry Washer device (supported by SmartThings, Alexa and Home Assistant)
|
53
|
+
- a laundry Dryer device (supported by SmartThings, Alexa and Home Assistant)
|
54
|
+
- a dishwasher device (supported by SmartThings, Alexa and Home Assistant)
|
55
|
+
- a refrigerator device (supported by SmartThings, Alexa and Home Assistant)
|
56
|
+
- an oven device (supported by SmartThings, Alexa and Home Assistant)
|
57
|
+
- a microwave Oven device (supported by SmartThings, Alexa and Home Assistant)
|
58
|
+
- an extractor Hood device (supported by SmartThings, Alexa and Home Assistant)
|
59
|
+
- a cooktop device (supported by SmartThings, Alexa and Home Assistant)
|
49
60
|
|
50
61
|
All these devices continuously change state and position. The plugin also shows how to use all the command handlers (you can control all the devices), how to subscribe to attributes and how to trigger events.
|
51
62
|
|
package/dist/appliances.js
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
import { MatterbridgeEndpoint, MatterbridgeServer, MatterbridgeOnOffServer,
|
2
|
-
import { ClusterBehavior } from 'matterbridge/matter';
|
3
|
-
import { OperationalState, TemperatureControl, DishwasherMode, LaundryWasherControls, LaundryWasherMode, LaundryDryerControls, OvenMode, RefrigeratorAndTemperatureControlledCabinetMode, MicrowaveOvenMode, MicrowaveOvenControl, OvenCavityOperationalState, } from 'matterbridge/matter/clusters';
|
4
|
-
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, MicrowaveOvenControlBehavior, MicrowaveOvenModeServer,
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeServer, MatterbridgeOnOffServer, laundryWasher, laundryDryer, dishwasher, refrigerator, temperatureControlledCabinetCooler, oven, temperatureControlledCabinetHeater, microwaveOven, extractorHood, cooktop, cookSurface, powerSource, } from 'matterbridge';
|
2
|
+
import { ClusterBehavior, PositionTag, RefrigeratorTag } from 'matterbridge/matter';
|
3
|
+
import { OperationalState, TemperatureControl, DishwasherMode, LaundryWasherControls, LaundryWasherMode, LaundryDryerControls, OvenMode, ModeBase, RefrigeratorAndTemperatureControlledCabinetMode, MicrowaveOvenMode, MicrowaveOvenControl, OvenCavityOperationalState, } from 'matterbridge/matter/clusters';
|
4
|
+
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, MicrowaveOvenControlBehavior, MicrowaveOvenModeServer, TemperatureControlBehavior, } from 'matterbridge/matter/behaviors';
|
5
5
|
export class Appliances extends MatterbridgeEndpoint {
|
6
6
|
constructor(deviceType, name, serial) {
|
7
|
-
super(deviceType, { uniqueStorageKey: `${name}-${serial}` }, true);
|
7
|
+
super([deviceType, powerSource], { uniqueStorageKey: `${name}-${serial}` }, true);
|
8
8
|
if (deviceType.code === laundryWasher.code) {
|
9
9
|
this.createDefaultIdentifyClusterServer();
|
10
10
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Washer');
|
11
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
11
12
|
this.createDeadFrontOnOffClusterServer();
|
12
13
|
this.createLevelTemperatureControlClusterServer(3, ['Cold', '30°', '40°', '60°', '80°']);
|
13
14
|
this.createDefaultLaundryWasherModeClusterServer();
|
@@ -17,6 +18,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
17
18
|
else if (deviceType.code === laundryDryer.code) {
|
18
19
|
this.createDefaultIdentifyClusterServer();
|
19
20
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Dryer');
|
21
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
20
22
|
this.createDeadFrontOnOffClusterServer();
|
21
23
|
this.createLevelTemperatureControlClusterServer(3, ['Cold', '30°', '40°', '60°', '80°']);
|
22
24
|
this.createDefaultLaundryWasherModeClusterServer();
|
@@ -26,6 +28,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
26
28
|
else if (deviceType.code === dishwasher.code) {
|
27
29
|
this.createDefaultIdentifyClusterServer();
|
28
30
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Dishwasher');
|
31
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
29
32
|
this.createDeadFrontOnOffClusterServer();
|
30
33
|
this.createLevelTemperatureControlClusterServer(1, ['Cold', '30°', '40°', '60°']);
|
31
34
|
this.createDefaultDishwasherModeClusterServer();
|
@@ -35,6 +38,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
35
38
|
else if (deviceType.name === refrigerator.name) {
|
36
39
|
this.createDefaultIdentifyClusterServer();
|
37
40
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Refrigerator');
|
41
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
38
42
|
const refrigerator = this.addChildDeviceType('Refrigerator', temperatureControlledCabinetCooler, { tagList: [{ mfgCode: null, namespaceId: RefrigeratorTag.Refrigerator.namespaceId, tag: RefrigeratorTag.Refrigerator.tag, label: RefrigeratorTag.Refrigerator.label }] }, true);
|
39
43
|
refrigerator.log.logName = `Refrigerator (cabinet Refrigerator)`;
|
40
44
|
refrigerator.createDefaultIdentifyClusterServer();
|
@@ -51,6 +55,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
51
55
|
else if (deviceType.name === oven.name) {
|
52
56
|
this.createDefaultIdentifyClusterServer();
|
53
57
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Oven');
|
58
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
54
59
|
const cabinettop = this.addChildDeviceType('Oven (top)', temperatureControlledCabinetHeater, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Top.namespaceId, tag: PositionTag.Top.tag, label: PositionTag.Top.label }] }, true);
|
55
60
|
cabinettop.log.logName = `Oven (top)`;
|
56
61
|
cabinettop.createDefaultIdentifyClusterServer();
|
@@ -67,6 +72,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
67
72
|
else if (deviceType.name === microwaveOven.name) {
|
68
73
|
this.createDefaultIdentifyClusterServer();
|
69
74
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Microwave Oven');
|
75
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
70
76
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
71
77
|
this.createDefaultMicrowaveOvenModeClusterServer();
|
72
78
|
this.createDefaultMicrowaveOvenControlClusterServer();
|
@@ -74,6 +80,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
74
80
|
else if (deviceType.name === extractorHood.name) {
|
75
81
|
this.createDefaultIdentifyClusterServer();
|
76
82
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Extractor Hood');
|
83
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
77
84
|
this.createBaseFanControlClusterServer();
|
78
85
|
this.createDefaultHepaFilterMonitoringClusterServer();
|
79
86
|
this.createDefaultActivatedCarbonFilterMonitoringClusterServer();
|
@@ -81,6 +88,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
81
88
|
else if (deviceType.name === cooktop.name) {
|
82
89
|
this.createDefaultIdentifyClusterServer();
|
83
90
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Cooktop');
|
91
|
+
this.createDefaultPowerSourceWiredClusterServer();
|
84
92
|
this.createOffOnlyOnOffClusterServer(true);
|
85
93
|
const cookSurface1 = this.addChildDeviceType('Surface 1', cookSurface, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Left.namespaceId, tag: PositionTag.Left.tag, label: PositionTag.Left.label }] }, true);
|
86
94
|
cookSurface1.log.logName = `Cook surface (right)`;
|
@@ -103,21 +111,6 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
103
111
|
});
|
104
112
|
}
|
105
113
|
}
|
106
|
-
createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
107
|
-
this.behaviors.require(MatterbridgeOperationalStateServer, {
|
108
|
-
phaseList: [],
|
109
|
-
currentPhase: null,
|
110
|
-
operationalStateList: [
|
111
|
-
{ operationalStateId: OperationalState.OperationalStateEnum.Stopped, operationalStateLabel: 'Stopped' },
|
112
|
-
{ operationalStateId: OperationalState.OperationalStateEnum.Running, operationalStateLabel: 'Running' },
|
113
|
-
{ operationalStateId: OperationalState.OperationalStateEnum.Paused, operationalStateLabel: 'Paused' },
|
114
|
-
{ operationalStateId: OperationalState.OperationalStateEnum.Error, operationalStateLabel: 'Error' },
|
115
|
-
],
|
116
|
-
operationalState,
|
117
|
-
operationalError: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
118
|
-
});
|
119
|
-
return this;
|
120
|
-
}
|
121
114
|
createDefaultOvenCavityOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
122
115
|
this.behaviors.require(OvenCavityOperationalStateServer, {
|
123
116
|
phaseList: [],
|
@@ -280,50 +273,6 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
280
273
|
return endpoint;
|
281
274
|
}
|
282
275
|
}
|
283
|
-
class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
284
|
-
initialize() {
|
285
|
-
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
286
|
-
device.log.info('MatterbridgeOperationalStateServer initialized: setting operational state to Stopped');
|
287
|
-
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
288
|
-
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
289
|
-
}
|
290
|
-
pause() {
|
291
|
-
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
292
|
-
device.log.info('MatterbridgeOperationalStateServer: pause called setting operational state to Paused');
|
293
|
-
this.state.operationalState = OperationalState.OperationalStateEnum.Paused;
|
294
|
-
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
295
|
-
return {
|
296
|
-
commandResponseState: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
297
|
-
};
|
298
|
-
}
|
299
|
-
stop() {
|
300
|
-
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
301
|
-
device.log.info('MatterbridgeOperationalStateServer: stop called setting operational state to Stopped');
|
302
|
-
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
303
|
-
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
304
|
-
return {
|
305
|
-
commandResponseState: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
306
|
-
};
|
307
|
-
}
|
308
|
-
start() {
|
309
|
-
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
310
|
-
device.log.info('MatterbridgeOperationalStateServer: start called setting operational state to Running');
|
311
|
-
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
312
|
-
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
313
|
-
return {
|
314
|
-
commandResponseState: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
315
|
-
};
|
316
|
-
}
|
317
|
-
resume() {
|
318
|
-
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
319
|
-
device.log.info('MatterbridgeOperationalStateServer: resume called setting operational state to Running');
|
320
|
-
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
321
|
-
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
322
|
-
return {
|
323
|
-
commandResponseState: { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' },
|
324
|
-
};
|
325
|
-
}
|
326
|
-
}
|
327
276
|
class MatterbridgeLevelTemperatureControlServer extends TemperatureControlBehavior.with(TemperatureControl.Feature.TemperatureLevel) {
|
328
277
|
initialize() {
|
329
278
|
if (this.state.supportedTemperatureLevels.length >= 2) {
|
@@ -365,12 +314,29 @@ class MatterbridgeMicrowaveOvenControlServer extends MicrowaveOvenControlBehavio
|
|
365
314
|
}
|
366
315
|
setCookingParameters(request) {
|
367
316
|
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
317
|
+
if (request.cookMode !== undefined) {
|
318
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting cookMode to ${request.cookMode}`);
|
319
|
+
this.endpoint.setStateOf(MicrowaveOvenModeServer, { currentMode: request.cookMode });
|
320
|
+
}
|
321
|
+
else {
|
322
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no cookMode so set to Normal`);
|
323
|
+
this.endpoint.setStateOf(MicrowaveOvenModeServer, { currentMode: 6 });
|
324
|
+
}
|
325
|
+
if (request.cookTime !== undefined && request.cookTime >= 0 && request.cookTime <= this.state.maxCookTime) {
|
326
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting cookTime to ${request.cookTime}`);
|
327
|
+
this.state.cookTime = request.cookTime;
|
328
|
+
}
|
329
|
+
else {
|
330
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no cookTime so set to 30sec.`);
|
331
|
+
this.state.cookTime = 30;
|
332
|
+
}
|
368
333
|
if (request.wattSettingIndex !== undefined && request.wattSettingIndex >= 0 && request.wattSettingIndex < this.state.supportedWatts.length) {
|
369
334
|
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting selectedWattIndex to ${request.wattSettingIndex}`);
|
370
335
|
this.state.selectedWattIndex = request.wattSettingIndex;
|
371
336
|
}
|
372
337
|
else {
|
373
|
-
device.log.
|
338
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no wattSettingIndex so set to the highest Watt setting for the selected CookMode`);
|
339
|
+
this.state.selectedWattIndex = this.state.supportedWatts.length - 1;
|
374
340
|
}
|
375
341
|
}
|
376
342
|
addMoreTime(request) {
|
@@ -424,11 +390,11 @@ class RefrigeratorAndTemperatureControlledCabinetModeServer extends Refrigerator
|
|
424
390
|
if (supportedMode) {
|
425
391
|
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
426
392
|
this.state.currentMode = request.newMode;
|
427
|
-
return { status:
|
393
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
428
394
|
}
|
429
395
|
else {
|
430
396
|
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
431
|
-
return { status:
|
397
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
432
398
|
}
|
433
399
|
}
|
434
400
|
}
|
@@ -445,11 +411,11 @@ class OvenModeServer extends OvenModeBehavior {
|
|
445
411
|
if (supportedMode) {
|
446
412
|
device.log.info(`OvenModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
447
413
|
this.state.currentMode = request.newMode;
|
448
|
-
return { status:
|
414
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
449
415
|
}
|
450
416
|
else {
|
451
417
|
device.log.info(`OvenModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
452
|
-
return { status:
|
418
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
453
419
|
}
|
454
420
|
}
|
455
421
|
}
|
@@ -474,11 +440,11 @@ class DishwasherModeServer extends DishwasherModeBehavior {
|
|
474
440
|
if (supportedMode) {
|
475
441
|
device.log.info(`DishwasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
476
442
|
this.state.currentMode = request.newMode;
|
477
|
-
return { status:
|
443
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
478
444
|
}
|
479
445
|
else {
|
480
446
|
device.log.error(`DishwasherModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
481
|
-
return { status:
|
447
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
482
448
|
}
|
483
449
|
}
|
484
450
|
}
|
@@ -503,11 +469,11 @@ class LaundryWasherModeServer extends LaundryWasherModeBehavior {
|
|
503
469
|
if (supportedMode) {
|
504
470
|
device.log.info(`LaundryWasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
505
471
|
this.state.currentMode = request.newMode;
|
506
|
-
return { status:
|
472
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
507
473
|
}
|
508
474
|
else {
|
509
475
|
device.log.error(`LaundryWasherModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
510
|
-
return { status:
|
476
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
511
477
|
}
|
512
478
|
}
|
513
479
|
}
|
package/dist/platform.js
CHANGED
@@ -1,4 +1,4 @@
|
|
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, laundryWasher, cooktop, extractorHood, microwaveOven, oven, refrigerator, dishwasher, laundryDryer, onOffMountedSwitch, dimmableMountedSwitch, } 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, laundryWasher, cooktop, extractorHood, microwaveOven, oven, refrigerator, dishwasher, laundryDryer, onOffMountedSwitch, dimmableMountedSwitch, extendedColorLight, } from 'matterbridge';
|
2
2
|
import { isValidBoolean, isValidNumber } from 'matterbridge/utils';
|
3
3
|
import { LocationTag } from 'matterbridge/matter';
|
4
4
|
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, } from 'matterbridge/matter/clusters';
|
@@ -52,18 +52,21 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
52
52
|
genericSwitchLastEvent = 'Release';
|
53
53
|
intervalOnOff = false;
|
54
54
|
intervalLevel = 0;
|
55
|
+
intervalColorTemperature = 147;
|
55
56
|
bridgedDevices = new Map();
|
56
57
|
fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
|
57
58
|
constructor(matterbridge, log, config) {
|
58
59
|
super(matterbridge, log, config);
|
59
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('
|
60
|
-
throw new Error(`This plugin requires Matterbridge version >= "
|
60
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('3.0.1')) {
|
61
|
+
throw new Error(`This plugin requires Matterbridge version >= "3.0.1". Please update Matterbridge from ${this.matterbridge.matterbridgeVersion} to the latest version in the frontend.`);
|
61
62
|
}
|
62
63
|
this.log.info('Initializing platform:', this.config.name);
|
63
64
|
if (config.whiteList === undefined)
|
64
65
|
config.whiteList = [];
|
65
66
|
if (config.blackList === undefined)
|
66
67
|
config.blackList = [];
|
68
|
+
if (config.enableRVC === undefined)
|
69
|
+
config.enableRVC = false;
|
67
70
|
}
|
68
71
|
async onStart(reason) {
|
69
72
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
@@ -212,7 +215,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
212
215
|
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
213
216
|
this.dimmer?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
214
217
|
});
|
215
|
-
this.light = new MatterbridgeEndpoint([
|
218
|
+
this.light = new MatterbridgeEndpoint([extendedColorLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug)
|
216
219
|
.createDefaultIdentifyClusterServer()
|
217
220
|
.createDefaultGroupsClusterServer()
|
218
221
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (XY, HS and CT)', '0x23480564', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
@@ -321,7 +324,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
321
324
|
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightHS?.log);
|
322
325
|
this.lightHS?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
323
326
|
});
|
324
|
-
this.lightXY = new MatterbridgeEndpoint([
|
327
|
+
this.lightXY = new MatterbridgeEndpoint([extendedColorLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug)
|
325
328
|
.createDefaultIdentifyClusterServer()
|
326
329
|
.createDefaultGroupsClusterServer()
|
327
330
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Light (XY, CT)', '0x23497564', 0xfff1, 'Matterbridge', 'Matterbridge Light', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
@@ -657,11 +660,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
657
660
|
if (isValidNumber(newValue, 0, 100))
|
658
661
|
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
659
662
|
}, this.airPurifier.log);
|
660
|
-
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air
|
661
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Air
|
663
|
+
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air Conditioner' }, this.config.debug)
|
664
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Air Conditioner', '0x96382864AC', 0xfff1, 'Matterbridge', 'Matterbridge Air Conditioner', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
662
665
|
.createDefaultIdentifyClusterServer()
|
663
666
|
.createDeadFrontOnOffClusterServer(true)
|
664
667
|
.createDefaultThermostatClusterServer(20, 18, 22)
|
668
|
+
.createDefaultThermostatUserInterfaceConfigurationClusterServer()
|
665
669
|
.createDefaultFanControlClusterServer(FanControl.FanMode.Auto)
|
666
670
|
.createDefaultTemperatureMeasurementClusterServer(20 * 100)
|
667
671
|
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
@@ -736,8 +740,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
736
740
|
this.valve?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
737
741
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
738
742
|
});
|
739
|
-
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
743
|
+
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
740
744
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Fan', 'serial_980545631228', 0xfff1, 'Matterbridge', 'Matterbridge Fan', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
745
|
+
.createDefaultPowerSourceWiredClusterServer()
|
741
746
|
.addRequiredClusterServers();
|
742
747
|
this.setSelectDevice(this.fan.serialNumber ?? '', this.fan.deviceName ?? '', undefined, 'hub');
|
743
748
|
if (this.validateDevice(this.fan.deviceName ?? '')) {
|
@@ -784,8 +789,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
784
789
|
if (isValidNumber(newValue, 0, 100))
|
785
790
|
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedCurrent', newValue, this.fan?.log);
|
786
791
|
}, this.fan.log);
|
787
|
-
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
792
|
+
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
788
793
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Water leak detector', 'serial_98745631222', 0xfff1, 'Matterbridge', 'Matterbridge WaterLeakDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
794
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
789
795
|
.createDefaultBooleanStateClusterServer(false)
|
790
796
|
.addRequiredClusterServers()
|
791
797
|
.addOptionalClusterServers();
|
@@ -797,8 +803,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
797
803
|
else {
|
798
804
|
this.waterLeak = undefined;
|
799
805
|
}
|
800
|
-
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
806
|
+
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
801
807
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Water freeze detector', 'serial_98745631223', 0xfff1, 'Matterbridge', 'Matterbridge WaterFreezeDetector', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
808
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
802
809
|
.createDefaultBooleanStateClusterServer(false)
|
803
810
|
.addRequiredClusterServers()
|
804
811
|
.addOptionalClusterServers();
|
@@ -810,8 +817,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
810
817
|
else {
|
811
818
|
this.waterFreeze = undefined;
|
812
819
|
}
|
813
|
-
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
820
|
+
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
814
821
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Rain sensor', 'serial_98745631224', 0xfff1, 'Matterbridge', 'Matterbridge RainSensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
822
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
815
823
|
.createDefaultIdentifyClusterServer()
|
816
824
|
.createDefaultBooleanStateClusterServer(false)
|
817
825
|
.createDefaultBooleanStateConfigurationClusterServer();
|
@@ -823,12 +831,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
823
831
|
else {
|
824
832
|
this.rain = undefined;
|
825
833
|
}
|
826
|
-
this.smokeCo = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'SmokeCo alarm sensor' }, this.config.debug)
|
834
|
+
this.smokeCo = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'SmokeCo alarm sensor' }, this.config.debug)
|
827
835
|
.createDefaultBridgedDeviceBasicInformationClusterServer('SmokeCo alarm sensor', 'serial_94745631225', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
828
836
|
.createDefaultIdentifyClusterServer()
|
829
|
-
.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
|
830
|
-
|
831
|
-
|
837
|
+
.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
|
838
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer()
|
839
|
+
.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
832
840
|
this.setSelectDevice(this.smokeCo.serialNumber ?? '', this.smokeCo.deviceName ?? '', undefined, 'hub');
|
833
841
|
if (this.validateDevice(this.smokeCo.deviceName ?? '')) {
|
834
842
|
await this.registerDevice(this.smokeCo);
|
@@ -837,10 +845,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
837
845
|
else {
|
838
846
|
this.smokeCo = undefined;
|
839
847
|
}
|
840
|
-
this.smokeOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke
|
841
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Smoke
|
848
|
+
this.smokeOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
|
849
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Smoke alarm sensor', 'serial_94755661225', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
842
850
|
.createDefaultIdentifyClusterServer()
|
843
|
-
.createSmokeOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
851
|
+
.createSmokeOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
852
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
844
853
|
this.setSelectDevice(this.smokeOnly.serialNumber ?? '', this.smokeOnly.deviceName ?? '', undefined, 'hub');
|
845
854
|
if (this.validateDevice(this.smokeOnly.deviceName ?? '')) {
|
846
855
|
await this.registerDevice(this.smokeOnly);
|
@@ -849,12 +858,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
849
858
|
else {
|
850
859
|
this.smokeOnly = undefined;
|
851
860
|
}
|
852
|
-
this.coOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Co
|
853
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Co
|
861
|
+
this.coOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Co alarm sensor' }, this.config.debug)
|
862
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Co alarm sensor', 'serial_947456317488', 0xfff1, 'Matterbridge', 'Matterbridge SmokeCoAlarm', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
854
863
|
.createDefaultIdentifyClusterServer()
|
855
|
-
.createCoOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
856
|
-
|
857
|
-
|
864
|
+
.createCoOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
865
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer()
|
866
|
+
.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
858
867
|
this.setSelectDevice(this.coOnly.serialNumber ?? '', this.coOnly.deviceName ?? '', undefined, 'hub');
|
859
868
|
if (this.validateDevice(this.coOnly.deviceName ?? '')) {
|
860
869
|
await this.registerDevice(this.coOnly);
|
@@ -863,22 +872,21 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
863
872
|
else {
|
864
873
|
this.coOnly = undefined;
|
865
874
|
}
|
866
|
-
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
875
|
+
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
867
876
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Air quality sensor', 'serial_987484318322', 0xfff1, 'Matterbridge', 'Matterbridge Air Quality Sensor', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
877
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(50, PowerSource.BatChargeLevel.Warning, 2900, 'CR2450', 1)
|
868
878
|
.addRequiredClusterServers()
|
869
|
-
.addClusterServers([TemperatureMeasurement.Cluster.id, RelativeHumidityMeasurement.Cluster.id])
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
this.airQuality.createDefaultTvocMeasurementClusterServer(100);
|
881
|
-
}
|
879
|
+
.addClusterServers([TemperatureMeasurement.Cluster.id, RelativeHumidityMeasurement.Cluster.id])
|
880
|
+
.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(10)
|
881
|
+
.createDefaultCarbonDioxideConcentrationMeasurementClusterServer(400)
|
882
|
+
.createDefaultNitrogenDioxideConcentrationMeasurementClusterServer(1)
|
883
|
+
.createDefaultOzoneConcentrationMeasurementClusterServer(1)
|
884
|
+
.createDefaultFormaldehydeConcentrationMeasurementClusterServer(1)
|
885
|
+
.createDefaultPm1ConcentrationMeasurementClusterServer(100)
|
886
|
+
.createDefaultPm25ConcentrationMeasurementClusterServer(100)
|
887
|
+
.createDefaultPm10ConcentrationMeasurementClusterServer(100)
|
888
|
+
.createDefaultRadonConcentrationMeasurementClusterServer(100)
|
889
|
+
.createDefaultTvocMeasurementClusterServer(100);
|
882
890
|
this.setSelectDevice(this.airQuality.serialNumber ?? '', this.airQuality.deviceName ?? '', undefined, 'hub');
|
883
891
|
if (this.validateDevice(this.airQuality.deviceName ?? '')) {
|
884
892
|
await this.registerDevice(this.airQuality);
|
@@ -913,11 +921,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
913
921
|
else {
|
914
922
|
this.latchingSwitch = undefined;
|
915
923
|
}
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
924
|
+
if (this.config.enableRVC === true) {
|
925
|
+
const robot = new Robot('Robot Vacuum', '1238777820');
|
926
|
+
this.setSelectDevice(robot.serialNumber ?? '', robot.deviceName ?? '', undefined, 'hub');
|
927
|
+
if (this.validateDevice(robot.deviceName ?? '')) {
|
928
|
+
await this.registerDevice(robot);
|
929
|
+
this.bridgedDevices.set(robot.deviceName ?? '', robot);
|
930
|
+
}
|
921
931
|
}
|
922
932
|
const laundryWasherDevice = new Appliances(laundryWasher, 'Laundry Washer', '1234567890');
|
923
933
|
this.setSelectDevice(laundryWasherDevice.serialNumber ?? '', laundryWasherDevice.deviceName ?? '', undefined, 'hub');
|
@@ -938,12 +948,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
938
948
|
this.bridgedDevices.set(dishwasherDevice.deviceName ?? '', dishwasherDevice);
|
939
949
|
}
|
940
950
|
const refrigeratorDevice = new Appliances(refrigerator, 'Refrigerator', '9987654322');
|
951
|
+
refrigeratorDevice.addFixedLabel('composed', 'Refrigerator');
|
941
952
|
this.setSelectDevice(refrigeratorDevice.serialNumber ?? '', refrigeratorDevice.deviceName ?? '', undefined, 'hub');
|
942
953
|
if (this.validateDevice(refrigeratorDevice.deviceName ?? '')) {
|
943
954
|
await this.registerDevice(refrigeratorDevice);
|
944
955
|
this.bridgedDevices.set(refrigeratorDevice.deviceName ?? '', refrigeratorDevice);
|
945
956
|
}
|
946
957
|
const ovenDevice = new Appliances(oven, 'Oven', '1298867891');
|
958
|
+
ovenDevice.addFixedLabel('composed', 'Oven');
|
947
959
|
this.setSelectDevice(ovenDevice.serialNumber ?? '', ovenDevice.deviceName ?? '', undefined, 'hub');
|
948
960
|
if (this.validateDevice(ovenDevice.deviceName ?? '')) {
|
949
961
|
await this.registerDevice(ovenDevice);
|
@@ -1043,6 +1055,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
1043
1055
|
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.lightCT.log);
|
1044
1056
|
this.log.info(`Set lights currentLevel to ${this.intervalLevel}`);
|
1045
1057
|
}
|
1058
|
+
this.intervalColorTemperature += 50;
|
1059
|
+
if (this.intervalColorTemperature > 500) {
|
1060
|
+
this.intervalColorTemperature = 147;
|
1061
|
+
}
|
1062
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.light.log);
|
1063
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightHS.log);
|
1064
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightXY.log);
|
1065
|
+
await this.lightCT?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightCT.log);
|
1066
|
+
await this.light?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1067
|
+
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1068
|
+
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1069
|
+
await this.lightCT?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1070
|
+
this.log.info(`Set lights colorTemperatureMireds to ${this.intervalColorTemperature}`);
|
1046
1071
|
}, 60 * 1000 + 200);
|
1047
1072
|
}
|
1048
1073
|
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet.log);
|
@@ -1222,6 +1247,24 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
1222
1247
|
}
|
1223
1248
|
}, 60 * 1000 + 1100);
|
1224
1249
|
}
|
1250
|
+
const airConditionerDevice = this.bridgedDevices.get('Air Conditioner');
|
1251
|
+
await airConditionerDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, airConditionerDevice.log);
|
1252
|
+
const laundryWasherDevice = this.bridgedDevices.get('Laundry Washer');
|
1253
|
+
await laundryWasherDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, laundryWasherDevice.log);
|
1254
|
+
const laundryDryerDevice = this.bridgedDevices.get('Laundry Dryer');
|
1255
|
+
await laundryDryerDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, laundryDryerDevice.log);
|
1256
|
+
const dishwasherDevice = this.bridgedDevices.get('Dishwasher');
|
1257
|
+
await dishwasherDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, dishwasherDevice.log);
|
1258
|
+
this.log.info(`Set appliances dead front OnOff to on`);
|
1259
|
+
const cooktopDevice = this.bridgedDevices.get('Cooktop');
|
1260
|
+
await cooktopDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, cooktopDevice.log);
|
1261
|
+
cooktopDevice?.log.info(`Set Cooktop onOff only OnOff to on`);
|
1262
|
+
const surface1 = cooktopDevice?.getChildEndpointByName('Surface1');
|
1263
|
+
await surface1?.setAttribute(OnOff.Cluster.id, 'onOff', true, surface1.log);
|
1264
|
+
surface1?.log.info(`Set Surface 1 onOff only OnOff to on`);
|
1265
|
+
const surface2 = cooktopDevice?.getChildEndpointByName('Surface2');
|
1266
|
+
await surface2?.setAttribute(OnOff.Cluster.id, 'onOff', true, surface2.log);
|
1267
|
+
surface2?.log.info(`Set Surface 2 onOff only OnOff to on`);
|
1225
1268
|
if (this.config.useInterval) {
|
1226
1269
|
this.genericSwitchInterval = setInterval(async () => {
|
1227
1270
|
if (this.genericSwitchLastEvent === 'Release') {
|
package/dist/robot.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import { Matterbridge, MatterbridgeServer, MatterbridgeEndpoint, roboticVacuumCleaner,
|
2
|
-
import { LogLevel as MatterLogLevel, LogFormat as MatterLogFormat,
|
3
|
-
import {
|
4
|
-
import { OperationalState, PowerSource, RvcRunMode, RvcCleanMode, RvcOperationalState, ServiceArea, Actions } from 'matterbridge/matter/clusters';
|
1
|
+
import { Matterbridge, MatterbridgeServer, MatterbridgeEndpoint, roboticVacuumCleaner, dishwasher } from 'matterbridge';
|
2
|
+
import { LogLevel as MatterLogLevel, LogFormat as MatterLogFormat, DeviceTypeId, VendorId } from 'matterbridge/matter';
|
3
|
+
import { ModeBase, OperationalState, PowerSource, RvcRunMode, RvcCleanMode, RvcOperationalState, ServiceArea } from 'matterbridge/matter/clusters';
|
5
4
|
import { ActionsServer, RvcCleanModeBehavior, RvcOperationalStateBehavior, RvcRunModeBehavior, ServiceAreaBehavior } from 'matterbridge/matter/behaviors';
|
6
5
|
import { AnsiLogger } from 'matterbridge/logger';
|
7
6
|
export class Robot extends MatterbridgeEndpoint {
|
@@ -91,7 +90,7 @@ export class MatterbridgeServiceAreaServer extends ServiceAreaBehavior {
|
|
91
90
|
initialize() {
|
92
91
|
}
|
93
92
|
selectAreas({ newAreas }) {
|
94
|
-
const device = this.
|
93
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
95
94
|
for (const area of newAreas) {
|
96
95
|
const supportedArea = this.state.supportedAreas.find((supportedArea) => supportedArea.areaId === area);
|
97
96
|
if (!supportedArea) {
|
@@ -110,27 +109,27 @@ export class MatterbridgeRvcRunModeServer extends RvcRunModeBehavior {
|
|
110
109
|
this.state.currentMode = 1;
|
111
110
|
}
|
112
111
|
changeToMode({ newMode }) {
|
113
|
-
const device = this.
|
112
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
114
113
|
const changedMode = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
115
114
|
if (!changedMode) {
|
116
115
|
device.log.error('MatterbridgeRvcRunModeServer changeToMode called with unsupported newMode:', newMode);
|
117
|
-
return { status:
|
116
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
118
117
|
}
|
119
118
|
device.changeToMode({ newMode });
|
120
119
|
this.state.currentMode = newMode;
|
121
120
|
if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Cleaning)) {
|
122
121
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Cleaning => Running');
|
123
122
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
124
|
-
return { status:
|
123
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Running' };
|
125
124
|
}
|
126
125
|
else if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Idle)) {
|
127
126
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Idle => Docked');
|
128
127
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Docked;
|
129
|
-
return { status:
|
128
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Docked' };
|
130
129
|
}
|
131
130
|
device.log.info(`***MatterbridgeRvcRunModeServer changeToMode called with newMode ${newMode} => ${changedMode.label}`);
|
132
131
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
133
|
-
return { status:
|
132
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
134
133
|
}
|
135
134
|
}
|
136
135
|
export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
@@ -138,27 +137,27 @@ export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
|
138
137
|
this.state.currentMode = 1;
|
139
138
|
}
|
140
139
|
changeToMode({ newMode }) {
|
141
|
-
const device = this.
|
140
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
142
141
|
const supported = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
143
142
|
if (!supported) {
|
144
143
|
device.log.error('***MatterbridgeRvcCleanModeServer changeToMode called with unsupported newMode:', newMode);
|
145
|
-
return { status:
|
144
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
146
145
|
}
|
147
146
|
device.changeToMode({ newMode });
|
148
147
|
this.state.currentMode = newMode;
|
149
148
|
device.log.info(`***MatterbridgeRvcCleanModeServer changeToMode called with newMode ${newMode} => ${supported.label}`);
|
150
|
-
return { status:
|
149
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
151
150
|
}
|
152
151
|
}
|
153
152
|
export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBehavior {
|
154
153
|
initialize() {
|
155
|
-
const device = this.
|
154
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
156
155
|
device.log.info('***MatterbridgeRvcOperationalStateServer initialized: setting operational state to Docked');
|
157
156
|
this.state.operationalState = RvcOperationalState.OperationalState.Docked;
|
158
157
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
159
158
|
}
|
160
159
|
pause() {
|
161
|
-
const device = this.
|
160
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
162
161
|
device.log.info('MatterbridgeRvcOperationalStateServer: pause called setting operational state to Paused and currentMode to Idle');
|
163
162
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
|
164
163
|
this.state.operationalState = RvcOperationalState.OperationalState.Paused;
|
@@ -168,7 +167,7 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBe
|
|
168
167
|
};
|
169
168
|
}
|
170
169
|
resume() {
|
171
|
-
const device = this.
|
170
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
172
171
|
device.log.info('MatterbridgeRvcOperationalStateServer: resume called setting operational state to Running and currentMode to Cleaning');
|
173
172
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2;
|
174
173
|
this.state.operationalState = RvcOperationalState.OperationalState.Running;
|
@@ -205,30 +204,7 @@ if (process.argv.includes('-testRobot')) {
|
|
205
204
|
matterbridge.environment.vars.set('runtime.exitcode', true);
|
206
205
|
matterbridge.environment.vars.set('mdns.networkInterface', 'Wi-Fi');
|
207
206
|
await matterbridge.startMatterStorage();
|
208
|
-
const deviceType =
|
207
|
+
const deviceType = dishwasher;
|
209
208
|
const context = await matterbridge.createServerNodeContext('Matterbridge', deviceType.name, DeviceTypeId(deviceType.code), VendorId(0xfff1), 'Matterbridge', 0x8000, 'Matterbridge device');
|
210
209
|
const server = (await matterbridge.createServerNode(context));
|
211
|
-
const aggregator = (await matterbridge.createAggregatorNode(context));
|
212
|
-
createEndpointActionsClusterServer(aggregator, [
|
213
|
-
{
|
214
|
-
endpointListId: 1,
|
215
|
-
name: 'Living room',
|
216
|
-
type: Actions.EndpointListType.Room,
|
217
|
-
endpoints: [EndpointNumber(2)],
|
218
|
-
},
|
219
|
-
]);
|
220
|
-
await server.add(aggregator);
|
221
|
-
const outlet = new MatterbridgeEndpoint(onOffOutlet, { uniqueStorageKey: 'Outlet' }, true)
|
222
|
-
.createDefaultIdentifyClusterServer()
|
223
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Outlet', '99914248654', 0xfff1, 'Matterbridge', 'Matterbridge Outlet')
|
224
|
-
.createDefaultOnOffClusterServer()
|
225
|
-
.createDefaultGroupsClusterServer()
|
226
|
-
.createDefaultPowerSourceRechargeableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 5900)
|
227
|
-
.addRequiredClusterServers();
|
228
|
-
await aggregator.add(outlet);
|
229
|
-
const device = new Robot('Robot Vacuum', '99914248654');
|
230
|
-
await aggregator.add(device);
|
231
|
-
await matterbridge.startServerNode(server);
|
232
|
-
logEndpoint(EndpointServer.forEndpoint(server));
|
233
|
-
matterbridge.log.info(`Matterbridge server started. ServerNode id ${server.id}-${server.number}. Aggregator id ${aggregator.id}-${aggregator.number}. Device id ${device.id}-${device.number}.`);
|
234
210
|
}
|
@@ -39,10 +39,10 @@
|
|
39
39
|
"type": "boolean",
|
40
40
|
"default": true
|
41
41
|
},
|
42
|
-
"
|
43
|
-
"description": "Enable the
|
42
|
+
"enableRVC": {
|
43
|
+
"description": "Enable the Robot Vacuum Cleaner (Apple Home will crash unless you use child bridge and put the rvc in the white list as a single device)",
|
44
44
|
"type": "boolean",
|
45
|
-
"default":
|
45
|
+
"default": false
|
46
46
|
},
|
47
47
|
"debug": {
|
48
48
|
"description": "Enable the debug for the plugin (development only)",
|
package/npm-shrinkwrap.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "matterbridge-example-dynamic-platform",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.1",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "matterbridge-example-dynamic-platform",
|
9
|
-
"version": "1.2.
|
9
|
+
"version": "1.2.1",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"node-ansi-logger": "3.0.1",
|
package/package.json
CHANGED