matterbridge-example-dynamic-platform 1.2.0-edge.8 → 1.2.0
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 +13 -5
- package/README.md +12 -1
- package/dist/appliances.js +37 -12
- package/dist/platform.js +74 -25
- package/dist/robot.js +34 -31
- package/matterbridge-example-dynamic-platform.schema.json +7 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/tsconfig.jest.json +8 -0
package/CHANGELOG.md
CHANGED
@@ -8,18 +8,26 @@ 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.0] - 2025-04-
|
11
|
+
## [1.2.0] - 2025-04-30
|
12
12
|
|
13
13
|
### Added
|
14
14
|
|
15
|
-
- [platform]: Added Robot Vacuum Cleaner device (supported by SmartThings, Alexa, Home Assistant and Apple Home).
|
16
|
-
- [platform]: Added
|
15
|
+
- [platform]: Added Robot Vacuum Cleaner device (supported by SmartThings, Alexa, Home Assistant and partially by Apple Home). Read carefully the readme please.
|
16
|
+
- [platform]: Added OnOff Mounted Switch device (supported by SmartThings, Alexa, Home Assistant).
|
17
|
+
- [platform]: Added Dimmer Mounted Switch device (supported by SmartThings, Alexa, Home Assistant).
|
18
|
+
- [platform]: Added Laundry Washer device (supported by SmartThings, Alexa and Home Assistant).
|
19
|
+
- [platform]: Added Laundry Dryer device (supported by SmartThings, Alexa and Home Assistant).
|
17
20
|
- [platform]: Added Dishwasher device (supported by SmartThings, Alexa and Home Assistant).
|
18
|
-
- [platform]: Added
|
19
|
-
- [platform]: Added
|
21
|
+
- [platform]: Added Refrigerator device (supported by SmartThings, Alexa and Home Assistant).
|
22
|
+
- [platform]: Added Oven device (supported by SmartThings, Alexa and Home Assistant).
|
23
|
+
- [platform]: Added Microwave Oven device (supported by SmartThings, Alexa and Home Assistant).
|
24
|
+
- [platform]: Added Extractor Hood device (supported by SmartThings, Alexa and Home Assistant).
|
25
|
+
- [platform]: Added Cooktop device (supported by SmartThings, Alexa and Home Assistant).
|
20
26
|
|
21
27
|
### Changed
|
22
28
|
|
29
|
+
- [package]: Require matterbridge 3.0.0.
|
30
|
+
- [package]: Updated package.
|
23
31
|
- [package]: Updated dependencies.
|
24
32
|
|
25
33
|
<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
|
@@ -46,6 +46,17 @@ It exposes:
|
|
46
46
|
- an airQuality device with all concentration measurements clusters (supported by Apple Home only without the concentration measurements)
|
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,
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeServer, MatterbridgeOnOffServer, RefrigeratorTag, PositionTag, laundryWasher, laundryDryer, dishwasher, refrigerator, temperatureControlledCabinetCooler, oven, temperatureControlledCabinetHeater, microwaveOven, extractorHood, cooktop, cookSurface, powerSource, } from 'matterbridge';
|
2
2
|
import { ClusterBehavior } from 'matterbridge/matter';
|
3
|
-
import { OperationalState, TemperatureControl, DishwasherMode, LaundryWasherControls, LaundryWasherMode, LaundryDryerControls, OvenMode, RefrigeratorAndTemperatureControlledCabinetMode, MicrowaveOvenMode, MicrowaveOvenControl, OvenCavityOperationalState, } from 'matterbridge/matter/clusters';
|
3
|
+
import { OperationalState, TemperatureControl, DishwasherMode, LaundryWasherControls, LaundryWasherMode, LaundryDryerControls, OvenMode, ModeBase, RefrigeratorAndTemperatureControlledCabinetMode, MicrowaveOvenMode, MicrowaveOvenControl, OvenCavityOperationalState, } from 'matterbridge/matter/clusters';
|
4
4
|
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, MicrowaveOvenControlBehavior, MicrowaveOvenModeServer, OperationalStateBehavior, 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)`;
|
@@ -365,12 +373,29 @@ class MatterbridgeMicrowaveOvenControlServer extends MicrowaveOvenControlBehavio
|
|
365
373
|
}
|
366
374
|
setCookingParameters(request) {
|
367
375
|
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
376
|
+
if (request.cookMode !== undefined) {
|
377
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting cookMode to ${request.cookMode}`);
|
378
|
+
this.endpoint.setStateOf(MicrowaveOvenModeServer, { currentMode: request.cookMode });
|
379
|
+
}
|
380
|
+
else {
|
381
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no cookMode so set to Normal`);
|
382
|
+
this.endpoint.setStateOf(MicrowaveOvenModeServer, { currentMode: 6 });
|
383
|
+
}
|
384
|
+
if (request.cookTime !== undefined && request.cookTime >= 0 && request.cookTime <= this.state.maxCookTime) {
|
385
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting cookTime to ${request.cookTime}`);
|
386
|
+
this.state.cookTime = request.cookTime;
|
387
|
+
}
|
388
|
+
else {
|
389
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no cookTime so set to 30sec.`);
|
390
|
+
this.state.cookTime = 30;
|
391
|
+
}
|
368
392
|
if (request.wattSettingIndex !== undefined && request.wattSettingIndex >= 0 && request.wattSettingIndex < this.state.supportedWatts.length) {
|
369
393
|
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting selectedWattIndex to ${request.wattSettingIndex}`);
|
370
394
|
this.state.selectedWattIndex = request.wattSettingIndex;
|
371
395
|
}
|
372
396
|
else {
|
373
|
-
device.log.
|
397
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with no wattSettingIndex so set to the highest Watt setting for the selected CookMode`);
|
398
|
+
this.state.selectedWattIndex = this.state.supportedWatts.length - 1;
|
374
399
|
}
|
375
400
|
}
|
376
401
|
addMoreTime(request) {
|
@@ -424,11 +449,11 @@ class RefrigeratorAndTemperatureControlledCabinetModeServer extends Refrigerator
|
|
424
449
|
if (supportedMode) {
|
425
450
|
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
426
451
|
this.state.currentMode = request.newMode;
|
427
|
-
return { status:
|
452
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
428
453
|
}
|
429
454
|
else {
|
430
455
|
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
431
|
-
return { status:
|
456
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
432
457
|
}
|
433
458
|
}
|
434
459
|
}
|
@@ -445,11 +470,11 @@ class OvenModeServer extends OvenModeBehavior {
|
|
445
470
|
if (supportedMode) {
|
446
471
|
device.log.info(`OvenModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
447
472
|
this.state.currentMode = request.newMode;
|
448
|
-
return { status:
|
473
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
449
474
|
}
|
450
475
|
else {
|
451
476
|
device.log.info(`OvenModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
452
|
-
return { status:
|
477
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
453
478
|
}
|
454
479
|
}
|
455
480
|
}
|
@@ -474,11 +499,11 @@ class DishwasherModeServer extends DishwasherModeBehavior {
|
|
474
499
|
if (supportedMode) {
|
475
500
|
device.log.info(`DishwasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
476
501
|
this.state.currentMode = request.newMode;
|
477
|
-
return { status:
|
502
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
478
503
|
}
|
479
504
|
else {
|
480
505
|
device.log.error(`DishwasherModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
481
|
-
return { status:
|
506
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
482
507
|
}
|
483
508
|
}
|
484
509
|
}
|
@@ -503,11 +528,11 @@ class LaundryWasherModeServer extends LaundryWasherModeBehavior {
|
|
503
528
|
if (supportedMode) {
|
504
529
|
device.log.info(`LaundryWasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
505
530
|
this.state.currentMode = request.newMode;
|
506
|
-
return { status:
|
531
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
507
532
|
}
|
508
533
|
else {
|
509
534
|
device.log.error(`LaundryWasherModeServer: changeToMode called with invalid mode ${request.newMode}`);
|
510
|
-
return { status:
|
535
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
511
536
|
}
|
512
537
|
}
|
513
538
|
}
|
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,23 @@ 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.0')) {
|
61
|
+
throw new Error(`This plugin requires Matterbridge version >= "3.0.0". 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.enableConcentrationMeasurements === undefined)
|
69
|
+
config.enableConcentrationMeasurements = false;
|
70
|
+
if (config.enableRVC === undefined)
|
71
|
+
config.enableRVC = false;
|
67
72
|
}
|
68
73
|
async onStart(reason) {
|
69
74
|
this.log.info('onStart called with reason:', reason ?? 'none');
|
@@ -212,7 +217,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
212
217
|
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
213
218
|
this.dimmer?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
214
219
|
});
|
215
|
-
this.light = new MatterbridgeEndpoint([
|
220
|
+
this.light = new MatterbridgeEndpoint([extendedColorLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, HS and CT)' }, this.config.debug)
|
216
221
|
.createDefaultIdentifyClusterServer()
|
217
222
|
.createDefaultGroupsClusterServer()
|
218
223
|
.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 +326,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
321
326
|
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', colorTemperatureMireds, this.lightHS?.log);
|
322
327
|
this.lightHS?.log.debug(`Command moveToColorTemperature called request: ${colorTemperatureMireds}`);
|
323
328
|
});
|
324
|
-
this.lightXY = new MatterbridgeEndpoint([
|
329
|
+
this.lightXY = new MatterbridgeEndpoint([extendedColorLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (XY, CT)' }, this.config.debug)
|
325
330
|
.createDefaultIdentifyClusterServer()
|
326
331
|
.createDefaultGroupsClusterServer()
|
327
332
|
.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 +662,12 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
657
662
|
if (isValidNumber(newValue, 0, 100))
|
658
663
|
await this.airPurifier?.setAttribute(FanControl.Cluster.id, 'percentCurrent', newValue, this.airPurifier?.log);
|
659
664
|
}, this.airPurifier.log);
|
660
|
-
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air
|
661
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Air
|
665
|
+
this.airConditioner = new MatterbridgeEndpoint([airConditioner, bridgedNode, powerSource], { uniqueStorageKey: 'Air Conditioner' }, this.config.debug)
|
666
|
+
.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
667
|
.createDefaultIdentifyClusterServer()
|
663
668
|
.createDeadFrontOnOffClusterServer(true)
|
664
669
|
.createDefaultThermostatClusterServer(20, 18, 22)
|
670
|
+
.createDefaultThermostatUserInterfaceConfigurationClusterServer()
|
665
671
|
.createDefaultFanControlClusterServer(FanControl.FanMode.Auto)
|
666
672
|
.createDefaultTemperatureMeasurementClusterServer(20 * 100)
|
667
673
|
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
@@ -736,8 +742,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
736
742
|
this.valve?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
737
743
|
this.valve?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
738
744
|
});
|
739
|
-
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
745
|
+
this.fan = new MatterbridgeEndpoint([fanDevice, bridgedNode, powerSource], { uniqueStorageKey: 'Fan' }, this.config.debug)
|
740
746
|
.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)
|
747
|
+
.createDefaultPowerSourceWiredClusterServer()
|
741
748
|
.addRequiredClusterServers();
|
742
749
|
this.setSelectDevice(this.fan.serialNumber ?? '', this.fan.deviceName ?? '', undefined, 'hub');
|
743
750
|
if (this.validateDevice(this.fan.deviceName ?? '')) {
|
@@ -784,8 +791,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
784
791
|
if (isValidNumber(newValue, 0, 100))
|
785
792
|
await this.fan?.setAttribute(FanControl.Cluster.id, 'speedCurrent', newValue, this.fan?.log);
|
786
793
|
}, this.fan.log);
|
787
|
-
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
794
|
+
this.waterLeak = new MatterbridgeEndpoint([waterLeakDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water leak detector' }, this.config.debug)
|
788
795
|
.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)
|
796
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
789
797
|
.createDefaultBooleanStateClusterServer(false)
|
790
798
|
.addRequiredClusterServers()
|
791
799
|
.addOptionalClusterServers();
|
@@ -797,8 +805,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
797
805
|
else {
|
798
806
|
this.waterLeak = undefined;
|
799
807
|
}
|
800
|
-
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
808
|
+
this.waterFreeze = new MatterbridgeEndpoint([waterFreezeDetector, bridgedNode, powerSource], { uniqueStorageKey: 'Water freeze detector' }, this.config.debug)
|
801
809
|
.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)
|
810
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
802
811
|
.createDefaultBooleanStateClusterServer(false)
|
803
812
|
.addRequiredClusterServers()
|
804
813
|
.addOptionalClusterServers();
|
@@ -810,8 +819,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
810
819
|
else {
|
811
820
|
this.waterFreeze = undefined;
|
812
821
|
}
|
813
|
-
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
822
|
+
this.rain = new MatterbridgeEndpoint([rainSensor, bridgedNode, powerSource], { uniqueStorageKey: 'Rain sensor' }, this.config.debug)
|
814
823
|
.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)
|
824
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer()
|
815
825
|
.createDefaultIdentifyClusterServer()
|
816
826
|
.createDefaultBooleanStateClusterServer(false)
|
817
827
|
.createDefaultBooleanStateConfigurationClusterServer();
|
@@ -823,10 +833,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
823
833
|
else {
|
824
834
|
this.rain = undefined;
|
825
835
|
}
|
826
|
-
this.smokeCo = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'SmokeCo alarm sensor' }, this.config.debug)
|
836
|
+
this.smokeCo = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'SmokeCo alarm sensor' }, this.config.debug)
|
827
837
|
.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
838
|
.createDefaultIdentifyClusterServer()
|
829
|
-
.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
|
839
|
+
.createDefaultSmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal, SmokeCoAlarm.AlarmState.Normal)
|
840
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
830
841
|
if (this.config.enableConcentrationMeasurements === true)
|
831
842
|
this.smokeCo.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
832
843
|
this.setSelectDevice(this.smokeCo.serialNumber ?? '', this.smokeCo.deviceName ?? '', undefined, 'hub');
|
@@ -837,10 +848,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
837
848
|
else {
|
838
849
|
this.smokeCo = undefined;
|
839
850
|
}
|
840
|
-
this.smokeOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Smoke
|
841
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Smoke
|
851
|
+
this.smokeOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Smoke alarm sensor' }, this.config.debug)
|
852
|
+
.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
853
|
.createDefaultIdentifyClusterServer()
|
843
|
-
.createSmokeOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
854
|
+
.createSmokeOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
855
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
844
856
|
this.setSelectDevice(this.smokeOnly.serialNumber ?? '', this.smokeOnly.deviceName ?? '', undefined, 'hub');
|
845
857
|
if (this.validateDevice(this.smokeOnly.deviceName ?? '')) {
|
846
858
|
await this.registerDevice(this.smokeOnly);
|
@@ -849,10 +861,11 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
849
861
|
else {
|
850
862
|
this.smokeOnly = undefined;
|
851
863
|
}
|
852
|
-
this.coOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode], { uniqueStorageKey: 'Co
|
853
|
-
.createDefaultBridgedDeviceBasicInformationClusterServer('Co
|
864
|
+
this.coOnly = new MatterbridgeEndpoint([smokeCoAlarm, bridgedNode, powerSource], { uniqueStorageKey: 'Co alarm sensor' }, this.config.debug)
|
865
|
+
.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
866
|
.createDefaultIdentifyClusterServer()
|
855
|
-
.createCoOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
867
|
+
.createCoOnlySmokeCOAlarmClusterServer(SmokeCoAlarm.AlarmState.Normal)
|
868
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
856
869
|
if (this.config.enableConcentrationMeasurements === true)
|
857
870
|
this.coOnly.createDefaultCarbonMonoxideConcentrationMeasurementClusterServer(100);
|
858
871
|
this.setSelectDevice(this.coOnly.serialNumber ?? '', this.coOnly.deviceName ?? '', undefined, 'hub');
|
@@ -863,8 +876,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
863
876
|
else {
|
864
877
|
this.coOnly = undefined;
|
865
878
|
}
|
866
|
-
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
879
|
+
this.airQuality = new MatterbridgeEndpoint([airQualitySensor, bridgedNode, powerSource], { uniqueStorageKey: 'Air quality sensor' }, this.config.debug)
|
867
880
|
.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)
|
881
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(50, PowerSource.BatChargeLevel.Warning, 2900, 'CR2450', 1)
|
868
882
|
.addRequiredClusterServers()
|
869
883
|
.addClusterServers([TemperatureMeasurement.Cluster.id, RelativeHumidityMeasurement.Cluster.id]);
|
870
884
|
if (this.config.enableConcentrationMeasurements === true) {
|
@@ -913,11 +927,13 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
913
927
|
else {
|
914
928
|
this.latchingSwitch = undefined;
|
915
929
|
}
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
930
|
+
if (this.config.enableRVC === true) {
|
931
|
+
const robot = new Robot('Robot Vacuum', '1238777820');
|
932
|
+
this.setSelectDevice(robot.serialNumber ?? '', robot.deviceName ?? '', undefined, 'hub');
|
933
|
+
if (this.validateDevice(robot.deviceName ?? '')) {
|
934
|
+
await this.registerDevice(robot);
|
935
|
+
this.bridgedDevices.set(robot.deviceName ?? '', robot);
|
936
|
+
}
|
921
937
|
}
|
922
938
|
const laundryWasherDevice = new Appliances(laundryWasher, 'Laundry Washer', '1234567890');
|
923
939
|
this.setSelectDevice(laundryWasherDevice.serialNumber ?? '', laundryWasherDevice.deviceName ?? '', undefined, 'hub');
|
@@ -938,12 +954,14 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
938
954
|
this.bridgedDevices.set(dishwasherDevice.deviceName ?? '', dishwasherDevice);
|
939
955
|
}
|
940
956
|
const refrigeratorDevice = new Appliances(refrigerator, 'Refrigerator', '9987654322');
|
957
|
+
refrigeratorDevice.addFixedLabel('composed', 'Refrigerator');
|
941
958
|
this.setSelectDevice(refrigeratorDevice.serialNumber ?? '', refrigeratorDevice.deviceName ?? '', undefined, 'hub');
|
942
959
|
if (this.validateDevice(refrigeratorDevice.deviceName ?? '')) {
|
943
960
|
await this.registerDevice(refrigeratorDevice);
|
944
961
|
this.bridgedDevices.set(refrigeratorDevice.deviceName ?? '', refrigeratorDevice);
|
945
962
|
}
|
946
963
|
const ovenDevice = new Appliances(oven, 'Oven', '1298867891');
|
964
|
+
ovenDevice.addFixedLabel('composed', 'Oven');
|
947
965
|
this.setSelectDevice(ovenDevice.serialNumber ?? '', ovenDevice.deviceName ?? '', undefined, 'hub');
|
948
966
|
if (this.validateDevice(ovenDevice.deviceName ?? '')) {
|
949
967
|
await this.registerDevice(ovenDevice);
|
@@ -1043,6 +1061,19 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
1043
1061
|
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.lightCT.log);
|
1044
1062
|
this.log.info(`Set lights currentLevel to ${this.intervalLevel}`);
|
1045
1063
|
}
|
1064
|
+
this.intervalColorTemperature += 50;
|
1065
|
+
if (this.intervalColorTemperature > 500) {
|
1066
|
+
this.intervalColorTemperature = 147;
|
1067
|
+
}
|
1068
|
+
await this.light?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.light.log);
|
1069
|
+
await this.lightHS?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightHS.log);
|
1070
|
+
await this.lightXY?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightXY.log);
|
1071
|
+
await this.lightCT?.setAttribute(ColorControl.Cluster.id, 'colorTemperatureMireds', this.intervalColorTemperature, this.lightCT.log);
|
1072
|
+
await this.light?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1073
|
+
await this.lightHS?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1074
|
+
await this.lightXY?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1075
|
+
await this.lightCT?.configureColorControlMode(ColorControl.ColorMode.ColorTemperatureMireds);
|
1076
|
+
this.log.info(`Set lights colorTemperatureMireds to ${this.intervalColorTemperature}`);
|
1046
1077
|
}, 60 * 1000 + 200);
|
1047
1078
|
}
|
1048
1079
|
await this.outlet?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.outlet.log);
|
@@ -1222,6 +1253,24 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
1222
1253
|
}
|
1223
1254
|
}, 60 * 1000 + 1100);
|
1224
1255
|
}
|
1256
|
+
const airConditionerDevice = this.bridgedDevices.get('Air Conditioner');
|
1257
|
+
await airConditionerDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, airConditionerDevice.log);
|
1258
|
+
const laundryWasherDevice = this.bridgedDevices.get('Laundry Washer');
|
1259
|
+
await laundryWasherDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, laundryWasherDevice.log);
|
1260
|
+
const laundryDryerDevice = this.bridgedDevices.get('Laundry Dryer');
|
1261
|
+
await laundryDryerDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, laundryDryerDevice.log);
|
1262
|
+
const dishwasherDevice = this.bridgedDevices.get('Dishwasher');
|
1263
|
+
await dishwasherDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, dishwasherDevice.log);
|
1264
|
+
this.log.info(`Set appliances dead front OnOff to on`);
|
1265
|
+
const cooktopDevice = this.bridgedDevices.get('Cooktop');
|
1266
|
+
await cooktopDevice?.setAttribute(OnOff.Cluster.id, 'onOff', true, cooktopDevice.log);
|
1267
|
+
cooktopDevice?.log.info(`Set Cooktop onOff only OnOff to on`);
|
1268
|
+
const surface1 = cooktopDevice?.getChildEndpointByName('Surface1');
|
1269
|
+
await surface1?.setAttribute(OnOff.Cluster.id, 'onOff', true, surface1.log);
|
1270
|
+
surface1?.log.info(`Set Surface 1 onOff only OnOff to on`);
|
1271
|
+
const surface2 = cooktopDevice?.getChildEndpointByName('Surface2');
|
1272
|
+
await surface2?.setAttribute(OnOff.Cluster.id, 'onOff', true, surface2.log);
|
1273
|
+
surface2?.log.info(`Set Surface 2 onOff only OnOff to on`);
|
1225
1274
|
if (this.config.useInterval) {
|
1226
1275
|
this.genericSwitchInterval = setInterval(async () => {
|
1227
1276
|
if (this.genericSwitchLastEvent === 'Release') {
|
package/dist/robot.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
import { Matterbridge, MatterbridgeServer, MatterbridgeEndpoint, roboticVacuumCleaner } from 'matterbridge';
|
2
|
-
import { LogLevel as MatterLogLevel, LogFormat as MatterLogFormat,
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import { RvcCleanModeBehavior, RvcOperationalStateBehavior, RvcRunModeBehavior, ServiceAreaBehavior } from 'matterbridge/matter/behaviors';
|
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';
|
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 {
|
8
7
|
constructor(name, serial) {
|
@@ -68,11 +67,11 @@ export class Robot extends MatterbridgeEndpoint {
|
|
68
67
|
});
|
69
68
|
return this;
|
70
69
|
}
|
71
|
-
createDefaultRvcOperationalStateClusterServer() {
|
70
|
+
createDefaultRvcOperationalStateClusterServer(phaseList = null, currentPhase = null, operationalStateList, operationalState, operationalError) {
|
72
71
|
this.behaviors.require(MatterbridgeRvcOperationalStateServer, {
|
73
|
-
phaseList
|
74
|
-
currentPhase
|
75
|
-
operationalStateList: [
|
72
|
+
phaseList,
|
73
|
+
currentPhase,
|
74
|
+
operationalStateList: operationalStateList ?? [
|
76
75
|
{ operationalStateId: RvcOperationalState.OperationalState.Stopped, operationalStateLabel: 'Stopped' },
|
77
76
|
{ operationalStateId: RvcOperationalState.OperationalState.Running, operationalStateLabel: 'Running' },
|
78
77
|
{ operationalStateId: RvcOperationalState.OperationalState.Paused, operationalStateLabel: 'Paused' },
|
@@ -81,8 +80,8 @@ export class Robot extends MatterbridgeEndpoint {
|
|
81
80
|
{ operationalStateId: RvcOperationalState.OperationalState.Charging, operationalStateLabel: 'Charging' },
|
82
81
|
{ operationalStateId: RvcOperationalState.OperationalState.Docked, operationalStateLabel: 'Docked' },
|
83
82
|
],
|
84
|
-
operationalState: RvcOperationalState.OperationalState.Docked,
|
85
|
-
operationalError: { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' },
|
83
|
+
operationalState: operationalState ?? RvcOperationalState.OperationalState.Docked,
|
84
|
+
operationalError: operationalError ?? { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' },
|
86
85
|
});
|
87
86
|
return this;
|
88
87
|
}
|
@@ -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) {
|
@@ -100,6 +99,8 @@ export class MatterbridgeServiceAreaServer extends ServiceAreaBehavior {
|
|
100
99
|
}
|
101
100
|
}
|
102
101
|
this.state.selectedAreas = newAreas;
|
102
|
+
this.state.currentArea = newAreas[0];
|
103
|
+
device.log.info(`***MatterbridgeServiceAreaServer selectAreas called with: ${newAreas.map((area) => area.toString()).join(', ')}`);
|
103
104
|
return { status: ServiceArea.SelectAreasStatus.Success, statusText: 'Succesfully selected new areas' };
|
104
105
|
}
|
105
106
|
}
|
@@ -108,27 +109,27 @@ export class MatterbridgeRvcRunModeServer extends RvcRunModeBehavior {
|
|
108
109
|
this.state.currentMode = 1;
|
109
110
|
}
|
110
111
|
changeToMode({ newMode }) {
|
111
|
-
const device = this.
|
112
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
112
113
|
const changedMode = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
113
114
|
if (!changedMode) {
|
114
115
|
device.log.error('MatterbridgeRvcRunModeServer changeToMode called with unsupported newMode:', newMode);
|
115
|
-
return { status:
|
116
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
116
117
|
}
|
117
118
|
device.changeToMode({ newMode });
|
118
119
|
this.state.currentMode = newMode;
|
119
120
|
if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Cleaning)) {
|
120
121
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Cleaning => Running');
|
121
122
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
122
|
-
return { status:
|
123
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Running' };
|
123
124
|
}
|
124
125
|
else if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Idle)) {
|
125
126
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Idle => Docked');
|
126
127
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Docked;
|
127
|
-
return { status:
|
128
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Docked' };
|
128
129
|
}
|
129
130
|
device.log.info(`***MatterbridgeRvcRunModeServer changeToMode called with newMode ${newMode} => ${changedMode.label}`);
|
130
131
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
131
|
-
return { status:
|
132
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
132
133
|
}
|
133
134
|
}
|
134
135
|
export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
@@ -136,27 +137,27 @@ export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
|
136
137
|
this.state.currentMode = 1;
|
137
138
|
}
|
138
139
|
changeToMode({ newMode }) {
|
139
|
-
const device = this.
|
140
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
140
141
|
const supported = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
141
142
|
if (!supported) {
|
142
143
|
device.log.error('***MatterbridgeRvcCleanModeServer changeToMode called with unsupported newMode:', newMode);
|
143
|
-
return { status:
|
144
|
+
return { status: ModeBase.ModeChangeStatus.InvalidInMode, statusText: 'Invalid mode' };
|
144
145
|
}
|
145
146
|
device.changeToMode({ newMode });
|
146
147
|
this.state.currentMode = newMode;
|
147
148
|
device.log.info(`***MatterbridgeRvcCleanModeServer changeToMode called with newMode ${newMode} => ${supported.label}`);
|
148
|
-
return { status:
|
149
|
+
return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
|
149
150
|
}
|
150
151
|
}
|
151
152
|
export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBehavior {
|
152
153
|
initialize() {
|
153
|
-
const device = this.
|
154
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
154
155
|
device.log.info('***MatterbridgeRvcOperationalStateServer initialized: setting operational state to Docked');
|
155
156
|
this.state.operationalState = RvcOperationalState.OperationalState.Docked;
|
156
157
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
157
158
|
}
|
158
159
|
pause() {
|
159
|
-
const device = this.
|
160
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
160
161
|
device.log.info('MatterbridgeRvcOperationalStateServer: pause called setting operational state to Paused and currentMode to Idle');
|
161
162
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
|
162
163
|
this.state.operationalState = RvcOperationalState.OperationalState.Paused;
|
@@ -166,7 +167,7 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBe
|
|
166
167
|
};
|
167
168
|
}
|
168
169
|
resume() {
|
169
|
-
const device = this.
|
170
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
170
171
|
device.log.info('MatterbridgeRvcOperationalStateServer: resume called setting operational state to Running and currentMode to Cleaning');
|
171
172
|
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2;
|
172
173
|
this.state.operationalState = RvcOperationalState.OperationalState.Running;
|
@@ -186,6 +187,13 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBe
|
|
186
187
|
};
|
187
188
|
}
|
188
189
|
}
|
190
|
+
function createEndpointActionsClusterServer(endpoint, endpointLists) {
|
191
|
+
endpoint.behaviors.require(ActionsServer, {
|
192
|
+
actionList: [],
|
193
|
+
endpointLists,
|
194
|
+
});
|
195
|
+
return endpoint;
|
196
|
+
}
|
189
197
|
if (process.argv.includes('-testRobot')) {
|
190
198
|
const matterbridge = await Matterbridge.loadInstance(false);
|
191
199
|
matterbridge.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4, logLevel: "debug" });
|
@@ -196,12 +204,7 @@ if (process.argv.includes('-testRobot')) {
|
|
196
204
|
matterbridge.environment.vars.set('runtime.exitcode', true);
|
197
205
|
matterbridge.environment.vars.set('mdns.networkInterface', 'Wi-Fi');
|
198
206
|
await matterbridge.startMatterStorage();
|
199
|
-
const deviceType =
|
200
|
-
const context = await matterbridge.createServerNodeContext('
|
201
|
-
const server = await matterbridge.createServerNode(context);
|
202
|
-
const device = new Robot('Robot Vacuum', '99914248654');
|
203
|
-
await server.add(device);
|
204
|
-
logEndpoint(EndpointServer.forEndpoint(device));
|
205
|
-
await matterbridge.startServerNode(server);
|
206
|
-
logEndpoint(EndpointServer.forEndpoint(server));
|
207
|
+
const deviceType = dishwasher;
|
208
|
+
const context = await matterbridge.createServerNodeContext('Matterbridge', deviceType.name, DeviceTypeId(deviceType.code), VendorId(0xfff1), 'Matterbridge', 0x8000, 'Matterbridge device');
|
209
|
+
const server = (await matterbridge.createServerNode(context));
|
207
210
|
}
|
@@ -40,9 +40,14 @@
|
|
40
40
|
"default": true
|
41
41
|
},
|
42
42
|
"enableConcentrationMeasurements": {
|
43
|
-
"description": "Enable the ConcentrationMeasurements in the Air Quality device and SmokeCoSensor
|
43
|
+
"description": "Enable the ConcentrationMeasurements in the Air Quality device and SmokeCoSensor device (Apple Home 18.4 will discard these devices when enabled)",
|
44
44
|
"type": "boolean",
|
45
|
-
"default":
|
45
|
+
"default": false
|
46
|
+
},
|
47
|
+
"enableRVC": {
|
48
|
+
"description": "Enable the Robot Vacuum Cleaner (Apple Home 18.4 will crash unless you use child bridge and put the rvc in the white list as a single device)",
|
49
|
+
"type": "boolean",
|
50
|
+
"default": false
|
46
51
|
},
|
47
52
|
"debug": {
|
48
53
|
"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.0
|
3
|
+
"version": "1.2.0",
|
4
4
|
"lockfileVersion": 3,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "matterbridge-example-dynamic-platform",
|
9
|
-
"version": "1.2.0
|
9
|
+
"version": "1.2.0",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"node-ansi-logger": "3.0.1",
|
package/package.json
CHANGED