matterbridge-example-dynamic-platform 1.2.0-edge.5 → 1.2.0-edge.8
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/dist/appliances.js +192 -131
- package/dist/platform.js +151 -78
- package/dist/robot.js +35 -36
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/implementations/carbonMonoxideConcentrationMeasurement.js +0 -113
- package/dist/implementations/ovenCavityOperationalStateCluster.js +0 -30
- package/dist/implementations/roboticVacuumCleanerClusters.js +0 -71
package/dist/appliances.js
CHANGED
@@ -1,54 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import { ClusterBehavior
|
3
|
-
import {
|
4
|
-
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, OperationalStateBehavior, TemperatureControlBehavior, } from 'matterbridge/matter/behaviors';
|
5
|
-
import { OvenCavityOperationalState } from './implementations/ovenCavityOperationalStateCluster.js';
|
6
|
-
import { AnsiLogger } from 'matterbridge/logger';
|
7
|
-
import { Robot } from './robot.js';
|
1
|
+
import { MatterbridgeEndpoint, MatterbridgeServer, MatterbridgeOnOffServer, Status, RefrigeratorTag, PositionTag, laundryWasher, laundryDryer, dishwasher, refrigerator, temperatureControlledCabinetCooler, oven, temperatureControlledCabinetHeater, microwaveOven, extractorHood, cooktop, cookSurface, } from 'matterbridge';
|
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, OperationalStateBehavior, TemperatureControlBehavior, } from 'matterbridge/matter/behaviors';
|
8
5
|
export class Appliances extends MatterbridgeEndpoint {
|
9
|
-
static temperatureControlledCabinetCooler = DeviceTypeDefinition({
|
10
|
-
name: 'MA-temperaturecontrolledcabinetcooler',
|
11
|
-
code: 0x71,
|
12
|
-
deviceClass: DeviceClasses.Simple,
|
13
|
-
revision: 3,
|
14
|
-
requiredServerClusters: [TemperatureControl.Cluster.id, RefrigeratorAndTemperatureControlledCabinetMode.Cluster.id],
|
15
|
-
optionalServerClusters: [TemperatureMeasurement.Cluster.id],
|
16
|
-
});
|
17
|
-
static temperatureControlledCabinetHeater = DeviceTypeDefinition({
|
18
|
-
name: 'MA-temperaturecontrolledcabinetheater',
|
19
|
-
code: 0x71,
|
20
|
-
deviceClass: DeviceClasses.Simple,
|
21
|
-
revision: 3,
|
22
|
-
requiredServerClusters: [TemperatureControl.Cluster.id, OvenMode.Cluster.id, OvenCavityOperationalState.Cluster.id],
|
23
|
-
optionalServerClusters: [TemperatureMeasurement.Cluster.id],
|
24
|
-
});
|
25
|
-
static laundryWasher = DeviceTypeDefinition({
|
26
|
-
name: 'MA-laundrywasher',
|
27
|
-
code: 0x73,
|
28
|
-
deviceClass: DeviceClasses.Simple,
|
29
|
-
revision: 1,
|
30
|
-
requiredServerClusters: [OperationalState.Cluster.id],
|
31
|
-
optionalServerClusters: [Identify.Cluster.id, LaundryWasherMode.Cluster.id, OnOff.Cluster.id, LaundryWasherControls.Cluster.id, TemperatureControl.Cluster.id],
|
32
|
-
});
|
33
|
-
static laundryDryer = DeviceTypeDefinition({
|
34
|
-
name: 'MA-laundrydryer',
|
35
|
-
code: 0x7c,
|
36
|
-
deviceClass: DeviceClasses.Simple,
|
37
|
-
revision: 1,
|
38
|
-
requiredServerClusters: [OperationalState.Cluster.id],
|
39
|
-
optionalServerClusters: [Identify.Cluster.id, LaundryWasherMode.Cluster.id, OnOff.Cluster.id, LaundryDryerControls.Cluster.id, TemperatureControl.Cluster.id],
|
40
|
-
});
|
41
|
-
static dishwasher = DeviceTypeDefinition({
|
42
|
-
name: 'MA-dishwasher',
|
43
|
-
code: 0x75,
|
44
|
-
deviceClass: DeviceClasses.Simple,
|
45
|
-
revision: 1,
|
46
|
-
requiredServerClusters: [OperationalState.Cluster.id],
|
47
|
-
optionalServerClusters: [Identify.Cluster.id, OnOff.Cluster.id, TemperatureControl.Cluster.id, DishwasherMode.Cluster.id, DishwasherAlarm.Cluster.id],
|
48
|
-
});
|
49
6
|
constructor(deviceType, name, serial) {
|
50
|
-
super(deviceType, { uniqueStorageKey: `${name}-${serial}` });
|
51
|
-
if (deviceType.code ===
|
7
|
+
super(deviceType, { uniqueStorageKey: `${name}-${serial}` }, true);
|
8
|
+
if (deviceType.code === laundryWasher.code) {
|
52
9
|
this.createDefaultIdentifyClusterServer();
|
53
10
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Washer');
|
54
11
|
this.createDeadFrontOnOffClusterServer();
|
@@ -57,7 +14,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
57
14
|
this.createSpinLaundryWasherControlsClusterServer(3, ['400', '800', '1200', '1600']);
|
58
15
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
59
16
|
}
|
60
|
-
else if (deviceType.code ===
|
17
|
+
else if (deviceType.code === laundryDryer.code) {
|
61
18
|
this.createDefaultIdentifyClusterServer();
|
62
19
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Dryer');
|
63
20
|
this.createDeadFrontOnOffClusterServer();
|
@@ -66,7 +23,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
66
23
|
this.createDefaultLaundryDryerControlsClusterServer(1);
|
67
24
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
68
25
|
}
|
69
|
-
else if (deviceType.code ===
|
26
|
+
else if (deviceType.code === dishwasher.code) {
|
70
27
|
this.createDefaultIdentifyClusterServer();
|
71
28
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Dishwasher');
|
72
29
|
this.createDeadFrontOnOffClusterServer();
|
@@ -75,20 +32,75 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
75
32
|
this.createDefaultDishwasherAlarmClusterServer();
|
76
33
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
77
34
|
}
|
78
|
-
else if (deviceType.name ===
|
35
|
+
else if (deviceType.name === refrigerator.name) {
|
79
36
|
this.createDefaultIdentifyClusterServer();
|
80
|
-
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, '
|
81
|
-
this.
|
82
|
-
|
83
|
-
|
37
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Refrigerator');
|
38
|
+
const refrigerator = this.addChildDeviceType('Refrigerator', temperatureControlledCabinetCooler, { tagList: [{ mfgCode: null, namespaceId: RefrigeratorTag.Refrigerator.namespaceId, tag: RefrigeratorTag.Refrigerator.tag, label: RefrigeratorTag.Refrigerator.label }] }, true);
|
39
|
+
refrigerator.log.logName = `Refrigerator (cabinet Refrigerator)`;
|
40
|
+
refrigerator.createDefaultIdentifyClusterServer();
|
41
|
+
Appliances.createLevelTemperatureControlClusterServer(refrigerator, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
42
|
+
refrigerator.createDefaultTemperatureMeasurementClusterServer(1000);
|
43
|
+
Appliances.createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(refrigerator, 1);
|
44
|
+
const freezer = this.addChildDeviceType('Freezer', temperatureControlledCabinetCooler, { tagList: [{ mfgCode: null, namespaceId: RefrigeratorTag.Freezer.namespaceId, tag: RefrigeratorTag.Freezer.tag, label: RefrigeratorTag.Freezer.label }] }, true);
|
45
|
+
freezer.log.logName = `Refrigerator (cabinet Freezer)`;
|
46
|
+
freezer.createDefaultIdentifyClusterServer();
|
47
|
+
Appliances.createLevelTemperatureControlClusterServer(freezer, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
48
|
+
freezer.createDefaultTemperatureMeasurementClusterServer(-2000);
|
49
|
+
Appliances.createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(freezer, 1);
|
84
50
|
}
|
85
|
-
else if (deviceType.name ===
|
51
|
+
else if (deviceType.name === oven.name) {
|
86
52
|
this.createDefaultIdentifyClusterServer();
|
87
|
-
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, '
|
88
|
-
this.
|
89
|
-
|
90
|
-
|
91
|
-
|
53
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Oven');
|
54
|
+
const cabinettop = this.addChildDeviceType('Oven (top)', temperatureControlledCabinetHeater, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Top.namespaceId, tag: PositionTag.Top.tag, label: PositionTag.Top.label }] }, true);
|
55
|
+
cabinettop.log.logName = `Oven (top)`;
|
56
|
+
cabinettop.createDefaultIdentifyClusterServer();
|
57
|
+
Appliances.createLevelTemperatureControlClusterServer(cabinettop, 2, ['Defrost', '180°', '200°', '250°', '300°']);
|
58
|
+
cabinettop.createDefaultTemperatureMeasurementClusterServer(20000);
|
59
|
+
Appliances.createDefaultOvenModeClusterServer(cabinettop, 1);
|
60
|
+
const cabinetbottom = this.addChildDeviceType('Oven (bottom)', temperatureControlledCabinetHeater, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Bottom.namespaceId, tag: PositionTag.Bottom.tag, label: PositionTag.Bottom.label }] }, true);
|
61
|
+
cabinetbottom.log.logName = `Oven (bottom)`;
|
62
|
+
cabinetbottom.createDefaultIdentifyClusterServer();
|
63
|
+
Appliances.createLevelTemperatureControlClusterServer(cabinetbottom, 2, ['Defrost', '180°', '200°', '250°', '300°']);
|
64
|
+
cabinetbottom.createDefaultTemperatureMeasurementClusterServer(30000);
|
65
|
+
Appliances.createDefaultOvenModeClusterServer(cabinetbottom, 1);
|
66
|
+
}
|
67
|
+
else if (deviceType.name === microwaveOven.name) {
|
68
|
+
this.createDefaultIdentifyClusterServer();
|
69
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Microwave Oven');
|
70
|
+
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
71
|
+
this.createDefaultMicrowaveOvenModeClusterServer();
|
72
|
+
this.createDefaultMicrowaveOvenControlClusterServer();
|
73
|
+
}
|
74
|
+
else if (deviceType.name === extractorHood.name) {
|
75
|
+
this.createDefaultIdentifyClusterServer();
|
76
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Extractor Hood');
|
77
|
+
this.createBaseFanControlClusterServer();
|
78
|
+
this.createDefaultHepaFilterMonitoringClusterServer();
|
79
|
+
this.createDefaultActivatedCarbonFilterMonitoringClusterServer();
|
80
|
+
}
|
81
|
+
else if (deviceType.name === cooktop.name) {
|
82
|
+
this.createDefaultIdentifyClusterServer();
|
83
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Cooktop');
|
84
|
+
this.createOffOnlyOnOffClusterServer(true);
|
85
|
+
const cookSurface1 = this.addChildDeviceType('Surface 1', cookSurface, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Left.namespaceId, tag: PositionTag.Left.tag, label: PositionTag.Left.label }] }, true);
|
86
|
+
cookSurface1.log.logName = `Cook surface (right)`;
|
87
|
+
cookSurface1.createDefaultIdentifyClusterServer();
|
88
|
+
Appliances.createLevelTemperatureControlClusterServer(cookSurface1, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
89
|
+
cookSurface1.createDefaultTemperatureMeasurementClusterServer(10000);
|
90
|
+
cookSurface1.createOffOnlyOnOffClusterServer(true);
|
91
|
+
const cookSurface2 = this.addChildDeviceType('Surface 2', cookSurface, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Right.namespaceId, tag: PositionTag.Right.tag, label: PositionTag.Right.label }] }, true);
|
92
|
+
cookSurface2.log.logName = `Cook surface (left)`;
|
93
|
+
cookSurface2.createDefaultIdentifyClusterServer();
|
94
|
+
Appliances.createLevelTemperatureControlClusterServer(cookSurface2, 3, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
95
|
+
cookSurface2.createDefaultTemperatureMeasurementClusterServer(12000);
|
96
|
+
cookSurface2.createOffOnlyOnOffClusterServer(true);
|
97
|
+
this.eventsOf(MatterbridgeOnOffServer).onOff$Changed.on(async (value) => {
|
98
|
+
if (!value) {
|
99
|
+
this.log.notice('Turning off all cook surfaces');
|
100
|
+
await cookSurface1.setStateOf(MatterbridgeOnOffServer, { onOff: false });
|
101
|
+
await cookSurface2.setStateOf(MatterbridgeOnOffServer, { onOff: false });
|
102
|
+
}
|
103
|
+
});
|
92
104
|
}
|
93
105
|
}
|
94
106
|
createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
@@ -120,15 +132,34 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
120
132
|
});
|
121
133
|
return this;
|
122
134
|
}
|
123
|
-
createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(currentMode) {
|
124
|
-
|
135
|
+
static createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(endpoint, currentMode) {
|
136
|
+
endpoint.behaviors.require(RefrigeratorAndTemperatureControlledCabinetModeServer, {
|
125
137
|
supportedModes: [
|
138
|
+
{ label: 'Auto', mode: 0, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.Auto }] },
|
126
139
|
{ label: 'RapidCool', mode: 1, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.RapidCool }] },
|
127
140
|
{ label: 'RapidFreeze', mode: 2, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.RapidFreeze }] },
|
128
141
|
],
|
129
142
|
currentMode,
|
130
143
|
});
|
131
|
-
return
|
144
|
+
return endpoint;
|
145
|
+
}
|
146
|
+
static createDefaultOvenModeClusterServer(endpoint, currentMode) {
|
147
|
+
endpoint.behaviors.require(OvenModeServer, {
|
148
|
+
supportedModes: [
|
149
|
+
{ label: 'Bake', mode: 1, modeTags: [{ value: OvenMode.ModeTag.Bake }] },
|
150
|
+
{ label: 'Convection', mode: 2, modeTags: [{ value: OvenMode.ModeTag.Convection }] },
|
151
|
+
{ label: 'Grill', mode: 3, modeTags: [{ value: OvenMode.ModeTag.Grill }] },
|
152
|
+
{ label: 'Roast', mode: 4, modeTags: [{ value: OvenMode.ModeTag.Roast }] },
|
153
|
+
{ label: 'Clean', mode: 5, modeTags: [{ value: OvenMode.ModeTag.Clean }] },
|
154
|
+
{ label: 'Convection Bake', mode: 6, modeTags: [{ value: OvenMode.ModeTag.ConvectionBake }] },
|
155
|
+
{ label: 'Convection Roast', mode: 7, modeTags: [{ value: OvenMode.ModeTag.ConvectionRoast }] },
|
156
|
+
{ label: 'Warming', mode: 8, modeTags: [{ value: OvenMode.ModeTag.Warming }] },
|
157
|
+
{ label: 'Proofing', mode: 9, modeTags: [{ value: OvenMode.ModeTag.Proofing }] },
|
158
|
+
{ label: 'Steam', mode: 10, modeTags: [{ value: OvenMode.ModeTag.Steam }] },
|
159
|
+
],
|
160
|
+
currentMode,
|
161
|
+
});
|
162
|
+
return endpoint;
|
132
163
|
}
|
133
164
|
createDefaultDishwasherModeClusterServer(currentMode) {
|
134
165
|
this.behaviors.require(DishwasherModeServer, {
|
@@ -153,6 +184,30 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
153
184
|
});
|
154
185
|
return this;
|
155
186
|
}
|
187
|
+
createDefaultMicrowaveOvenModeClusterServer(currentMode, supportedModes) {
|
188
|
+
this.behaviors.require(MicrowaveOvenModeServer, {
|
189
|
+
supportedModes: supportedModes ?? [
|
190
|
+
{ label: 'Auto', mode: 1, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Auto }] },
|
191
|
+
{ label: 'Quick', mode: 2, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Quick }] },
|
192
|
+
{ label: 'Quiet', mode: 3, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Quiet }] },
|
193
|
+
{ label: 'Min', mode: 4, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Min }] },
|
194
|
+
{ label: 'Max', mode: 5, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Max }] },
|
195
|
+
{ label: 'Normal', mode: 6, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Normal }] },
|
196
|
+
{ label: 'Defrost', mode: 7, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Defrost }] },
|
197
|
+
],
|
198
|
+
currentMode: currentMode ?? 1,
|
199
|
+
});
|
200
|
+
return this;
|
201
|
+
}
|
202
|
+
createDefaultMicrowaveOvenControlClusterServer(selectedWattIndex = 5, supportedWatts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], cookTime = 60, maxCookTime = 3600) {
|
203
|
+
this.behaviors.require(MatterbridgeMicrowaveOvenControlServer.with(MicrowaveOvenControl.Feature.PowerInWatts), {
|
204
|
+
supportedWatts,
|
205
|
+
selectedWattIndex,
|
206
|
+
cookTime,
|
207
|
+
maxCookTime,
|
208
|
+
});
|
209
|
+
return this;
|
210
|
+
}
|
156
211
|
createSpinLaundryWasherControlsClusterServer(spinSpeedCurrent, spinSpeeds) {
|
157
212
|
this.behaviors.require(LaundryWasherControlsServer.with(LaundryWasherControls.Feature.Spin), {
|
158
213
|
spinSpeeds: spinSpeeds ?? ['400', '800', '1200', '1600'],
|
@@ -192,24 +247,6 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
192
247
|
});
|
193
248
|
return this;
|
194
249
|
}
|
195
|
-
createDefaultOvenModeClusterServer(currentMode) {
|
196
|
-
this.behaviors.require(OvenModeServer, {
|
197
|
-
supportedModes: [
|
198
|
-
{ label: 'Bake', mode: 1, modeTags: [{ value: OvenMode.ModeTag.Bake }] },
|
199
|
-
{ label: 'Convection', mode: 2, modeTags: [{ value: OvenMode.ModeTag.Convection }] },
|
200
|
-
{ label: 'Grill', mode: 3, modeTags: [{ value: OvenMode.ModeTag.Grill }] },
|
201
|
-
{ label: 'Roast', mode: 4, modeTags: [{ value: OvenMode.ModeTag.Roast }] },
|
202
|
-
{ label: 'Clean', mode: 5, modeTags: [{ value: OvenMode.ModeTag.Clean }] },
|
203
|
-
{ label: 'Convection Bake', mode: 6, modeTags: [{ value: OvenMode.ModeTag.ConvectionBake }] },
|
204
|
-
{ label: 'Convection Roast', mode: 7, modeTags: [{ value: OvenMode.ModeTag.ConvectionRoast }] },
|
205
|
-
{ label: 'Warming', mode: 8, modeTags: [{ value: OvenMode.ModeTag.Warming }] },
|
206
|
-
{ label: 'Proofing', mode: 9, modeTags: [{ value: OvenMode.ModeTag.Proofing }] },
|
207
|
-
{ label: 'Steam', mode: 10, modeTags: [{ value: OvenMode.ModeTag.Steam }] },
|
208
|
-
],
|
209
|
-
currentMode,
|
210
|
-
});
|
211
|
-
return this;
|
212
|
-
}
|
213
250
|
createLevelTemperatureControlClusterServer(selectedTemperatureLevel = 1, supportedTemperatureLevels = ['Cold', 'Warm', 'Hot']) {
|
214
251
|
this.behaviors.require(MatterbridgeLevelTemperatureControlServer.with(TemperatureControl.Feature.TemperatureLevel), {
|
215
252
|
selectedTemperatureLevel,
|
@@ -217,6 +254,13 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
217
254
|
});
|
218
255
|
return this;
|
219
256
|
}
|
257
|
+
static createLevelTemperatureControlClusterServer(endpoint, selectedTemperatureLevel = 1, supportedTemperatureLevels = ['Cold', 'Warm', 'Hot']) {
|
258
|
+
endpoint.behaviors.require(MatterbridgeLevelTemperatureControlServer.with(TemperatureControl.Feature.TemperatureLevel), {
|
259
|
+
selectedTemperatureLevel,
|
260
|
+
supportedTemperatureLevels,
|
261
|
+
});
|
262
|
+
return endpoint;
|
263
|
+
}
|
220
264
|
createNumberTemperatureControlClusterServer(temperatureSetpoint, minTemperature, maxTemperature, step = 1) {
|
221
265
|
this.behaviors.require(MatterbridgeNumberTemperatureControlServer.with(TemperatureControl.Feature.TemperatureNumber, TemperatureControl.Feature.TemperatureStep), {
|
222
266
|
temperatureSetpoint,
|
@@ -226,16 +270,25 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
226
270
|
});
|
227
271
|
return this;
|
228
272
|
}
|
273
|
+
static createNumberTemperatureControlClusterServer(endpoint, temperatureSetpoint, minTemperature, maxTemperature, step = 1) {
|
274
|
+
endpoint.behaviors.require(MatterbridgeNumberTemperatureControlServer.with(TemperatureControl.Feature.TemperatureNumber, TemperatureControl.Feature.TemperatureStep), {
|
275
|
+
temperatureSetpoint,
|
276
|
+
minTemperature,
|
277
|
+
maxTemperature,
|
278
|
+
step,
|
279
|
+
});
|
280
|
+
return endpoint;
|
281
|
+
}
|
229
282
|
}
|
230
283
|
class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
231
284
|
initialize() {
|
232
|
-
const device = this.
|
285
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
233
286
|
device.log.info('MatterbridgeOperationalStateServer initialized: setting operational state to Stopped');
|
234
287
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
235
288
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
236
289
|
}
|
237
290
|
pause() {
|
238
|
-
const device = this.
|
291
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
239
292
|
device.log.info('MatterbridgeOperationalStateServer: pause called setting operational state to Paused');
|
240
293
|
this.state.operationalState = OperationalState.OperationalStateEnum.Paused;
|
241
294
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -244,7 +297,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
244
297
|
};
|
245
298
|
}
|
246
299
|
stop() {
|
247
|
-
const device = this.
|
300
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
248
301
|
device.log.info('MatterbridgeOperationalStateServer: stop called setting operational state to Stopped');
|
249
302
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
250
303
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -253,7 +306,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
253
306
|
};
|
254
307
|
}
|
255
308
|
start() {
|
256
|
-
const device = this.
|
309
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
257
310
|
device.log.info('MatterbridgeOperationalStateServer: start called setting operational state to Running');
|
258
311
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
259
312
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -262,7 +315,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
262
315
|
};
|
263
316
|
}
|
264
317
|
resume() {
|
265
|
-
const device = this.
|
318
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
266
319
|
device.log.info('MatterbridgeOperationalStateServer: resume called setting operational state to Running');
|
267
320
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
268
321
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -274,13 +327,12 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
274
327
|
class MatterbridgeLevelTemperatureControlServer extends TemperatureControlBehavior.with(TemperatureControl.Feature.TemperatureLevel) {
|
275
328
|
initialize() {
|
276
329
|
if (this.state.supportedTemperatureLevels.length >= 2) {
|
277
|
-
const device = this.
|
278
|
-
device.log.info('MatterbridgeLevelTemperatureControlServer initialized
|
279
|
-
this.state.selectedTemperatureLevel = 1;
|
330
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
331
|
+
device.log.info('MatterbridgeLevelTemperatureControlServer initialized');
|
280
332
|
}
|
281
333
|
}
|
282
334
|
setTemperature(request) {
|
283
|
-
const device = this.
|
335
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
284
336
|
if (request.targetTemperatureLevel !== undefined && request.targetTemperatureLevel >= 0 && request.targetTemperatureLevel < this.state.supportedTemperatureLevels.length) {
|
285
337
|
device.log.info(`MatterbridgeLevelTemperatureControlServer: setTemperature called setting selectedTemperatureLevel to ${request.targetTemperatureLevel}: ${this.state.supportedTemperatureLevels[request.targetTemperatureLevel]}`);
|
286
338
|
this.state.selectedTemperatureLevel = request.targetTemperatureLevel;
|
@@ -292,11 +344,11 @@ class MatterbridgeLevelTemperatureControlServer extends TemperatureControlBehavi
|
|
292
344
|
}
|
293
345
|
class MatterbridgeNumberTemperatureControlServer extends TemperatureControlBehavior.with(TemperatureControl.Feature.TemperatureNumber) {
|
294
346
|
initialize() {
|
295
|
-
const device = this.
|
347
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
296
348
|
device.log.info('MatterbridgeNumberTemperatureControlServer initialized');
|
297
349
|
}
|
298
350
|
setTemperature(request) {
|
299
|
-
const device = this.
|
351
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
300
352
|
if (request.targetTemperature !== undefined && request.targetTemperature >= this.state.minTemperature && request.targetTemperature <= this.state.maxTemperature) {
|
301
353
|
device.log.info(`MatterbridgeNumberTemperatureControlServer: setTemperature called setting temperatureSetpoint to ${request.targetTemperature}`);
|
302
354
|
this.state.temperatureSetpoint = request.targetTemperature;
|
@@ -306,16 +358,42 @@ class MatterbridgeNumberTemperatureControlServer extends TemperatureControlBehav
|
|
306
358
|
}
|
307
359
|
}
|
308
360
|
}
|
361
|
+
class MatterbridgeMicrowaveOvenControlServer extends MicrowaveOvenControlBehavior.with(MicrowaveOvenControl.Feature.PowerInWatts) {
|
362
|
+
initialize() {
|
363
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
364
|
+
device.log.info('MatterbridgeMicrowaveOvenControlServer initialized');
|
365
|
+
}
|
366
|
+
setCookingParameters(request) {
|
367
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
368
|
+
if (request.wattSettingIndex !== undefined && request.wattSettingIndex >= 0 && request.wattSettingIndex < this.state.supportedWatts.length) {
|
369
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting selectedWattIndex to ${request.wattSettingIndex}`);
|
370
|
+
this.state.selectedWattIndex = request.wattSettingIndex;
|
371
|
+
}
|
372
|
+
else {
|
373
|
+
device.log.error(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with invalid wattSettingIndex ${request.wattSettingIndex}`);
|
374
|
+
}
|
375
|
+
}
|
376
|
+
addMoreTime(request) {
|
377
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
378
|
+
if (request.timeToAdd !== undefined && request.timeToAdd >= 0) {
|
379
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: addMoreTime called setting cookTime to ${this.state.cookTime + request.timeToAdd}`);
|
380
|
+
this.state.cookTime += request.timeToAdd;
|
381
|
+
}
|
382
|
+
else {
|
383
|
+
device.log.error(`MatterbridgeMicrowaveOvenControlServer: addMoreTime called with invalid cookTime ${request.timeToAdd}`);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
309
387
|
export const OvenCavityOperationalStateBehavior = ClusterBehavior.withInterface().for(OvenCavityOperationalState.Cluster);
|
310
388
|
export class OvenCavityOperationalStateServer extends OvenCavityOperationalStateBehavior {
|
311
389
|
initialize() {
|
312
|
-
const device = this.
|
390
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
313
391
|
device.log.info('OvenCavityOperationalStateServer initialized: setting operational state to Stopped and operational error to No error');
|
314
392
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
315
393
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
316
394
|
}
|
317
395
|
stop() {
|
318
|
-
const device = this.
|
396
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
319
397
|
device.log.info('OvenCavityOperationalStateServer: stop called setting operational state to Stopped and operational error to No error');
|
320
398
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
321
399
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -324,7 +402,7 @@ export class OvenCavityOperationalStateServer extends OvenCavityOperationalState
|
|
324
402
|
};
|
325
403
|
}
|
326
404
|
start() {
|
327
|
-
const device = this.
|
405
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
328
406
|
device.log.info('OvenCavityOperationalStateServer: start called setting operational state to Running and operational error to No error');
|
329
407
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
330
408
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -336,14 +414,15 @@ export class OvenCavityOperationalStateServer extends OvenCavityOperationalState
|
|
336
414
|
export const RefrigeratorAndTemperatureControlledCabinetModeBehavior = ClusterBehavior.withInterface().for(RefrigeratorAndTemperatureControlledCabinetMode.Cluster);
|
337
415
|
class RefrigeratorAndTemperatureControlledCabinetModeServer extends RefrigeratorAndTemperatureControlledCabinetModeBehavior {
|
338
416
|
initialize() {
|
339
|
-
const device = this.
|
417
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
340
418
|
device.log.info('MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer initialized: setting currentMode to 1');
|
341
419
|
this.state.currentMode = 1;
|
342
420
|
}
|
343
421
|
changeToMode(request) {
|
344
|
-
const device = this.
|
345
|
-
|
346
|
-
|
422
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
423
|
+
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
424
|
+
if (supportedMode) {
|
425
|
+
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
347
426
|
this.state.currentMode = request.newMode;
|
348
427
|
return { status: Status.Success, statusText: 'Success' };
|
349
428
|
}
|
@@ -356,14 +435,15 @@ class RefrigeratorAndTemperatureControlledCabinetModeServer extends Refrigerator
|
|
356
435
|
export const OvenModeBehavior = ClusterBehavior.withInterface().for(OvenMode.Cluster);
|
357
436
|
class OvenModeServer extends OvenModeBehavior {
|
358
437
|
initialize() {
|
359
|
-
const device = this.
|
438
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
360
439
|
device.log.info('OvenModeServer initialized: setting currentMode to 3');
|
361
440
|
this.state.currentMode = 3;
|
362
441
|
}
|
363
442
|
changeToMode(request) {
|
364
|
-
const device = this.
|
365
|
-
|
366
|
-
|
443
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
444
|
+
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
445
|
+
if (supportedMode) {
|
446
|
+
device.log.info(`OvenModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
367
447
|
this.state.currentMode = request.newMode;
|
368
448
|
return { status: Status.Success, statusText: 'Success' };
|
369
449
|
}
|
@@ -376,20 +456,20 @@ class OvenModeServer extends OvenModeBehavior {
|
|
376
456
|
export const DishwasherModeBehavior = ClusterBehavior.withInterface().for(DishwasherMode.Cluster);
|
377
457
|
class DishwasherModeServer extends DishwasherModeBehavior {
|
378
458
|
initialize() {
|
379
|
-
const device = this.
|
459
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
380
460
|
device.log.info('DishwasherModeServer initialized: setting currentMode to 3');
|
381
461
|
this.state.currentMode = 2;
|
382
462
|
this.reactTo(this.agent.get(MatterbridgeOnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
383
463
|
}
|
384
464
|
handleOnOffChange(onOff) {
|
385
|
-
const device = this.
|
465
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
386
466
|
if (onOff === false) {
|
387
467
|
device.log.info('***OnOffServer changed to OFF: setting Dead Front state to Manufacturer Specific');
|
388
468
|
this.state.currentMode = 2;
|
389
469
|
}
|
390
470
|
}
|
391
471
|
changeToMode(request) {
|
392
|
-
const device = this.
|
472
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
393
473
|
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
394
474
|
if (supportedMode) {
|
395
475
|
device.log.info(`DishwasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
@@ -405,20 +485,20 @@ class DishwasherModeServer extends DishwasherModeBehavior {
|
|
405
485
|
export const LaundryWasherModeBehavior = ClusterBehavior.withInterface().for(LaundryWasherMode.Cluster);
|
406
486
|
class LaundryWasherModeServer extends LaundryWasherModeBehavior {
|
407
487
|
initialize() {
|
408
|
-
const device = this.
|
488
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
409
489
|
device.log.info('LaundryWasherModeServer initialized: setting currentMode to 3');
|
410
490
|
this.state.currentMode = 2;
|
411
491
|
this.reactTo(this.agent.get(MatterbridgeOnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
412
492
|
}
|
413
493
|
handleOnOffChange(onOff) {
|
414
|
-
const device = this.
|
494
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
415
495
|
if (onOff === false) {
|
416
|
-
device.log.
|
496
|
+
device.log.notice('OnOffServer changed to OFF: setting Dead Front state to Manufacturer Specific');
|
417
497
|
this.state.currentMode = 2;
|
418
498
|
}
|
419
499
|
}
|
420
500
|
changeToMode(request) {
|
421
|
-
const device = this.
|
501
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
422
502
|
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
423
503
|
if (supportedMode) {
|
424
504
|
device.log.info(`LaundryWasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
@@ -431,22 +511,3 @@ class LaundryWasherModeServer extends LaundryWasherModeBehavior {
|
|
431
511
|
}
|
432
512
|
}
|
433
513
|
}
|
434
|
-
if (process.argv.includes('-testRobot')) {
|
435
|
-
const matterbridge = await Matterbridge.loadInstance(false);
|
436
|
-
matterbridge.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4, logLevel: "debug" });
|
437
|
-
matterbridge.environment.vars.set('log.level', MatterLogLevel.DEBUG);
|
438
|
-
matterbridge.environment.vars.set('log.format', MatterLogFormat.ANSI);
|
439
|
-
matterbridge.environment.vars.set('path.root', 'matterstorage');
|
440
|
-
matterbridge.environment.vars.set('runtime.signals', true);
|
441
|
-
matterbridge.environment.vars.set('runtime.exitcode', true);
|
442
|
-
matterbridge.environment.vars.set('mdns.networkInterface', 'Wi-Fi');
|
443
|
-
await matterbridge.startMatterStorage();
|
444
|
-
const deviceType = smokeCoAlarm;
|
445
|
-
const context = await matterbridge.createServerNodeContext('Jest', deviceType.name, DeviceTypeId(deviceType.code), VendorId(0xfff1), 'Matterbridge', 0x8000, 'Matterbridge device');
|
446
|
-
const server = await matterbridge.createServerNode(context);
|
447
|
-
const device = new Robot('Robot Vacuum', '99914248654');
|
448
|
-
await server.add(device);
|
449
|
-
logEndpoint(EndpointServer.forEndpoint(device));
|
450
|
-
await matterbridge.startServerNode(server);
|
451
|
-
logEndpoint(EndpointServer.forEndpoint(server));
|
452
|
-
}
|
package/dist/platform.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { MatterbridgeEndpoint, MatterbridgeDynamicPlatform,
|
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';
|
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';
|
@@ -50,6 +50,8 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
50
50
|
airConditionerInterval;
|
51
51
|
genericSwitchInterval;
|
52
52
|
genericSwitchLastEvent = 'Release';
|
53
|
+
intervalOnOff = false;
|
54
|
+
intervalLevel = 0;
|
53
55
|
bridgedDevices = new Map();
|
54
56
|
fanModeLookup = ['Off', 'Low', 'Medium', 'High', 'On', 'Auto', 'Smart'];
|
55
57
|
constructor(matterbridge, log, config) {
|
@@ -92,6 +94,65 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
92
94
|
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.switch.log);
|
93
95
|
this.switch?.log.info('Command off called');
|
94
96
|
});
|
97
|
+
this.mountedOnOffSwitch = new MatterbridgeEndpoint([onOffMountedSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'OnOffMountedSwitch' }, this.config.debug)
|
98
|
+
.createDefaultIdentifyClusterServer()
|
99
|
+
.createDefaultGroupsClusterServer()
|
100
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('OnOff Mounted Switch', '0x298242164', 0xfff1, 'Matterbridge', 'Matterbridge OnOff Mounted Switch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
101
|
+
.createDefaultOnOffClusterServer()
|
102
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
103
|
+
this.setSelectDevice(this.mountedOnOffSwitch.serialNumber ?? '', this.mountedOnOffSwitch.deviceName ?? '', undefined, 'hub');
|
104
|
+
if (this.validateDevice(this.mountedOnOffSwitch.deviceName ?? '')) {
|
105
|
+
await this.registerDevice(this.mountedOnOffSwitch);
|
106
|
+
this.bridgedDevices.set(this.mountedOnOffSwitch.deviceName ?? '', this.mountedOnOffSwitch);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
this.mountedOnOffSwitch = undefined;
|
110
|
+
}
|
111
|
+
this.mountedOnOffSwitch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
112
|
+
this.mountedOnOffSwitch?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
113
|
+
});
|
114
|
+
this.mountedOnOffSwitch?.addCommandHandler('on', async () => {
|
115
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.mountedOnOffSwitch.log);
|
116
|
+
this.mountedOnOffSwitch?.log.info('Command on called');
|
117
|
+
});
|
118
|
+
this.mountedOnOffSwitch?.addCommandHandler('off', async () => {
|
119
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.mountedOnOffSwitch.log);
|
120
|
+
this.mountedOnOffSwitch?.log.info('Command off called');
|
121
|
+
});
|
122
|
+
this.mountedDimmerSwitch = new MatterbridgeEndpoint([dimmableMountedSwitch, bridgedNode, powerSource], { uniqueStorageKey: 'DimmerMountedSwitch' }, this.config.debug)
|
123
|
+
.createDefaultIdentifyClusterServer()
|
124
|
+
.createDefaultGroupsClusterServer()
|
125
|
+
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer Mounted Switch', '0x22145578864', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer Mounted Switch', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
126
|
+
.createDefaultOnOffClusterServer()
|
127
|
+
.createDefaultLevelControlClusterServer()
|
128
|
+
.createDefaultPowerSourceRechargeableBatteryClusterServer(70);
|
129
|
+
this.setSelectDevice(this.mountedDimmerSwitch.serialNumber ?? '', this.mountedDimmerSwitch.deviceName ?? '', undefined, 'hub');
|
130
|
+
if (this.validateDevice(this.mountedDimmerSwitch.deviceName ?? '')) {
|
131
|
+
await this.registerDevice(this.mountedDimmerSwitch);
|
132
|
+
this.bridgedDevices.set(this.mountedDimmerSwitch.deviceName ?? '', this.mountedDimmerSwitch);
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
this.mountedDimmerSwitch = undefined;
|
136
|
+
}
|
137
|
+
this.mountedDimmerSwitch?.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
138
|
+
this.mountedDimmerSwitch?.log.info(`Command identify called identifyTime:${identifyTime}`);
|
139
|
+
});
|
140
|
+
this.mountedDimmerSwitch?.addCommandHandler('on', async () => {
|
141
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.mountedDimmerSwitch.log);
|
142
|
+
this.mountedDimmerSwitch?.log.info('Command on called');
|
143
|
+
});
|
144
|
+
this.mountedDimmerSwitch?.addCommandHandler('off', async () => {
|
145
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.mountedDimmerSwitch.log);
|
146
|
+
this.mountedDimmerSwitch?.log.info('Command off called');
|
147
|
+
});
|
148
|
+
this.mountedDimmerSwitch?.addCommandHandler('moveToLevel', async ({ request: { level } }) => {
|
149
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.mountedDimmerSwitch.log);
|
150
|
+
this.mountedDimmerSwitch?.log.debug(`Command moveToLevel called request: ${level}`);
|
151
|
+
});
|
152
|
+
this.mountedDimmerSwitch?.addCommandHandler('moveToLevelWithOnOff', async ({ request: { level } }) => {
|
153
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.mountedDimmerSwitch.log);
|
154
|
+
this.mountedDimmerSwitch?.log.debug(`Command moveToLevelWithOnOff called request: ${level}`);
|
155
|
+
});
|
95
156
|
this.lightOnOff = new MatterbridgeEndpoint([onOffLight, bridgedNode, powerSource], { uniqueStorageKey: 'Light (on/off)' }, this.config.debug)
|
96
157
|
.createDefaultIdentifyClusterServer()
|
97
158
|
.createDefaultGroupsClusterServer()
|
@@ -123,7 +184,7 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
123
184
|
.createDefaultBridgedDeviceBasicInformationClusterServer('Dimmer', '0x234554564', 0xfff1, 'Matterbridge', 'Matterbridge Dimmer', parseInt(this.version.replace(/\D/g, '')), this.version === '' ? 'Unknown' : this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion)
|
124
185
|
.createDefaultOnOffClusterServer()
|
125
186
|
.createDefaultLevelControlClusterServer()
|
126
|
-
.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
|
187
|
+
.createDefaultPowerSourceReplaceableBatteryClusterServer(70, PowerSource.BatChargeLevel.Ok, 2990, '2 x AA', 2);
|
127
188
|
this.setSelectDevice(this.dimmer.serialNumber ?? '', this.dimmer.deviceName ?? '', undefined, 'hub');
|
128
189
|
if (this.validateDevice(this.dimmer.deviceName ?? '')) {
|
129
190
|
await this.registerDevice(this.dimmer);
|
@@ -556,7 +617,9 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
556
617
|
.createDefaultFanControlClusterServer()
|
557
618
|
.createDefaultTemperatureMeasurementClusterServer(20 * 100)
|
558
619
|
.createDefaultRelativeHumidityMeasurementClusterServer(50 * 100)
|
559
|
-
.createDefaultPowerSourceWiredClusterServer()
|
620
|
+
.createDefaultPowerSourceWiredClusterServer()
|
621
|
+
.createDefaultActivatedCarbonFilterMonitoringClusterServer()
|
622
|
+
.createDefaultHepaFilterMonitoringClusterServer();
|
560
623
|
this.setSelectDevice(this.airPurifier.serialNumber ?? '', this.airPurifier.deviceName ?? '', undefined, 'hub');
|
561
624
|
if (this.validateDevice(this.airPurifier.deviceName ?? '')) {
|
562
625
|
await this.registerDevice(this.airPurifier);
|
@@ -617,8 +680,6 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
617
680
|
});
|
618
681
|
this.airConditioner?.addCommandHandler('on', async () => {
|
619
682
|
this.airConditioner?.log.info('Command on called');
|
620
|
-
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.airConditioner?.log);
|
621
|
-
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.airConditioner?.log);
|
622
683
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', 20 * 100, this.airConditioner?.log);
|
623
684
|
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', 20 * 100, this.airConditioner?.log);
|
624
685
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', 50 * 100, this.airConditioner?.log);
|
@@ -627,7 +688,6 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
627
688
|
});
|
628
689
|
this.airConditioner?.addCommandHandler('off', async () => {
|
629
690
|
this.airConditioner?.log.info('Command off called');
|
630
|
-
await this.airConditioner?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.airConditioner?.log);
|
631
691
|
await this.airConditioner?.setAttribute(ThermostatCluster.id, 'localTemperature', null, this.airConditioner?.log);
|
632
692
|
await this.airConditioner?.setAttribute(TemperatureMeasurement.Cluster.id, 'measuredValue', null, this.airConditioner?.log);
|
633
693
|
await this.airConditioner?.setAttribute(RelativeHumidityMeasurementCluster.id, 'measuredValue', null, this.airConditioner?.log);
|
@@ -859,55 +919,75 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
859
919
|
await this.registerDevice(robot);
|
860
920
|
this.bridgedDevices.set(robot.deviceName ?? '', robot);
|
861
921
|
}
|
862
|
-
const
|
863
|
-
this.setSelectDevice(
|
864
|
-
if (this.validateDevice(
|
865
|
-
await this.registerDevice(
|
866
|
-
this.bridgedDevices.set(
|
867
|
-
}
|
868
|
-
const
|
869
|
-
this.setSelectDevice(
|
870
|
-
if (this.validateDevice(
|
871
|
-
await this.registerDevice(
|
872
|
-
this.bridgedDevices.set(
|
873
|
-
}
|
874
|
-
const
|
875
|
-
this.setSelectDevice(
|
876
|
-
if (this.validateDevice(
|
877
|
-
await this.registerDevice(
|
878
|
-
this.bridgedDevices.set(
|
879
|
-
}
|
880
|
-
const
|
881
|
-
this.setSelectDevice(
|
882
|
-
if (this.validateDevice(
|
883
|
-
await this.registerDevice(
|
884
|
-
this.bridgedDevices.set(
|
885
|
-
}
|
886
|
-
const
|
887
|
-
this.setSelectDevice(
|
888
|
-
if (this.validateDevice(
|
889
|
-
await this.registerDevice(
|
890
|
-
this.bridgedDevices.set(
|
922
|
+
const laundryWasherDevice = new Appliances(laundryWasher, 'Laundry Washer', '1234567890');
|
923
|
+
this.setSelectDevice(laundryWasherDevice.serialNumber ?? '', laundryWasherDevice.deviceName ?? '', undefined, 'hub');
|
924
|
+
if (this.validateDevice(laundryWasherDevice.deviceName ?? '')) {
|
925
|
+
await this.registerDevice(laundryWasherDevice);
|
926
|
+
this.bridgedDevices.set(laundryWasherDevice.deviceName ?? '', laundryWasherDevice);
|
927
|
+
}
|
928
|
+
const laundryDryerDevice = new Appliances(laundryDryer, 'Laundry Dryer', '1235227890');
|
929
|
+
this.setSelectDevice(laundryDryerDevice.serialNumber ?? '', laundryDryerDevice.deviceName ?? '', undefined, 'hub');
|
930
|
+
if (this.validateDevice(laundryDryerDevice.deviceName ?? '')) {
|
931
|
+
await this.registerDevice(laundryDryerDevice);
|
932
|
+
this.bridgedDevices.set(laundryDryerDevice.deviceName ?? '', laundryDryerDevice);
|
933
|
+
}
|
934
|
+
const dishwasherDevice = new Appliances(dishwasher, 'Dishwasher', '0987654321');
|
935
|
+
this.setSelectDevice(dishwasherDevice.serialNumber ?? '', dishwasherDevice.deviceName ?? '', undefined, 'hub');
|
936
|
+
if (this.validateDevice(dishwasherDevice.deviceName ?? '')) {
|
937
|
+
await this.registerDevice(dishwasherDevice);
|
938
|
+
this.bridgedDevices.set(dishwasherDevice.deviceName ?? '', dishwasherDevice);
|
939
|
+
}
|
940
|
+
const refrigeratorDevice = new Appliances(refrigerator, 'Refrigerator', '9987654322');
|
941
|
+
this.setSelectDevice(refrigeratorDevice.serialNumber ?? '', refrigeratorDevice.deviceName ?? '', undefined, 'hub');
|
942
|
+
if (this.validateDevice(refrigeratorDevice.deviceName ?? '')) {
|
943
|
+
await this.registerDevice(refrigeratorDevice);
|
944
|
+
this.bridgedDevices.set(refrigeratorDevice.deviceName ?? '', refrigeratorDevice);
|
945
|
+
}
|
946
|
+
const ovenDevice = new Appliances(oven, 'Oven', '1298867891');
|
947
|
+
this.setSelectDevice(ovenDevice.serialNumber ?? '', ovenDevice.deviceName ?? '', undefined, 'hub');
|
948
|
+
if (this.validateDevice(ovenDevice.deviceName ?? '')) {
|
949
|
+
await this.registerDevice(ovenDevice);
|
950
|
+
this.bridgedDevices.set(ovenDevice.deviceName ?? '', ovenDevice);
|
951
|
+
}
|
952
|
+
const microwaveOvenDevice = new Appliances(microwaveOven, 'Microwave Oven', '1234567892');
|
953
|
+
this.setSelectDevice(microwaveOvenDevice.serialNumber ?? '', microwaveOvenDevice.deviceName ?? '', undefined, 'hub');
|
954
|
+
if (this.validateDevice(microwaveOvenDevice.deviceName ?? '')) {
|
955
|
+
await this.registerDevice(microwaveOvenDevice);
|
956
|
+
this.bridgedDevices.set(microwaveOvenDevice.deviceName ?? '', microwaveOvenDevice);
|
957
|
+
}
|
958
|
+
const extractorHoodDevice = new Appliances(extractorHood, 'Extractor Hood', '1234567893');
|
959
|
+
this.setSelectDevice(extractorHoodDevice.serialNumber ?? '', extractorHoodDevice.deviceName ?? '', undefined, 'hub');
|
960
|
+
if (this.validateDevice(extractorHoodDevice.deviceName ?? '')) {
|
961
|
+
await this.registerDevice(extractorHoodDevice);
|
962
|
+
this.bridgedDevices.set(extractorHoodDevice.deviceName ?? '', extractorHoodDevice);
|
963
|
+
}
|
964
|
+
const cooktopDevice = new Appliances(cooktop, 'Cooktop', '1255887894');
|
965
|
+
this.setSelectDevice(cooktopDevice.serialNumber ?? '', cooktopDevice.deviceName ?? '', undefined, 'hub');
|
966
|
+
if (this.validateDevice(cooktopDevice.deviceName ?? '')) {
|
967
|
+
await this.registerDevice(cooktopDevice);
|
968
|
+
this.bridgedDevices.set(cooktopDevice.deviceName ?? '', cooktopDevice);
|
891
969
|
}
|
892
970
|
}
|
893
971
|
async onConfigure() {
|
894
972
|
await super.onConfigure();
|
895
973
|
this.log.info('onConfigure called');
|
896
|
-
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff',
|
897
|
-
this.
|
974
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.switch.log);
|
975
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitch.log);
|
976
|
+
this.switch?.log.info(`Set switch initial onOff to ${this.intervalOnOff}`);
|
898
977
|
if (this.config.useInterval) {
|
899
978
|
this.switchInterval = setInterval(async () => {
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
}
|
979
|
+
await this.switch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.switch.log);
|
980
|
+
await this.mountedOnOffSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', this.intervalOnOff, this.mountedOnOffSwitch.log);
|
981
|
+
this.log.info(`Set switches onOff to ${this.intervalOnOff}`);
|
982
|
+
this.intervalOnOff = !this.intervalOnOff;
|
905
983
|
}, 60 * 1000 + 100);
|
906
984
|
}
|
907
985
|
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff.log);
|
908
986
|
this.lightOnOff?.log.info('Set light initial onOff to false.');
|
909
987
|
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
910
988
|
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 1, this.dimmer.log);
|
989
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.mountedDimmerSwitch.log);
|
990
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 1, this.mountedDimmerSwitch.log);
|
911
991
|
this.dimmer?.log.info(`Set dimmer initial onOff to false, currentLevel to 1.`);
|
912
992
|
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light.log);
|
913
993
|
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', 200, this.light.log);
|
@@ -934,41 +1014,34 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
934
1014
|
this.lightCT?.log.info('Set light CT initial onOff to true, currentLevel to 128, colorTemperatureMireds to 250.');
|
935
1015
|
if (this.config.useInterval) {
|
936
1016
|
this.lightInterval = setInterval(async () => {
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.dimmer.log);
|
966
|
-
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.light.log);
|
967
|
-
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightXY.log);
|
968
|
-
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightHS.log);
|
969
|
-
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', level, this.lightCT.log);
|
970
|
-
this.log.info(`Set lights currentLevel to ${level}`);
|
971
|
-
}
|
1017
|
+
this.intervalLevel += 10;
|
1018
|
+
if (this.intervalLevel >= 250) {
|
1019
|
+
this.intervalLevel = 0;
|
1020
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightOnOff.log);
|
1021
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.dimmer.log);
|
1022
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.mountedDimmerSwitch.log);
|
1023
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.light.log);
|
1024
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightXY.log);
|
1025
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightHS.log);
|
1026
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', false, this.lightCT.log);
|
1027
|
+
this.log.info('Set lights onOff to false');
|
1028
|
+
}
|
1029
|
+
else {
|
1030
|
+
await this.lightOnOff?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightOnOff?.log);
|
1031
|
+
await this.dimmer?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.dimmer.log);
|
1032
|
+
await this.mountedDimmerSwitch?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.mountedDimmerSwitch.log);
|
1033
|
+
await this.light?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.light.log);
|
1034
|
+
await this.lightXY?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightXY.log);
|
1035
|
+
await this.lightHS?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightHS.log);
|
1036
|
+
await this.lightCT?.setAttribute(OnOff.Cluster.id, 'onOff', true, this.lightCT.log);
|
1037
|
+
this.log.info('Set lights onOff to true');
|
1038
|
+
await this.dimmer?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.dimmer.log);
|
1039
|
+
await this.mountedDimmerSwitch?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.mountedDimmerSwitch.log);
|
1040
|
+
await this.light?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.light.log);
|
1041
|
+
await this.lightXY?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.lightXY.log);
|
1042
|
+
await this.lightHS?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.lightHS.log);
|
1043
|
+
await this.lightCT?.setAttribute(LevelControl.Cluster.id, 'currentLevel', this.intervalLevel, this.lightCT.log);
|
1044
|
+
this.log.info(`Set lights currentLevel to ${this.intervalLevel}`);
|
972
1045
|
}
|
973
1046
|
}, 60 * 1000 + 200);
|
974
1047
|
}
|
@@ -1192,6 +1265,6 @@ export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatf
|
|
1192
1265
|
await super.onShutdown(reason);
|
1193
1266
|
this.log.info('onShutdown called with reason:', reason ?? 'none');
|
1194
1267
|
if (this.config.unregisterOnShutdown === true)
|
1195
|
-
await this.unregisterAllDevices(
|
1268
|
+
await this.unregisterAllDevices(500);
|
1196
1269
|
}
|
1197
1270
|
}
|
package/dist/robot.js
CHANGED
@@ -1,41 +1,40 @@
|
|
1
|
-
import { MatterbridgeServer, MatterbridgeEndpoint, roboticVacuumCleaner } from 'matterbridge';
|
2
|
-
import {
|
3
|
-
import { ClusterBehavior } from 'matterbridge/matter';
|
1
|
+
import { Matterbridge, MatterbridgeServer, MatterbridgeEndpoint, roboticVacuumCleaner } from 'matterbridge';
|
2
|
+
import { LogLevel as MatterLogLevel, LogFormat as MatterLogFormat, EndpointServer, logEndpoint, DeviceTypeId, VendorId } from 'matterbridge/matter';
|
4
3
|
import { Status } from 'matterbridge/matter/types';
|
5
|
-
import { OperationalState, PowerSource, RvcRunMode, RvcCleanMode, ServiceArea } from 'matterbridge/matter/clusters';
|
6
|
-
import {
|
4
|
+
import { OperationalState, PowerSource, RvcRunMode, RvcCleanMode, RvcOperationalState, ServiceArea } from 'matterbridge/matter/clusters';
|
5
|
+
import { RvcCleanModeBehavior, RvcOperationalStateBehavior, RvcRunModeBehavior, ServiceAreaBehavior } from 'matterbridge/matter/behaviors';
|
6
|
+
import { AnsiLogger } from 'matterbridge/logger';
|
7
7
|
export class Robot extends MatterbridgeEndpoint {
|
8
8
|
constructor(name, serial) {
|
9
9
|
super(roboticVacuumCleaner, { uniqueStorageKey: `${name}-${serial}` }, true);
|
10
10
|
this.createDefaultIdentifyClusterServer()
|
11
11
|
.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge Robot Vacuum Cleaner')
|
12
|
-
.createDefaultOnOffClusterServer()
|
13
12
|
.createDefaultRvcRunModeClusterServer()
|
14
13
|
.createDefaultRvcOperationalStateClusterServer()
|
15
14
|
.createDefaultRvcCleanModeClusterServer()
|
16
15
|
.createDefaultServiceAreaClusterServer()
|
17
16
|
.createDefaultPowerSourceRechargeableBatteryClusterServer(80, PowerSource.BatChargeLevel.Ok, 5900);
|
18
17
|
}
|
19
|
-
createDefaultRvcRunModeClusterServer() {
|
18
|
+
createDefaultRvcRunModeClusterServer(currentMode, supportedModes) {
|
20
19
|
this.behaviors.require(MatterbridgeRvcRunModeServer, {
|
21
|
-
supportedModes: [
|
20
|
+
supportedModes: supportedModes ?? [
|
22
21
|
{ label: 'Idle', mode: 1, modeTags: [{ value: RvcRunMode.ModeTag.Idle }] },
|
23
22
|
{ label: 'Cleaning', mode: 2, modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }] },
|
24
23
|
{ label: 'Mapping', mode: 3, modeTags: [{ value: RvcRunMode.ModeTag.Mapping }] },
|
25
24
|
{ label: 'SpotCleaning', mode: 4, modeTags: [{ value: RvcRunMode.ModeTag.Cleaning }, { value: RvcRunMode.ModeTag.Max }] },
|
26
25
|
],
|
27
|
-
currentMode: 1,
|
26
|
+
currentMode: currentMode ?? 1,
|
28
27
|
});
|
29
28
|
return this;
|
30
29
|
}
|
31
|
-
createDefaultRvcCleanModeClusterServer() {
|
30
|
+
createDefaultRvcCleanModeClusterServer(currentMode, supportedModes) {
|
32
31
|
this.behaviors.require(MatterbridgeRvcCleanModeServer, {
|
33
|
-
supportedModes: [
|
32
|
+
supportedModes: supportedModes ?? [
|
34
33
|
{ label: 'Vacuum', mode: 1, modeTags: [{ value: RvcCleanMode.ModeTag.Vacuum }] },
|
35
34
|
{ label: 'Mop', mode: 2, modeTags: [{ value: RvcCleanMode.ModeTag.Mop }] },
|
36
35
|
{ label: 'Clean', mode: 3, modeTags: [{ value: RvcCleanMode.ModeTag.DeepClean }] },
|
37
36
|
],
|
38
|
-
currentMode: 1,
|
37
|
+
currentMode: currentMode ?? 1,
|
39
38
|
});
|
40
39
|
return this;
|
41
40
|
}
|
@@ -104,36 +103,34 @@ export class MatterbridgeServiceAreaServer extends ServiceAreaBehavior {
|
|
104
103
|
return { status: ServiceArea.SelectAreasStatus.Success, statusText: 'Succesfully selected new areas' };
|
105
104
|
}
|
106
105
|
}
|
107
|
-
export const RvcRunModeBehavior = ClusterBehavior.withInterface().for(RvcRunMode.Cluster);
|
108
106
|
export class MatterbridgeRvcRunModeServer extends RvcRunModeBehavior {
|
109
107
|
initialize() {
|
110
108
|
this.state.currentMode = 1;
|
111
109
|
}
|
112
110
|
changeToMode({ newMode }) {
|
113
111
|
const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
|
114
|
-
const
|
115
|
-
if (!
|
112
|
+
const changedMode = this.state.supportedModes.find((mode) => mode.mode === newMode);
|
113
|
+
if (!changedMode) {
|
116
114
|
device.log.error('MatterbridgeRvcRunModeServer changeToMode called with unsupported newMode:', newMode);
|
117
115
|
return { status: Status.InvalidCommand, statusText: 'Invalid command' };
|
118
116
|
}
|
119
117
|
device.changeToMode({ newMode });
|
120
118
|
this.state.currentMode = newMode;
|
121
|
-
if (
|
119
|
+
if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Cleaning)) {
|
122
120
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Cleaning => Running');
|
123
121
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
124
122
|
return { status: Status.Success, statusText: 'Running' };
|
125
123
|
}
|
126
|
-
else if (
|
124
|
+
else if (changedMode.modeTags.find((tag) => tag.value === RvcRunMode.ModeTag.Idle)) {
|
127
125
|
device.log.info('***MatterbridgeRvcRunModeServer changeToMode called with newMode Idle => Docked');
|
128
126
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Docked;
|
129
127
|
return { status: Status.Success, statusText: 'Docked' };
|
130
128
|
}
|
131
|
-
device.log.info(`***MatterbridgeRvcRunModeServer changeToMode called with newMode ${newMode} => ${
|
129
|
+
device.log.info(`***MatterbridgeRvcRunModeServer changeToMode called with newMode ${newMode} => ${changedMode.label}`);
|
132
130
|
this.agent.get(MatterbridgeRvcOperationalStateServer).state.operationalState = RvcOperationalState.OperationalState.Running;
|
133
131
|
return { status: Status.Success, statusText: 'Success' };
|
134
132
|
}
|
135
133
|
}
|
136
|
-
export const RvcCleanModeBehavior = ClusterBehavior.withInterface().for(RvcCleanMode.Cluster);
|
137
134
|
export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
138
135
|
initialize() {
|
139
136
|
this.state.currentMode = 1;
|
@@ -151,29 +148,12 @@ export class MatterbridgeRvcCleanModeServer extends RvcCleanModeBehavior {
|
|
151
148
|
return { status: Status.Success, statusText: 'Success' };
|
152
149
|
}
|
153
150
|
}
|
154
|
-
export const RvcOperationalStateBehavior = ClusterBehavior.withInterface().for(RvcOperationalState.Cluster);
|
155
151
|
export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBehavior {
|
156
152
|
initialize() {
|
157
153
|
const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
|
158
154
|
device.log.info('***MatterbridgeRvcOperationalStateServer initialized: setting operational state to Docked');
|
159
155
|
this.state.operationalState = RvcOperationalState.OperationalState.Docked;
|
160
156
|
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
161
|
-
this.reactTo(this.agent.get(OnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
162
|
-
}
|
163
|
-
handleOnOffChange(onOff) {
|
164
|
-
const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
|
165
|
-
if (onOff) {
|
166
|
-
device.log.info('***OnOffServer changed to ON: setting operational state to Running');
|
167
|
-
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2;
|
168
|
-
this.state.operationalState = RvcOperationalState.OperationalState.Running;
|
169
|
-
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
device.log.info('***OnOffServer changed to OFF: setting operational state to Docked');
|
173
|
-
this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
|
174
|
-
this.state.operationalState = RvcOperationalState.OperationalState.Docked;
|
175
|
-
this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
|
176
|
-
}
|
177
157
|
}
|
178
158
|
pause() {
|
179
159
|
const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
|
@@ -206,3 +186,22 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateBe
|
|
206
186
|
};
|
207
187
|
}
|
208
188
|
}
|
189
|
+
if (process.argv.includes('-testRobot')) {
|
190
|
+
const matterbridge = await Matterbridge.loadInstance(false);
|
191
|
+
matterbridge.log = new AnsiLogger({ logName: 'Matterbridge', logTimestampFormat: 4, logLevel: "debug" });
|
192
|
+
matterbridge.environment.vars.set('log.level', MatterLogLevel.DEBUG);
|
193
|
+
matterbridge.environment.vars.set('log.format', MatterLogFormat.ANSI);
|
194
|
+
matterbridge.environment.vars.set('path.root', 'matterstorage');
|
195
|
+
matterbridge.environment.vars.set('runtime.signals', true);
|
196
|
+
matterbridge.environment.vars.set('runtime.exitcode', true);
|
197
|
+
matterbridge.environment.vars.set('mdns.networkInterface', 'Wi-Fi');
|
198
|
+
await matterbridge.startMatterStorage();
|
199
|
+
const deviceType = roboticVacuumCleaner;
|
200
|
+
const context = await matterbridge.createServerNodeContext('Jest', deviceType.name, DeviceTypeId(deviceType.code), VendorId(0xfff1), 'Matterbridge', 0x8000, 'Matterbridge device');
|
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
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "matterbridge-example-dynamic-platform",
|
3
|
-
"version": "1.2.0-edge.
|
3
|
+
"version": "1.2.0-edge.8",
|
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-edge.
|
9
|
+
"version": "1.2.0-edge.8",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"node-ansi-logger": "3.0.1",
|
package/package.json
CHANGED
@@ -1,113 +0,0 @@
|
|
1
|
-
import { ClusterBehavior } from 'matterbridge/matter';
|
2
|
-
import { Attribute, MutableCluster, OptionalAttribute, TlvEnum, TlvNullable, TlvUInt32, TlvFloat, FixedAttribute, BitFlag, ClusterType, ClusterRegistry, } from 'matterbridge/matter/types';
|
3
|
-
export var CarbonMonoxideConcentrationMeasurement;
|
4
|
-
(function (CarbonMonoxideConcentrationMeasurement) {
|
5
|
-
let Feature;
|
6
|
-
(function (Feature) {
|
7
|
-
Feature["NumericMeasurement"] = "NumericMeasurement";
|
8
|
-
Feature["LevelIndication"] = "LevelIndication";
|
9
|
-
Feature["MediumLevel"] = "MediumLevel";
|
10
|
-
Feature["CriticalLevel"] = "CriticalLevel";
|
11
|
-
Feature["PeakMeasurement"] = "PeakMeasurement";
|
12
|
-
Feature["AverageMeasurement"] = "AverageMeasurement";
|
13
|
-
})(Feature = CarbonMonoxideConcentrationMeasurement.Feature || (CarbonMonoxideConcentrationMeasurement.Feature = {}));
|
14
|
-
let MeasurementUnit;
|
15
|
-
(function (MeasurementUnit) {
|
16
|
-
MeasurementUnit[MeasurementUnit["Ppm"] = 0] = "Ppm";
|
17
|
-
MeasurementUnit[MeasurementUnit["Ppb"] = 1] = "Ppb";
|
18
|
-
MeasurementUnit[MeasurementUnit["Ppt"] = 2] = "Ppt";
|
19
|
-
MeasurementUnit[MeasurementUnit["Mgm3"] = 3] = "Mgm3";
|
20
|
-
MeasurementUnit[MeasurementUnit["Ugm3"] = 4] = "Ugm3";
|
21
|
-
MeasurementUnit[MeasurementUnit["Ngm3"] = 5] = "Ngm3";
|
22
|
-
MeasurementUnit[MeasurementUnit["Pm3"] = 6] = "Pm3";
|
23
|
-
MeasurementUnit[MeasurementUnit["Bqm3"] = 7] = "Bqm3";
|
24
|
-
})(MeasurementUnit = CarbonMonoxideConcentrationMeasurement.MeasurementUnit || (CarbonMonoxideConcentrationMeasurement.MeasurementUnit = {}));
|
25
|
-
let LevelValue;
|
26
|
-
(function (LevelValue) {
|
27
|
-
LevelValue[LevelValue["Unknown"] = 0] = "Unknown";
|
28
|
-
LevelValue[LevelValue["Low"] = 1] = "Low";
|
29
|
-
LevelValue[LevelValue["Medium"] = 2] = "Medium";
|
30
|
-
LevelValue[LevelValue["High"] = 3] = "High";
|
31
|
-
LevelValue[LevelValue["Critical"] = 4] = "Critical";
|
32
|
-
})(LevelValue = CarbonMonoxideConcentrationMeasurement.LevelValue || (CarbonMonoxideConcentrationMeasurement.LevelValue = {}));
|
33
|
-
let MeasurementMedium;
|
34
|
-
(function (MeasurementMedium) {
|
35
|
-
MeasurementMedium[MeasurementMedium["Air"] = 0] = "Air";
|
36
|
-
MeasurementMedium[MeasurementMedium["Water"] = 1] = "Water";
|
37
|
-
MeasurementMedium[MeasurementMedium["Soil"] = 2] = "Soil";
|
38
|
-
})(MeasurementMedium = CarbonMonoxideConcentrationMeasurement.MeasurementMedium || (CarbonMonoxideConcentrationMeasurement.MeasurementMedium = {}));
|
39
|
-
CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent = MutableCluster.Component({
|
40
|
-
attributes: {
|
41
|
-
measuredValue: Attribute(0x0, TlvNullable(TlvFloat), { default: null }),
|
42
|
-
minMeasuredValue: Attribute(0x1, TlvNullable(TlvFloat), { default: null }),
|
43
|
-
maxMeasuredValue: Attribute(0x2, TlvNullable(TlvFloat), { default: null }),
|
44
|
-
uncertainty: OptionalAttribute(0x7, TlvFloat),
|
45
|
-
measurementUnit: FixedAttribute(0x8, TlvEnum()),
|
46
|
-
},
|
47
|
-
});
|
48
|
-
CarbonMonoxideConcentrationMeasurement.PeakMeasurementComponent = MutableCluster.Component({
|
49
|
-
attributes: {
|
50
|
-
peakMeasuredValue: Attribute(0x3, TlvNullable(TlvFloat), { default: null }),
|
51
|
-
peakMeasuredValueWindow: Attribute(0x4, TlvUInt32.bound({ max: 604800 }), { default: 1 }),
|
52
|
-
},
|
53
|
-
});
|
54
|
-
CarbonMonoxideConcentrationMeasurement.AverageMeasurementComponent = MutableCluster.Component({
|
55
|
-
attributes: {
|
56
|
-
averageMeasuredValue: Attribute(0x5, TlvNullable(TlvFloat), { default: null }),
|
57
|
-
averageMeasuredValueWindow: Attribute(0x6, TlvUInt32.bound({ max: 604800 }), { default: 1 }),
|
58
|
-
},
|
59
|
-
});
|
60
|
-
CarbonMonoxideConcentrationMeasurement.LevelIndicationComponent = MutableCluster.Component({
|
61
|
-
attributes: {
|
62
|
-
levelValue: Attribute(0xa, TlvEnum(), { default: LevelValue.Unknown }),
|
63
|
-
},
|
64
|
-
});
|
65
|
-
CarbonMonoxideConcentrationMeasurement.Base = MutableCluster.Component({
|
66
|
-
id: 0x40c,
|
67
|
-
name: 'CarbonMonoxideConcentrationMeasurement',
|
68
|
-
revision: 3,
|
69
|
-
features: {
|
70
|
-
numericMeasurement: BitFlag(0),
|
71
|
-
levelIndication: BitFlag(1),
|
72
|
-
mediumLevel: BitFlag(2),
|
73
|
-
criticalLevel: BitFlag(3),
|
74
|
-
peakMeasurement: BitFlag(4),
|
75
|
-
averageMeasurement: BitFlag(5),
|
76
|
-
},
|
77
|
-
attributes: {
|
78
|
-
measurementMedium: FixedAttribute(0x9, TlvEnum()),
|
79
|
-
},
|
80
|
-
extensions: MutableCluster.Extensions({ flags: { numericMeasurement: true }, component: CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent }, { flags: { peakMeasurement: true }, component: CarbonMonoxideConcentrationMeasurement.PeakMeasurementComponent }, { flags: { averageMeasurement: true }, component: CarbonMonoxideConcentrationMeasurement.AverageMeasurementComponent }, { flags: { levelIndication: true }, component: CarbonMonoxideConcentrationMeasurement.LevelIndicationComponent }, { flags: { mediumLevel: true, levelIndication: false }, component: false }, { flags: { criticalLevel: true, levelIndication: false }, component: false }, { flags: { peakMeasurement: true, numericMeasurement: false }, component: false }, { flags: { averageMeasurement: true, numericMeasurement: false }, component: false }, { flags: { numericMeasurement: false, levelIndication: false }, component: false }),
|
81
|
-
});
|
82
|
-
CarbonMonoxideConcentrationMeasurement.ClusterInstance = MutableCluster.ExtensibleOnly(CarbonMonoxideConcentrationMeasurement.Base);
|
83
|
-
CarbonMonoxideConcentrationMeasurement.Cluster = CarbonMonoxideConcentrationMeasurement.ClusterInstance;
|
84
|
-
const MEA = { numericMeasurement: true };
|
85
|
-
const PEA = { peakMeasurement: true };
|
86
|
-
const AVG = { averageMeasurement: true };
|
87
|
-
const LEV = { levelIndication: true };
|
88
|
-
CarbonMonoxideConcentrationMeasurement.CompleteInstance = MutableCluster({
|
89
|
-
id: CarbonMonoxideConcentrationMeasurement.Base.id,
|
90
|
-
name: CarbonMonoxideConcentrationMeasurement.Base.name,
|
91
|
-
revision: CarbonMonoxideConcentrationMeasurement.Base.revision,
|
92
|
-
features: CarbonMonoxideConcentrationMeasurement.Base.features,
|
93
|
-
attributes: {
|
94
|
-
...CarbonMonoxideConcentrationMeasurement.Base.attributes,
|
95
|
-
measuredValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent.attributes.measuredValue, { mandatoryIf: [MEA] }),
|
96
|
-
minMeasuredValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent.attributes.minMeasuredValue, { mandatoryIf: [MEA] }),
|
97
|
-
maxMeasuredValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent.attributes.maxMeasuredValue, { mandatoryIf: [MEA] }),
|
98
|
-
peakMeasuredValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.PeakMeasurementComponent.attributes.peakMeasuredValue, { mandatoryIf: [PEA] }),
|
99
|
-
peakMeasuredValueWindow: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.PeakMeasurementComponent.attributes.peakMeasuredValueWindow, { mandatoryIf: [PEA] }),
|
100
|
-
averageMeasuredValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.AverageMeasurementComponent.attributes.averageMeasuredValue, { mandatoryIf: [AVG] }),
|
101
|
-
averageMeasuredValueWindow: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.AverageMeasurementComponent.attributes.averageMeasuredValueWindow, { mandatoryIf: [AVG] }),
|
102
|
-
uncertainty: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent.attributes.uncertainty, { optionalIf: [MEA] }),
|
103
|
-
measurementUnit: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.NumericMeasurementComponent.attributes.measurementUnit, { mandatoryIf: [MEA] }),
|
104
|
-
levelValue: MutableCluster.AsConditional(CarbonMonoxideConcentrationMeasurement.LevelIndicationComponent.attributes.levelValue, { mandatoryIf: [LEV] }),
|
105
|
-
},
|
106
|
-
});
|
107
|
-
CarbonMonoxideConcentrationMeasurement.Complete = CarbonMonoxideConcentrationMeasurement.CompleteInstance;
|
108
|
-
})(CarbonMonoxideConcentrationMeasurement || (CarbonMonoxideConcentrationMeasurement = {}));
|
109
|
-
export const CarbonMonoxideConcentrationMeasurementCluster = CarbonMonoxideConcentrationMeasurement.Cluster;
|
110
|
-
ClusterRegistry.register(ClusterType(CarbonMonoxideConcentrationMeasurement.Complete));
|
111
|
-
export const CarbonMonoxideConcentrationMeasurementBehavior = ClusterBehavior.for(ClusterType(CarbonMonoxideConcentrationMeasurement.Base));
|
112
|
-
export class CarbonMonoxideConcentrationMeasurementServer extends CarbonMonoxideConcentrationMeasurementBehavior.for(ClusterType(CarbonMonoxideConcentrationMeasurement.Base)) {
|
113
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
import { OperationalState } from 'matterbridge/matter/clusters';
|
2
|
-
import { Attribute, EventPriority, MutableCluster, OptionalAttribute, TlvArray, Event, TlvEnum, TlvNullable, TlvString, TlvUInt32, TlvUInt8, OptionalEvent, ClusterRegistry, TlvNoArguments, Command, } from 'matterbridge/matter/types';
|
3
|
-
export var OvenCavityOperationalState;
|
4
|
-
(function (OvenCavityOperationalState) {
|
5
|
-
OvenCavityOperationalState.ClusterInstance = MutableCluster({
|
6
|
-
id: 0x48,
|
7
|
-
name: 'OvenCavityOperationalState',
|
8
|
-
revision: 2,
|
9
|
-
attributes: {
|
10
|
-
phaseList: Attribute(0x0, TlvNullable(TlvArray(TlvString, { maxLength: 32 }))),
|
11
|
-
currentPhase: Attribute(0x1, TlvNullable(TlvUInt8)),
|
12
|
-
countdownTime: OptionalAttribute(0x2, TlvNullable(TlvUInt32.bound({ max: 259200 })), { default: null }),
|
13
|
-
operationalStateList: Attribute(0x3, TlvArray(OperationalState.TlvOperationalStateStruct), { default: [] }),
|
14
|
-
operationalState: Attribute(0x4, TlvEnum()),
|
15
|
-
operationalError: Attribute(0x5, OperationalState.TlvErrorStateStruct),
|
16
|
-
},
|
17
|
-
commands: {
|
18
|
-
stop: Command(0x1, TlvNoArguments, 0x4, OperationalState.TlvOperationalCommandResponse),
|
19
|
-
start: Command(0x2, TlvNoArguments, 0x4, OperationalState.TlvOperationalCommandResponse),
|
20
|
-
},
|
21
|
-
events: {
|
22
|
-
operationalError: Event(0x0, EventPriority.Critical, OperationalState.TlvOperationalErrorEvent),
|
23
|
-
operationCompletion: OptionalEvent(0x1, EventPriority.Info, OperationalState.TlvOperationCompletionEvent),
|
24
|
-
},
|
25
|
-
});
|
26
|
-
OvenCavityOperationalState.Cluster = OvenCavityOperationalState.ClusterInstance;
|
27
|
-
OvenCavityOperationalState.Complete = OvenCavityOperationalState.Cluster;
|
28
|
-
})(OvenCavityOperationalState || (OvenCavityOperationalState = {}));
|
29
|
-
export const OvenCavityOperationalStateCluster = OvenCavityOperationalState.Cluster;
|
30
|
-
ClusterRegistry.register(OvenCavityOperationalState.Complete);
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import { OperationalState as OperationalStateNamespace } from 'matterbridge/matter/clusters';
|
2
|
-
import { Attribute, ClusterRegistry, Event, EventPriority, MutableCluster, OptionalAttribute, OptionalCommand, OptionalEvent, TlvArray, TlvEnum, TlvField, TlvNoArguments, TlvNullable, TlvObject, TlvOptionalField, TlvString, TlvUInt32, TlvUInt8, } from 'matterbridge/matter/types';
|
3
|
-
export var RvcOperationalState;
|
4
|
-
(function (RvcOperationalState) {
|
5
|
-
let OperationalState;
|
6
|
-
(function (OperationalState) {
|
7
|
-
OperationalState[OperationalState["Stopped"] = 0] = "Stopped";
|
8
|
-
OperationalState[OperationalState["Running"] = 1] = "Running";
|
9
|
-
OperationalState[OperationalState["Paused"] = 2] = "Paused";
|
10
|
-
OperationalState[OperationalState["Error"] = 3] = "Error";
|
11
|
-
OperationalState[OperationalState["SeekingCharger"] = 64] = "SeekingCharger";
|
12
|
-
OperationalState[OperationalState["Charging"] = 65] = "Charging";
|
13
|
-
OperationalState[OperationalState["Docked"] = 66] = "Docked";
|
14
|
-
})(OperationalState = RvcOperationalState.OperationalState || (RvcOperationalState.OperationalState = {}));
|
15
|
-
RvcOperationalState.TlvOperationalStateStruct = TlvObject({
|
16
|
-
operationalStateId: TlvField(0, TlvEnum()),
|
17
|
-
operationalStateLabel: TlvOptionalField(1, TlvString.bound({ maxLength: 64 })),
|
18
|
-
});
|
19
|
-
let ErrorState;
|
20
|
-
(function (ErrorState) {
|
21
|
-
ErrorState[ErrorState["NoError"] = 0] = "NoError";
|
22
|
-
ErrorState[ErrorState["UnableToStartOrResume"] = 1] = "UnableToStartOrResume";
|
23
|
-
ErrorState[ErrorState["UnableToCompleteOperation"] = 2] = "UnableToCompleteOperation";
|
24
|
-
ErrorState[ErrorState["CommandInvalidInState"] = 3] = "CommandInvalidInState";
|
25
|
-
ErrorState[ErrorState["FailedToFindChargingDock"] = 64] = "FailedToFindChargingDock";
|
26
|
-
ErrorState[ErrorState["Stuck"] = 65] = "Stuck";
|
27
|
-
ErrorState[ErrorState["DustBinMissing"] = 66] = "DustBinMissing";
|
28
|
-
ErrorState[ErrorState["DustBinFull"] = 67] = "DustBinFull";
|
29
|
-
ErrorState[ErrorState["WaterTankEmpty"] = 68] = "WaterTankEmpty";
|
30
|
-
ErrorState[ErrorState["WaterTankMissing"] = 69] = "WaterTankMissing";
|
31
|
-
ErrorState[ErrorState["WaterTankLidOpen"] = 70] = "WaterTankLidOpen";
|
32
|
-
ErrorState[ErrorState["MopCleaningPadMissing"] = 71] = "MopCleaningPadMissing";
|
33
|
-
})(ErrorState = RvcOperationalState.ErrorState || (RvcOperationalState.ErrorState = {}));
|
34
|
-
RvcOperationalState.TlvErrorStateStruct = TlvObject({
|
35
|
-
errorStateId: TlvField(0, TlvEnum()),
|
36
|
-
errorStateLabel: TlvOptionalField(1, TlvString.bound({ maxLength: 64 })),
|
37
|
-
errorStateDetails: TlvOptionalField(2, TlvString.bound({ maxLength: 64 })),
|
38
|
-
});
|
39
|
-
RvcOperationalState.TlvOperationalCommandResponse = TlvObject({
|
40
|
-
commandResponseState: TlvField(0, RvcOperationalState.TlvErrorStateStruct),
|
41
|
-
});
|
42
|
-
RvcOperationalState.TlvOperationalErrorEvent = TlvObject({ errorState: TlvField(0, RvcOperationalState.TlvErrorStateStruct) });
|
43
|
-
RvcOperationalState.ClusterInstance = MutableCluster({
|
44
|
-
id: 0x61,
|
45
|
-
name: 'RvcOperationalState',
|
46
|
-
revision: 2,
|
47
|
-
attributes: {
|
48
|
-
phaseList: Attribute(0x0, TlvNullable(TlvArray(TlvString, { maxLength: 32 }))),
|
49
|
-
currentPhase: Attribute(0x1, TlvNullable(TlvUInt8)),
|
50
|
-
countdownTime: OptionalAttribute(0x2, TlvNullable(TlvUInt32.bound({ max: 259200 })), { default: null }),
|
51
|
-
operationalStateList: Attribute(0x3, TlvArray(RvcOperationalState.TlvOperationalStateStruct), { default: [] }),
|
52
|
-
operationalState: Attribute(0x4, TlvEnum()),
|
53
|
-
operationalError: Attribute(0x5, RvcOperationalState.TlvErrorStateStruct),
|
54
|
-
},
|
55
|
-
commands: {
|
56
|
-
pause: OptionalCommand(0x0, TlvNoArguments, 0x4, RvcOperationalState.TlvOperationalCommandResponse),
|
57
|
-
stop: OptionalCommand(0x1, TlvNoArguments, 0x4, RvcOperationalState.TlvOperationalCommandResponse),
|
58
|
-
start: OptionalCommand(0x2, TlvNoArguments, 0x4, RvcOperationalState.TlvOperationalCommandResponse),
|
59
|
-
resume: OptionalCommand(0x3, TlvNoArguments, 0x4, RvcOperationalState.TlvOperationalCommandResponse),
|
60
|
-
goHome: OptionalCommand(0x80, TlvNoArguments, 0x4, RvcOperationalState.TlvOperationalCommandResponse),
|
61
|
-
},
|
62
|
-
events: {
|
63
|
-
operationalError: Event(0x0, EventPriority.Critical, RvcOperationalState.TlvOperationalErrorEvent),
|
64
|
-
operationCompletion: OptionalEvent(0x1, EventPriority.Info, OperationalStateNamespace.TlvOperationCompletionEvent),
|
65
|
-
},
|
66
|
-
});
|
67
|
-
RvcOperationalState.Cluster = RvcOperationalState.ClusterInstance;
|
68
|
-
RvcOperationalState.Complete = RvcOperationalState.Cluster;
|
69
|
-
})(RvcOperationalState || (RvcOperationalState = {}));
|
70
|
-
export const RvcOperationalStateCluster = RvcOperationalState.Cluster;
|
71
|
-
ClusterRegistry.register(RvcOperationalState.Complete);
|