matterbridge 1.6.5 → 1.6.6-dev.2
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 +11 -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 -1
- package/dist/matterbridge.js +62 -702
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +1 -29
- package/dist/matterbridgeDevice.js +39 -933
- package/dist/matterbridgeDeviceTypes.js +21 -41
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEdge.js +0 -525
- package/dist/matterbridgeEndpoint.js +61 -1027
- package/dist/matterbridgePlatform.js +3 -74
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/matterbridgeWebsocket.js +0 -45
- package/dist/pluginManager.js +3 -237
- package/dist/storage/export.js +0 -1
- package/dist/utils/colorUtils.js +2 -78
- package/dist/utils/export.js +0 -1
- package/dist/utils/utils.js +7 -252
- package/npm-shrinkwrap.json +12 -15
- package/package.json +2 -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 -5
- 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 -934
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDevice.d.ts +0 -6504
- package/dist/matterbridgeDevice.d.ts.map +0 -1
- package/dist/matterbridgeDevice.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -65
- 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 -89
- package/dist/matterbridgeEdge.d.ts.map +0 -1
- package/dist/matterbridgeEdge.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -8529
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -96
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -147
- 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
|
@@ -1,88 +1,30 @@
|
|
|
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.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 { MatterbridgeDevice } from './matterbridgeDevice.js';
|
|
24
2
|
import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
25
|
-
/**
|
|
26
|
-
* Represents the base Matterbridge platform.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
3
|
export class MatterbridgePlatform {
|
|
30
4
|
matterbridge;
|
|
31
5
|
log;
|
|
32
6
|
config = {};
|
|
33
|
-
name = '';
|
|
34
|
-
type = '';
|
|
35
|
-
version = '';
|
|
36
|
-
/**
|
|
37
|
-
* Creates an instance of the base MatterbridgePlatform.
|
|
38
|
-
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
39
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
40
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
41
|
-
*/
|
|
7
|
+
name = '';
|
|
8
|
+
type = '';
|
|
9
|
+
version = '';
|
|
42
10
|
constructor(matterbridge, log, config) {
|
|
43
11
|
this.matterbridge = matterbridge;
|
|
44
12
|
this.log = log;
|
|
45
13
|
this.config = config;
|
|
46
14
|
}
|
|
47
|
-
/**
|
|
48
|
-
* This method must be overridden in the extended class.
|
|
49
|
-
* It is called when the platform is started.
|
|
50
|
-
* Use this method to create the MatterbridgeDevice and call this.registerDevice().
|
|
51
|
-
* @param {string} [reason] - The reason for starting.
|
|
52
|
-
* @throws {Error} - Throws an error if the method is not overridden.
|
|
53
|
-
*/
|
|
54
15
|
async onStart(reason) {
|
|
55
16
|
this.log.error('Plugins must override onStart.', reason);
|
|
56
17
|
throw new Error('Plugins must override onStart.');
|
|
57
18
|
}
|
|
58
|
-
/**
|
|
59
|
-
* This method can be overridden in the extended class.
|
|
60
|
-
* It is called after the platform has been commissioned.
|
|
61
|
-
* Use this method to perform any configuration of your devices.
|
|
62
|
-
*/
|
|
63
19
|
async onConfigure() {
|
|
64
20
|
this.log.debug("The plugin doesn't override onConfigure.");
|
|
65
21
|
}
|
|
66
|
-
/**
|
|
67
|
-
* This method can be overridden in the extended class.
|
|
68
|
-
* It is called when the platform is shutting down.
|
|
69
|
-
* Use this method to clean up any resources.
|
|
70
|
-
* @param {string} [reason] - The reason for shutting down.
|
|
71
|
-
*/
|
|
72
22
|
async onShutdown(reason) {
|
|
73
23
|
this.log.debug("The plugin doesn't override onShutdown.", reason);
|
|
74
24
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
|
|
77
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
78
|
-
*/
|
|
79
25
|
async onChangeLoggerLevel(logLevel) {
|
|
80
26
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
81
27
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Registers a device with the Matterbridge platform.
|
|
84
|
-
* @param {MatterbridgeDevice} device - The device to register.
|
|
85
|
-
*/
|
|
86
28
|
async registerDevice(device) {
|
|
87
29
|
device.plugin = this.name;
|
|
88
30
|
if (device instanceof MatterbridgeDevice)
|
|
@@ -90,27 +32,15 @@ export class MatterbridgePlatform {
|
|
|
90
32
|
if (device instanceof MatterbridgeEndpoint)
|
|
91
33
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
92
34
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
95
|
-
* @param {MatterbridgeDevice} device - The device to unregister.
|
|
96
|
-
*/
|
|
97
35
|
async unregisterDevice(device) {
|
|
98
36
|
if (device instanceof MatterbridgeDevice)
|
|
99
37
|
await this.matterbridge.removeBridgedDevice(this.name, device);
|
|
100
38
|
if (device instanceof MatterbridgeEndpoint)
|
|
101
39
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
102
40
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
105
|
-
*/
|
|
106
41
|
async unregisterAllDevices() {
|
|
107
42
|
await this.matterbridge.removeAllBridgedDevices(this.name);
|
|
108
43
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Verifies if the Matterbridge version meets the required version.
|
|
111
|
-
* @param {string} requiredVersion - The required version to compare against.
|
|
112
|
-
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
113
|
-
*/
|
|
114
44
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
115
45
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
116
46
|
const stripTag = (v) => {
|
|
@@ -136,4 +66,3 @@ export class MatterbridgePlatform {
|
|
|
136
66
|
return true;
|
|
137
67
|
}
|
|
138
68
|
}
|
|
139
|
-
//# 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 {
|
|
@@ -180,4 +136,3 @@ export async function wsMessageHandler(client, message) {
|
|
|
180
136
|
return;
|
|
181
137
|
}
|
|
182
138
|
}
|
|
183
|
-
//# sourceMappingURL=matterbridgeWebsocket.js.map
|