matterbridge 1.3.10 → 1.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +4 -4
- package/dist/history/export.d.ts +2 -0
- package/dist/history/export.d.ts.map +1 -0
- package/dist/history/export.js +2 -0
- package/dist/history/export.js.map +1 -0
- package/dist/matterbridge.d.ts +2 -2
- package/dist/matterbridge.d.ts.map +1 -1
- package/dist/matterbridge.js +79 -53
- package/dist/matterbridge.js.map +1 -1
- package/dist/matterbridgeDevice.d.ts +155 -15
- package/dist/matterbridgeDevice.d.ts.map +1 -1
- package/dist/matterbridgeDevice.js +243 -35
- package/dist/matterbridgeDevice.js.map +1 -1
- package/dist/matterbridgePlatform.js +1 -1
- package/dist/matterbridgePlatform.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +5 -5
- package/dist/utils/utils.js.map +1 -1
- package/frontend/build/asset-manifest.json +6 -6
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/css/{main.8e9f022b.css → main.b4d28450.css} +2 -2
- package/frontend/build/static/css/main.b4d28450.css.map +1 -0
- package/frontend/build/static/js/{main.cf22e7af.js → main.3105733e.js} +3 -3
- package/frontend/build/static/js/{main.cf22e7af.js.map → main.3105733e.js.map} +1 -1
- package/package.json +14 -8
- package/frontend/build/static/css/main.8e9f022b.css.map +0 -1
- /package/frontend/build/static/js/{main.cf22e7af.js.LICENSE.txt → main.3105733e.js.LICENSE.txt} +0 -0
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* See the License for the specific language governing permissions and
|
|
21
21
|
* limitations under the License. *
|
|
22
22
|
*/
|
|
23
|
-
import { BasicInformationCluster, BooleanState, BooleanStateCluster, ClusterServer, ColorControl, ColorControlCluster, DoorLock, DoorLockCluster, ElectricalMeasurement, ElectricalMeasurementCluster, FanControl, FanControlCluster, FixedLabelCluster, FlowMeasurement, FlowMeasurementCluster, Groups, Identify, IdentifyCluster, IlluminanceMeasurement, IlluminanceMeasurementCluster, LevelControl, LevelControlCluster, ModeSelectCluster, OccupancySensing, OccupancySensingCluster, OnOff, OnOffCluster, PowerSource, PowerSourceCluster, PowerSourceConfigurationCluster, PressureMeasurement, PressureMeasurementCluster, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, Scenes, Switch, SwitchCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, ThreadNetworkDiagnostics, ThreadNetworkDiagnosticsCluster, TimeSync, TimeSyncCluster, WindowCovering, WindowCoveringCluster,
|
|
24
|
-
import { EndpointNumber, VendorId } from '@project-chip/matter-node.js/datatype';
|
|
23
|
+
import { BasicInformationCluster, BooleanState, BooleanStateCluster, ClusterServer, ColorControl, ColorControlCluster, DoorLock, DoorLockCluster, ElectricalMeasurement, ElectricalMeasurementCluster, FanControl, FanControlCluster, FixedLabelCluster, FlowMeasurement, FlowMeasurementCluster, Groups, GroupsCluster, GroupsClusterHandler, Identify, IdentifyCluster, IlluminanceMeasurement, IlluminanceMeasurementCluster, LevelControl, LevelControlCluster, ModeSelectCluster, OccupancySensing, OccupancySensingCluster, OnOff, OnOffCluster, PowerSource, PowerSourceCluster, PowerSourceConfigurationCluster, PressureMeasurement, PressureMeasurementCluster, RelativeHumidityMeasurement, RelativeHumidityMeasurementCluster, Scenes, ScenesCluster, ScenesClusterHandler, Switch, SwitchCluster, TemperatureMeasurement, TemperatureMeasurementCluster, Thermostat, ThermostatCluster, ThreadNetworkDiagnostics, ThreadNetworkDiagnosticsCluster, TimeSync, TimeSyncCluster, WindowCovering, WindowCoveringCluster, getClusterNameById, } from '@project-chip/matter-node.js/cluster';
|
|
24
|
+
import { EndpointNumber, GroupId, VendorId } from '@project-chip/matter-node.js/datatype';
|
|
25
25
|
import { Device, DeviceClasses, DeviceTypeDefinition, Endpoint } from '@project-chip/matter-node.js/device';
|
|
26
26
|
import { extendPublicHandlerMethods } from '@project-chip/matter-node.js/util';
|
|
27
27
|
import { EveHistory, EveHistoryCluster } from 'matter-history';
|
|
@@ -169,28 +169,110 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
169
169
|
/**
|
|
170
170
|
* Create a Matterbridge device.
|
|
171
171
|
* @constructor
|
|
172
|
-
* @param {DeviceTypeDefinition} definition - The
|
|
172
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
173
173
|
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
174
|
+
* @param {boolean} [debug=false] - The debug level for the device.
|
|
174
175
|
*/
|
|
175
176
|
constructor(definition, options = {}, debug = false) {
|
|
176
|
-
|
|
177
|
+
let firstDefinition;
|
|
178
|
+
if (Array.isArray(definition))
|
|
179
|
+
firstDefinition = definition[0];
|
|
180
|
+
else
|
|
181
|
+
firstDefinition = definition;
|
|
182
|
+
super(firstDefinition, options);
|
|
177
183
|
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logDebug: debug });
|
|
178
|
-
this.log.debug(`MatterbridgeDevice with deviceType: ${zb}${
|
|
184
|
+
this.log.debug(`new MatterbridgeDevice with deviceType: ${zb}${firstDefinition.code}${db}-${zb}${firstDefinition.name}${db}`);
|
|
185
|
+
if (Array.isArray(definition)) {
|
|
186
|
+
definition.forEach((deviceType) => {
|
|
187
|
+
this.addDeviceType(deviceType);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
this.addDeviceType(firstDefinition);
|
|
179
191
|
}
|
|
180
192
|
/**
|
|
181
|
-
* Loads an instance of the MatterbridgeDevice class.
|
|
193
|
+
* Loads asyncronously an instance of the MatterbridgeDevice class.
|
|
182
194
|
*
|
|
183
|
-
* @param {DeviceTypeDefinition} definition - The DeviceTypeDefinition of the device.
|
|
184
|
-
* @
|
|
195
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The DeviceTypeDefinition of the device.
|
|
196
|
+
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
197
|
+
* @param {boolean} [debug=false] - The debug level for the device.
|
|
198
|
+
* @returns {Promise<MatterbridgeDevice>} A Promise of MatterbridgeDevice instance.
|
|
185
199
|
*/
|
|
186
200
|
static async loadInstance(definition, options = {}, debug = false) {
|
|
187
201
|
return new MatterbridgeDevice(definition, options, debug);
|
|
188
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Create asyncronously a device with one or more device types and with the required cluster servers and the specified cluster servers.
|
|
205
|
+
*
|
|
206
|
+
* @param {DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>} definition - The device types to add.
|
|
207
|
+
* @param {EndpointOptions} [options={}] - The options for the device.
|
|
208
|
+
* @param {ClusterId[]} clusterServerList - The list of cluster IDs to include.
|
|
209
|
+
* @param {boolean} [debug=false] - The debug level for the device.
|
|
210
|
+
* @returns {Promise<MatterbridgeDevice>} The MatterbridgeDevice instance.
|
|
211
|
+
*
|
|
212
|
+
static async createWithClusterServer(definition: DeviceTypeDefinition | AtLeastOne<DeviceTypeDefinition>, options: EndpointOptions = {}, clusterServerList: ClusterId[] = [], debug = false): Promise<MatterbridgeDevice> {
|
|
213
|
+
const device = new MatterbridgeDevice(definition, options, debug);
|
|
214
|
+
if (Array.isArray(definition)) {
|
|
215
|
+
definition.forEach((deviceType) => {
|
|
216
|
+
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
217
|
+
if (!clusterServerList.includes(clusterId)) clusterServerList.push(clusterId);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
definition.requiredServerClusters.forEach((clusterId) => {
|
|
222
|
+
if (!clusterServerList.includes(clusterId)) clusterServerList.push(clusterId);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
device.log.debug(`createWithClusterServer:`);
|
|
226
|
+
const deviceTypes = device.getDeviceTypes();
|
|
227
|
+
deviceTypes.forEach((deviceType) => {
|
|
228
|
+
device.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
229
|
+
});
|
|
230
|
+
clusterServerList.forEach((clusterId) => {
|
|
231
|
+
device.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
232
|
+
});
|
|
233
|
+
device.addClusterServerFromList(device, clusterServerList);
|
|
234
|
+
// TODO must by typed and tested
|
|
235
|
+
Object.entries(options).forEach(([key, value]) => {
|
|
236
|
+
if (key === 'basicInformation') {
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
+
const basicInformation = value as any;
|
|
239
|
+
device.createDefaultBasicInformationClusterServer(
|
|
240
|
+
basicInformation.deviceName,
|
|
241
|
+
basicInformation.serialNumber,
|
|
242
|
+
basicInformation.vendorId,
|
|
243
|
+
basicInformation.vendorName,
|
|
244
|
+
basicInformation.productId,
|
|
245
|
+
basicInformation.productName,
|
|
246
|
+
basicInformation.softwareVersion,
|
|
247
|
+
basicInformation.softwareVersionString,
|
|
248
|
+
basicInformation.hardwareVersion,
|
|
249
|
+
basicInformation.hardwareVersionString,
|
|
250
|
+
);
|
|
251
|
+
} else if (key === 'bridgedDeviceBasicInformation') {
|
|
252
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
253
|
+
const bridgedDeviceBasicInformation = value as any;
|
|
254
|
+
device.createDefaultBridgedDeviceBasicInformationClusterServer(
|
|
255
|
+
bridgedDeviceBasicInformation.deviceName,
|
|
256
|
+
bridgedDeviceBasicInformation.serialNumber,
|
|
257
|
+
bridgedDeviceBasicInformation.vendorId,
|
|
258
|
+
bridgedDeviceBasicInformation.vendorName,
|
|
259
|
+
bridgedDeviceBasicInformation.productName,
|
|
260
|
+
bridgedDeviceBasicInformation.softwareVersion,
|
|
261
|
+
bridgedDeviceBasicInformation.softwareVersionString,
|
|
262
|
+
bridgedDeviceBasicInformation.hardwareVersion,
|
|
263
|
+
bridgedDeviceBasicInformation.hardwareVersionString,
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return device;
|
|
268
|
+
}
|
|
269
|
+
*/
|
|
189
270
|
/**
|
|
190
271
|
* Adds a device type to the list of device types of the MatterbridgeDevice endpoint.
|
|
191
272
|
* If the device type is not already present in the list, it will be added.
|
|
192
273
|
*
|
|
193
274
|
* @param {DeviceTypeDefinition} deviceType - The device type to add.
|
|
275
|
+
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
194
276
|
*/
|
|
195
277
|
addDeviceType(deviceType) {
|
|
196
278
|
const deviceTypes = this.getDeviceTypes();
|
|
@@ -199,14 +281,16 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
199
281
|
deviceTypes.push(deviceType);
|
|
200
282
|
this.setDeviceTypes(deviceTypes);
|
|
201
283
|
}
|
|
284
|
+
return this;
|
|
202
285
|
}
|
|
203
286
|
/**
|
|
204
287
|
* Adds one or more device types with the required cluster servers and the specified cluster servers.
|
|
205
288
|
*
|
|
206
289
|
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
|
|
207
290
|
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
291
|
+
* @returns {MatterbridgeDevice} The MatterbridgeDevice instance.
|
|
208
292
|
*/
|
|
209
|
-
addDeviceTypeWithClusterServer(deviceTypes, includeServerList) {
|
|
293
|
+
addDeviceTypeWithClusterServer(deviceTypes, includeServerList = []) {
|
|
210
294
|
this.log.debug('addDeviceTypeWithClusterServer:');
|
|
211
295
|
deviceTypes.forEach((deviceType) => {
|
|
212
296
|
this.addDeviceType(deviceType);
|
|
@@ -220,6 +304,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
220
304
|
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
221
305
|
});
|
|
222
306
|
this.addClusterServerFromList(this, includeServerList);
|
|
307
|
+
return this;
|
|
223
308
|
}
|
|
224
309
|
/**
|
|
225
310
|
* Adds a child endpoint with one or more device types with the required cluster servers and the specified cluster servers.
|
|
@@ -231,12 +316,13 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
231
316
|
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
232
317
|
* @returns {Endpoint} - The child endpoint that was found or added.
|
|
233
318
|
*/
|
|
234
|
-
addChildDeviceTypeWithClusterServer(endpointName, deviceTypes, includeServerList) {
|
|
319
|
+
addChildDeviceTypeWithClusterServer(endpointName, deviceTypes, includeServerList = []) {
|
|
235
320
|
this.log.debug(`addChildDeviceTypeWithClusterServer: ${CYAN}${endpointName}${db}`);
|
|
236
321
|
let child = this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
237
322
|
if (!child) {
|
|
238
323
|
child = new Endpoint(deviceTypes, { uniqueStorageKey: endpointName });
|
|
239
324
|
child.addFixedLabel('endpointName', endpointName);
|
|
325
|
+
this.addChildEndpoint(child);
|
|
240
326
|
}
|
|
241
327
|
deviceTypes.forEach((deviceType) => {
|
|
242
328
|
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
@@ -248,16 +334,65 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
248
334
|
includeServerList.forEach((clusterId) => {
|
|
249
335
|
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
250
336
|
});
|
|
337
|
+
const childDeviceTypes = child.getDeviceTypes();
|
|
338
|
+
deviceTypes.forEach((deviceType) => {
|
|
339
|
+
if (!childDeviceTypes.includes(deviceType))
|
|
340
|
+
childDeviceTypes.push(deviceType);
|
|
341
|
+
});
|
|
342
|
+
child.setDeviceTypes(childDeviceTypes);
|
|
251
343
|
this.addClusterServerFromList(child, includeServerList);
|
|
252
|
-
this.addChildEndpoint(child);
|
|
253
344
|
return child;
|
|
254
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* Adds the required cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
348
|
+
*
|
|
349
|
+
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
350
|
+
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
351
|
+
*/
|
|
352
|
+
addRequiredClusterServers(endpoint) {
|
|
353
|
+
const requiredServerList = [];
|
|
354
|
+
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
355
|
+
endpoint.getDeviceTypes().forEach((deviceType) => {
|
|
356
|
+
this.log.debug(`- for deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
357
|
+
deviceType.requiredServerClusters.forEach((clusterId) => {
|
|
358
|
+
if (!requiredServerList.includes(clusterId) && !endpoint.getClusterClientById(clusterId))
|
|
359
|
+
requiredServerList.push(clusterId);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
requiredServerList.forEach((clusterId) => {
|
|
363
|
+
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
364
|
+
});
|
|
365
|
+
this.addClusterServerFromList(endpoint, requiredServerList);
|
|
366
|
+
return endpoint;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Adds the optional cluster servers (only if they are not present) for the device types of the specified endpoint.
|
|
370
|
+
*
|
|
371
|
+
* @param {Endpoint} endpoint - The endpoint to add the required cluster servers to.
|
|
372
|
+
* @returns {Endpoint} The updated endpoint with the required cluster servers added.
|
|
373
|
+
*/
|
|
374
|
+
addOptionalClusterServers(endpoint) {
|
|
375
|
+
const optionalServerList = [];
|
|
376
|
+
this.log.debug(`addRequiredClusterServer for ${CYAN}${endpoint.name}${db}`);
|
|
377
|
+
endpoint.getDeviceTypes().forEach((deviceType) => {
|
|
378
|
+
this.log.debug(`- for deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
|
|
379
|
+
deviceType.optionalServerClusters.forEach((clusterId) => {
|
|
380
|
+
if (!optionalServerList.includes(clusterId) && !endpoint.getClusterClientById(clusterId))
|
|
381
|
+
optionalServerList.push(clusterId);
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
optionalServerList.forEach((clusterId) => {
|
|
385
|
+
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
|
|
386
|
+
});
|
|
387
|
+
this.addClusterServerFromList(endpoint, optionalServerList);
|
|
388
|
+
return endpoint;
|
|
389
|
+
}
|
|
255
390
|
/**
|
|
256
391
|
* Adds cluster servers to the specified endpoint based on the provided server list.
|
|
257
392
|
*
|
|
258
393
|
* @param {Endpoint} endpoint - The endpoint to add cluster servers to.
|
|
259
394
|
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
|
|
260
|
-
* @returns
|
|
395
|
+
* @returns {Endpoint} The updated endpoint with the cluster servers added.
|
|
261
396
|
*/
|
|
262
397
|
addClusterServerFromList(endpoint, includeServerList) {
|
|
263
398
|
if (includeServerList.includes(Identify.Cluster.id))
|
|
@@ -340,6 +475,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
340
475
|
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementClusterServer());
|
|
341
476
|
if (includeServerList.includes(DeviceEnergyManagementMode.Cluster.id))
|
|
342
477
|
endpoint.addClusterServer(this.getDefaultDeviceEnergyManagementModeClusterServer());
|
|
478
|
+
return endpoint;
|
|
343
479
|
}
|
|
344
480
|
/**
|
|
345
481
|
* Retrieves a child endpoint by its name.
|
|
@@ -348,16 +484,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
348
484
|
* @returns {Endpoint | undefined} The child endpoint with the specified name, or undefined if not found.
|
|
349
485
|
*/
|
|
350
486
|
getChildEndpointByName(endpointName) {
|
|
351
|
-
|
|
352
|
-
// Find the endpoint name (l1...)
|
|
353
|
-
const labelList = child.getClusterServer(FixedLabelCluster)?.getLabelListAttribute();
|
|
354
|
-
if (!labelList)
|
|
355
|
-
continue;
|
|
356
|
-
const value = labelList.find((entry) => entry.label === 'endpointName');
|
|
357
|
-
if (value && value.value === endpointName)
|
|
358
|
-
return child;
|
|
359
|
-
}
|
|
360
|
-
return undefined;
|
|
487
|
+
return this.getChildEndpoints().find((endpoint) => endpoint.uniqueStorageKey === endpointName);
|
|
361
488
|
}
|
|
362
489
|
/**
|
|
363
490
|
* Retrieves a child endpoint name.
|
|
@@ -373,7 +500,6 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
373
500
|
const endpointNameLabel = labelList.find((entry) => entry.label === 'endpointName');
|
|
374
501
|
if (endpointNameLabel)
|
|
375
502
|
return endpointNameLabel.value;
|
|
376
|
-
return undefined;
|
|
377
503
|
}
|
|
378
504
|
/**
|
|
379
505
|
* Sets the endpoint name for a child endpoint.
|
|
@@ -399,7 +525,6 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
399
525
|
if (entry.label === 'endpointName')
|
|
400
526
|
return entry.value;
|
|
401
527
|
}
|
|
402
|
-
return undefined;
|
|
403
528
|
}
|
|
404
529
|
/**
|
|
405
530
|
* Retrieves the child endpoint with the specified label.
|
|
@@ -408,8 +533,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
408
533
|
* @returns {Endpoint | undefined} The child endpoint with the specified label, or undefined if not found.
|
|
409
534
|
*/
|
|
410
535
|
getChildEndpointWithLabel(label) {
|
|
411
|
-
const
|
|
412
|
-
for (const endpoint of endpoints) {
|
|
536
|
+
for (const endpoint of this.getChildEndpoints()) {
|
|
413
537
|
const labelList = endpoint.getClusterServer(FixedLabelCluster)?.getLabelListAttribute();
|
|
414
538
|
if (!labelList)
|
|
415
539
|
return undefined;
|
|
@@ -421,7 +545,6 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
421
545
|
if (endpointName === label)
|
|
422
546
|
return endpoint;
|
|
423
547
|
}
|
|
424
|
-
return undefined;
|
|
425
548
|
}
|
|
426
549
|
/**
|
|
427
550
|
* Serializes the Matterbridge device into a serialized object.
|
|
@@ -432,11 +555,18 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
432
555
|
serialize(pluginName) {
|
|
433
556
|
if (!this.serialNumber || !this.deviceName || !this.uniqueId)
|
|
434
557
|
return;
|
|
558
|
+
const cluster = this.getClusterServer(BasicInformationCluster) ?? this.getClusterServer(BridgedDeviceBasicInformationCluster);
|
|
559
|
+
if (!cluster)
|
|
560
|
+
return;
|
|
435
561
|
const serialized = {
|
|
436
562
|
pluginName,
|
|
437
563
|
serialNumber: this.serialNumber,
|
|
438
564
|
deviceName: this.deviceName,
|
|
439
565
|
uniqueId: this.uniqueId,
|
|
566
|
+
productId: cluster.attributes.productId?.getLocal(),
|
|
567
|
+
productName: cluster.attributes.productName?.getLocal(),
|
|
568
|
+
vendorId: cluster.attributes.vendorId?.getLocal(),
|
|
569
|
+
vendorName: cluster.attributes.vendorName?.getLocal(),
|
|
440
570
|
deviceTypes: this.getDeviceTypes(),
|
|
441
571
|
endpoint: this.number,
|
|
442
572
|
endpointName: this.name,
|
|
@@ -447,6 +577,27 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
447
577
|
});
|
|
448
578
|
return serialized;
|
|
449
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Serializes the Matterbridge device into a serialized object.
|
|
582
|
+
*
|
|
583
|
+
* @param pluginName - The name of the plugin.
|
|
584
|
+
* @returns The serialized Matterbridge device object.
|
|
585
|
+
*/
|
|
586
|
+
static deserialize(serializedDevice) {
|
|
587
|
+
const device = new MatterbridgeDevice(serializedDevice.deviceTypes);
|
|
588
|
+
device.serialNumber = serializedDevice.serialNumber;
|
|
589
|
+
device.deviceName = serializedDevice.deviceName;
|
|
590
|
+
device.uniqueId = serializedDevice.uniqueId;
|
|
591
|
+
for (const clusterId of serializedDevice.clusterServersId) {
|
|
592
|
+
if (clusterId === BasicInformationCluster.id)
|
|
593
|
+
device.createDefaultBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productId ?? 0x8000, serializedDevice.productName ?? 'Matterbridge device');
|
|
594
|
+
else if (clusterId === BridgedDeviceBasicInformationCluster.id)
|
|
595
|
+
device.createDefaultBridgedDeviceBasicInformationClusterServer(serializedDevice.deviceName, serializedDevice.serialNumber, serializedDevice.vendorId ?? 0xfff1, serializedDevice.vendorName ?? 'Matterbridge', serializedDevice.productName ?? 'Matterbridge device');
|
|
596
|
+
else
|
|
597
|
+
device.addClusterServerFromList(device, [clusterId]);
|
|
598
|
+
}
|
|
599
|
+
return device;
|
|
600
|
+
}
|
|
450
601
|
/**
|
|
451
602
|
* Returns a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
|
|
452
603
|
* This shows up in HA as a static sensor!
|
|
@@ -467,7 +618,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
467
618
|
HistorySetTime: Uint8Array.fromHex(''),
|
|
468
619
|
LastEvent: 0,
|
|
469
620
|
ResetTotal: 0,
|
|
470
|
-
// Normal attributes
|
|
621
|
+
// Normal static attributes
|
|
471
622
|
Voltage: voltage,
|
|
472
623
|
Current: current,
|
|
473
624
|
Consumption: power,
|
|
@@ -477,6 +628,18 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
477
628
|
RLoc: 46080,
|
|
478
629
|
}, {}, {});
|
|
479
630
|
}
|
|
631
|
+
/**
|
|
632
|
+
* Create a default static EveHistoryClusterServer object with the specified voltage, current, power, and consumption values.
|
|
633
|
+
* This shows up in HA as a static sensor!
|
|
634
|
+
* @param voltage - The voltage value (default: 0).
|
|
635
|
+
* @param current - The current value (default: 0).
|
|
636
|
+
* @param power - The power value (default: 0).
|
|
637
|
+
* @param consumption - The consumption value (default: 0).
|
|
638
|
+
* @returns The default static EveHistoryClusterServer object.
|
|
639
|
+
*/
|
|
640
|
+
createDefaultStaticEveHistoryClusterServer(voltage = 0, current = 0, power = 0, consumption = 0) {
|
|
641
|
+
this.addClusterServer(this.getDefaultStaticEveHistoryClusterServer(voltage, current, power, consumption));
|
|
642
|
+
}
|
|
480
643
|
/**
|
|
481
644
|
* Creates a room Eve History Cluster Server.
|
|
482
645
|
*
|
|
@@ -815,28 +978,37 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
815
978
|
/**
|
|
816
979
|
* Get a default IdentifyCluster server.
|
|
817
980
|
*/
|
|
818
|
-
getDefaultIdentifyClusterServer() {
|
|
981
|
+
getDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
819
982
|
return ClusterServer(IdentifyCluster, {
|
|
820
|
-
identifyTime
|
|
821
|
-
identifyType
|
|
983
|
+
identifyTime,
|
|
984
|
+
identifyType,
|
|
822
985
|
}, {
|
|
823
986
|
identify: async (data) => {
|
|
824
987
|
this.log.debug('Matter command: Identify');
|
|
825
988
|
await this.commandHandler.executeHandler('identify', data);
|
|
826
989
|
},
|
|
990
|
+
triggerEffect: async (data) => {
|
|
991
|
+
this.log.debug('Matter command: TriggerEffect');
|
|
992
|
+
await this.commandHandler.executeHandler('triggerEffect', data);
|
|
993
|
+
},
|
|
827
994
|
});
|
|
828
995
|
}
|
|
829
996
|
/**
|
|
830
997
|
* Creates a default IdentifyCluster server.
|
|
831
998
|
*/
|
|
832
|
-
createDefaultIdentifyClusterServer() {
|
|
833
|
-
this.addClusterServer(this.getDefaultIdentifyClusterServer());
|
|
999
|
+
createDefaultIdentifyClusterServer(identifyTime = 0, identifyType = Identify.IdentifyType.None) {
|
|
1000
|
+
this.addClusterServer(this.getDefaultIdentifyClusterServer(identifyTime, identifyType));
|
|
834
1001
|
}
|
|
835
1002
|
/**
|
|
836
1003
|
* Get a default IdentifyCluster server.
|
|
837
1004
|
*/
|
|
838
1005
|
getDefaultGroupsClusterServer() {
|
|
839
|
-
return
|
|
1006
|
+
return ClusterServer(GroupsCluster, {
|
|
1007
|
+
nameSupport: {
|
|
1008
|
+
nameSupport: true,
|
|
1009
|
+
},
|
|
1010
|
+
}, GroupsClusterHandler());
|
|
1011
|
+
// return createDefaultGroupsClusterServer();
|
|
840
1012
|
}
|
|
841
1013
|
/**
|
|
842
1014
|
* Creates a default groups cluster server and adds it to the device.
|
|
@@ -848,7 +1020,17 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
848
1020
|
* Get a default scenes cluster server and adds it to the current instance.
|
|
849
1021
|
*/
|
|
850
1022
|
getDefaultScenesClusterServer() {
|
|
851
|
-
return
|
|
1023
|
+
return ClusterServer(ScenesCluster, {
|
|
1024
|
+
sceneCount: 0,
|
|
1025
|
+
currentScene: 0,
|
|
1026
|
+
currentGroup: GroupId(0),
|
|
1027
|
+
sceneValid: false,
|
|
1028
|
+
nameSupport: {
|
|
1029
|
+
nameSupport: true,
|
|
1030
|
+
},
|
|
1031
|
+
lastConfiguredBy: null,
|
|
1032
|
+
}, ScenesClusterHandler());
|
|
1033
|
+
// return createDefaultScenesClusterServer();
|
|
852
1034
|
}
|
|
853
1035
|
/**
|
|
854
1036
|
* Creates a default scenes cluster server and adds it to the current instance.
|
|
@@ -1079,6 +1261,7 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1079
1261
|
}
|
|
1080
1262
|
/**
|
|
1081
1263
|
* Creates a default Dummy Thread Network Diagnostics Cluster server.
|
|
1264
|
+
* @deprecated This method is deprecated and is only for testing.
|
|
1082
1265
|
*
|
|
1083
1266
|
* @remarks
|
|
1084
1267
|
* This method adds a cluster server used only to give the networkName to Eve app.
|
|
@@ -1276,6 +1459,8 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1276
1459
|
/**
|
|
1277
1460
|
* Get a default color control cluster server.
|
|
1278
1461
|
*
|
|
1462
|
+
* @param currentX - The current X value.
|
|
1463
|
+
* @param currentY - The current Y value.
|
|
1279
1464
|
* @param currentHue - The current hue value.
|
|
1280
1465
|
* @param currentSaturation - The current saturation value.
|
|
1281
1466
|
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
@@ -1351,6 +1536,8 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1351
1536
|
/**
|
|
1352
1537
|
* Creates a default color control cluster server.
|
|
1353
1538
|
*
|
|
1539
|
+
* @param currentX - The current X value.
|
|
1540
|
+
* @param currentY - The current Y value.
|
|
1354
1541
|
* @param currentHue - The current hue value.
|
|
1355
1542
|
* @param currentSaturation - The current saturation value.
|
|
1356
1543
|
* @param colorTemperatureMireds - The color temperature in mireds.
|
|
@@ -1590,6 +1777,17 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1590
1777
|
this.addFixedLabel('orientation', 'Switch');
|
|
1591
1778
|
this.addFixedLabel('label', 'Switch');
|
|
1592
1779
|
}
|
|
1780
|
+
/**
|
|
1781
|
+
* Retrieves the default mode select cluster server.
|
|
1782
|
+
*
|
|
1783
|
+
* @deprecated This method is currently under development and should not be used.
|
|
1784
|
+
*
|
|
1785
|
+
* @param description - The description of the cluster server.
|
|
1786
|
+
* @param supportedModes - The supported modes for the cluster server.
|
|
1787
|
+
* @param currentMode - The current mode of the cluster server. Defaults to 0.
|
|
1788
|
+
* @param startUpMode - The startup mode of the cluster server. Defaults to 0.
|
|
1789
|
+
* @returns The default mode select cluster server.
|
|
1790
|
+
*/
|
|
1593
1791
|
getDefaultModeSelectClusterServer(description, supportedModes, currentMode = 0, startUpMode = 0) {
|
|
1594
1792
|
return ClusterServer(ModeSelectCluster, {
|
|
1595
1793
|
description: description,
|
|
@@ -1604,6 +1802,16 @@ export class MatterbridgeDevice extends extendPublicHandlerMethods(Device) {
|
|
|
1604
1802
|
},
|
|
1605
1803
|
});
|
|
1606
1804
|
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Creates a default mode select cluster server.
|
|
1807
|
+
*
|
|
1808
|
+
* @remarks
|
|
1809
|
+
* This method adds a cluster server for a mode select cluster with default settings.
|
|
1810
|
+
*
|
|
1811
|
+
* @deprecated This method is currently under development and should not be used.
|
|
1812
|
+
*
|
|
1813
|
+
* @param endpoint - The endpoint to add the cluster server to. Defaults to `this` if not provided.
|
|
1814
|
+
*/
|
|
1607
1815
|
createDefaultModeSelectClusterServer(endpoint) {
|
|
1608
1816
|
if (!endpoint)
|
|
1609
1817
|
endpoint = this;
|