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
|
@@ -1,59 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the class MatterbridgeAccessoryPlatform.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgePlatform.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2024-03-21
|
|
7
|
-
* @version 1.1.0
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
1
|
import { MatterbridgeDevice } from './matterbridgeDevice.js';
|
|
24
2
|
import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
25
3
|
import { isValidArray, isValidObject, isValidString } from './utils/utils.js';
|
|
26
|
-
// AnsiLogger module
|
|
27
4
|
import { CYAN, db, nf, wr } from 'node-ansi-logger';
|
|
28
|
-
// Storage module
|
|
29
5
|
import { NodeStorageManager } from 'node-persist-manager';
|
|
30
|
-
// Node.js module
|
|
31
6
|
import path from 'path';
|
|
32
|
-
/**
|
|
33
|
-
* Represents the base Matterbridge platform.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
7
|
export class MatterbridgePlatform {
|
|
37
8
|
matterbridge;
|
|
38
9
|
log;
|
|
39
10
|
config = {};
|
|
40
|
-
name = '';
|
|
41
|
-
type = '';
|
|
42
|
-
version = '';
|
|
11
|
+
name = '';
|
|
12
|
+
type = '';
|
|
13
|
+
version = '';
|
|
43
14
|
storage;
|
|
44
15
|
context;
|
|
45
16
|
selectDevice = new Map();
|
|
46
|
-
|
|
47
|
-
* Creates an instance of the base MatterbridgePlatform.
|
|
48
|
-
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
49
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
50
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
51
|
-
*/
|
|
17
|
+
selectEntity = new Map();
|
|
52
18
|
constructor(matterbridge, log, config) {
|
|
53
19
|
this.matterbridge = matterbridge;
|
|
54
20
|
this.log = log;
|
|
55
21
|
this.config = config;
|
|
56
|
-
// create the NodeStorageManager for the plugin platform
|
|
57
22
|
if (!isValidString(this.config.name))
|
|
58
23
|
return;
|
|
59
24
|
this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
|
|
@@ -65,47 +30,21 @@ export class MatterbridgePlatform {
|
|
|
65
30
|
forgiveParseErrors: true,
|
|
66
31
|
});
|
|
67
32
|
}
|
|
68
|
-
/**
|
|
69
|
-
* This method must be overridden in the extended class.
|
|
70
|
-
* It is called when the platform is started.
|
|
71
|
-
* Use this method to create the MatterbridgeDevice and call this.registerDevice().
|
|
72
|
-
* @param {string} [reason] - The reason for starting.
|
|
73
|
-
* @throws {Error} - Throws an error if the method is not overridden.
|
|
74
|
-
*/
|
|
75
33
|
async onStart(reason) {
|
|
76
34
|
this.log.error('Plugins must override onStart.', reason);
|
|
77
35
|
throw new Error('Plugins must override onStart.');
|
|
78
36
|
}
|
|
79
|
-
/**
|
|
80
|
-
* This method can be overridden in the extended class.
|
|
81
|
-
* It is called after the platform has been commissioned.
|
|
82
|
-
* Use this method to perform any configuration of your devices.
|
|
83
|
-
*/
|
|
84
37
|
async onConfigure() {
|
|
85
38
|
this.log.debug(`Configuring platform ${this.name}`);
|
|
86
39
|
await this.checkEndpointNumbers();
|
|
87
40
|
}
|
|
88
|
-
/**
|
|
89
|
-
* This method can be overridden in the extended class.
|
|
90
|
-
* It is called when the platform is shutting down.
|
|
91
|
-
* Use this method to clean up any resources.
|
|
92
|
-
* @param {string} [reason] - The reason for shutting down.
|
|
93
|
-
*/
|
|
94
41
|
async onShutdown(reason) {
|
|
95
42
|
this.log.debug(`Shutting down platform ${this.name}`, reason);
|
|
96
43
|
await this.checkEndpointNumbers();
|
|
97
44
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
|
|
100
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
101
|
-
*/
|
|
102
45
|
async onChangeLoggerLevel(logLevel) {
|
|
103
46
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
104
47
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Registers a device with the Matterbridge platform.
|
|
107
|
-
* @param {MatterbridgeDevice} device - The device to register.
|
|
108
|
-
*/
|
|
109
48
|
async registerDevice(device) {
|
|
110
49
|
device.plugin = this.name;
|
|
111
50
|
if (device instanceof MatterbridgeDevice)
|
|
@@ -113,30 +52,18 @@ export class MatterbridgePlatform {
|
|
|
113
52
|
if (device instanceof MatterbridgeEndpoint)
|
|
114
53
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
115
54
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
118
|
-
* @param {MatterbridgeDevice} device - The device to unregister.
|
|
119
|
-
*/
|
|
120
55
|
async unregisterDevice(device) {
|
|
121
56
|
if (device instanceof MatterbridgeDevice)
|
|
122
57
|
await this.matterbridge.removeBridgedDevice(this.name, device);
|
|
123
58
|
if (device instanceof MatterbridgeEndpoint)
|
|
124
59
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
125
60
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
128
|
-
*/
|
|
129
61
|
async unregisterAllDevices() {
|
|
130
62
|
if (this.matterbridge.edge)
|
|
131
63
|
await this.matterbridge.removeAllBridgedEndpoints(this.name);
|
|
132
64
|
else
|
|
133
65
|
await this.matterbridge.removeAllBridgedDevices(this.name);
|
|
134
66
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Verifies if the Matterbridge version meets the required version.
|
|
137
|
-
* @param {string} requiredVersion - The required version to compare against.
|
|
138
|
-
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
139
|
-
*/
|
|
140
67
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
141
68
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
142
69
|
const stripTag = (v) => {
|
|
@@ -161,14 +88,9 @@ export class MatterbridgePlatform {
|
|
|
161
88
|
return false;
|
|
162
89
|
return true;
|
|
163
90
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
*
|
|
168
|
-
* @param {string | string[]} device - The device name(s) to validate.
|
|
169
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
170
|
-
* @returns {boolean} - Returns true if the device is allowed, false otherwise.
|
|
171
|
-
*/
|
|
91
|
+
validateDevice(device, log = true) {
|
|
92
|
+
return this.validateDeviceWhiteBlackList(device, log);
|
|
93
|
+
}
|
|
172
94
|
validateDeviceWhiteBlackList(device, log = true) {
|
|
173
95
|
if (!Array.isArray(device))
|
|
174
96
|
device = [device];
|
|
@@ -198,25 +120,9 @@ export class MatterbridgePlatform {
|
|
|
198
120
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
199
121
|
return false;
|
|
200
122
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Validates if an entity is allowed based on the entity whitelist and blacklist and the device-entity blacklist configurations.
|
|
203
|
-
*
|
|
204
|
-
* @param {string} device - The device to which the entity belongs.
|
|
205
|
-
* @param {string} entity - The entity to validate.
|
|
206
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
207
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
208
|
-
*/
|
|
209
123
|
validateEntity(device, entity, log = true) {
|
|
210
124
|
return this.validateEntityBlackList(device, entity, log);
|
|
211
125
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
|
|
214
|
-
*
|
|
215
|
-
* @param {string} device - The device to which the entity belongs.
|
|
216
|
-
* @param {string} entity - The entity to validate.
|
|
217
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
218
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
219
|
-
*/
|
|
220
126
|
validateEntityBlackList(device, entity, log = true) {
|
|
221
127
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
222
128
|
if (log)
|
|
@@ -235,15 +141,6 @@ export class MatterbridgePlatform {
|
|
|
235
141
|
}
|
|
236
142
|
return true;
|
|
237
143
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Checks and updates the endpoint numbers for Matterbridge devices.
|
|
240
|
-
*
|
|
241
|
-
* This method retrieves the list of Matterbridge devices and their child endpoints,
|
|
242
|
-
* compares their current endpoint numbers with the stored ones, and updates the storage
|
|
243
|
-
* if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
|
|
244
|
-
*
|
|
245
|
-
* @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
|
|
246
|
-
*/
|
|
247
144
|
async checkEndpointNumbers() {
|
|
248
145
|
if (!this.storage)
|
|
249
146
|
return -1;
|
|
@@ -282,7 +179,6 @@ export class MatterbridgePlatform {
|
|
|
282
179
|
this.log.debug('Endpoint numbers check completed.');
|
|
283
180
|
return endpointMap.size;
|
|
284
181
|
}
|
|
285
|
-
// Temporary method to create a MatterbridgeDevice before switching to the edge
|
|
286
182
|
async _createMutableDevice(definition, options = {}, debug = false) {
|
|
287
183
|
let device;
|
|
288
184
|
if (this.matterbridge.edge === true) {
|
|
@@ -293,4 +189,3 @@ export class MatterbridgePlatform {
|
|
|
293
189
|
return device;
|
|
294
190
|
}
|
|
295
191
|
}
|
|
296
|
-
//# sourceMappingURL=matterbridgePlatform.js.map
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the types for Matterbridge.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeTypes.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2024-07-12
|
|
7
|
-
* @version 1.0.2
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2023, 2024, 2025 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
|
-
// Default colors
|
|
24
1
|
export const plg = '\u001B[38;5;33m';
|
|
25
2
|
export const dev = '\u001B[38;5;79m';
|
|
26
3
|
export const typ = '\u001B[38;5;207m';
|
|
27
|
-
//# sourceMappingURL=matterbridgeTypes.js.map
|
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the function matterbridgeMessageHandler.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeWebsocket.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @date 2024-10-16
|
|
7
|
-
* @version 1.0.0
|
|
8
|
-
*
|
|
9
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
10
|
-
*
|
|
11
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
-
* you may not use this file except in compliance with the License.
|
|
13
|
-
* You may obtain a copy of the License at
|
|
14
|
-
*
|
|
15
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
-
* See the License for the specific language governing permissions and
|
|
21
|
-
* limitations under the License. *
|
|
22
|
-
*/
|
|
23
1
|
import { isValidNumber, isValidObject, isValidString } from './utils/utils.js';
|
|
24
|
-
// AnsiLogger module
|
|
25
2
|
import { debugStringify, stringify } from 'node-ansi-logger';
|
|
26
|
-
// @matter
|
|
27
3
|
import { EndpointServer, Logger } from '@matter/main';
|
|
28
4
|
import { BasicInformationCluster, BridgedDeviceBasicInformationCluster } from '@matter/main/clusters';
|
|
29
|
-
/**
|
|
30
|
-
* Websocket message ID for logging.
|
|
31
|
-
* @constant {number}
|
|
32
|
-
*/
|
|
33
5
|
export const WS_ID_LOG = 0;
|
|
34
|
-
/**
|
|
35
|
-
* Websocket message ID indicating a refresh is needed.
|
|
36
|
-
* @constant {number}
|
|
37
|
-
*/
|
|
38
6
|
export const WS_ID_REFRESH_NEEDED = 1;
|
|
39
|
-
/**
|
|
40
|
-
* Websocket message ID indicating a restart is needed.
|
|
41
|
-
* @constant {number}
|
|
42
|
-
*/
|
|
43
7
|
export const WS_ID_RESTART_NEEDED = 2;
|
|
44
|
-
/**
|
|
45
|
-
* Handles incoming websocket messages for the Matterbridge.
|
|
46
|
-
*
|
|
47
|
-
* @param {Matterbridge} this - The Matterbridge instance.
|
|
48
|
-
* @param {WebSocket} client - The websocket client that sent the message.
|
|
49
|
-
* @param {WebSocket.RawData} message - The raw data of the message received from the client.
|
|
50
|
-
* @returns {Promise<void>} A promise that resolves when the message has been handled.
|
|
51
|
-
*/
|
|
52
8
|
export async function wsMessageHandler(client, message) {
|
|
53
9
|
let data;
|
|
54
10
|
try {
|
|
@@ -239,7 +195,6 @@ export async function wsMessageHandler(client, message) {
|
|
|
239
195
|
});
|
|
240
196
|
device.getChildEndpoints().forEach((childEndpoint) => {
|
|
241
197
|
deviceTypes = [];
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
243
198
|
const name = this.edge ? childEndpoint.endpoint?.id : childEndpoint.uniqueStorageKey;
|
|
244
199
|
const clusterServers = childEndpoint.getAllClusterServers();
|
|
245
200
|
clusterServers.forEach((clusterServer) => {
|
|
@@ -297,6 +252,20 @@ export async function wsMessageHandler(client, message) {
|
|
|
297
252
|
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, plugin: data.params.plugin, response: selectDeviceValues }));
|
|
298
253
|
return;
|
|
299
254
|
}
|
|
255
|
+
else if (data.method === '/api/select/entities') {
|
|
256
|
+
if (!isValidString(data.params.plugin, 10)) {
|
|
257
|
+
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select/entities' }));
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const plugin = this.plugins.get(data.params.plugin);
|
|
261
|
+
if (!plugin) {
|
|
262
|
+
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select/entities' }));
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const selectEntityValues = plugin.platform?.selectDevice ? Array.from(plugin.platform.selectEntity.values()).sort((keyA, keyB) => keyA.name.localeCompare(keyB.name)) : [];
|
|
266
|
+
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, plugin: data.params.plugin, response: selectEntityValues }));
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
300
269
|
else {
|
|
301
270
|
this.log.error(`Invalid method from websocket client: ${debugStringify(data)}`);
|
|
302
271
|
client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Invalid method' }));
|
|
@@ -308,4 +277,3 @@ export async function wsMessageHandler(client, message) {
|
|
|
308
277
|
return;
|
|
309
278
|
}
|
|
310
279
|
}
|
|
311
|
-
//# sourceMappingURL=matterbridgeWebsocket.js.map
|