matterbridge 1.7.0 → 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.
Files changed (106) hide show
  1. package/CHANGELOG.md +52 -9
  2. package/README-EDGE.md +4 -6
  3. package/README-SERVICE.md +2 -2
  4. package/dist/cli.js +0 -26
  5. package/dist/cluster/export.js +0 -2
  6. package/dist/defaultConfigSchema.js +0 -23
  7. package/dist/deviceManager.js +1 -26
  8. package/dist/index.js +0 -30
  9. package/dist/logger/export.js +0 -1
  10. package/dist/matter/export.js +0 -4
  11. package/dist/matterbridge.js +61 -707
  12. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  13. package/dist/matterbridgeBehaviors.js +1 -29
  14. package/dist/matterbridgeDevice.js +9 -996
  15. package/dist/matterbridgeDeviceTypes.js +11 -82
  16. package/dist/matterbridgeDynamicPlatform.js +0 -33
  17. package/dist/matterbridgeEdge.js +0 -530
  18. package/dist/matterbridgeEndpoint.js +14 -1121
  19. package/dist/matterbridgePlatform.js +8 -112
  20. package/dist/matterbridgeTypes.js +0 -24
  21. package/dist/matterbridgeWebsocket.js +60 -49
  22. package/dist/pluginManager.js +3 -238
  23. package/dist/storage/export.js +0 -1
  24. package/dist/utils/colorUtils.js +2 -205
  25. package/dist/utils/export.js +0 -1
  26. package/dist/utils/utils.js +7 -252
  27. package/frontend/build/asset-manifest.json +6 -6
  28. package/frontend/build/index.html +1 -1
  29. package/frontend/build/static/css/{main.f1fce054.css → main.b1a621ee.css} +2 -2
  30. package/frontend/build/static/css/main.b1a621ee.css.map +1 -0
  31. package/frontend/build/static/js/{main.5caad8c7.js → main.0cc31fc9.js} +10 -10
  32. package/frontend/build/static/js/main.0cc31fc9.js.map +1 -0
  33. package/npm-shrinkwrap.json +8 -8
  34. package/package.json +1 -2
  35. package/dist/cli.d.ts +0 -25
  36. package/dist/cli.d.ts.map +0 -1
  37. package/dist/cli.js.map +0 -1
  38. package/dist/cluster/export.d.ts +0 -2
  39. package/dist/cluster/export.d.ts.map +0 -1
  40. package/dist/cluster/export.js.map +0 -1
  41. package/dist/defaultConfigSchema.d.ts +0 -27
  42. package/dist/defaultConfigSchema.d.ts.map +0 -1
  43. package/dist/defaultConfigSchema.js.map +0 -1
  44. package/dist/deviceManager.d.ts +0 -46
  45. package/dist/deviceManager.d.ts.map +0 -1
  46. package/dist/deviceManager.js.map +0 -1
  47. package/dist/index.d.ts +0 -40
  48. package/dist/index.d.ts.map +0 -1
  49. package/dist/index.js.map +0 -1
  50. package/dist/logger/export.d.ts +0 -2
  51. package/dist/logger/export.d.ts.map +0 -1
  52. package/dist/logger/export.js.map +0 -1
  53. package/dist/matter/export.d.ts +0 -11
  54. package/dist/matter/export.d.ts.map +0 -1
  55. package/dist/matter/export.js.map +0 -1
  56. package/dist/matterbridge.d.ts +0 -483
  57. package/dist/matterbridge.d.ts.map +0 -1
  58. package/dist/matterbridge.js.map +0 -1
  59. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  60. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  61. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  62. package/dist/matterbridgeBehaviors.d.ts +0 -942
  63. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  64. package/dist/matterbridgeBehaviors.js.map +0 -1
  65. package/dist/matterbridgeDevice.d.ts +0 -7077
  66. package/dist/matterbridgeDevice.d.ts.map +0 -1
  67. package/dist/matterbridgeDevice.js.map +0 -1
  68. package/dist/matterbridgeDeviceTypes.d.ts +0 -109
  69. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  70. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  71. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  72. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  73. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  74. package/dist/matterbridgeEdge.d.ts +0 -91
  75. package/dist/matterbridgeEdge.d.ts.map +0 -1
  76. package/dist/matterbridgeEdge.js.map +0 -1
  77. package/dist/matterbridgeEndpoint.d.ts +0 -10151
  78. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  79. package/dist/matterbridgeEndpoint.js.map +0 -1
  80. package/dist/matterbridgePlatform.d.ts +0 -140
  81. package/dist/matterbridgePlatform.d.ts.map +0 -1
  82. package/dist/matterbridgePlatform.js.map +0 -1
  83. package/dist/matterbridgeTypes.d.ts +0 -169
  84. package/dist/matterbridgeTypes.d.ts.map +0 -1
  85. package/dist/matterbridgeTypes.js.map +0 -1
  86. package/dist/matterbridgeWebsocket.d.ts +0 -49
  87. package/dist/matterbridgeWebsocket.d.ts.map +0 -1
  88. package/dist/matterbridgeWebsocket.js.map +0 -1
  89. package/dist/pluginManager.d.ts +0 -238
  90. package/dist/pluginManager.d.ts.map +0 -1
  91. package/dist/pluginManager.js.map +0 -1
  92. package/dist/storage/export.d.ts +0 -2
  93. package/dist/storage/export.d.ts.map +0 -1
  94. package/dist/storage/export.js.map +0 -1
  95. package/dist/utils/colorUtils.d.ts +0 -61
  96. package/dist/utils/colorUtils.d.ts.map +0 -1
  97. package/dist/utils/colorUtils.js.map +0 -1
  98. package/dist/utils/export.d.ts +0 -3
  99. package/dist/utils/export.d.ts.map +0 -1
  100. package/dist/utils/export.js.map +0 -1
  101. package/dist/utils/utils.d.ts +0 -221
  102. package/dist/utils/utils.d.ts.map +0 -1
  103. package/dist/utils/utils.js.map +0 -1
  104. package/frontend/build/static/css/main.f1fce054.css.map +0 -1
  105. package/frontend/build/static/js/main.5caad8c7.js.map +0 -1
  106. /package/frontend/build/static/js/{main.5caad8c7.js.LICENSE.txt → main.0cc31fc9.js.LICENSE.txt} +0 -0
@@ -1,58 +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 = ''; // Will be set by the loadPlugin() method using the package.json value.
41
- type = ''; // Will be set by the extending classes.
42
- version = ''; // Will be set by the loadPlugin() method using the package.json value.
11
+ name = '';
12
+ type = '';
13
+ version = '';
43
14
  storage;
44
15
  context;
45
- /**
46
- * Creates an instance of the base MatterbridgePlatform.
47
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
48
- * @param {AnsiLogger} log - The logger instance.
49
- * @param {PlatformConfig} config - The platform configuration.
50
- */
16
+ selectDevice = new Map();
17
+ selectEntity = new Map();
51
18
  constructor(matterbridge, log, config) {
52
19
  this.matterbridge = matterbridge;
53
20
  this.log = log;
54
21
  this.config = config;
55
- // create the NodeStorageManager for the plugin platform
56
22
  if (!isValidString(this.config.name))
57
23
  return;
58
24
  this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
@@ -64,47 +30,21 @@ export class MatterbridgePlatform {
64
30
  forgiveParseErrors: true,
65
31
  });
66
32
  }
67
- /**
68
- * This method must be overridden in the extended class.
69
- * It is called when the platform is started.
70
- * Use this method to create the MatterbridgeDevice and call this.registerDevice().
71
- * @param {string} [reason] - The reason for starting.
72
- * @throws {Error} - Throws an error if the method is not overridden.
73
- */
74
33
  async onStart(reason) {
75
34
  this.log.error('Plugins must override onStart.', reason);
76
35
  throw new Error('Plugins must override onStart.');
77
36
  }
78
- /**
79
- * This method can be overridden in the extended class.
80
- * It is called after the platform has been commissioned.
81
- * Use this method to perform any configuration of your devices.
82
- */
83
37
  async onConfigure() {
84
38
  this.log.debug(`Configuring platform ${this.name}`);
85
39
  await this.checkEndpointNumbers();
86
40
  }
87
- /**
88
- * This method can be overridden in the extended class.
89
- * It is called when the platform is shutting down.
90
- * Use this method to clean up any resources.
91
- * @param {string} [reason] - The reason for shutting down.
92
- */
93
41
  async onShutdown(reason) {
94
42
  this.log.debug(`Shutting down platform ${this.name}`, reason);
95
43
  await this.checkEndpointNumbers();
96
44
  }
97
- /**
98
- * Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
99
- * @param {LogLevel} logLevel The new logger level.
100
- */
101
45
  async onChangeLoggerLevel(logLevel) {
102
46
  this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
103
47
  }
104
- /**
105
- * Registers a device with the Matterbridge platform.
106
- * @param {MatterbridgeDevice} device - The device to register.
107
- */
108
48
  async registerDevice(device) {
109
49
  device.plugin = this.name;
110
50
  if (device instanceof MatterbridgeDevice)
@@ -112,30 +52,18 @@ export class MatterbridgePlatform {
112
52
  if (device instanceof MatterbridgeEndpoint)
113
53
  await this.matterbridge.addBridgedEndpoint(this.name, device);
114
54
  }
115
- /**
116
- * Unregisters a device registered with the Matterbridge platform.
117
- * @param {MatterbridgeDevice} device - The device to unregister.
118
- */
119
55
  async unregisterDevice(device) {
120
56
  if (device instanceof MatterbridgeDevice)
121
57
  await this.matterbridge.removeBridgedDevice(this.name, device);
122
58
  if (device instanceof MatterbridgeEndpoint)
123
59
  await this.matterbridge.removeBridgedEndpoint(this.name, device);
124
60
  }
125
- /**
126
- * Unregisters all devices registered with the Matterbridge platform.
127
- */
128
61
  async unregisterAllDevices() {
129
62
  if (this.matterbridge.edge)
130
63
  await this.matterbridge.removeAllBridgedEndpoints(this.name);
131
64
  else
132
65
  await this.matterbridge.removeAllBridgedDevices(this.name);
133
66
  }
134
- /**
135
- * Verifies if the Matterbridge version meets the required version.
136
- * @param {string} requiredVersion - The required version to compare against.
137
- * @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
138
- */
139
67
  verifyMatterbridgeVersion(requiredVersion) {
140
68
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
141
69
  const stripTag = (v) => {
@@ -160,14 +88,9 @@ export class MatterbridgePlatform {
160
88
  return false;
161
89
  return true;
162
90
  }
163
- /**
164
- * Validates if a device is allowed based on the whitelist and blacklist configurations.
165
- * The blacklist has priority over the whitelist.
166
- *
167
- * @param {string | string[]} device - The device name(s) to validate.
168
- * @param {boolean} [log=true] - Whether to log the validation result.
169
- * @returns {boolean} - Returns true if the device is allowed, false otherwise.
170
- */
91
+ validateDevice(device, log = true) {
92
+ return this.validateDeviceWhiteBlackList(device, log);
93
+ }
171
94
  validateDeviceWhiteBlackList(device, log = true) {
172
95
  if (!Array.isArray(device))
173
96
  device = [device];
@@ -197,25 +120,9 @@ export class MatterbridgePlatform {
197
120
  this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
198
121
  return false;
199
122
  }
200
- /**
201
- * Validates if an entity is allowed based on the entity whitelist and blacklist and the device-entity blacklist configurations.
202
- *
203
- * @param {string} device - The device to which the entity belongs.
204
- * @param {string} entity - The entity to validate.
205
- * @param {boolean} [log=true] - Whether to log the validation result.
206
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
207
- */
208
123
  validateEntity(device, entity, log = true) {
209
124
  return this.validateEntityBlackList(device, entity, log);
210
125
  }
211
- /**
212
- * Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
213
- *
214
- * @param {string} device - The device to which the entity belongs.
215
- * @param {string} entity - The entity to validate.
216
- * @param {boolean} [log=true] - Whether to log the validation result.
217
- * @returns {boolean} - Returns true if the entity is allowed, false otherwise.
218
- */
219
126
  validateEntityBlackList(device, entity, log = true) {
220
127
  if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
221
128
  if (log)
@@ -234,15 +141,6 @@ export class MatterbridgePlatform {
234
141
  }
235
142
  return true;
236
143
  }
237
- /**
238
- * Checks and updates the endpoint numbers for Matterbridge devices.
239
- *
240
- * This method retrieves the list of Matterbridge devices and their child endpoints,
241
- * compares their current endpoint numbers with the stored ones, and updates the storage
242
- * if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
243
- *
244
- * @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
245
- */
246
144
  async checkEndpointNumbers() {
247
145
  if (!this.storage)
248
146
  return -1;
@@ -281,7 +179,6 @@ export class MatterbridgePlatform {
281
179
  this.log.debug('Endpoint numbers check completed.');
282
180
  return endpointMap.size;
283
181
  }
284
- // Temporary method to create a MatterbridgeDevice before switching to the edge
285
182
  async _createMutableDevice(definition, options = {}, debug = false) {
286
183
  let device;
287
184
  if (this.matterbridge.edge === true) {
@@ -292,4 +189,3 @@ export class MatterbridgePlatform {
292
189
  return device;
293
190
  }
294
191
  }
295
- //# 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 {
@@ -187,11 +143,17 @@ export async function wsMessageHandler(client, message) {
187
143
  return;
188
144
  }
189
145
  const clusters = [];
146
+ let deviceName = '';
147
+ let serialNumber = '';
148
+ let deviceTypes = [];
190
149
  this.devices.forEach(async (device) => {
191
150
  if (data.params.plugin !== device.plugin)
192
151
  return;
193
152
  if (data.params.endpoint !== device.number)
194
153
  return;
154
+ deviceName = device.deviceName ?? 'Unknown';
155
+ serialNumber = device.serialNumber ?? 'Unknown';
156
+ deviceTypes = [];
195
157
  if (this.edge)
196
158
  device = EndpointServer.forEndpoint(device);
197
159
  const clusterServers = device.getAllClusterServers();
@@ -199,59 +161,109 @@ export async function wsMessageHandler(client, message) {
199
161
  Object.entries(clusterServer.attributes).forEach(([key, value]) => {
200
162
  if (clusterServer.name === 'EveHistory')
201
163
  return;
164
+ if (clusterServer.name === 'Descriptor' && key === 'deviceTypeList') {
165
+ value.getLocal().forEach((deviceType) => {
166
+ deviceTypes.push(deviceType.deviceType);
167
+ });
168
+ }
202
169
  let attributeValue;
170
+ let attributeLocalValue;
203
171
  try {
204
172
  if (typeof value.getLocal() === 'object')
205
173
  attributeValue = stringify(value.getLocal());
206
174
  else
207
175
  attributeValue = value.getLocal().toString();
176
+ attributeLocalValue = value.getLocal();
208
177
  }
209
178
  catch (error) {
210
179
  attributeValue = 'Fabric-Scoped';
180
+ attributeLocalValue = 'Fabric-Scoped';
211
181
  this.log.debug(`GetLocal value ${error} in clusterServer: ${clusterServer.name}(${clusterServer.id}) attribute: ${key}(${value.id})`);
212
182
  }
213
183
  clusters.push({
214
184
  endpoint: device.number ? device.number.toString() : '...',
185
+ id: 'main',
186
+ deviceTypes,
215
187
  clusterName: clusterServer.name,
216
188
  clusterId: '0x' + clusterServer.id.toString(16).padStart(2, '0'),
217
189
  attributeName: key,
218
190
  attributeId: '0x' + value.id.toString(16).padStart(2, '0'),
219
191
  attributeValue,
192
+ attributeLocalValue,
220
193
  });
221
194
  });
222
195
  });
223
196
  device.getChildEndpoints().forEach((childEndpoint) => {
224
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
197
+ deviceTypes = [];
225
198
  const name = this.edge ? childEndpoint.endpoint?.id : childEndpoint.uniqueStorageKey;
226
199
  const clusterServers = childEndpoint.getAllClusterServers();
227
200
  clusterServers.forEach((clusterServer) => {
228
201
  Object.entries(clusterServer.attributes).forEach(([key, value]) => {
229
202
  if (clusterServer.name === 'EveHistory')
230
203
  return;
204
+ if (clusterServer.name === 'Descriptor' && key === 'deviceTypeList') {
205
+ value.getLocal().forEach((deviceType) => {
206
+ deviceTypes.push(deviceType.deviceType);
207
+ });
208
+ }
231
209
  let attributeValue;
210
+ let attributeLocalValue;
232
211
  try {
233
212
  if (typeof value.getLocal() === 'object')
234
213
  attributeValue = stringify(value.getLocal());
235
214
  else
236
215
  attributeValue = value.getLocal().toString();
216
+ attributeLocalValue = value.getLocal();
237
217
  }
238
218
  catch (error) {
239
- attributeValue = 'Unavailable';
219
+ attributeValue = 'Fabric-Scoped';
220
+ attributeLocalValue = 'Fabric-Scoped';
240
221
  this.log.debug(`GetLocal error ${error} in clusterServer: ${clusterServer.name}(${clusterServer.id}) attribute: ${key}(${value.id})`);
241
222
  }
242
223
  clusters.push({
243
- endpoint: (childEndpoint.number ? childEndpoint.number.toString() : '...') + (name ? ' (' + name + ')' : ''),
224
+ endpoint: childEndpoint.number ? childEndpoint.number.toString() : '...',
225
+ id: name,
226
+ deviceTypes,
244
227
  clusterName: clusterServer.name,
245
228
  clusterId: '0x' + clusterServer.id.toString(16).padStart(2, '0'),
246
229
  attributeName: key,
247
230
  attributeId: '0x' + value.id.toString(16).padStart(2, '0'),
248
231
  attributeValue,
232
+ attributeLocalValue,
249
233
  });
250
234
  });
251
235
  });
252
236
  });
253
237
  });
254
- client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, response: clusters }));
238
+ client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, plugin: data.params.plugin, deviceName, serialNumber, endpoint: data.params.endpoint, deviceTypes, response: clusters }));
239
+ return;
240
+ }
241
+ else if (data.method === '/api/select') {
242
+ if (!isValidString(data.params.plugin, 10)) {
243
+ client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Wrong parameter plugin in /api/select' }));
244
+ return;
245
+ }
246
+ const plugin = this.plugins.get(data.params.plugin);
247
+ if (!plugin) {
248
+ client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, error: 'Plugin not found in /api/select' }));
249
+ return;
250
+ }
251
+ const selectDeviceValues = plugin.platform?.selectDevice ? Array.from(plugin.platform.selectDevice.values()).sort((keyA, keyB) => keyA.name.localeCompare(keyB.name)) : [];
252
+ client.send(JSON.stringify({ id: data.id, method: data.method, src: 'Matterbridge', dst: data.src, plugin: data.params.plugin, response: selectDeviceValues }));
253
+ return;
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 }));
255
267
  return;
256
268
  }
257
269
  else {
@@ -265,4 +277,3 @@ export async function wsMessageHandler(client, message) {
265
277
  return;
266
278
  }
267
279
  }
268
- //# sourceMappingURL=matterbridgeWebsocket.js.map