matterbridge 1.6.7 → 1.6.8-dev.10
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 +23 -3
- package/README-SERVICE.md +12 -3
- package/README.md +3 -1
- package/dist/cli.js +0 -26
- package/dist/cluster/export.js +0 -2
- package/dist/defaultConfigSchema.js +3 -24
- package/dist/deviceManager.js +1 -26
- package/dist/index.js +0 -30
- package/dist/logger/export.js +0 -1
- package/dist/matter/export.js +5 -1
- package/dist/matterbridge.js +239 -661
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +1 -29
- package/dist/matterbridgeDevice.js +24 -986
- package/dist/matterbridgeDeviceTypes.js +11 -82
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEdge.js +3 -534
- package/dist/matterbridgeEndpoint.js +26 -1111
- package/dist/matterbridgePlatform.js +65 -95
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/matterbridgeWebsocket.js +0 -45
- 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/npm-shrinkwrap.json +17 -81
- 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 -6
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -466
- 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 -7063
- 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 -92
- package/dist/matterbridgeEdge.d.ts.map +0 -1
- package/dist/matterbridgeEdge.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -10164
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -114
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -162
- 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/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,21 +14,12 @@ 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
|
-
// Mapping of sessions
|
|
59
|
-
activeSessions = new Map();
|
|
60
23
|
constructor() {
|
|
61
24
|
super();
|
|
62
25
|
}
|
|
@@ -73,30 +36,24 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
73
36
|
async initialize() {
|
|
74
37
|
if (hasParameter('debug'))
|
|
75
38
|
console.log('Initializing MatterbridgeEdge...');
|
|
76
|
-
// Set the matterbridge directory
|
|
77
39
|
this.homeDirectory = getParameter('homedir') ?? os.homedir();
|
|
78
40
|
this.matterbridgeDirectory = path.join(this.homeDirectory, '.matterbridge');
|
|
79
41
|
this.matterStorageName = 'matterstorage' + (getParameter('profile') ? '.' + getParameter('profile') : '');
|
|
80
|
-
// Setup matter environment
|
|
81
42
|
this.environment.vars.set('log.level', MatterLogLevel.INFO);
|
|
82
43
|
this.environment.vars.set('log.format', MatterLogFormat.ANSI);
|
|
83
44
|
this.environment.vars.set('path.root', path.join(this.matterbridgeDirectory, this.matterStorageName));
|
|
84
45
|
this.environment.vars.set('runtime.signals', false);
|
|
85
46
|
this.environment.vars.set('runtime.exitcode', false);
|
|
86
|
-
// Setup Matter commissioning server
|
|
87
47
|
this.port = 5540;
|
|
88
48
|
this.passcode = PaseClient.generateRandomPasscode();
|
|
89
49
|
this.discriminator = PaseClient.generateRandomDiscriminator();
|
|
90
50
|
if (hasParameter('debug'))
|
|
91
51
|
console.log(`Initializing server node for Matterbridge... on port ${this.port} with passcode ${this.passcode} and discriminator ${this.discriminator}`);
|
|
92
|
-
// Initialize the base Matterbridge class
|
|
93
52
|
await super.initialize();
|
|
94
|
-
// Setup Matter mdnsInterface
|
|
95
53
|
if (this.mdnsInterface)
|
|
96
54
|
this.environment.vars.set('mdns.networkInterface', this.mdnsInterface);
|
|
97
55
|
}
|
|
98
56
|
async startMatterStorage(storageType, storageName) {
|
|
99
|
-
// Setup Matter storage
|
|
100
57
|
this.log.info(`Starting matter node storage...`);
|
|
101
58
|
this.matterStorageService = this.environment.get(StorageService);
|
|
102
59
|
this.log.info(`Matter node storage service created: ${this.matterStorageService.location}`);
|
|
@@ -104,7 +61,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
104
61
|
this.log.info('Matter node storage manager "Matterbridge" created');
|
|
105
62
|
this.matterbridgeContext = await this.createServerNodeContext('Matterbridge', 'Matterbridge', bridge.code, this.aggregatorVendorId, 'Matterbridge', this.aggregatorProductId, 'Matterbridge aggregator');
|
|
106
63
|
this.log.info('Matter node storage started');
|
|
107
|
-
// Backup matter storage since it is created/opened correctly
|
|
108
64
|
await this.backupMatterStorage(path.join(this.matterbridgeDirectory, this.matterStorageName), path.join(this.matterbridgeDirectory, this.matterStorageName + '.backup'));
|
|
109
65
|
}
|
|
110
66
|
async backupMatterStorage(storageName, backupName) {
|
|
@@ -120,24 +76,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
120
76
|
this.matterbridgeContext = undefined;
|
|
121
77
|
this.log.info('Matter node storage closed');
|
|
122
78
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Creates a server node storage context.
|
|
125
|
-
*
|
|
126
|
-
* @param pluginName - The name of the plugin.
|
|
127
|
-
* @param deviceName - The name of the device.
|
|
128
|
-
* @param deviceType - The deviceType of the device.
|
|
129
|
-
* @param vendorId - The vendor ID.
|
|
130
|
-
* @param vendorName - The vendor name.
|
|
131
|
-
* @param productId - The product ID.
|
|
132
|
-
* @param productName - The product name.
|
|
133
|
-
* @param serialNumber - The serial number of the device (optional).
|
|
134
|
-
* @param uniqueId - The unique ID of the device (optional).
|
|
135
|
-
* @param softwareVersion - The software version of the device (optional).
|
|
136
|
-
* @param softwareVersionString - The software version string of the device (optional).
|
|
137
|
-
* @param hardwareVersion - The hardware version of the device (optional).
|
|
138
|
-
* @param hardwareVersionString - The hardware version string of the device (optional).
|
|
139
|
-
* @returns The storage context for the commissioning server.
|
|
140
|
-
*/
|
|
141
79
|
async createServerNodeContext(pluginName, deviceName, deviceType, vendorId, vendorName, productId, productName, serialNumber) {
|
|
142
80
|
if (!this.matterStorageService)
|
|
143
81
|
throw new Error('No storage service initialized');
|
|
@@ -179,33 +117,21 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
179
117
|
this.log.debug(`- uniqueId: ${await storageContext.get('uniqueId')}`);
|
|
180
118
|
this.log.debug(`- softwareVersion: ${await storageContext.get('softwareVersion')} softwareVersionString: ${await storageContext.get('softwareVersionString')}`);
|
|
181
119
|
this.log.debug(`- hardwareVersion: ${await storageContext.get('hardwareVersion')} hardwareVersionString: ${await storageContext.get('hardwareVersionString')}`);
|
|
182
|
-
/**
|
|
183
|
-
* Create a Matter ServerNode, which contains the Root Endpoint and all relevant data and configuration
|
|
184
|
-
*/
|
|
185
120
|
const serverNode = await ServerNode.create({
|
|
186
|
-
// Required: Give the Node a unique ID which is used to store the state of this node
|
|
187
121
|
id: storeId,
|
|
188
|
-
// Provide Network relevant configuration like the port
|
|
189
|
-
// Optional when operating only one device on a host, Default port is 5540
|
|
190
122
|
network: {
|
|
191
123
|
listeningAddressIpv4: this.ipv4address,
|
|
192
124
|
listeningAddressIpv6: this.ipv6address,
|
|
193
125
|
port,
|
|
194
126
|
},
|
|
195
|
-
// Provide Commissioning relevant settings
|
|
196
|
-
// Optional for development/testing purposes
|
|
197
127
|
commissioning: {
|
|
198
128
|
passcode,
|
|
199
129
|
discriminator,
|
|
200
130
|
},
|
|
201
|
-
// Provide Node announcement settings
|
|
202
|
-
// Optional: If Ommitted some development defaults are used
|
|
203
131
|
productDescription: {
|
|
204
132
|
name: await storageContext.get('deviceName'),
|
|
205
133
|
deviceType: DeviceTypeId(await storageContext.get('deviceType')),
|
|
206
134
|
},
|
|
207
|
-
// Provide defaults for the BasicInformation cluster on the Root endpoint
|
|
208
|
-
// Optional: If Omitted some development defaults are used
|
|
209
135
|
basicInformation: {
|
|
210
136
|
vendorId: VendorId(await storageContext.get('vendorId')),
|
|
211
137
|
vendorName: await storageContext.get('vendorName'),
|
|
@@ -222,8 +148,7 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
222
148
|
},
|
|
223
149
|
});
|
|
224
150
|
const sanitizeFabrics = (fabrics) => {
|
|
225
|
-
|
|
226
|
-
const sanitizedFabrics = this.sanitizeFabricInformations(Array.from(Object.values(serverNode.state.commissioning.fabrics)));
|
|
151
|
+
const sanitizedFabrics = this.sanitizeFabricInformations(Array.from(Object.values(fabrics)));
|
|
227
152
|
this.log.info(`Fabrics: ${debugStringify(sanitizedFabrics)}`);
|
|
228
153
|
if (this.bridgeMode === 'bridge') {
|
|
229
154
|
this.matterbridgeFabricInformations = sanitizedFabrics;
|
|
@@ -239,14 +164,8 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
239
164
|
}
|
|
240
165
|
}
|
|
241
166
|
};
|
|
242
|
-
/**
|
|
243
|
-
* This event is triggered when the device is initially commissioned successfully.
|
|
244
|
-
* This means: It is added to the first fabric.
|
|
245
|
-
*/
|
|
246
167
|
serverNode.lifecycle.commissioned.on(() => this.log.notice(`Server node for ${storeId} was initially commissioned successfully!`));
|
|
247
|
-
/** This event is triggered when all fabrics are removed from the device, usually it also does a factory reset then. */
|
|
248
168
|
serverNode.lifecycle.decommissioned.on(() => this.log.notice(`Server node for ${storeId} was fully decommissioned successfully!`));
|
|
249
|
-
/** This event is triggered when the device went online. This means that it is discoverable in the network. */
|
|
250
169
|
serverNode.lifecycle.online.on(() => {
|
|
251
170
|
this.log.notice(`Server node for ${storeId} is online`);
|
|
252
171
|
if (!serverNode.lifecycle.isCommissioned) {
|
|
@@ -281,7 +200,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
281
200
|
sanitizeFabrics(serverNode.state.commissioning.fabrics);
|
|
282
201
|
}
|
|
283
202
|
});
|
|
284
|
-
/** This event is triggered when the device went offline. it is not longer discoverable or connectable in the network. */
|
|
285
203
|
serverNode.lifecycle.offline.on(() => {
|
|
286
204
|
this.log.notice(`Server node for ${storeId} is offline`);
|
|
287
205
|
if (this.bridgeMode === 'bridge') {
|
|
@@ -293,10 +211,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
293
211
|
this.matterbridgeConnected = false;
|
|
294
212
|
}
|
|
295
213
|
});
|
|
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
214
|
serverNode.events.commissioning.fabricsChanged.on((fabricIndex, fabricAction) => {
|
|
301
215
|
let action = '';
|
|
302
216
|
switch (fabricAction) {
|
|
@@ -329,22 +243,14 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
329
243
|
}
|
|
330
244
|
}
|
|
331
245
|
};
|
|
332
|
-
/**
|
|
333
|
-
* This event is triggered when an operative new session was opened by a Controller.
|
|
334
|
-
* It is not triggered for the initial commissioning process, just afterwards for real connections.
|
|
335
|
-
*/
|
|
336
246
|
serverNode.events.sessions.opened.on((session) => {
|
|
337
247
|
this.log.notice(`Session opened on server node for ${storeId}: ${debugStringify(session)}`);
|
|
338
248
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
339
249
|
});
|
|
340
|
-
/**
|
|
341
|
-
* This event is triggered when an operative session is closed by a Controller or because the Device goes offline.
|
|
342
|
-
*/
|
|
343
250
|
serverNode.events.sessions.closed.on((session) => {
|
|
344
251
|
this.log.notice(`Session closed on server node for ${storeId}: ${debugStringify(session)}`);
|
|
345
252
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
346
253
|
});
|
|
347
|
-
/** This event is triggered when a subscription gets added or removed on an operative session. */
|
|
348
254
|
serverNode.events.sessions.subscriptionsChanged.on((session) => {
|
|
349
255
|
this.log.notice(`Session subscriptions changed on server node for ${storeId}: ${debugStringify(session)}`);
|
|
350
256
|
sanitizeSessions(Object.values(serverNode.state.sessions.sessions));
|
|
@@ -366,17 +272,15 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
366
272
|
}
|
|
367
273
|
async createAggregatorNode(storageContext) {
|
|
368
274
|
this.log.notice(`Creating ${await storageContext.get('storeId')} aggregator `);
|
|
369
|
-
const
|
|
370
|
-
return
|
|
275
|
+
const aggregatorNode = new EndpointNode(AggregatorEndpoint, { id: `${await storageContext.get('storeId')}` });
|
|
276
|
+
return aggregatorNode;
|
|
371
277
|
}
|
|
372
278
|
async addBridgedEndpoint(pluginName, device) {
|
|
373
|
-
// Check if the plugin is registered
|
|
374
279
|
const plugin = this.plugins.get(pluginName);
|
|
375
280
|
if (!plugin) {
|
|
376
281
|
this.log.error(`Error adding bridged endpoint ${dev}${device.deviceName}${er} (${zb}${device.id}${er}) plugin ${plg}${pluginName}${er} not found`);
|
|
377
282
|
return;
|
|
378
283
|
}
|
|
379
|
-
// Register and add the device to the matterbridge aggregator node
|
|
380
284
|
if (this.bridgeMode === 'bridge') {
|
|
381
285
|
this.log.info(`Adding ${pluginName}:${device.deviceName} to Matterbridge aggregator node`);
|
|
382
286
|
const aggregatorNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
@@ -412,19 +316,16 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
412
316
|
plugin.registeredDevices++;
|
|
413
317
|
if (plugin.addedDevices !== undefined)
|
|
414
318
|
plugin.addedDevices++;
|
|
415
|
-
// Add the device to the DeviceManager
|
|
416
319
|
this.devices.set(device);
|
|
417
320
|
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}`);
|
|
418
321
|
}
|
|
419
322
|
async removeBridgedEndpoint(pluginName, device) {
|
|
420
323
|
this.log.debug(`Removing bridged endpoint ${dev}${device.deviceName}${db} (${zb}${device.name}${db}) for plugin ${plg}${pluginName}${db}`);
|
|
421
|
-
// Check if the plugin is registered
|
|
422
324
|
const plugin = this.plugins.get(pluginName);
|
|
423
325
|
if (!plugin) {
|
|
424
326
|
this.log.error(`Error removing bridged endpoint ${dev}${device.deviceName}${er} (${zb}${device.name}${er}) for plugin ${plg}${pluginName}${er}: plugin not found`);
|
|
425
327
|
return;
|
|
426
328
|
}
|
|
427
|
-
// Register and add the device to the matterbridge aggregator node
|
|
428
329
|
if (this.bridgeMode === 'bridge') {
|
|
429
330
|
const aggregatoreNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
430
331
|
if (!aggregatoreNode) {
|
|
@@ -440,7 +341,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
440
341
|
}
|
|
441
342
|
else if (this.bridgeMode === 'childbridge') {
|
|
442
343
|
if (plugin.type === 'AccessoryPlatform') {
|
|
443
|
-
// Nothing to do
|
|
444
344
|
}
|
|
445
345
|
else if (plugin.type === 'DynamicPlatform') {
|
|
446
346
|
const aggregatoreNode = this.agToAggregatorEndpoint.get(pluginName)?.aggregatorNode;
|
|
@@ -455,7 +355,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
455
355
|
plugin.registeredDevices--;
|
|
456
356
|
if (plugin.addedDevices !== undefined)
|
|
457
357
|
plugin.addedDevices--;
|
|
458
|
-
// Close the server node
|
|
459
358
|
if (plugin.registeredDevices === 0 && plugin.addedDevices === 0) {
|
|
460
359
|
const serverNode = this.csToServerNode.get(pluginName)?.serverNode;
|
|
461
360
|
if (serverNode)
|
|
@@ -464,7 +363,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
464
363
|
this.log.info(`Removed server node for plugin ${plg}${pluginName}${nf}`);
|
|
465
364
|
}
|
|
466
365
|
}
|
|
467
|
-
// Remove the device from the DeviceManager
|
|
468
366
|
this.devices.remove(device);
|
|
469
367
|
}
|
|
470
368
|
async removeAllBridgedEndpoints(pluginName) {
|
|
@@ -473,9 +371,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
473
371
|
await this.removeBridgedEndpoint(pluginName, device);
|
|
474
372
|
}
|
|
475
373
|
}
|
|
476
|
-
/**
|
|
477
|
-
* override from Matterbridge
|
|
478
|
-
*/
|
|
479
374
|
createMatterServer(storageManager) {
|
|
480
375
|
if (hasParameter('debug'))
|
|
481
376
|
this.log.warn('createMatterServer() => mock MatterServer.addCommissioningServer()');
|
|
@@ -539,7 +434,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
539
434
|
const commissioningServer = {
|
|
540
435
|
getPort: () => port,
|
|
541
436
|
addDevice: async (device) => {
|
|
542
|
-
// if (hasParameter('debug')) this.log.warn('CommissioningServer.addDevice()', device.name);
|
|
543
437
|
if (device instanceof Device) {
|
|
544
438
|
if (hasParameter('debug'))
|
|
545
439
|
this.log.warn('CommissioningServer.addDevice() => Device');
|
|
@@ -554,7 +448,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
554
448
|
await serverNode.add(aggregatorNode);
|
|
555
449
|
if (!this.test) {
|
|
556
450
|
this.test = true;
|
|
557
|
-
// await this.testEndpoints();
|
|
558
451
|
}
|
|
559
452
|
}
|
|
560
453
|
},
|
|
@@ -611,37 +504,6 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
611
504
|
const aggregatorNode = this.agToAggregatorEndpoint.get('Matterbridge')?.aggregatorNode;
|
|
612
505
|
if (!aggregatorNode)
|
|
613
506
|
return;
|
|
614
|
-
/*
|
|
615
|
-
this.log.notice(`Creating OnOffLight1`);
|
|
616
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'OnOffLight1' }, true);
|
|
617
|
-
lightEndpoint.addDeviceType(bridgedNode);
|
|
618
|
-
lightEndpoint.createDefaultBridgedDeviceBasicInformationClusterServer('OnOffLight 1', '123456789', 0xfff1, 'Matterbridge', 'Light');
|
|
619
|
-
lightEndpoint.addDeviceType(powerSource);
|
|
620
|
-
lightEndpoint.createDefaultPowerSourceWiredClusterServer();
|
|
621
|
-
lightEndpoint.addDeviceType(electricalSensor);
|
|
622
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
623
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultElectricalPowerMeasurementClusterServer());
|
|
624
|
-
lightEndpoint.addRequiredClusterServers(lightEndpoint);
|
|
625
|
-
this.log.notice(`Adding OnOffLight1 to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
626
|
-
await aggregatorNode.add(lightEndpoint);
|
|
627
|
-
logEndpoint(EndpointServer.forEndpoint(lightEndpoint));
|
|
628
|
-
|
|
629
|
-
this.log.notice(`Creating Outlet1`);
|
|
630
|
-
const outletEndpoint = new MatterbridgeEndpoint(onOffOutlet, { uniqueStorageKey: 'OnOffOutlet1' }, true);
|
|
631
|
-
outletEndpoint.addDeviceType(bridgedNode);
|
|
632
|
-
outletEndpoint.createDefaultBridgedDeviceBasicInformationClusterServer('OnOffOutlet 1', '123456789', 0xfff1, 'Matterbridge', 'Outlet');
|
|
633
|
-
outletEndpoint.addDeviceType(powerSource);
|
|
634
|
-
outletEndpoint.createDefaultPowerSourceReplaceableBatteryClusterServer();
|
|
635
|
-
outletEndpoint.addDeviceType(electricalSensor);
|
|
636
|
-
outletEndpoint.addClusterServer(outletEndpoint.getDefaultElectricalEnergyMeasurementClusterServer());
|
|
637
|
-
outletEndpoint.addClusterServer(outletEndpoint.getDefaultElectricalPowerMeasurementClusterServer());
|
|
638
|
-
outletEndpoint.addRequiredClusterServers(outletEndpoint);
|
|
639
|
-
const input0 = outletEndpoint.addChildDeviceTypeWithClusterServer('Input:0', [genericSwitch], undefined, undefined, true);
|
|
640
|
-
const input1 = outletEndpoint.addChildDeviceTypeWithClusterServer('Input:1', [genericSwitch], undefined, undefined, true);
|
|
641
|
-
this.log.notice(`Adding OnOffOutlet1 to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
642
|
-
await aggregatorNode.add(outletEndpoint);
|
|
643
|
-
logEndpoint(EndpointServer.forEndpoint(outletEndpoint));
|
|
644
|
-
*/
|
|
645
507
|
this.log.notice(`Creating switchEnpoint1`);
|
|
646
508
|
const switchEnpoint1 = new EndpointNode(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
647
509
|
id: 'GenericSwitch',
|
|
@@ -664,398 +526,5 @@ export class MatterbridgeEdge extends Matterbridge {
|
|
|
664
526
|
this.log.notice(`Adding switchEnpoint1 to ${await this.matterbridgeContext.get('storeId')} aggregator`);
|
|
665
527
|
await aggregatorNode.add(switchEnpoint1);
|
|
666
528
|
logEndpoint(EndpointServer.forEndpoint(switchEnpoint1), { logNotSupportedClusterAttributes: true, logNotSupportedClusterEvents: true, logNotSupportedClusterCommands: true });
|
|
667
|
-
// if (switchEnpoint2.behaviors.has(SwitchServer)) this.log.notice(`SwitchServer found`);
|
|
668
|
-
// switchEnpoint2.act((agent) => agent['switch'].events['initialPress'].emit({ newPosition: 1 }, agent.context));
|
|
669
|
-
/*
|
|
670
|
-
const device = new MatterbridgeEndpoint(genericSwitch, { uniqueStorageKey: 'GenericSwitch 2' }, true);
|
|
671
|
-
device.createDefaultSwitchClusterServer();
|
|
672
|
-
device.addRequiredClusterServers(device);
|
|
673
|
-
await aggregatorNode.add(device);
|
|
674
|
-
logEndpoint(EndpointServer.forEndpoint(device));
|
|
675
|
-
await device.triggerSwitchEvent('Single', this.log);
|
|
676
|
-
await device.triggerSwitchEvent('Double', this.log);
|
|
677
|
-
await device.triggerSwitchEvent('Long', this.log);
|
|
678
|
-
|
|
679
|
-
const device1 = new MatterbridgeEndpoint(genericSwitch, { uniqueStorageKey: 'GenericSwitch 3' }, true);
|
|
680
|
-
device1.createDefaultLatchingSwitchClusterServer();
|
|
681
|
-
device1.addRequiredClusterServers(device1);
|
|
682
|
-
await aggregatorNode.add(device1);
|
|
683
|
-
logEndpoint(EndpointServer.forEndpoint(device1));
|
|
684
|
-
await device1.triggerSwitchEvent('Press', this.log);
|
|
685
|
-
await device1.triggerSwitchEvent('Release', this.log);
|
|
686
|
-
|
|
687
|
-
this.log.notice(`Creating TestLight`);
|
|
688
|
-
const matterbridgeDevice = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'Test .Light:2' }, true);
|
|
689
|
-
matterbridgeDevice.behaviors.require(MatterbridgeIdentifyServer, {
|
|
690
|
-
identifyTime: 0,
|
|
691
|
-
identifyType: Identify.IdentifyType.None,
|
|
692
|
-
});
|
|
693
|
-
matterbridgeDevice.behaviors.require(GroupsServer);
|
|
694
|
-
matterbridgeDevice.behaviors.require(MatterbridgeOnOffServer, {
|
|
695
|
-
onOff: false,
|
|
696
|
-
});
|
|
697
|
-
matterbridgeDevice.behaviors.require(MatterbridgeLevelControlServer, {
|
|
698
|
-
currentLevel: 0,
|
|
699
|
-
options: { executeIfOff: false },
|
|
700
|
-
});
|
|
701
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
702
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
703
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
704
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
705
|
-
options: { executeIfOff: false },
|
|
706
|
-
numberOfPrimaries: null,
|
|
707
|
-
currentX: 24939,
|
|
708
|
-
currentY: 24701,
|
|
709
|
-
currentHue: 0,
|
|
710
|
-
currentSaturation: 0,
|
|
711
|
-
colorTemperatureMireds: 450,
|
|
712
|
-
colorTempPhysicalMinMireds: 150,
|
|
713
|
-
colorTempPhysicalMaxMireds: 450,
|
|
714
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
715
|
-
startUpColorTemperatureMireds: null,
|
|
716
|
-
});
|
|
717
|
-
matterbridgeDevice.behaviors.require(BridgedDeviceBasicInformationServer, {
|
|
718
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
719
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
720
|
-
productName: 'TestLight2',
|
|
721
|
-
productLabel: 'TestLight2',
|
|
722
|
-
nodeLabel: 'TestLight2',
|
|
723
|
-
serialNumber: 'SN 0x123456789',
|
|
724
|
-
uniqueId: '0x123456789',
|
|
725
|
-
reachable: true,
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
// await matterbridgeDevice.setTagList(null, 0x07, 1, 'endpoint 2');
|
|
729
|
-
// await matterbridgeDevice.configureColorControlCluster(false, false, true, ColorControl.ColorMode.ColorTemperatureMireds);
|
|
730
|
-
|
|
731
|
-
this.log.notice(`Adding TestLight`);
|
|
732
|
-
await aggregatorNode?.add(matterbridgeDevice);
|
|
733
|
-
|
|
734
|
-
this.log.notice(`Creating switchEnpoint1`);
|
|
735
|
-
const switchEnpoint2 = new EndpointNode(
|
|
736
|
-
GenericSwitchDevice.with(DescriptorServer.with(Descriptor.Feature.TagList), BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')),
|
|
737
|
-
{
|
|
738
|
-
id: 'GenericSwitch1',
|
|
739
|
-
descriptor: {
|
|
740
|
-
tagList: [{ mfgCode: null, namespaceId: 0x07, tag: 1, label: 'Switch1' }],
|
|
741
|
-
},
|
|
742
|
-
bridgedDeviceBasicInformation: {
|
|
743
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
744
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
745
|
-
|
|
746
|
-
productName: 'GenericSwitch',
|
|
747
|
-
productLabel: 'GenericSwitch',
|
|
748
|
-
nodeLabel: 'GenericSwitch',
|
|
749
|
-
|
|
750
|
-
serialNumber: 'SN 0x1234567397',
|
|
751
|
-
uniqueId: '0x1234567397',
|
|
752
|
-
reachable: true,
|
|
753
|
-
},
|
|
754
|
-
switch: {
|
|
755
|
-
numberOfPositions: 2,
|
|
756
|
-
currentPosition: 0,
|
|
757
|
-
multiPressMax: 2,
|
|
758
|
-
},
|
|
759
|
-
},
|
|
760
|
-
);
|
|
761
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
762
|
-
await aggregatorNode?.add(switchEnpoint2);
|
|
763
|
-
*/
|
|
764
|
-
/*
|
|
765
|
-
const lightEndpoint1 = new EndpointNode(ColorTemperatureLightDevice.with(BridgedDeviceBasicInformationServer), {
|
|
766
|
-
// }, MatterbridgeIdentifyServer, MatterbridgeOnOffServer, MatterbridgeLevelControlServer, MatterbridgeColorControlServer), {
|
|
767
|
-
id: 'OnOffLight',
|
|
768
|
-
bridgedDeviceBasicInformation: {
|
|
769
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
770
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
771
|
-
|
|
772
|
-
productName: 'Light',
|
|
773
|
-
productLabel: 'Light',
|
|
774
|
-
nodeLabel: 'Light',
|
|
775
|
-
|
|
776
|
-
serialNumber: 'SN 0x123456789',
|
|
777
|
-
uniqueId: '0x123456789',
|
|
778
|
-
reachable: true,
|
|
779
|
-
},
|
|
780
|
-
levelControl: {
|
|
781
|
-
currentLevel: 0,
|
|
782
|
-
options: { executeIfOff: false, coupleColorTempToLevel: false },
|
|
783
|
-
},
|
|
784
|
-
colorControl: {
|
|
785
|
-
colorTemperatureMireds: 450,
|
|
786
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
787
|
-
colorTempPhysicalMinMireds: 150,
|
|
788
|
-
colorTempPhysicalMaxMireds: 450,
|
|
789
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
790
|
-
startUpColorTemperatureMireds: 450,
|
|
791
|
-
},
|
|
792
|
-
});
|
|
793
|
-
lightEndpoint1.behaviors.require(ColorControlServer.with('ColorTemperature'), {
|
|
794
|
-
colorTemperatureMireds: 450,
|
|
795
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
796
|
-
colorTempPhysicalMinMireds: 150,
|
|
797
|
-
colorTempPhysicalMaxMireds: 450,
|
|
798
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
799
|
-
startUpColorTemperatureMireds: 450,
|
|
800
|
-
});
|
|
801
|
-
await aggregatorNode?.add(lightEndpoint1);
|
|
802
|
-
|
|
803
|
-
/*
|
|
804
|
-
lightEndpoint1.behaviors.require(MatterbridgeIdentifyServer);
|
|
805
|
-
lightEndpoint1.behaviors.require(MatterbridgeOnOffServer);
|
|
806
|
-
lightEndpoint1.behaviors.require(MatterbridgeLevelControlServer);
|
|
807
|
-
lightEndpoint1.behaviors.require(MatterbridgeColorControlServer, {
|
|
808
|
-
colorTemperatureMireds: 250,
|
|
809
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
810
|
-
colorTempPhysicalMinMireds: 150,
|
|
811
|
-
colorTempPhysicalMaxMireds: 450,
|
|
812
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
813
|
-
startUpColorTemperatureMireds: 450,
|
|
814
|
-
});
|
|
815
|
-
await aggregatorNode?.add(lightEndpoint1);
|
|
816
|
-
|
|
817
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
818
|
-
const switchEnpoint2 = new EndpointNode(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
819
|
-
id: 'GenericSwitch',
|
|
820
|
-
bridgedDeviceBasicInformation: {
|
|
821
|
-
vendorId: VendorId(await this.matterbridgeContext.get<number>('vendorId')),
|
|
822
|
-
vendorName: await this.matterbridgeContext.get<string>('vendorName'),
|
|
823
|
-
|
|
824
|
-
productName: 'GenericSwitch',
|
|
825
|
-
productLabel: 'GenericSwitch',
|
|
826
|
-
nodeLabel: 'GenericSwitch',
|
|
827
|
-
|
|
828
|
-
serialNumber: 'SN 0x123456739',
|
|
829
|
-
uniqueId: '0x123456739',
|
|
830
|
-
reachable: true,
|
|
831
|
-
},
|
|
832
|
-
switch: {
|
|
833
|
-
numberOfPositions: 2,
|
|
834
|
-
currentPosition: 0,
|
|
835
|
-
multiPressMax: 2,
|
|
836
|
-
},
|
|
837
|
-
});
|
|
838
|
-
await aggregatorNode?.add(switchEnpoint2);
|
|
839
|
-
*/
|
|
840
|
-
/*
|
|
841
|
-
for (let i = 1; i <= max; i++) {
|
|
842
|
-
this.log.notice(`Creating lightEndpoint${i}`);
|
|
843
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffLight, { uniqueStorageKey: 'OnOffLight' + i });
|
|
844
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultBridgedDeviceBasicInformationClusterServer('OnOffLight' + i, '123456789', 0xfff1, 'Matterbridge', 'Light'));
|
|
845
|
-
this.log.notice(`Adding lightEndpoint${i} to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
846
|
-
await aggregatorNode?.add(lightEndpoint);
|
|
847
|
-
setInterval(async () => {
|
|
848
|
-
const state = lightEndpoint.getAttribute(OnOffCluster.id, 'onOff');
|
|
849
|
-
lightEndpoint.setAttribute(OnOffCluster.id, 'onOff', !state);
|
|
850
|
-
this.log.notice(`Setting state for lightEndpoint${i} from:`, state, 'to:', !state);
|
|
851
|
-
}, 10000);
|
|
852
|
-
}
|
|
853
|
-
for (let i = 1; i <= max; i++) {
|
|
854
|
-
this.log.notice(`Creating outletEndpoint${i}`);
|
|
855
|
-
const lightEndpoint = new MatterbridgeEndpoint(onOffOutlet, { uniqueStorageKey: 'OnOffOutlet' + i });
|
|
856
|
-
lightEndpoint.addClusterServer(lightEndpoint.getDefaultBridgedDeviceBasicInformationClusterServer('OnOffOutlet' + i, '123456789', 0xfff1, 'Matterbridge', 'Outlet'));
|
|
857
|
-
this.log.notice(`Adding outletEndpoint${i} to ${await this.matterbridgeContext.get<string>('storeId')} aggregator`);
|
|
858
|
-
await aggregatorNode?.add(lightEndpoint);
|
|
859
|
-
setInterval(async () => {
|
|
860
|
-
const state = lightEndpoint.getAttribute(OnOffCluster.id, 'onOff');
|
|
861
|
-
lightEndpoint.setAttribute(OnOffCluster.id, 'onOff', !state);
|
|
862
|
-
this.log.notice(`Setting state for outletEndpoint${i} from:`, state, 'to:', !state);
|
|
863
|
-
}, 10000);
|
|
864
|
-
}
|
|
865
|
-
*/
|
|
866
529
|
}
|
|
867
530
|
}
|
|
868
|
-
/*
|
|
869
|
-
/*
|
|
870
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy, ColorControl.Feature.ColorTemperature), {
|
|
871
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
872
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
873
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
874
|
-
options: { executeIfOff: false },
|
|
875
|
-
numberOfPrimaries: null,
|
|
876
|
-
currentX: 24939,
|
|
877
|
-
currentY: 24701,
|
|
878
|
-
currentHue: 0,
|
|
879
|
-
currentSaturation: 0,
|
|
880
|
-
colorTemperatureMireds: 450,
|
|
881
|
-
colorTempPhysicalMinMireds: 150,
|
|
882
|
-
colorTempPhysicalMaxMireds: 450,
|
|
883
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
884
|
-
startUpColorTemperatureMireds: null,
|
|
885
|
-
});
|
|
886
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.ColorTemperature), {
|
|
887
|
-
colorCapabilities: { xy: false, hueSaturation: false, colorLoop: false, enhancedHue: false, colorTemperature: true },
|
|
888
|
-
colorMode: ColorControl.ColorMode.ColorTemperatureMireds,
|
|
889
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.ColorTemperatureMireds,
|
|
890
|
-
options: { executeIfOff: false },
|
|
891
|
-
numberOfPrimaries: null,
|
|
892
|
-
colorTemperatureMireds: 450,
|
|
893
|
-
colorTempPhysicalMinMireds: 150,
|
|
894
|
-
colorTempPhysicalMaxMireds: 450,
|
|
895
|
-
coupleColorTempToLevelMinMireds: 150,
|
|
896
|
-
startUpColorTemperatureMireds: null,
|
|
897
|
-
});
|
|
898
|
-
*/
|
|
899
|
-
/*
|
|
900
|
-
matterbridgeDevice.behaviors.require(MatterbridgeColorControlServer.with(ColorControl.Feature.HueSaturation, ColorControl.Feature.Xy), {
|
|
901
|
-
colorCapabilities: { xy: true, hueSaturation: true, colorLoop: false, enhancedHue: false, colorTemperature: false },
|
|
902
|
-
colorMode: ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
903
|
-
enhancedColorMode: ColorControl.EnhancedColorMode.CurrentHueAndCurrentSaturation,
|
|
904
|
-
options: { executeIfOff: false },
|
|
905
|
-
numberOfPrimaries: null,
|
|
906
|
-
currentX: 24939,
|
|
907
|
-
currentY: 24701,
|
|
908
|
-
currentHue: 0,
|
|
909
|
-
currentSaturation: 0,
|
|
910
|
-
});
|
|
911
|
-
// node dist/matterbridgeEdge.js MatterbridgeEdge -debug -ssl -frontend 443
|
|
912
|
-
if (process.argv.includes('MatterbridgeEdge')) {
|
|
913
|
-
const matterbridge = await MatterbridgeEdge.loadInstance(true);
|
|
914
|
-
|
|
915
|
-
process.on('SIGINT', async function () {
|
|
916
|
-
// eslint-disable-next-line no-console
|
|
917
|
-
console.log('Caught interrupt signal');
|
|
918
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
919
|
-
if (matterbridge) await (matterbridge as any).cleanup('shutting down...', false);
|
|
920
|
-
// if (matterbridge && matterbridge.matterServerNode && matterbridge.matterServerNodeContext) await matterbridge.stopServerNode(matterbridge.matterServerNode, matterbridge.matterServerNodeContext);
|
|
921
|
-
const exit = setTimeout(() => {
|
|
922
|
-
// eslint-disable-next-line no-console
|
|
923
|
-
console.log('Exiting after caught interrupt signal');
|
|
924
|
-
process.exit();
|
|
925
|
-
}, 10000);
|
|
926
|
-
exit.unref();
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
*/
|
|
930
|
-
/*
|
|
931
|
-
async startBridgeNode(): Promise<void> {
|
|
932
|
-
this.log.notice(`Creating lightEndpoint1`);
|
|
933
|
-
const lightEndpoint1 = new Endpoint(OnOffLightDevice.with(BridgedDeviceBasicInformationServer), {
|
|
934
|
-
id: 'OnOffLight',
|
|
935
|
-
bridgedDeviceBasicInformation: {
|
|
936
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
937
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
938
|
-
|
|
939
|
-
productName: 'Light',
|
|
940
|
-
productLabel: 'Light',
|
|
941
|
-
nodeLabel: 'Light',
|
|
942
|
-
|
|
943
|
-
serialNumber: 'SN 0x123456789',
|
|
944
|
-
uniqueId: '0x123456789',
|
|
945
|
-
reachable: true,
|
|
946
|
-
},
|
|
947
|
-
});
|
|
948
|
-
this.log.notice(`Adding lightEndpoint1 to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
949
|
-
await this.matterAggregatorNode.add(lightEndpoint1);
|
|
950
|
-
// logEndpoint(EndpointServer.forEndpoint(lightEndpoint1));
|
|
951
|
-
|
|
952
|
-
this.log.notice(`Creating switchEnpoint2`);
|
|
953
|
-
const switchEnpoint2 = new Endpoint(GenericSwitchDevice.with(BridgedDeviceBasicInformationServer, SwitchServer.with('MomentarySwitch', 'MomentarySwitchLongPress', 'MomentarySwitchMultiPress', 'MomentarySwitchRelease')), {
|
|
954
|
-
id: 'GenericSwitch',
|
|
955
|
-
bridgedDeviceBasicInformation: {
|
|
956
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
957
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
958
|
-
|
|
959
|
-
productName: 'GenericSwitch',
|
|
960
|
-
productLabel: 'GenericSwitch',
|
|
961
|
-
nodeLabel: 'GenericSwitch',
|
|
962
|
-
|
|
963
|
-
serialNumber: 'SN 0x123456739',
|
|
964
|
-
uniqueId: '0x123456739',
|
|
965
|
-
reachable: true,
|
|
966
|
-
},
|
|
967
|
-
switch: {
|
|
968
|
-
numberOfPositions: 2,
|
|
969
|
-
currentPosition: 0,
|
|
970
|
-
multiPressMax: 2,
|
|
971
|
-
},
|
|
972
|
-
});
|
|
973
|
-
this.log.notice(`Adding switchEnpoint2 to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
974
|
-
await this.matterAggregatorNode.add(switchEnpoint2);
|
|
975
|
-
// logEndpoint(EndpointServer.forEndpoint(switchEnpoint2));
|
|
976
|
-
|
|
977
|
-
// switchEnpoint2.events.identify.startIdentifying.on(() => this.log.notice('GenericSwitch.identify logic, ideally blink a light every 0.5s ...'));
|
|
978
|
-
// switchEnpoint2.events.switch.currentPosition$Changed.on(() => this.log.notice('GenericSwitch.currentPosition changed ...'));
|
|
979
|
-
// switchEnpoint2.act((agent) => agent.switch.events.initialPress.emit({ newPosition: 1 }, agent.context));
|
|
980
|
-
// switchEnpoint2.events.switch.emit('initialPress', { newPosition: 1 }, switchEnpoint2.events.switch.context);
|
|
981
|
-
*/
|
|
982
|
-
/*
|
|
983
|
-
log.notice(`Creating matterbridge device ClimateSensor`);
|
|
984
|
-
const matterbridgeDevice3 = new MatterbridgeDeviceV8(DeviceTypes.TEMPERATURE_SENSOR, { uniqueStorageKey: 'ClimateSensor' });
|
|
985
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.TEMPERATURE_SENSOR], [TemperatureMeasurement.Cluster.id]);
|
|
986
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.HUMIDITY_SENSOR], [RelativeHumidityMeasurement.Cluster.id]);
|
|
987
|
-
matterbridgeDevice3.addDeviceTypeWithClusterServer([DeviceTypes.PRESSURE_SENSOR], [PressureMeasurement.Cluster.id]);
|
|
988
|
-
matterbridgeDevice3.behaviors.require(IdentifyServer, {
|
|
989
|
-
identifyTime: 5,
|
|
990
|
-
});
|
|
991
|
-
matterbridgeDevice3.behaviors.require(TemperatureMeasurementServer, {
|
|
992
|
-
measuredValue: 25.0,
|
|
993
|
-
minMeasuredValue: null,
|
|
994
|
-
maxMeasuredValue: null,
|
|
995
|
-
});
|
|
996
|
-
*/
|
|
997
|
-
/*
|
|
998
|
-
log.notice(`Adding BridgedDeviceBasicInformationServer to ClimateSensor`);
|
|
999
|
-
matterbridgeDevice3.behaviors.require(BridgedDeviceBasicInformationServer, {
|
|
1000
|
-
vendorId: VendorId(await storageContext.get<number>('vendorId')),
|
|
1001
|
-
vendorName: await storageContext.get<string>('vendorName'),
|
|
1002
|
-
|
|
1003
|
-
productName: 'ClimateSensor',
|
|
1004
|
-
productLabel: 'ClimateSensor',
|
|
1005
|
-
nodeLabel: 'ClimateSensor',
|
|
1006
|
-
|
|
1007
|
-
serialNumber: '0x145433356739',
|
|
1008
|
-
uniqueId: '0x1254446739',
|
|
1009
|
-
reachable: true,
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
log.notice(`Adding DescriptorServer to ClimateSensor`);
|
|
1013
|
-
matterbridgeDevice3.behaviors.require(DescriptorServer, {
|
|
1014
|
-
deviceTypeList: [
|
|
1015
|
-
{ deviceType: 0x0302, revision: 2 },
|
|
1016
|
-
{ deviceType: 0x0307, revision: 2 },
|
|
1017
|
-
{ deviceType: 0x0305, revision: 2 },
|
|
1018
|
-
],
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
this.log.notice(`Adding ClimateSensor to ${await storageContext.get<string>('storeId')} aggregator`);
|
|
1022
|
-
await this.matterAggregator.add(matterbridgeDevice3);
|
|
1023
|
-
logEndpoint(EndpointServer.forEndpoint(matterbridgeDevice3));
|
|
1024
|
-
*/
|
|
1025
|
-
/*
|
|
1026
|
-
await lightEndpoint1.set({
|
|
1027
|
-
onOff: {
|
|
1028
|
-
onOff: true,
|
|
1029
|
-
},
|
|
1030
|
-
});
|
|
1031
|
-
await switchEnpoint2.set({
|
|
1032
|
-
switch: {
|
|
1033
|
-
currentPosition: 1,
|
|
1034
|
-
},
|
|
1035
|
-
});
|
|
1036
|
-
switchEnpoint2.act((agent) => agent.switch.events.initialPress.emit({ newPosition: 1 }, agent.context));
|
|
1037
|
-
*/
|
|
1038
|
-
/*
|
|
1039
|
-
await matterbridgeDevice3.set({
|
|
1040
|
-
temperatureMeasurement: {
|
|
1041
|
-
measuredValue: 20 * 100,
|
|
1042
|
-
},
|
|
1043
|
-
relativeHumidityMeasurement: {
|
|
1044
|
-
measuredValue: 50 * 100,
|
|
1045
|
-
},
|
|
1046
|
-
});
|
|
1047
|
-
*/
|
|
1048
|
-
// logEndpoint(EndpointServer.forEndpoint(this.matterServerNode));
|
|
1049
|
-
/*
|
|
1050
|
-
logEndpoint(EndpointServer.forEndpoint(this.matterServerNode));
|
|
1051
|
-
logEndpoint(EndpointServer.forEndpoint(matterbridgeDevice3));
|
|
1052
|
-
console.log('matterbridgeDevice3\n', matterbridgeDevice3);
|
|
1053
|
-
console.log('matterbridgeDevice3.events\n', matterbridgeDevice3.events);
|
|
1054
|
-
console.log('matterbridgeDevice3.events.identify\n', matterbridgeDevice3.eventsOf(IdentifyServer));
|
|
1055
|
-
console.log('matterbridgeDevice3.state\n', matterbridgeDevice3.state);
|
|
1056
|
-
console.log('matterbridgeDevice3.state.temperatureMeasurement\n', matterbridgeDevice3.stateOf(TemperatureMeasurementServer));
|
|
1057
|
-
// matterbridgeDevice3.eventsOf(IdentifyServer);
|
|
1058
|
-
// matterbridgeDevice3.events.identify.startIdentifying.on(() => log.notice('Run identify logic, ideally blink a light every 0.5s ...'));
|
|
1059
|
-
}
|
|
1060
|
-
*/
|
|
1061
|
-
//# sourceMappingURL=matterbridgeEdge.js.map
|