matterbridge 1.6.8-dev.6 → 1.6.8-dev.8
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 +2 -2
- 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 -1
- package/dist/matterbridge.js +189 -812
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +1 -29
- package/dist/matterbridgeDevice.js +10 -997
- package/dist/matterbridgeDeviceTypes.js +11 -82
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEdge.js +0 -529
- package/dist/matterbridgeEndpoint.js +12 -1121
- package/dist/matterbridgePlatform.js +3 -99
- 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 +8 -253
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cluster/export.d.ts.map +0 -1
- package/dist/cluster/export.js.map +0 -1
- 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.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -473
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -116
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDevice.d.ts +0 -1142
- 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.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEdge.d.ts +0 -90
- package/dist/matterbridgeEdge.d.ts.map +0 -1
- package/dist/matterbridgeEdge.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1134
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -123
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- 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.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- 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
|
@@ -1,91 +1,32 @@
|
|
|
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
|
-
// AnsiLogger module
|
|
25
2
|
import { CYAN, nf } from 'node-ansi-logger';
|
|
26
3
|
import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
27
4
|
import { isValidArray, isValidObject } from './utils/utils.js';
|
|
28
|
-
/**
|
|
29
|
-
* Represents the base Matterbridge platform.
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
5
|
export class MatterbridgePlatform {
|
|
33
6
|
matterbridge;
|
|
34
7
|
log;
|
|
35
8
|
config = {};
|
|
36
|
-
name = '';
|
|
37
|
-
type = '';
|
|
38
|
-
version = '';
|
|
39
|
-
/**
|
|
40
|
-
* Creates an instance of the base MatterbridgePlatform.
|
|
41
|
-
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
42
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
43
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
44
|
-
*/
|
|
9
|
+
name = '';
|
|
10
|
+
type = '';
|
|
11
|
+
version = '';
|
|
45
12
|
constructor(matterbridge, log, config) {
|
|
46
13
|
this.matterbridge = matterbridge;
|
|
47
14
|
this.log = log;
|
|
48
15
|
this.config = config;
|
|
49
16
|
}
|
|
50
|
-
/**
|
|
51
|
-
* This method must be overridden in the extended class.
|
|
52
|
-
* It is called when the platform is started.
|
|
53
|
-
* Use this method to create the MatterbridgeDevice and call this.registerDevice().
|
|
54
|
-
* @param {string} [reason] - The reason for starting.
|
|
55
|
-
* @throws {Error} - Throws an error if the method is not overridden.
|
|
56
|
-
*/
|
|
57
17
|
async onStart(reason) {
|
|
58
18
|
this.log.error('Plugins must override onStart.', reason);
|
|
59
19
|
throw new Error('Plugins must override onStart.');
|
|
60
20
|
}
|
|
61
|
-
/**
|
|
62
|
-
* This method can be overridden in the extended class.
|
|
63
|
-
* It is called after the platform has been commissioned.
|
|
64
|
-
* Use this method to perform any configuration of your devices.
|
|
65
|
-
*/
|
|
66
21
|
async onConfigure() {
|
|
67
22
|
this.log.debug("The plugin doesn't override onConfigure.");
|
|
68
23
|
}
|
|
69
|
-
/**
|
|
70
|
-
* This method can be overridden in the extended class.
|
|
71
|
-
* It is called when the platform is shutting down.
|
|
72
|
-
* Use this method to clean up any resources.
|
|
73
|
-
* @param {string} [reason] - The reason for shutting down.
|
|
74
|
-
*/
|
|
75
24
|
async onShutdown(reason) {
|
|
76
25
|
this.log.debug("The plugin doesn't override onShutdown.", reason);
|
|
77
26
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
|
|
80
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
81
|
-
*/
|
|
82
27
|
async onChangeLoggerLevel(logLevel) {
|
|
83
28
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
84
29
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Registers a device with the Matterbridge platform.
|
|
87
|
-
* @param {MatterbridgeDevice} device - The device to register.
|
|
88
|
-
*/
|
|
89
30
|
async registerDevice(device) {
|
|
90
31
|
device.plugin = this.name;
|
|
91
32
|
if (device instanceof MatterbridgeDevice)
|
|
@@ -93,30 +34,18 @@ export class MatterbridgePlatform {
|
|
|
93
34
|
if (device instanceof MatterbridgeEndpoint)
|
|
94
35
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
95
36
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
98
|
-
* @param {MatterbridgeDevice} device - The device to unregister.
|
|
99
|
-
*/
|
|
100
37
|
async unregisterDevice(device) {
|
|
101
38
|
if (device instanceof MatterbridgeDevice)
|
|
102
39
|
await this.matterbridge.removeBridgedDevice(this.name, device);
|
|
103
40
|
if (device instanceof MatterbridgeEndpoint)
|
|
104
41
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
105
42
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
108
|
-
*/
|
|
109
43
|
async unregisterAllDevices() {
|
|
110
44
|
if (this.matterbridge.edge)
|
|
111
45
|
await this.matterbridge.removeAllBridgedEndpoints(this.name);
|
|
112
46
|
else
|
|
113
47
|
await this.matterbridge.removeAllBridgedDevices(this.name);
|
|
114
48
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Verifies if the Matterbridge version meets the required version.
|
|
117
|
-
* @param {string} requiredVersion - The required version to compare against.
|
|
118
|
-
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
119
|
-
*/
|
|
120
49
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
121
50
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
122
51
|
const stripTag = (v) => {
|
|
@@ -141,14 +70,6 @@ export class MatterbridgePlatform {
|
|
|
141
70
|
return false;
|
|
142
71
|
return true;
|
|
143
72
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Validates if a device is allowed based on the whitelist and blacklist configurations.
|
|
146
|
-
* The blacklist has priority over the whitelist.
|
|
147
|
-
*
|
|
148
|
-
* @param {string | string[]} device - The device name(s) to validate.
|
|
149
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
150
|
-
* @returns {boolean} - Returns true if the device is allowed, false otherwise.
|
|
151
|
-
*/
|
|
152
73
|
validateDeviceWhiteBlackList(device, log = true) {
|
|
153
74
|
if (!Array.isArray(device))
|
|
154
75
|
device = [device];
|
|
@@ -178,25 +99,9 @@ export class MatterbridgePlatform {
|
|
|
178
99
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
179
100
|
return false;
|
|
180
101
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Validates if an entity is allowed based on the entity whitelist and blacklist and the device-entity blacklist configurations.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} device - The device to which the entity belongs.
|
|
185
|
-
* @param {string} entity - The entity to validate.
|
|
186
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
187
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
188
|
-
*/
|
|
189
102
|
validateEntity(device, entity, log = true) {
|
|
190
103
|
return this.validateEntityBlackList(device, entity, log);
|
|
191
104
|
}
|
|
192
|
-
/**
|
|
193
|
-
* Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
|
|
194
|
-
*
|
|
195
|
-
* @param {string} device - The device to which the entity belongs.
|
|
196
|
-
* @param {string} entity - The entity to validate.
|
|
197
|
-
* @param {boolean} [log=true] - Whether to log the validation result.
|
|
198
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
199
|
-
*/
|
|
200
105
|
validateEntityBlackList(device, entity, log = true) {
|
|
201
106
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
202
107
|
if (log)
|
|
@@ -216,4 +121,3 @@ export class MatterbridgePlatform {
|
|
|
216
121
|
return true;
|
|
217
122
|
}
|
|
218
123
|
}
|
|
219
|
-
//# 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 } from 'node-ansi-logger';
|
|
26
|
-
// @matter
|
|
27
3
|
import { 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 {
|
|
@@ -188,4 +144,3 @@ export async function wsMessageHandler(client, message) {
|
|
|
188
144
|
return;
|
|
189
145
|
}
|
|
190
146
|
}
|
|
191
|
-
//# sourceMappingURL=matterbridgeWebsocket.js.map
|