matterbridge-example-dynamic-platform 1.2.0-edge.5 → 1.2.0-edge.7
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 +191 -108
- package/dist/platform.js +151 -78
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/appliances.js
CHANGED
@@ -1,54 +1,14 @@
|
|
1
|
-
import {
|
1
|
+
import { DeviceTypeId, Matterbridge, MatterbridgeEndpoint, MatterbridgeServer, MatterbridgeOnOffServer, Status, VendorId, smokeCoAlarm, RefrigeratorTag, PositionTag, laundryWasher, laundryDryer, dishwasher, refrigerator, temperatureControlledCabinetCooler, oven, temperatureControlledCabinetHeater, microwaveOven, extractorHood, cooktop, cookSurface, } from 'matterbridge';
|
2
2
|
import { ClusterBehavior, LogLevel as MatterLogLevel, LogFormat as MatterLogFormat, EndpointServer, logEndpoint } from 'matterbridge/matter';
|
3
|
-
import {
|
4
|
-
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, OperationalStateBehavior, TemperatureControlBehavior, } from 'matterbridge/matter/behaviors';
|
3
|
+
import { OperationalState, TemperatureControl, DishwasherMode, LaundryWasherControls, LaundryWasherMode, LaundryDryerControls, OvenMode, RefrigeratorAndTemperatureControlledCabinetMode, MicrowaveOvenMode, MicrowaveOvenControl, } from 'matterbridge/matter/clusters';
|
4
|
+
import { DishwasherAlarmServer, LaundryDryerControlsServer, LaundryWasherControlsServer, MicrowaveOvenControlBehavior, MicrowaveOvenModeServer, OperationalStateBehavior, TemperatureControlBehavior, } from 'matterbridge/matter/behaviors';
|
5
5
|
import { OvenCavityOperationalState } from './implementations/ovenCavityOperationalStateCluster.js';
|
6
6
|
import { AnsiLogger } from 'matterbridge/logger';
|
7
7
|
import { Robot } from './robot.js';
|
8
8
|
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
9
|
constructor(deviceType, name, serial) {
|
50
|
-
super(deviceType, { uniqueStorageKey: `${name}-${serial}` });
|
51
|
-
if (deviceType.code ===
|
10
|
+
super(deviceType, { uniqueStorageKey: `${name}-${serial}` }, true);
|
11
|
+
if (deviceType.code === laundryWasher.code) {
|
52
12
|
this.createDefaultIdentifyClusterServer();
|
53
13
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Washer');
|
54
14
|
this.createDeadFrontOnOffClusterServer();
|
@@ -57,7 +17,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
57
17
|
this.createSpinLaundryWasherControlsClusterServer(3, ['400', '800', '1200', '1600']);
|
58
18
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
59
19
|
}
|
60
|
-
else if (deviceType.code ===
|
20
|
+
else if (deviceType.code === laundryDryer.code) {
|
61
21
|
this.createDefaultIdentifyClusterServer();
|
62
22
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Laundry Dryer');
|
63
23
|
this.createDeadFrontOnOffClusterServer();
|
@@ -66,7 +26,7 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
66
26
|
this.createDefaultLaundryDryerControlsClusterServer(1);
|
67
27
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
68
28
|
}
|
69
|
-
else if (deviceType.code ===
|
29
|
+
else if (deviceType.code === dishwasher.code) {
|
70
30
|
this.createDefaultIdentifyClusterServer();
|
71
31
|
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Dishwasher');
|
72
32
|
this.createDeadFrontOnOffClusterServer();
|
@@ -75,20 +35,75 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
75
35
|
this.createDefaultDishwasherAlarmClusterServer();
|
76
36
|
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
77
37
|
}
|
78
|
-
else if (deviceType.name ===
|
38
|
+
else if (deviceType.name === refrigerator.name) {
|
79
39
|
this.createDefaultIdentifyClusterServer();
|
80
|
-
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, '
|
81
|
-
this.
|
82
|
-
|
83
|
-
|
40
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Refrigerator');
|
41
|
+
const refrigerator = this.addChildDeviceType('Refrigerator', temperatureControlledCabinetCooler, { tagList: [{ mfgCode: null, namespaceId: RefrigeratorTag.Refrigerator.namespaceId, tag: RefrigeratorTag.Refrigerator.tag, label: RefrigeratorTag.Refrigerator.label }] }, true);
|
42
|
+
refrigerator.log.logName = `Refrigerator (cabinet Refrigerator)`;
|
43
|
+
refrigerator.createDefaultIdentifyClusterServer();
|
44
|
+
Appliances.createLevelTemperatureControlClusterServer(refrigerator, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
45
|
+
refrigerator.createDefaultTemperatureMeasurementClusterServer(1000);
|
46
|
+
Appliances.createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(refrigerator, 1);
|
47
|
+
const freezer = this.addChildDeviceType('Freezer', temperatureControlledCabinetCooler, { tagList: [{ mfgCode: null, namespaceId: RefrigeratorTag.Freezer.namespaceId, tag: RefrigeratorTag.Freezer.tag, label: RefrigeratorTag.Freezer.label }] }, true);
|
48
|
+
freezer.log.logName = `Refrigerator (cabinet Freezer)`;
|
49
|
+
freezer.createDefaultIdentifyClusterServer();
|
50
|
+
Appliances.createLevelTemperatureControlClusterServer(freezer, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
51
|
+
freezer.createDefaultTemperatureMeasurementClusterServer(-2000);
|
52
|
+
Appliances.createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(freezer, 1);
|
84
53
|
}
|
85
|
-
else if (deviceType.name ===
|
54
|
+
else if (deviceType.name === oven.name) {
|
86
55
|
this.createDefaultIdentifyClusterServer();
|
87
|
-
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, '
|
88
|
-
this.
|
89
|
-
|
90
|
-
|
91
|
-
|
56
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Oven');
|
57
|
+
const cabinettop = this.addChildDeviceType('Oven (top)', temperatureControlledCabinetHeater, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Top.namespaceId, tag: PositionTag.Top.tag, label: PositionTag.Top.label }] }, true);
|
58
|
+
cabinettop.log.logName = `Oven (top)`;
|
59
|
+
cabinettop.createDefaultIdentifyClusterServer();
|
60
|
+
Appliances.createLevelTemperatureControlClusterServer(cabinettop, 2, ['Defrost', '180°', '200°', '250°', '300°']);
|
61
|
+
cabinettop.createDefaultTemperatureMeasurementClusterServer(20000);
|
62
|
+
Appliances.createDefaultOvenModeClusterServer(cabinettop, 1);
|
63
|
+
const cabinetbottom = this.addChildDeviceType('Oven (bottom)', temperatureControlledCabinetHeater, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Bottom.namespaceId, tag: PositionTag.Bottom.tag, label: PositionTag.Bottom.label }] }, true);
|
64
|
+
cabinetbottom.log.logName = `Oven (bottom)`;
|
65
|
+
cabinetbottom.createDefaultIdentifyClusterServer();
|
66
|
+
Appliances.createLevelTemperatureControlClusterServer(cabinetbottom, 2, ['Defrost', '180°', '200°', '250°', '300°']);
|
67
|
+
cabinetbottom.createDefaultTemperatureMeasurementClusterServer(30000);
|
68
|
+
Appliances.createDefaultOvenModeClusterServer(cabinetbottom, 1);
|
69
|
+
}
|
70
|
+
else if (deviceType.name === microwaveOven.name) {
|
71
|
+
this.createDefaultIdentifyClusterServer();
|
72
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Microwave Oven');
|
73
|
+
this.createDefaultOperationalStateClusterServer(OperationalState.OperationalStateEnum.Stopped);
|
74
|
+
this.createDefaultMicrowaveOvenModeClusterServer();
|
75
|
+
this.createDefaultMicrowaveOvenControlClusterServer();
|
76
|
+
}
|
77
|
+
else if (deviceType.name === extractorHood.name) {
|
78
|
+
this.createDefaultIdentifyClusterServer();
|
79
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Extractor Hood');
|
80
|
+
this.createBaseFanControlClusterServer();
|
81
|
+
this.createDefaultHepaFilterMonitoringClusterServer();
|
82
|
+
this.createDefaultActivatedCarbonFilterMonitoringClusterServer();
|
83
|
+
}
|
84
|
+
else if (deviceType.name === cooktop.name) {
|
85
|
+
this.createDefaultIdentifyClusterServer();
|
86
|
+
this.createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Cooktop');
|
87
|
+
this.createOffOnlyOnOffClusterServer(true);
|
88
|
+
const cookSurface1 = this.addChildDeviceType('Surface 1', cookSurface, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Left.namespaceId, tag: PositionTag.Left.tag, label: PositionTag.Left.label }] }, true);
|
89
|
+
cookSurface1.log.logName = `Cook surface (right)`;
|
90
|
+
cookSurface1.createDefaultIdentifyClusterServer();
|
91
|
+
Appliances.createLevelTemperatureControlClusterServer(cookSurface1, 2, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
92
|
+
cookSurface1.createDefaultTemperatureMeasurementClusterServer(10000);
|
93
|
+
cookSurface1.createOffOnlyOnOffClusterServer(true);
|
94
|
+
const cookSurface2 = this.addChildDeviceType('Surface 2', cookSurface, { tagList: [{ mfgCode: null, namespaceId: PositionTag.Right.namespaceId, tag: PositionTag.Right.tag, label: PositionTag.Right.label }] }, true);
|
95
|
+
cookSurface2.log.logName = `Cook surface (left)`;
|
96
|
+
cookSurface2.createDefaultIdentifyClusterServer();
|
97
|
+
Appliances.createLevelTemperatureControlClusterServer(cookSurface2, 3, ['Level 1', 'Level 2', 'Level 3', 'Level 4', 'Level 5']);
|
98
|
+
cookSurface2.createDefaultTemperatureMeasurementClusterServer(12000);
|
99
|
+
cookSurface2.createOffOnlyOnOffClusterServer(true);
|
100
|
+
this.eventsOf(MatterbridgeOnOffServer).onOff$Changed.on(async (value) => {
|
101
|
+
if (!value) {
|
102
|
+
this.log.notice('Turning off all cook surfaces');
|
103
|
+
await cookSurface1.setStateOf(MatterbridgeOnOffServer, { onOff: false });
|
104
|
+
await cookSurface2.setStateOf(MatterbridgeOnOffServer, { onOff: false });
|
105
|
+
}
|
106
|
+
});
|
92
107
|
}
|
93
108
|
}
|
94
109
|
createDefaultOperationalStateClusterServer(operationalState = OperationalState.OperationalStateEnum.Stopped) {
|
@@ -120,15 +135,34 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
120
135
|
});
|
121
136
|
return this;
|
122
137
|
}
|
123
|
-
createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(currentMode) {
|
124
|
-
|
138
|
+
static createDefaultRefrigeratorAndTemperatureControlledCabinetModeClusterServer(endpoint, currentMode) {
|
139
|
+
endpoint.behaviors.require(RefrigeratorAndTemperatureControlledCabinetModeServer, {
|
125
140
|
supportedModes: [
|
141
|
+
{ label: 'Auto', mode: 0, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.Auto }] },
|
126
142
|
{ label: 'RapidCool', mode: 1, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.RapidCool }] },
|
127
143
|
{ label: 'RapidFreeze', mode: 2, modeTags: [{ value: RefrigeratorAndTemperatureControlledCabinetMode.ModeTag.RapidFreeze }] },
|
128
144
|
],
|
129
145
|
currentMode,
|
130
146
|
});
|
131
|
-
return
|
147
|
+
return endpoint;
|
148
|
+
}
|
149
|
+
static createDefaultOvenModeClusterServer(endpoint, currentMode) {
|
150
|
+
endpoint.behaviors.require(OvenModeServer, {
|
151
|
+
supportedModes: [
|
152
|
+
{ label: 'Bake', mode: 1, modeTags: [{ value: OvenMode.ModeTag.Bake }] },
|
153
|
+
{ label: 'Convection', mode: 2, modeTags: [{ value: OvenMode.ModeTag.Convection }] },
|
154
|
+
{ label: 'Grill', mode: 3, modeTags: [{ value: OvenMode.ModeTag.Grill }] },
|
155
|
+
{ label: 'Roast', mode: 4, modeTags: [{ value: OvenMode.ModeTag.Roast }] },
|
156
|
+
{ label: 'Clean', mode: 5, modeTags: [{ value: OvenMode.ModeTag.Clean }] },
|
157
|
+
{ label: 'Convection Bake', mode: 6, modeTags: [{ value: OvenMode.ModeTag.ConvectionBake }] },
|
158
|
+
{ label: 'Convection Roast', mode: 7, modeTags: [{ value: OvenMode.ModeTag.ConvectionRoast }] },
|
159
|
+
{ label: 'Warming', mode: 8, modeTags: [{ value: OvenMode.ModeTag.Warming }] },
|
160
|
+
{ label: 'Proofing', mode: 9, modeTags: [{ value: OvenMode.ModeTag.Proofing }] },
|
161
|
+
{ label: 'Steam', mode: 10, modeTags: [{ value: OvenMode.ModeTag.Steam }] },
|
162
|
+
],
|
163
|
+
currentMode,
|
164
|
+
});
|
165
|
+
return endpoint;
|
132
166
|
}
|
133
167
|
createDefaultDishwasherModeClusterServer(currentMode) {
|
134
168
|
this.behaviors.require(DishwasherModeServer, {
|
@@ -153,6 +187,30 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
153
187
|
});
|
154
188
|
return this;
|
155
189
|
}
|
190
|
+
createDefaultMicrowaveOvenModeClusterServer(currentMode, supportedModes) {
|
191
|
+
this.behaviors.require(MicrowaveOvenModeServer, {
|
192
|
+
supportedModes: supportedModes ?? [
|
193
|
+
{ label: 'Auto', mode: 1, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Auto }] },
|
194
|
+
{ label: 'Quick', mode: 2, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Quick }] },
|
195
|
+
{ label: 'Quiet', mode: 3, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Quiet }] },
|
196
|
+
{ label: 'Min', mode: 4, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Min }] },
|
197
|
+
{ label: 'Max', mode: 5, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Max }] },
|
198
|
+
{ label: 'Normal', mode: 6, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Normal }] },
|
199
|
+
{ label: 'Defrost', mode: 7, modeTags: [{ value: MicrowaveOvenMode.ModeTag.Defrost }] },
|
200
|
+
],
|
201
|
+
currentMode: currentMode ?? 1,
|
202
|
+
});
|
203
|
+
return this;
|
204
|
+
}
|
205
|
+
createDefaultMicrowaveOvenControlClusterServer(selectedWattIndex = 5, supportedWatts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], cookTime = 60, maxCookTime = 3600) {
|
206
|
+
this.behaviors.require(MatterbridgeMicrowaveOvenControlServer.with(MicrowaveOvenControl.Feature.PowerInWatts), {
|
207
|
+
supportedWatts,
|
208
|
+
selectedWattIndex,
|
209
|
+
cookTime,
|
210
|
+
maxCookTime,
|
211
|
+
});
|
212
|
+
return this;
|
213
|
+
}
|
156
214
|
createSpinLaundryWasherControlsClusterServer(spinSpeedCurrent, spinSpeeds) {
|
157
215
|
this.behaviors.require(LaundryWasherControlsServer.with(LaundryWasherControls.Feature.Spin), {
|
158
216
|
spinSpeeds: spinSpeeds ?? ['400', '800', '1200', '1600'],
|
@@ -192,24 +250,6 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
192
250
|
});
|
193
251
|
return this;
|
194
252
|
}
|
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
253
|
createLevelTemperatureControlClusterServer(selectedTemperatureLevel = 1, supportedTemperatureLevels = ['Cold', 'Warm', 'Hot']) {
|
214
254
|
this.behaviors.require(MatterbridgeLevelTemperatureControlServer.with(TemperatureControl.Feature.TemperatureLevel), {
|
215
255
|
selectedTemperatureLevel,
|
@@ -217,6 +257,13 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
217
257
|
});
|
218
258
|
return this;
|
219
259
|
}
|
260
|
+
static createLevelTemperatureControlClusterServer(endpoint, selectedTemperatureLevel = 1, supportedTemperatureLevels = ['Cold', 'Warm', 'Hot']) {
|
261
|
+
endpoint.behaviors.require(MatterbridgeLevelTemperatureControlServer.with(TemperatureControl.Feature.TemperatureLevel), {
|
262
|
+
selectedTemperatureLevel,
|
263
|
+
supportedTemperatureLevels,
|
264
|
+
});
|
265
|
+
return endpoint;
|
266
|
+
}
|
220
267
|
createNumberTemperatureControlClusterServer(temperatureSetpoint, minTemperature, maxTemperature, step = 1) {
|
221
268
|
this.behaviors.require(MatterbridgeNumberTemperatureControlServer.with(TemperatureControl.Feature.TemperatureNumber, TemperatureControl.Feature.TemperatureStep), {
|
222
269
|
temperatureSetpoint,
|
@@ -226,16 +273,25 @@ export class Appliances extends MatterbridgeEndpoint {
|
|
226
273
|
});
|
227
274
|
return this;
|
228
275
|
}
|
276
|
+
static createNumberTemperatureControlClusterServer(endpoint, temperatureSetpoint, minTemperature, maxTemperature, step = 1) {
|
277
|
+
endpoint.behaviors.require(MatterbridgeNumberTemperatureControlServer.with(TemperatureControl.Feature.TemperatureNumber, TemperatureControl.Feature.TemperatureStep), {
|
278
|
+
temperatureSetpoint,
|
279
|
+
minTemperature,
|
280
|
+
maxTemperature,
|
281
|
+
step,
|
282
|
+
});
|
283
|
+
return endpoint;
|
284
|
+
}
|
229
285
|
}
|
230
286
|
class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
231
287
|
initialize() {
|
232
|
-
const device = this.
|
288
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
233
289
|
device.log.info('MatterbridgeOperationalStateServer initialized: setting operational state to Stopped');
|
234
290
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
235
291
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
236
292
|
}
|
237
293
|
pause() {
|
238
|
-
const device = this.
|
294
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
239
295
|
device.log.info('MatterbridgeOperationalStateServer: pause called setting operational state to Paused');
|
240
296
|
this.state.operationalState = OperationalState.OperationalStateEnum.Paused;
|
241
297
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -244,7 +300,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
244
300
|
};
|
245
301
|
}
|
246
302
|
stop() {
|
247
|
-
const device = this.
|
303
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
248
304
|
device.log.info('MatterbridgeOperationalStateServer: stop called setting operational state to Stopped');
|
249
305
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
250
306
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -253,7 +309,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
253
309
|
};
|
254
310
|
}
|
255
311
|
start() {
|
256
|
-
const device = this.
|
312
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
257
313
|
device.log.info('MatterbridgeOperationalStateServer: start called setting operational state to Running');
|
258
314
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
259
315
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -262,7 +318,7 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
262
318
|
};
|
263
319
|
}
|
264
320
|
resume() {
|
265
|
-
const device = this.
|
321
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
266
322
|
device.log.info('MatterbridgeOperationalStateServer: resume called setting operational state to Running');
|
267
323
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
268
324
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -274,13 +330,12 @@ class MatterbridgeOperationalStateServer extends OperationalStateBehavior {
|
|
274
330
|
class MatterbridgeLevelTemperatureControlServer extends TemperatureControlBehavior.with(TemperatureControl.Feature.TemperatureLevel) {
|
275
331
|
initialize() {
|
276
332
|
if (this.state.supportedTemperatureLevels.length >= 2) {
|
277
|
-
const device = this.
|
278
|
-
device.log.info('MatterbridgeLevelTemperatureControlServer initialized
|
279
|
-
this.state.selectedTemperatureLevel = 1;
|
333
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
334
|
+
device.log.info('MatterbridgeLevelTemperatureControlServer initialized');
|
280
335
|
}
|
281
336
|
}
|
282
337
|
setTemperature(request) {
|
283
|
-
const device = this.
|
338
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
284
339
|
if (request.targetTemperatureLevel !== undefined && request.targetTemperatureLevel >= 0 && request.targetTemperatureLevel < this.state.supportedTemperatureLevels.length) {
|
285
340
|
device.log.info(`MatterbridgeLevelTemperatureControlServer: setTemperature called setting selectedTemperatureLevel to ${request.targetTemperatureLevel}: ${this.state.supportedTemperatureLevels[request.targetTemperatureLevel]}`);
|
286
341
|
this.state.selectedTemperatureLevel = request.targetTemperatureLevel;
|
@@ -292,11 +347,11 @@ class MatterbridgeLevelTemperatureControlServer extends TemperatureControlBehavi
|
|
292
347
|
}
|
293
348
|
class MatterbridgeNumberTemperatureControlServer extends TemperatureControlBehavior.with(TemperatureControl.Feature.TemperatureNumber) {
|
294
349
|
initialize() {
|
295
|
-
const device = this.
|
350
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
296
351
|
device.log.info('MatterbridgeNumberTemperatureControlServer initialized');
|
297
352
|
}
|
298
353
|
setTemperature(request) {
|
299
|
-
const device = this.
|
354
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
300
355
|
if (request.targetTemperature !== undefined && request.targetTemperature >= this.state.minTemperature && request.targetTemperature <= this.state.maxTemperature) {
|
301
356
|
device.log.info(`MatterbridgeNumberTemperatureControlServer: setTemperature called setting temperatureSetpoint to ${request.targetTemperature}`);
|
302
357
|
this.state.temperatureSetpoint = request.targetTemperature;
|
@@ -306,16 +361,42 @@ class MatterbridgeNumberTemperatureControlServer extends TemperatureControlBehav
|
|
306
361
|
}
|
307
362
|
}
|
308
363
|
}
|
364
|
+
class MatterbridgeMicrowaveOvenControlServer extends MicrowaveOvenControlBehavior.with(MicrowaveOvenControl.Feature.PowerInWatts) {
|
365
|
+
initialize() {
|
366
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
367
|
+
device.log.info('MatterbridgeMicrowaveOvenControlServer initialized');
|
368
|
+
}
|
369
|
+
setCookingParameters(request) {
|
370
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
371
|
+
if (request.wattSettingIndex !== undefined && request.wattSettingIndex >= 0 && request.wattSettingIndex < this.state.supportedWatts.length) {
|
372
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called setting selectedWattIndex to ${request.wattSettingIndex}`);
|
373
|
+
this.state.selectedWattIndex = request.wattSettingIndex;
|
374
|
+
}
|
375
|
+
else {
|
376
|
+
device.log.error(`MatterbridgeMicrowaveOvenControlServer: setCookingParameters called with invalid wattSettingIndex ${request.wattSettingIndex}`);
|
377
|
+
}
|
378
|
+
}
|
379
|
+
addMoreTime(request) {
|
380
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
381
|
+
if (request.timeToAdd !== undefined && request.timeToAdd >= 0) {
|
382
|
+
device.log.info(`MatterbridgeMicrowaveOvenControlServer: addMoreTime called setting cookTime to ${this.state.cookTime + request.timeToAdd}`);
|
383
|
+
this.state.cookTime += request.timeToAdd;
|
384
|
+
}
|
385
|
+
else {
|
386
|
+
device.log.error(`MatterbridgeMicrowaveOvenControlServer: addMoreTime called with invalid cookTime ${request.timeToAdd}`);
|
387
|
+
}
|
388
|
+
}
|
389
|
+
}
|
309
390
|
export const OvenCavityOperationalStateBehavior = ClusterBehavior.withInterface().for(OvenCavityOperationalState.Cluster);
|
310
391
|
export class OvenCavityOperationalStateServer extends OvenCavityOperationalStateBehavior {
|
311
392
|
initialize() {
|
312
|
-
const device = this.
|
393
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
313
394
|
device.log.info('OvenCavityOperationalStateServer initialized: setting operational state to Stopped and operational error to No error');
|
314
395
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
315
396
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
316
397
|
}
|
317
398
|
stop() {
|
318
|
-
const device = this.
|
399
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
319
400
|
device.log.info('OvenCavityOperationalStateServer: stop called setting operational state to Stopped and operational error to No error');
|
320
401
|
this.state.operationalState = OperationalState.OperationalStateEnum.Stopped;
|
321
402
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -324,7 +405,7 @@ export class OvenCavityOperationalStateServer extends OvenCavityOperationalState
|
|
324
405
|
};
|
325
406
|
}
|
326
407
|
start() {
|
327
|
-
const device = this.
|
408
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
328
409
|
device.log.info('OvenCavityOperationalStateServer: start called setting operational state to Running and operational error to No error');
|
329
410
|
this.state.operationalState = OperationalState.OperationalStateEnum.Running;
|
330
411
|
this.state.operationalError = { errorStateId: OperationalState.ErrorState.NoError, errorStateLabel: 'No error', errorStateDetails: 'Fully operational' };
|
@@ -336,14 +417,15 @@ export class OvenCavityOperationalStateServer extends OvenCavityOperationalState
|
|
336
417
|
export const RefrigeratorAndTemperatureControlledCabinetModeBehavior = ClusterBehavior.withInterface().for(RefrigeratorAndTemperatureControlledCabinetMode.Cluster);
|
337
418
|
class RefrigeratorAndTemperatureControlledCabinetModeServer extends RefrigeratorAndTemperatureControlledCabinetModeBehavior {
|
338
419
|
initialize() {
|
339
|
-
const device = this.
|
420
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
340
421
|
device.log.info('MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer initialized: setting currentMode to 1');
|
341
422
|
this.state.currentMode = 1;
|
342
423
|
}
|
343
424
|
changeToMode(request) {
|
344
|
-
const device = this.
|
345
|
-
|
346
|
-
|
425
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
426
|
+
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
427
|
+
if (supportedMode) {
|
428
|
+
device.log.info(`MatterbridgeRefrigeratorAndTemperatureControlledCabinetModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
347
429
|
this.state.currentMode = request.newMode;
|
348
430
|
return { status: Status.Success, statusText: 'Success' };
|
349
431
|
}
|
@@ -356,14 +438,15 @@ class RefrigeratorAndTemperatureControlledCabinetModeServer extends Refrigerator
|
|
356
438
|
export const OvenModeBehavior = ClusterBehavior.withInterface().for(OvenMode.Cluster);
|
357
439
|
class OvenModeServer extends OvenModeBehavior {
|
358
440
|
initialize() {
|
359
|
-
const device = this.
|
441
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
360
442
|
device.log.info('OvenModeServer initialized: setting currentMode to 3');
|
361
443
|
this.state.currentMode = 3;
|
362
444
|
}
|
363
445
|
changeToMode(request) {
|
364
|
-
const device = this.
|
365
|
-
|
366
|
-
|
446
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
447
|
+
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
448
|
+
if (supportedMode) {
|
449
|
+
device.log.info(`OvenModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
367
450
|
this.state.currentMode = request.newMode;
|
368
451
|
return { status: Status.Success, statusText: 'Success' };
|
369
452
|
}
|
@@ -376,20 +459,20 @@ class OvenModeServer extends OvenModeBehavior {
|
|
376
459
|
export const DishwasherModeBehavior = ClusterBehavior.withInterface().for(DishwasherMode.Cluster);
|
377
460
|
class DishwasherModeServer extends DishwasherModeBehavior {
|
378
461
|
initialize() {
|
379
|
-
const device = this.
|
462
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
380
463
|
device.log.info('DishwasherModeServer initialized: setting currentMode to 3');
|
381
464
|
this.state.currentMode = 2;
|
382
465
|
this.reactTo(this.agent.get(MatterbridgeOnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
383
466
|
}
|
384
467
|
handleOnOffChange(onOff) {
|
385
|
-
const device = this.
|
468
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
386
469
|
if (onOff === false) {
|
387
470
|
device.log.info('***OnOffServer changed to OFF: setting Dead Front state to Manufacturer Specific');
|
388
471
|
this.state.currentMode = 2;
|
389
472
|
}
|
390
473
|
}
|
391
474
|
changeToMode(request) {
|
392
|
-
const device = this.
|
475
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
393
476
|
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
394
477
|
if (supportedMode) {
|
395
478
|
device.log.info(`DishwasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
@@ -405,20 +488,20 @@ class DishwasherModeServer extends DishwasherModeBehavior {
|
|
405
488
|
export const LaundryWasherModeBehavior = ClusterBehavior.withInterface().for(LaundryWasherMode.Cluster);
|
406
489
|
class LaundryWasherModeServer extends LaundryWasherModeBehavior {
|
407
490
|
initialize() {
|
408
|
-
const device = this.
|
491
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
409
492
|
device.log.info('LaundryWasherModeServer initialized: setting currentMode to 3');
|
410
493
|
this.state.currentMode = 2;
|
411
494
|
this.reactTo(this.agent.get(MatterbridgeOnOffServer).events.onOff$Changed, this.handleOnOffChange);
|
412
495
|
}
|
413
496
|
handleOnOffChange(onOff) {
|
414
|
-
const device = this.
|
497
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
415
498
|
if (onOff === false) {
|
416
|
-
device.log.
|
499
|
+
device.log.notice('OnOffServer changed to OFF: setting Dead Front state to Manufacturer Specific');
|
417
500
|
this.state.currentMode = 2;
|
418
501
|
}
|
419
502
|
}
|
420
503
|
changeToMode(request) {
|
421
|
-
const device = this.
|
504
|
+
const device = this.endpoint.stateOf(MatterbridgeServer).deviceCommand;
|
422
505
|
const supportedMode = this.state.supportedModes.find((supportedMode) => supportedMode.mode === request.newMode);
|
423
506
|
if (supportedMode) {
|
424
507
|
device.log.info(`LaundryWasherModeServer: changeToMode called with mode ${supportedMode.mode} = ${supportedMode.label}`);
|
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/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.7",
|
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.7",
|
10
10
|
"license": "MIT",
|
11
11
|
"dependencies": {
|
12
12
|
"node-ansi-logger": "3.0.1",
|