matterbridge 1.7.1 → 1.7.2-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cli.js +0 -26
- package/dist/cluster/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -23
- package/dist/deviceManager.js +1 -26
- package/dist/index.js +0 -30
- package/dist/logger/export.js +0 -1
- package/dist/matter/export.js +0 -4
- package/dist/matterbridge.js +61 -707
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +1 -29
- package/dist/matterbridgeDevice.js +9 -996
- package/dist/matterbridgeDeviceTypes.js +11 -82
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEdge.js +0 -530
- package/dist/matterbridgeEndpoint.js +14 -1121
- package/dist/matterbridgePlatform.js +7 -112
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/matterbridgeWebsocket.js +14 -46
- package/dist/pluginManager.js +3 -238
- package/dist/storage/export.js +0 -1
- package/dist/utils/colorUtils.js +2 -205
- package/dist/utils/export.js +0 -1
- package/dist/utils/utils.js +7 -252
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.ecd94d17.js → main.0cc31fc9.js} +4 -4
- package/frontend/build/static/js/main.0cc31fc9.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -2
- package/dist/cli.d.ts +0 -25
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cluster/export.d.ts +0 -2
- package/dist/cluster/export.d.ts.map +0 -1
- package/dist/cluster/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -27
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -46
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/index.d.ts +0 -40
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/export.d.ts +0 -2
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/export.d.ts +0 -11
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -483
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -942
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDevice.d.ts +0 -7077
- package/dist/matterbridgeDevice.d.ts.map +0 -1
- package/dist/matterbridgeDevice.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -109
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEdge.d.ts +0 -91
- package/dist/matterbridgeEdge.d.ts.map +0 -1
- package/dist/matterbridgeEdge.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -10151
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -145
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -172
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/matterbridgeWebsocket.d.ts +0 -49
- package/dist/matterbridgeWebsocket.d.ts.map +0 -1
- package/dist/matterbridgeWebsocket.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -238
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/storage/export.d.ts +0 -2
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -61
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/export.d.ts +0 -3
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/utils.d.ts +0 -221
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/frontend/build/static/js/main.ecd94d17.js.map +0 -1
- /package/frontend/build/static/js/{main.ecd94d17.js.LICENSE.txt → main.0cc31fc9.js.LICENSE.txt} +0 -0
package/dist/matterbridgeEdge.js
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
/**
|
|
3
|
-
* This file contains the class MatterbridgeEdge that extends the Matterbridge class.
|
|
4
|
-
*
|
|
5
|
-
* @file matterbridgeEdge.ts
|
|
6
|
-
* @author Luca Liguori
|
|
7
|
-
* @date 2024-10-01
|
|
8
|
-
* @version 1.0.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License. *
|
|
23
|
-
*/
|
|
24
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
25
|
-
// Node.js modules
|
|
26
1
|
import path from 'path';
|
|
27
2
|
import os from 'os';
|
|
28
3
|
import { randomBytes } from 'crypto';
|
|
29
|
-
// NodeStorage and AnsiLogger modules
|
|
30
4
|
import { rs, GREEN, debugStringify, er, zb, nf, db } from 'node-ansi-logger';
|
|
31
|
-
// Matterbridge
|
|
32
5
|
import { Matterbridge } from './matterbridge.js';
|
|
33
6
|
import { bridge } from './matterbridgeDeviceTypes.js';
|
|
34
7
|
import { dev, plg } from './matterbridgeTypes.js';
|
|
35
8
|
import { copyDirectory, getParameter, hasParameter } from './utils/utils.js';
|
|
36
|
-
// @matter
|
|
37
9
|
import { DeviceTypeId, LogLevel as MatterLogLevel, LogFormat as MatterLogFormat, VendorId, EndpointServer } from '@matter/main';
|
|
38
10
|
import { ServerNode, Endpoint as EndpointNode, Environment, StorageService } from '@matter/main';
|
|
39
11
|
import { BasicInformationCluster } from '@matter/main/clusters';
|
|
@@ -42,18 +14,11 @@ import { GenericSwitchDevice } from '@matter/main/devices';
|
|
|
42
14
|
import { AggregatorEndpoint } from '@matter/main/endpoints';
|
|
43
15
|
import { BridgedDeviceBasicInformationServer, SwitchServer } from '@matter/main/behaviors';
|
|
44
16
|
import { Device, logEndpoint } from '@project-chip/matter.js/device';
|
|
45
|
-
/**
|
|
46
|
-
* Represents the MatterbridgeEdge application.
|
|
47
|
-
*/
|
|
48
17
|
export class MatterbridgeEdge extends Matterbridge {
|
|
49
18
|
static instance;
|
|
50
|
-
// Matter environment
|
|
51
19
|
environment = Environment.default;
|
|
52
|
-
// Matter storage
|
|
53
20
|
matterStorageService;
|
|
54
|
-
// Mapping of CommissioningServer to ServerNode
|
|
55
21
|
csToServerNode = new Map();
|
|
56
|
-
// Mapping of Aggregator to AggregatorEndpoint
|
|
57
22
|
agToAggregatorEndpoint = new Map();
|
|
58
23
|
constructor() {
|
|
59
24
|
super();
|
|
@@ -71,30 +36,24 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
71
36
|
async initialize() {
|
|
72
37
|
if (hasParameter('debug'))
|
|
73
38
|
console.log('Initializing MatterbridgeEdge...');
|
|
74
|
-
// Set the matterbridge directory
|
|
75
39
|
this.homeDirectory = getParameter('homedir') ?? os.homedir();
|
|
76
40
|
this.matterbridgeDirectory = path.join(this.homeDirectory, '.matterbridge');
|
|
77
41
|
this.matterStorageName = 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : '');
|
|
78
|
-
// Setup matter environment
|
|
79
42
|
this.environment.vars.set('log.level', MatterLogLevel.INFO);
|
|
80
43
|
this.environment.vars.set('log.format', MatterLogFormat.ANSI);
|
|
81
44
|
this.environment.vars.set('path.root', path.join(this.matterbridgeDirectory, this.matterStorageName));
|
|
82
45
|
this.environment.vars.set('runtime.signals', false);
|
|
83
46
|
this.environment.vars.set('runtime.exitcode', false);
|
|
84
|
-
// Setup Matter commissioning server
|
|
85
47
|
this.port = 5540;
|
|
86
48
|
this.passcode = PaseClient.generateRandomPasscode();
|
|
87
49
|
this.discriminator = PaseClient.generateRandomDiscriminator();
|
|
88
50
|
if (hasParameter('debug'))
|
|
89
51
|
console.log(`Initializing server node for Matterbridge... on port ${this.port} with passcode ${this.passcode} and discriminator ${this.discriminator}`);
|
|
90
|
-
// Initialize the base Matterbridge class
|
|
91
52
|
await super.initialize();
|
|
92
|
-
// Setup Matter mdnsInterface
|
|
93
53
|
if (this.mdnsInterface)
|
|
94
54
|
this.environment.vars.set('mdns.networkInterface', this.mdnsInterface);
|
|
95
55
|
}
|
|
96
56
|
async startMatterStorage(storageType, storageName) {
|
|
97
|
-
// Setup Matter storage
|
|
98
57
|
this.log.info(`Starting matter node storage...`);
|
|
99
58
|
this.matterStorageService = this.environment.get(StorageService);
|
|
100
59
|
this.log.info(`Matter node storage service created: ${this.matterStorageService.location}`);
|
|
@@ -102,7 +61,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
102
61
|
this.log.info('Matter node storage manager "Matterbridge" created');
|
|
103
62
|
this.matterbridgeContext = await this.createServerNodeContext('Matterbridge', 'Matterbridge', bridge.code, this.aggregatorVendorId, 'Matterbridge', this.aggregatorProductId, 'Matterbridge aggregator');
|
|
104
63
|
this.log.info('Matter node storage started');
|
|
105
|
-
// Backup matter storage since it is created/opened correctly
|
|
106
64
|
await this.backupMatterStorage(path.join(this.matterbridgeDirectory, this.matterStorageName), path.join(this.matterbridgeDirectory, this.matterStorageName + '.backup'));
|
|
107
65
|
}
|
|
108
66
|
async backupMatterStorage(storageName, backupName) {
|
|
@@ -118,24 +76,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
118
76
|
this.matterbridgeContext = undefined;
|
|
119
77
|
this.log.info('Matter node storage closed');
|
|
120
78
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Creates a server node storage context.
|
|
123
|
-
*
|
|
124
|
-
* @param pluginName - The name of the plugin.
|
|
125
|
-
* @param deviceName - The name of the device.
|
|
126
|
-
* @param deviceType - The deviceType of the device.
|
|
127
|
-
* @param vendorId - The vendor ID.
|
|
128
|
-
* @param vendorName - The vendor name.
|
|
129
|
-
* @param productId - The product ID.
|
|
130
|
-
* @param productName - The product name.
|
|
131
|
-
* @param serialNumber - The serial number of the device (optional).
|
|
132
|
-
* @param uniqueId - The unique ID of the device (optional).
|
|
133
|
-
* @param softwareVersion - The software version of the device (optional).
|
|
134
|
-
* @param softwareVersionString - The software version string of the device (optional).
|
|
135
|
-
* @param hardwareVersion - The hardware version of the device (optional).
|
|
136
|
-
* @param hardwareVersionString - The hardware version string of the device (optional).
|
|
137
|
-
* @returns The storage context for the commissioning server.
|
|
138
|
-
*/
|
|
139
79
|
async createServerNodeContext(pluginName, deviceName, deviceType, vendorId, vendorName, productId, productName, serialNumber) {
|
|
140
80
|
if (!this.matterStorageService)
|
|
141
81
|
throw new Error('No storage service initialized');
|
|
@@ -177,33 +117,21 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
177
117
|
this.log.debug(`- uniqueId: ${await storageContext.get('uniqueId')}`);
|
|
178
118
|
this.log.debug(`- softwareVersion: ${await storageContext.get('softwareVersion')} softwareVersionString: ${await storageContext.get('softwareVersionString')}`);
|
|
179
119
|
this.log.debug(`- hardwareVersion: ${await storageContext.get('hardwareVersion')} hardwareVersionString: ${await storageContext.get('hardwareVersionString')}`);
|
|
180
|
-
/**
|
|
181
|
-
* Create a Matter ServerNode, which contains the Root Endpoint and all relevant data and configuration
|
|
182
|
-
*/
|
|
183
120
|
const serverNode = await ServerNode.create({
|
|
184
|
-
// Required: Give the Node a unique ID which is used to store the state of this node
|
|
185
121
|
id: storeId,
|
|
186
|
-
// Provide Network relevant configuration like the port
|
|
187
|
-
// Optional when operating only one device on a host, Default port is 5540
|
|
188
122
|
network: {
|
|
189
123
|
listeningAddressIpv4: this.ipv4address,
|
|
190
124
|
listeningAddressIpv6: this.ipv6address,
|
|
191
125
|
port,
|
|
192
126
|
},
|
|
193
|
-
// Provide Commissioning relevant settings
|
|
194
|
-
// Optional for development/testing purposes
|
|
195
127
|
commissioning: {
|
|
196
128
|
passcode,
|
|
197
129
|
discriminator,
|
|
198
130
|
},
|
|
199
|
-
// Provide Node announcement settings
|
|
200
|
-
// Optional: If Ommitted some development defaults are used
|
|
201
131
|
productDescription: {
|
|
202
132
|
name: await storageContext.get('deviceName'),
|
|
203
133
|
deviceType: DeviceTypeId(await storageContext.get('deviceType')),
|
|
204
134
|
},
|
|
205
|
-
// Provide defaults for the BasicInformation cluster on the Root endpoint
|
|
206
|
-
// Optional: If Omitted some development defaults are used
|
|
207
135
|
basicInformation: {
|
|
208
136
|
vendorId: VendorId(await storageContext.get('vendorId')),
|
|
209
137
|
vendorName: await storageContext.get('vendorName'),
|
|
@@ -220,7 +148,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
220
148
|
},
|
|
221
149
|
});
|
|
222
150
|
const sanitizeFabrics = (fabrics) => {
|
|
223
|
-
// New type of fabric information: Record<FabricIndex, ExposedFabricInformation>
|
|
224
151
|
const sanitizedFabrics = this.sanitizeFabricInformations(Array.from(Object.values(fabrics)));
|
|
225
152
|
this.log.info(`Fabrics: ${debugStringify(sanitizedFabrics)}`);
|
|
226
153
|
if (this.bridgeMode === 'bridge') {
|
|
@@ -237,14 +164,8 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
237
164
|
}
|
|
238
165
|
}
|
|
239
166
|
};
|
|
240
|
-
/**
|
|
241
|
-
* This event is triggered when the device is initially commissioned successfully.
|
|
242
|
-
* This means: It is added to the first fabric.
|
|
243
|
-
*/
|
|
244
167
|
serverNode.lifecycle.commissioned.on(() => this.log.notice(`Server node for ${storeId} was initially commissioned successfully!`));
|
|
245
|
-
/** This event is triggered when all fabrics are removed from the device, usually it also does a factory reset then. */
|
|
246
168
|
serverNode.lifecycle.decommissioned.on(() => this.log.notice(`Server node for ${storeId} was fully decommissioned successfully!`));
|
|
247
|
-
/** This event is triggered when the device went online. This means that it is discoverable in the network. */
|
|
248
169
|
serverNode.lifecycle.online.on(() => {
|
|
249
170
|
this.log.notice(`Server node for ${storeId} is online`);
|
|
250
171
|
if (!serverNode.lifecycle.isCommissioned) {
|
|
@@ -280,7 +201,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
280
201
|
}
|
|
281
202
|
this.wssSendRefreshRequired();
|
|
282
203
|
});
|
|
283
|
-
/** This event is triggered when the device went offline. it is not longer discoverable or connectable in the network. */
|
|
284
204
|
serverNode.lifecycle.offline.on(() => {
|
|
285
205
|
this.log.notice(`Server node for ${storeId} is offline`);
|
|
286
206
|
if (this.bridgeMode === 'bridge') {
|
|
@@ -293,10 +213,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
293
213
|
}
|
|
294
214
|
this.wssSendRefreshRequired();
|
|
295
215
|
});
|
|
296
|
-
/**
|
|
297
|
-
* This event is triggered when a fabric is added, removed or updated on the device. Use this if more granular
|
|
298
|
-
* information is needed.
|
|
299
|
-
*/
|
|
300
216
|
serverNode.events.commissioning.fabricsChanged.on((fabricIndex, fabricAction) => {
|
|
301
217
|
let action = '';
|
|
302
218
|
switch (fabricAction) {
|
|
@@ -331,22 +247,14 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
331
247
|
}
|
|
332
248
|
this.wssSendRefreshRequired();
|
|
333
249
|
};
|
|
334
|
-
/**
|
|
335
|
-
* This event is triggered when an operative new session was opened by a Controller.
|
|
336
|
-
* It is not triggered for the initial commissioning process, just afterwards for real connections.
|
|
337
|
-
*/
|
|
338
250
|
serverNode.events.sessions.opened.on((session) => {
|
|
339
251
|
this.log.notice(`Session opened on server node for ${storeId}: ${debugStringify(session)}`);
|
|
340
252
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
341
253
|
});
|
|
342
|
-
/**
|
|
343
|
-
* This event is triggered when an operative session is closed by a Controller or because the Device goes offline.
|
|
344
|
-
*/
|
|
345
254
|
serverNode.events.sessions.closed.on((session) => {
|
|
346
255
|
this.log.notice(`Session closed on server node for ${storeId}: ${debugStringify(session)}`);
|
|
347
256
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
348
257
|
});
|
|
349
|
-
/** This event is triggered when a subscription gets added or removed on an operative session. */
|
|
350
258
|
serverNode.events.sessions.subscriptionsChanged.on((session) => {
|
|
351
259
|
this.log.notice(`Session subscriptions changed on server node for ${storeId}: ${debugStringify(session)}`);
|
|
352
260
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
@@ -372,13 +280,11 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
372
280
|
return aggregatorNode;
|
|
373
281
|
}
|
|
374
282
|
async addBridgedEndpoint(pluginName, device) {
|
|
375
|
-
// Check if the plugin is registered
|
|
376
283
|
const plugin = this.plugins.get(pluginName);
|
|
377
284
|
if (!plugin) {
|
|
378
285
|
this.log.error(`Error adding bridged endpoint ${dev}${device.deviceName}${er} (${zb}${device.id}${er}) plugin ${plg}${pluginName}${er} not found`);
|
|
379
286
|
return;
|
|
380
287
|
}
|
|
381
|
-
// Register and add the device to the matterbridge aggregator node
|
|
382
288
|
if (this.bridgeMode === 'bridge') {
|
|
383
289
|
this.log.info(`Adding ${pluginName}:${device.deviceName} to Matterbridge aggregator node`);
|
|
384
290
|
const aggregatorNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
@@ -407,19 +313,16 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
407
313
|
plugin.registeredDevices++;
|
|
408
314
|
if (plugin.addedDevices !== undefined)
|
|
409
315
|
plugin.addedDevices++;
|
|
410
|
-
// Add the device to the DeviceManager
|
|
411
316
|
this.devices.set(device);
|
|
412
317
|
this.log.info(`Added and registered bridged endpoint (${plugin.registeredDevices}/${plugin.addedDevices}) ${dev}${device.deviceName}${nf} (${dev}${device.id}${nf}) for plugin ${plg}${pluginName}${nf}`);
|
|
413
318
|
}
|
|
414
319
|
async removeBridgedEndpoint(pluginName, device) {
|
|
415
320
|
this.log.debug(`Removing bridged endpoint ${dev}${device.deviceName}${db} (${zb}${device.name}${db}) for plugin ${plg}${pluginName}${db}`);
|
|
416
|
-
// Check if the plugin is registered
|
|
417
321
|
const plugin = this.plugins.get(pluginName);
|
|
418
322
|
if (!plugin) {
|
|
419
323
|
this.log.error(`Error removing bridged endpoint ${dev}${device.deviceName}${er} (${zb}${device.name}${er}) for plugin ${plg}${pluginName}${er}: plugin not found`);
|
|
420
324
|
return;
|
|
421
325
|
}
|
|
422
|
-
// Register and add the device to the matterbridge aggregator node
|
|
423
326
|
if (this.bridgeMode === 'bridge') {
|
|
424
327
|
const aggregatoreNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
425
328
|
if (!aggregatoreNode) {
|
|
@@ -435,7 +338,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
435
338
|
}
|
|
436
339
|
else if (this.bridgeMode === 'childbridge') {
|
|
437
340
|
if (plugin.type === 'AccessoryPlatform') {
|
|
438
|
-
// Nothing to do
|
|
439
341
|
}
|
|
440
342
|
else if (plugin.type === 'DynamicPlatform') {
|
|
441
343
|
const aggregatoreNode = this.agToAggregatorEndpoint.get(pluginName)?.aggregatorNode;
|
|
@@ -450,7 +352,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
450
352
|
plugin.registeredDevices--;
|
|
451
353
|
if (plugin.addedDevices !== undefined)
|
|
452
354
|
plugin.addedDevices--;
|
|
453
|
-
// Close the server node
|
|
454
355
|
if (plugin.registeredDevices === 0 && plugin.addedDevices === 0) {
|
|
455
356
|
const serverNode = this.csToServerNode.get(pluginName)?.serverNode;
|
|
456
357
|
if (serverNode)
|
|
@@ -459,7 +360,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
459
360
|
this.log.info(`Removed server node for plugin ${plg}${pluginName}${nf}`);
|
|
460
361
|
}
|
|
461
362
|
}
|
|
462
|
-
// Remove the device from the DeviceManager
|
|
463
363
|
this.devices.remove(device);
|
|
464
364
|
}
|
|
465
365
|
async removeAllBridgedEndpoints(pluginName) {
|
|
@@ -468,11 +368,7 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
468
368
|
await this.removeBridgedEndpoint(pluginName, device);
|
|
469
369
|
}
|
|
470
370
|
}
|
|
471
|
-
/**
|
|
472
|
-
* temporary override from Matterbridge: will be moved in Matterbridge in 2.0.0
|
|
473
|
-
*/
|
|
474
371
|
async createMatterServer(storageManager) {
|
|
475
|
-
// Create the server node and aggregator node for the Matterbridge plugin
|
|
476
372
|
if (this.bridgeMode === 'childbridge') {
|
|
477
373
|
for (const plugin of this.plugins) {
|
|
478
374
|
if (!plugin.enabled)
|
|
@@ -555,7 +451,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
555
451
|
const commissioningServer = {
|
|
556
452
|
getPort: () => port,
|
|
557
453
|
addDevice: async (device) => {
|
|
558
|
-
// if (hasParameter('debug')) this.log.warn('CommissioningServer.addDevice()', device.name);
|
|
559
454
|
if (device instanceof Device) {
|
|
560
455
|
if (hasParameter('debug'))
|
|
561
456
|
this.log.warn('CommissioningServer.addDevice() => Device');
|
|
@@ -570,7 +465,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
570
465
|
await serverNode.add(aggregatorNode);
|
|
571
466
|
if (!this.test) {
|
|
572
467
|
this.test = true;
|
|
573
|
-
// await this.testEndpoints();
|
|
574
468
|
}
|
|
575
469
|
}
|
|
576
470
|
},
|
|
@@ -627,37 +521,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
627
521
|
const aggregatorNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
628
522
|
if (!aggregatorNode)
|
|
629
523
|
return;
|
|
630
|
-
/*
|
|
631
|
-
this.log.notice(`Creating OnOffLight1`);
|
|
632
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'OnOffLight1' }, true);
|
|
633
|
-
lightEndpoint.addDeviceType(bridgedNode);
|
|
634
|
-
lightEndpoint.createDefaultBridgedDeviceBasicInformationClusterServer('OnOffLight 1', '123456789', 0xfff1, 'Matterbridge', 'Light');
|
|
635
|
-
lightEndpoint.addDeviceType(powerSource);
|
|
636
|
-
lightEndpoint.createDefaultPowerSourceWiredClusterServer();
|
|
637
|
-
lightEndpoint.addDeviceType(electricalSensor);
|
|
638
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
639
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultElectricalPowerMeasurementClusterServer());
|
|
640
|
-
lightEndpoint.addRequiredClusterServers(lightEndpoint);
|
|
641
|
-
this.log.notice(`Adding OnOffLight1 to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
642
|
-
await aggregatorNode.add(lightEndpoint);
|
|
643
|
-
logEndpoint(EndpointServer.forEndpoint(lightEndpoint));
|
|
644
|
-
|
|
645
|
-
this.log.notice(`Creating Outlet1`);
|
|
646
|
-
const outletEndpoint = new MatterbridgeEndpoint(onOffOutlet, { uniqueStorageKey: 'OnOffOutlet1' }, true);
|
|
647
|
-
outletEndpoint.addDeviceType(bridgedNode);
|
|
648
|
-
outletEndpoint.createDefaultBridgedDeviceBasicInformationClusterServer('OnOffOutlet 1', '123456789', 0xfff1, 'Matterbridge', 'Outlet');
|
|
649
|
-
outletEndpoint.addDeviceType(powerSource);
|
|
650
|
-
outletEndpoint.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
|
651
|
-
outletEndpoint.addDeviceType(electricalSensor);
|
|
652
|
-
outletEndpoint.addClusterServer(outletEndpoint.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
653
|
-
outletEndpoint.addClusterServer(outletEndpoint.getDefaultElectricalPowerMeasurementClusterServer());
|
|
654
|
-
outletEndpoint.addRequiredClusterServers(outletEndpoint);
|
|
655
|
-
const input0 = outletEndpoint.addChildDeviceTypeWithClusterServer('Input:0', [genericSwitch], undefined, undefined, true);
|
|
656
|
-
const input1 = outletEndpoint.addChildDeviceTypeWithClusterServer('Input:1', [genericSwitch], undefined, undefined, true);
|
|
657
|
-
this.log.notice(`Adding OnOffOutlet1 to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
658
|
-
await aggregatorNode.add(outletEndpoint);
|
|
659
|
-
logEndpoint(EndpointServer.forEndpoint(outletEndpoint));
|
|
660
|
-
*/
|
|
661
524
|
this.log.notice(`Creating switchEnpoint1`);
|
|
662
525
|
const switchEnpoint1 = new EndpointNode(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
663
526
|
id: 'GenericSwitch',
|
|
@@ -680,398 +543,5 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
680
543
|
this.log.notice(`Adding switchEnpoint1 to ${await this.matterbridgeContext.get('storeId')} aggregator`);
|
|
681
544
|
await aggregatorNode.add(switchEnpoint1);
|
|
682
545
|
logEndpoint(EndpointServer.forEndpoint(switchEnpoint1), { logNotSupportedClusterAttributes: true, logNotSupportedClusterEvents: true, logNotSupportedClusterCommands: true });
|
|
683
|
-
// if (switchEnpoint2.behaviors.has(SwitchServer)) this.log.notice(`SwitchServer found`);
|
|
684
|
-
// switchEnpoint2.act((agent) => agent['switch'].events['initialPress'].emit({ newPosition: 1 }, agent.context));
|
|
685
|
-
/*
|
|
686
|
-
const device = new MatterbridgeEndpoint(genericSwitch, { uniqueStorageKey: 'GenericSwitch 2' }, true);
|
|
687
|
-
device.createDefaultSwitchClusterServer();
|
|
688
|
-
device.addRequiredClusterServers(device);
|
|
689
|
-
await aggregatorNode.add(device);
|
|
690
|
-
logEndpoint(EndpointServer.forEndpoint(device));
|
|
691
|
-
await device.triggerSwitchEvent('Single', this.log);
|
|
692
|
-
await device.triggerSwitchEvent('Double', this.log);
|
|
693
|
-
await device.triggerSwitchEvent('Long', this.log);
|
|
694
|
-
|
|
695
|
-
const device1 = new MatterbridgeEndpoint(genericSwitch, { uniqueStorageKey: 'GenericSwitch 3' }, true);
|
|
696
|
-
device1.createDefaultLatchingSwitchClusterServer();
|
|
697
|
-
device1.addRequiredClusterServers(device1);
|
|
698
|
-
await aggregatorNode.add(device1);
|
|
699
|
-
logEndpoint(EndpointServer.forEndpoint(device1));
|
|
700
|
-
await device1.triggerSwitchEvent('Press', this.log);
|
|
701
|
-
await device1.triggerSwitchEvent('Release', this.log);
|
|
702
|
-
|
|
703
|
-
this.log.notice(`Creating TestLight`);
|
|
704
|
-
const matterbridgeDevice = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'Test .Light:2' }, true);
|
|
705
|
-
matterbridgeDevice.behaviors.require(MatterbridgeIdentifyServer, {
|
|
706
|
-
identifyTime: 0,
|
|
707
|
-
identifyType: Identify.IdentifyType.None,
|
|
708
|
-
});
|
|
709
|
-
matterbridgeDevice.behaviors.require(GroupsServer);
|
|
710
|
-
matterbridgeDevice.behaviors.require(MatterbridgeOnOffServer, {
|
|
711
|
-
onOff: false,
|
|
712
|
-
});
|
|
713
|
-
matterbridgeDevice.behaviors.require(MatterbridgeLevelControlServer, {
|
|
714
|
-
currentLevel: 0,
|
|
715
|
-
options: { executeIfOff: false },
|
|
716
|
-
});
|
|
717
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
718
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
719
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
720
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
721
|
-
options: { executeIfOff: false },
|
|
722
|
-
numberOfPrimaries: null,
|
|
723
|
-
currentX: 24939,
|
|
724
|
-
currentY: 24701,
|
|
725
|
-
currentHue: 0,
|
|
726
|
-
currentSaturation: 0,
|
|
727
|
-
colorTemperatureMireds: 450,
|
|
728
|
-
colorTempPhysicalMinMireds: 150,
|
|
729
|
-
colorTempPhysicalMaxMireds: 450,
|
|
730
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
731
|
-
startUpColorTemperatureMireds: null,
|
|
732
|
-
});
|
|
733
|
-
matterbridgeDevice.behaviors.require(BridgedDeviceBasicInformationServer, {
|
|
734
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
735
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
736
|
-
productName: 'TestLight2',
|
|
737
|
-
productLabel: 'TestLight2',
|
|
738
|
-
nodeLabel: 'TestLight2',
|
|
739
|
-
serialNumber: 'SN 0x123456789',
|
|
740
|
-
uniqueId: '0x123456789',
|
|
741
|
-
reachable: true,
|
|
742
|
-
});
|
|
743
|
-
|
|
744
|
-
// await matterbridgeDevice.setTagList(null, 0x07, 1, 'endpoint 2');
|
|
745
|
-
// await matterbridgeDevice.configureColorControlCluster(false, false, true, ColorControl.ColorMode.ColorTemperatureMireds);
|
|
746
|
-
|
|
747
|
-
this.log.notice(`Adding TestLight`);
|
|
748
|
-
await aggregatorNode?.add(matterbridgeDevice);
|
|
749
|
-
|
|
750
|
-
this.log.notice(`Creating switchEnpoint1`);
|
|
751
|
-
const switchEnpoint2 = new EndpointNode(
|
|
752
|
-
GenericSwitchDevice.with(DescriptorServer.with(Descriptor.Feature.TagList), BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')),
|
|
753
|
-
{
|
|
754
|
-
id: 'GenericSwitch1',
|
|
755
|
-
descriptor: {
|
|
756
|
-
tagList: [{ mfgCode: null, namespaceId: 0x07, tag: 1, label: 'Switch1' }],
|
|
757
|
-
},
|
|
758
|
-
bridgedDeviceBasicInformation: {
|
|
759
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
760
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
761
|
-
|
|
762
|
-
productName: 'GenericSwitch',
|
|
763
|
-
productLabel: 'GenericSwitch',
|
|
764
|
-
nodeLabel: 'GenericSwitch',
|
|
765
|
-
|
|
766
|
-
serialNumber: 'SN 0x1234567397',
|
|
767
|
-
uniqueId: '0x1234567397',
|
|
768
|
-
reachable: true,
|
|
769
|
-
},
|
|
770
|
-
switch: {
|
|
771
|
-
numberOfPositions: 2,
|
|
772
|
-
currentPosition: 0,
|
|
773
|
-
multiPressMax: 2,
|
|
774
|
-
},
|
|
775
|
-
},
|
|
776
|
-
);
|
|
777
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
778
|
-
await aggregatorNode?.add(switchEnpoint2);
|
|
779
|
-
*/
|
|
780
|
-
/*
|
|
781
|
-
const lightEndpoint1 = new EndpointNode(ColorTemperatureLightDevice.with(BridgedDeviceBasicInformationServer), {
|
|
782
|
-
// }, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer), {
|
|
783
|
-
id: 'OnOffLight',
|
|
784
|
-
bridgedDeviceBasicInformation: {
|
|
785
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
786
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
787
|
-
|
|
788
|
-
productName: 'Light',
|
|
789
|
-
productLabel: 'Light',
|
|
790
|
-
nodeLabel: 'Light',
|
|
791
|
-
|
|
792
|
-
serialNumber: 'SN 0x123456789',
|
|
793
|
-
uniqueId: '0x123456789',
|
|
794
|
-
reachable: true,
|
|
795
|
-
},
|
|
796
|
-
levelControl: {
|
|
797
|
-
currentLevel: 0,
|
|
798
|
-
options: { executeIfOff: false, coupleColorTempToLevel: false },
|
|
799
|
-
},
|
|
800
|
-
colorControl: {
|
|
801
|
-
colorTemperatureMireds: 450,
|
|
802
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
803
|
-
colorTempPhysicalMinMireds: 150,
|
|
804
|
-
colorTempPhysicalMaxMireds: 450,
|
|
805
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
806
|
-
startUpColorTemperatureMireds: 450,
|
|
807
|
-
},
|
|
808
|
-
});
|
|
809
|
-
lightEndpoint1.behaviors.require(ColorControlServer.with('ColorTemperature'), {
|
|
810
|
-
colorTemperatureMireds: 450,
|
|
811
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
812
|
-
colorTempPhysicalMinMireds: 150,
|
|
813
|
-
colorTempPhysicalMaxMireds: 450,
|
|
814
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
815
|
-
startUpColorTemperatureMireds: 450,
|
|
816
|
-
});
|
|
817
|
-
await aggregatorNode?.add(lightEndpoint1);
|
|
818
|
-
|
|
819
|
-
/*
|
|
820
|
-
lightEndpoint1.behaviors.require(MatterbridgeIdentifyServer);
|
|
821
|
-
lightEndpoint1.behaviors.require(MatterbridgeOnOffServer);
|
|
822
|
-
lightEndpoint1.behaviors.require(MatterbridgeLevelControlServer);
|
|
823
|
-
lightEndpoint1.behaviors.require(MatterbridgeColorControlServer, {
|
|
824
|
-
colorTemperatureMireds: 250,
|
|
825
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
826
|
-
colorTempPhysicalMinMireds: 150,
|
|
827
|
-
colorTempPhysicalMaxMireds: 450,
|
|
828
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
829
|
-
startUpColorTemperatureMireds: 450,
|
|
830
|
-
});
|
|
831
|
-
await aggregatorNode?.add(lightEndpoint1);
|
|
832
|
-
|
|
833
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
834
|
-
const switchEnpoint2 = new EndpointNode(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
835
|
-
id: 'GenericSwitch',
|
|
836
|
-
bridgedDeviceBasicInformation: {
|
|
837
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
838
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
839
|
-
|
|
840
|
-
productName: 'GenericSwitch',
|
|
841
|
-
productLabel: 'GenericSwitch',
|
|
842
|
-
nodeLabel: 'GenericSwitch',
|
|
843
|
-
|
|
844
|
-
serialNumber: 'SN 0x123456739',
|
|
845
|
-
uniqueId: '0x123456739',
|
|
846
|
-
reachable: true,
|
|
847
|
-
},
|
|
848
|
-
switch: {
|
|
849
|
-
numberOfPositions: 2,
|
|
850
|
-
currentPosition: 0,
|
|
851
|
-
multiPressMax: 2,
|
|
852
|
-
},
|
|
853
|
-
});
|
|
854
|
-
await aggregatorNode?.add(switchEnpoint2);
|
|
855
|
-
*/
|
|
856
|
-
/*
|
|
857
|
-
for (let i = 1; i <= max; i++) {
|
|
858
|
-
this.log.notice(`Creating lightEndpoint${i}`);
|
|
859
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'OnOffLight' + i });
|
|
860
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultBridgedDeviceBasicInformationClusterServer('OnOffLight' + i, '123456789', 0xfff1, 'Matterbridge', 'Light'));
|
|
861
|
-
this.log.notice(`Adding lightEndpoint${i} to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
862
|
-
await aggregatorNode?.add(lightEndpoint);
|
|
863
|
-
setInterval(async () => {
|
|
864
|
-
const state = lightEndpoint.getAttribute(OnOffCluster.id, 'onOff');
|
|
865
|
-
lightEndpoint.setAttribute(OnOffCluster.id, 'onOff', !state);
|
|
866
|
-
this.log.notice(`Setting state for lightEndpoint${i} from:`, state, 'to:', !state);
|
|
867
|
-
}, 10000);
|
|
868
|
-
}
|
|
869
|
-
for (let i = 1; i <= max; i++) {
|
|
870
|
-
this.log.notice(`Creating outletEndpoint${i}`);
|
|
871
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffOutlet, { uniqueStorageKey: 'OnOffOutlet' + i });
|
|
872
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultBridgedDeviceBasicInformationClusterServer('OnOffOutlet' + i, '123456789', 0xfff1, 'Matterbridge', 'Outlet'));
|
|
873
|
-
this.log.notice(`Adding outletEndpoint${i} to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
874
|
-
await aggregatorNode?.add(lightEndpoint);
|
|
875
|
-
setInterval(async () => {
|
|
876
|
-
const state = lightEndpoint.getAttribute(OnOffCluster.id, 'onOff');
|
|
877
|
-
lightEndpoint.setAttribute(OnOffCluster.id, 'onOff', !state);
|
|
878
|
-
this.log.notice(`Setting state for outletEndpoint${i} from:`, state, 'to:', !state);
|
|
879
|
-
}, 10000);
|
|
880
|
-
}
|
|
881
|
-
*/
|
|
882
546
|
}
|
|
883
547
|
}
|
|
884
|
-
/*
|
|
885
|
-
/*
|
|
886
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
887
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
888
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
889
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
890
|
-
options: { executeIfOff: false },
|
|
891
|
-
numberOfPrimaries: null,
|
|
892
|
-
currentX: 24939,
|
|
893
|
-
currentY: 24701,
|
|
894
|
-
currentHue: 0,
|
|
895
|
-
currentSaturation: 0,
|
|
896
|
-
colorTemperatureMireds: 450,
|
|
897
|
-
colorTempPhysicalMinMireds: 150,
|
|
898
|
-
colorTempPhysicalMaxMireds: 450,
|
|
899
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
900
|
-
startUpColorTemperatureMireds: null,
|
|
901
|
-
});
|
|
902
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
903
|
-
colorCapabilities: { xy: false, hueSaturation: false, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
904
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
905
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
906
|
-
options: { executeIfOff: false },
|
|
907
|
-
numberOfPrimaries: null,
|
|
908
|
-
colorTemperatureMireds: 450,
|
|
909
|
-
colorTempPhysicalMinMireds: 150,
|
|
910
|
-
colorTempPhysicalMaxMireds: 450,
|
|
911
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
912
|
-
startUpColorTemperatureMireds: null,
|
|
913
|
-
});
|
|
914
|
-
*/
|
|
915
|
-
/*
|
|
916
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy), {
|
|
917
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: false },
|
|
918
|
-
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
919
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
920
|
-
options: { executeIfOff: false },
|
|
921
|
-
numberOfPrimaries: null,
|
|
922
|
-
currentX: 24939,
|
|
923
|
-
currentY: 24701,
|
|
924
|
-
currentHue: 0,
|
|
925
|
-
currentSaturation: 0,
|
|
926
|
-
});
|
|
927
|
-
// node dist/matterbridgeEdge.js MatterbridgeEdge -debug -ssl -frontend 443
|
|
928
|
-
if (process.argv.includes('MatterbridgeEdge')) {
|
|
929
|
-
const matterbridge = await MatterbridgeEdge.loadInstance(true);
|
|
930
|
-
|
|
931
|
-
process.on('SIGINT', async function () {
|
|
932
|
-
// eslint-disable-next-line no-console
|
|
933
|
-
console.log('Caught interrupt signal');
|
|
934
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
935
|
-
if (matterbridge) await (matterbridge as any).cleanup('shutting down...', false);
|
|
936
|
-
// if (matterbridge && matterbridge.matterServerNode && matterbridge.matterServerNodeContext) await matterbridge.stopServerNode(matterbridge.matterServerNode, matterbridge.matterServerNodeContext);
|
|
937
|
-
const exit = setTimeout(() => {
|
|
938
|
-
// eslint-disable-next-line no-console
|
|
939
|
-
console.log('Exiting after caught interrupt signal');
|
|
940
|
-
process.exit();
|
|
941
|
-
}, 10000);
|
|
942
|
-
exit.unref();
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
*/
|
|
946
|
-
/*
|
|
947
|
-
async startBridgeNode(): Promise<void> {
|
|
948
|
-
this.log.notice(`Creating lightEndpoint1`);
|
|
949
|
-
const lightEndpoint1 = new Endpoint(OnOffLightDevice.with(BridgedDeviceBasicInformationServer), {
|
|
950
|
-
id: 'OnOffLight',
|
|
951
|
-
bridgedDeviceBasicInformation: {
|
|
952
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
953
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
954
|
-
|
|
955
|
-
productName: 'Light',
|
|
956
|
-
productLabel: 'Light',
|
|
957
|
-
nodeLabel: 'Light',
|
|
958
|
-
|
|
959
|
-
serialNumber: 'SN 0x123456789',
|
|
960
|
-
uniqueId: '0x123456789',
|
|
961
|
-
reachable: true,
|
|
962
|
-
},
|
|
963
|
-
});
|
|
964
|
-
this.log.notice(`Adding lightEndpoint1 to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
965
|
-
await this.matterAggregatorNode.add(lightEndpoint1);
|
|
966
|
-
// logEndpoint(EndpointServer.forEndpoint(lightEndpoint1));
|
|
967
|
-
|
|
968
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
969
|
-
const switchEnpoint2 = new Endpoint(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
970
|
-
id: 'GenericSwitch',
|
|
971
|
-
bridgedDeviceBasicInformation: {
|
|
972
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
973
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
974
|
-
|
|
975
|
-
productName: 'GenericSwitch',
|
|
976
|
-
productLabel: 'GenericSwitch',
|
|
977
|
-
nodeLabel: 'GenericSwitch',
|
|
978
|
-
|
|
979
|
-
serialNumber: 'SN 0x123456739',
|
|
980
|
-
uniqueId: '0x123456739',
|
|
981
|
-
reachable: true,
|
|
982
|
-
},
|
|
983
|
-
switch: {
|
|
984
|
-
numberOfPositions: 2,
|
|
985
|
-
currentPosition: 0,
|
|
986
|
-
multiPressMax: 2,
|
|
987
|
-
},
|
|
988
|
-
});
|
|
989
|
-
this.log.notice(`Adding switchEnpoint2 to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
990
|
-
await this.matterAggregatorNode.add(switchEnpoint2);
|
|
991
|
-
// logEndpoint(EndpointServer.forEndpoint(switchEnpoint2));
|
|
992
|
-
|
|
993
|
-
// switchEnpoint2.events.identify.startIdentifying.on(() => this.log.notice('GenericSwitch.identify logic, ideally blink a light every 0.5s ...'));
|
|
994
|
-
// switchEnpoint2.events.switch.currentPosition$Changed.on(() => this.log.notice('GenericSwitch.currentPosition changed ...'));
|
|
995
|
-
// switchEnpoint2.act((agent) => agent.switch.events.initialPress.emit({ newPosition: 1 }, agent.context));
|
|
996
|
-
// switchEnpoint2.events.switch.emit('initialPress', { newPosition: 1 }, switchEnpoint2.events.switch.context);
|
|
997
|
-
*/
|
|
998
|
-
/*
|
|
999
|
-
log.notice(`Creating matterbridge device ClimateSensor`);
|
|
1000
|
-
const matterbridgeDevice3 = new MatterbridgeDeviceV8(DeviceTypes.TEMPERATURE_SENSOR, { uniqueStorageKey: 'ClimateSensor' });
|
|
1001
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.TEMPERATURE_SENSOR], [TemperatureMeasurement.Cluster.id]);
|
|
1002
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.HUMIDITY_SENSOR], [RelativeHumidityMeasurement.Cluster.id]);
|
|
1003
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.PRESSURE_SENSOR], [PressureMeasurement.Cluster.id]);
|
|
1004
|
-
matterbridgeDevice3.behaviors.require(IdentifyServer, {
|
|
1005
|
-
identifyTime: 5,
|
|
1006
|
-
});
|
|
1007
|
-
matterbridgeDevice3.behaviors.require(TemperatureMeasurementServer, {
|
|
1008
|
-
measuredValue: 25.0,
|
|
1009
|
-
minMeasuredValue: null,
|
|
1010
|
-
maxMeasuredValue: null,
|
|
1011
|
-
});
|
|
1012
|
-
*/
|
|
1013
|
-
/*
|
|
1014
|
-
log.notice(`Adding BridgedDeviceBasicInformationServer to ClimateSensor`);
|
|
1015
|
-
matterbridgeDevice3.behaviors.require(BridgedDeviceBasicInformationServer, {
|
|
1016
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
1017
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
1018
|
-
|
|
1019
|
-
productName: 'ClimateSensor',
|
|
1020
|
-
productLabel: 'ClimateSensor',
|
|
1021
|
-
nodeLabel: 'ClimateSensor',
|
|
1022
|
-
|
|
1023
|
-
serialNumber: '0x145433356739',
|
|
1024
|
-
uniqueId: '0x1254446739',
|
|
1025
|
-
reachable: true,
|
|
1026
|
-
});
|
|
1027
|
-
|
|
1028
|
-
log.notice(`Adding DescriptorServer to ClimateSensor`);
|
|
1029
|
-
matterbridgeDevice3.behaviors.require(DescriptorServer, {
|
|
1030
|
-
deviceTypeList: [
|
|
1031
|
-
{ deviceType: 0x0302, revision: 2 },
|
|
1032
|
-
{ deviceType: 0x0307, revision: 2 },
|
|
1033
|
-
{ deviceType: 0x0305, revision: 2 },
|
|
1034
|
-
],
|
|
1035
|
-
});
|
|
1036
|
-
|
|
1037
|
-
this.log.notice(`Adding ClimateSensor to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
1038
|
-
await this.matterAggregator.add(matterbridgeDevice3);
|
|
1039
|
-
logEndpoint(EndpointServer.forEndpoint(matterbridgeDevice3));
|
|
1040
|
-
*/
|
|
1041
|
-
/*
|
|
1042
|
-
await lightEndpoint1.set({
|
|
1043
|
-
onOff: {
|
|
1044
|
-
onOff: true,
|
|
1045
|
-
},
|
|
1046
|
-
});
|
|
1047
|
-
await switchEnpoint2.set({
|
|
1048
|
-
switch: {
|
|
1049
|
-
currentPosition: 1,
|
|
1050
|
-
},
|
|
1051
|
-
});
|
|
1052
|
-
switchEnpoint2.act((agent) => agent.switch.events.initialPress.emit({ newPosition: 1 }, agent.context));
|
|
1053
|
-
*/
|
|
1054
|
-
/*
|
|
1055
|
-
await matterbridgeDevice3.set({
|
|
1056
|
-
temperatureMeasurement: {
|
|
1057
|
-
measuredValue: 20 * 100,
|
|
1058
|
-
},
|
|
1059
|
-
relativeHumidityMeasurement: {
|
|
1060
|
-
measuredValue: 50 * 100,
|
|
1061
|
-
},
|
|
1062
|
-
});
|
|
1063
|
-
*/
|
|
1064
|
-
// logEndpoint(EndpointServer.forEndpoint(this.matterServerNode));
|
|
1065
|
-
/*
|
|
1066
|
-
logEndpoint(EndpointServer.forEndpoint(this.matterServerNode));
|
|
1067
|
-
logEndpoint(EndpointServer.forEndpoint(matterbridgeDevice3));
|
|
1068
|
-
console.log('matterbridgeDevice3\n', matterbridgeDevice3);
|
|
1069
|
-
console.log('matterbridgeDevice3.events\n', matterbridgeDevice3.events);
|
|
1070
|
-
console.log('matterbridgeDevice3.events.identify\n', matterbridgeDevice3.eventsOf(IdentifyServer));
|
|
1071
|
-
console.log('matterbridgeDevice3.state\n', matterbridgeDevice3.state);
|
|
1072
|
-
console.log('matterbridgeDevice3.state.temperatureMeasurement\n', matterbridgeDevice3.stateOf(TemperatureMeasurementServer));
|
|
1073
|
-
// matterbridgeDevice3.eventsOf(IdentifyServer);
|
|
1074
|
-
// matterbridgeDevice3.events.identify.startIdentifying.on(() => log.notice('Run identify logic, ideally blink a light every 0.5s ...'));
|
|
1075
|
-
}
|
|
1076
|
-
*/
|
|
1077
|
-
//# sourceMappingURL=matterbridgeEdge.js.map
|