matterbridge 1.6.5 → 1.6.6-dev.13
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 +35 -0
- package/README-DEV.md +3 -3
- package/README.md +4 -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 +106 -706
- package/dist/matterbridgeAccessoryPlatform.js +0 -33
- package/dist/matterbridgeBehaviors.js +10 -29
- package/dist/matterbridgeDevice.js +58 -939
- package/dist/matterbridgeDeviceTypes.js +21 -42
- package/dist/matterbridgeDynamicPlatform.js +0 -33
- package/dist/matterbridgeEdge.js +0 -528
- package/dist/matterbridgeEndpoint.js +79 -1090
- package/dist/matterbridgePlatform.js +36 -76
- package/dist/matterbridgeTypes.js +0 -24
- package/dist/matterbridgeWebsocket.js +8 -45
- package/dist/pluginManager.js +3 -237
- package/dist/storage/export.js +0 -1
- package/dist/utils/colorUtils.js +33 -165
- 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.0ab89802.js → main.a742de4e.js} +9 -9
- package/frontend/build/static/js/{main.0ab89802.js.map → main.a742de4e.js.map} +1 -1
- package/npm-shrinkwrap.json +115 -104
- package/package.json +5 -5
- 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
- /package/frontend/build/static/js/{main.0ab89802.js.LICENSE.txt → main.a742de4e.js.LICENSE.txt} +0 -0
|
@@ -1,88 +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.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';
|
|
2
|
+
import { CYAN, nf, wr } from 'node-ansi-logger';
|
|
24
3
|
import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
|
|
25
|
-
|
|
26
|
-
* Represents the base Matterbridge platform.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
4
|
+
import { isValidArray, isValidObject } from './utils/utils.js';
|
|
29
5
|
export class MatterbridgePlatform {
|
|
30
6
|
matterbridge;
|
|
31
7
|
log;
|
|
32
8
|
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
|
-
*/
|
|
9
|
+
name = '';
|
|
10
|
+
type = '';
|
|
11
|
+
version = '';
|
|
42
12
|
constructor(matterbridge, log, config) {
|
|
43
13
|
this.matterbridge = matterbridge;
|
|
44
14
|
this.log = log;
|
|
45
15
|
this.config = config;
|
|
46
16
|
}
|
|
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
17
|
async onStart(reason) {
|
|
55
18
|
this.log.error('Plugins must override onStart.', reason);
|
|
56
19
|
throw new Error('Plugins must override onStart.');
|
|
57
20
|
}
|
|
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
21
|
async onConfigure() {
|
|
64
22
|
this.log.debug("The plugin doesn't override onConfigure.");
|
|
65
23
|
}
|
|
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
24
|
async onShutdown(reason) {
|
|
73
25
|
this.log.debug("The plugin doesn't override onShutdown.", reason);
|
|
74
26
|
}
|
|
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
27
|
async onChangeLoggerLevel(logLevel) {
|
|
80
28
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
81
29
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Registers a device with the Matterbridge platform.
|
|
84
|
-
* @param {MatterbridgeDevice} device - The device to register.
|
|
85
|
-
*/
|
|
86
30
|
async registerDevice(device) {
|
|
87
31
|
device.plugin = this.name;
|
|
88
32
|
if (device instanceof MatterbridgeDevice)
|
|
@@ -90,32 +34,23 @@ export class MatterbridgePlatform {
|
|
|
90
34
|
if (device instanceof MatterbridgeEndpoint)
|
|
91
35
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
92
36
|
}
|
|
93
|
-
/**
|
|
94
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
95
|
-
* @param {MatterbridgeDevice} device - The device to unregister.
|
|
96
|
-
*/
|
|
97
37
|
async unregisterDevice(device) {
|
|
98
38
|
if (device instanceof MatterbridgeDevice)
|
|
99
39
|
await this.matterbridge.removeBridgedDevice(this.name, device);
|
|
100
40
|
if (device instanceof MatterbridgeEndpoint)
|
|
101
41
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
102
42
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
105
|
-
*/
|
|
106
43
|
async unregisterAllDevices() {
|
|
107
|
-
|
|
44
|
+
if (this.matterbridge.edge)
|
|
45
|
+
await this.matterbridge.removeAllBridgedEndpoints(this.name);
|
|
46
|
+
else
|
|
47
|
+
await this.matterbridge.removeAllBridgedDevices(this.name);
|
|
108
48
|
}
|
|
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
49
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
115
50
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
116
51
|
const stripTag = (v) => {
|
|
117
52
|
const parts = v.split('-');
|
|
118
|
-
return parts
|
|
53
|
+
return parts[0];
|
|
119
54
|
};
|
|
120
55
|
const v1Parts = stripTag(matterbridgeVersion).split('.').map(Number);
|
|
121
56
|
const v2Parts = stripTag(requiredVersion).split('.').map(Number);
|
|
@@ -135,5 +70,30 @@ export class MatterbridgePlatform {
|
|
|
135
70
|
return false;
|
|
136
71
|
return true;
|
|
137
72
|
}
|
|
73
|
+
validateDeviceWhiteBlackList(device, log = true) {
|
|
74
|
+
if (isValidArray(this.config.whiteList, 1) && !this.config.whiteList.includes(device)) {
|
|
75
|
+
if (log)
|
|
76
|
+
this.log.info(`Skipping device ${CYAN}${device}${nf} because not in whitelist`);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (isValidArray(this.config.blackList, 1) && this.config.blackList.includes(device)) {
|
|
80
|
+
if (log)
|
|
81
|
+
this.log.info(`Skipping device ${CYAN}${device}${nf} because in blacklist`);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
validateEntityBlackList(device, entity, log = true) {
|
|
87
|
+
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
88
|
+
if (log)
|
|
89
|
+
this.log.info(`Skipping entity ${CYAN}${entity}${nf} because in entityBlackList`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (isValidObject(this.config.deviceEntityBlackList, 1) && device in this.config.deviceEntityBlackList && this.config.deviceEntityBlackList[device].includes(entity)) {
|
|
93
|
+
if (log)
|
|
94
|
+
this.log.info(`Skipping entity ${CYAN}${entity}${wr} for device ${CYAN}${device}${nf} because in deviceEntityBlackList`);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
138
99
|
}
|
|
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 {
|
|
@@ -125,6 +81,9 @@ export async function wsMessageHandler(client, message) {
|
|
|
125
81
|
this.matterbridgeInformation.mattermdnsinterface = (await this.nodeContext?.get('mattermdnsinterface', '')) || '';
|
|
126
82
|
this.matterbridgeInformation.matteripv4address = (await this.nodeContext?.get('matteripv4address', '')) || '';
|
|
127
83
|
this.matterbridgeInformation.matteripv6address = (await this.nodeContext?.get('matteripv6address', '')) || '';
|
|
84
|
+
this.matterbridgeInformation.matterPort = (await this.nodeContext?.get('matterport', 5540)) ?? 5540;
|
|
85
|
+
this.matterbridgeInformation.matterDiscriminator = await this.nodeContext?.get('matterdiscriminator');
|
|
86
|
+
this.matterbridgeInformation.matterPasscode = await this.nodeContext?.get('matterpasscode');
|
|
128
87
|
this.matterbridgeInformation.matterbridgePaired = this.matterbridgePaired;
|
|
129
88
|
this.matterbridgeInformation.matterbridgeConnected = this.matterbridgeConnected;
|
|
130
89
|
this.matterbridgeInformation.matterbridgeQrPairingCode = this.matterbridgeQrPairingCode;
|
|
@@ -152,6 +111,9 @@ export async function wsMessageHandler(client, message) {
|
|
|
152
111
|
let serial = device.getClusterServer(BasicInformationCluster)?.attributes.serialNumber?.getLocal();
|
|
153
112
|
if (!serial)
|
|
154
113
|
serial = device.getClusterServer(BridgedDeviceBasicInformationCluster)?.attributes.serialNumber?.getLocal() ?? 'Unknown';
|
|
114
|
+
let productUrl = device.getClusterServer(BasicInformationCluster)?.attributes.productUrl?.getLocal();
|
|
115
|
+
if (!productUrl)
|
|
116
|
+
productUrl = device.getClusterServer(BridgedDeviceBasicInformationCluster)?.attributes.productUrl?.getLocal() ?? 'Unknown';
|
|
155
117
|
let uniqueId = device.getClusterServer(BasicInformationCluster)?.attributes.uniqueId?.getLocal();
|
|
156
118
|
if (!uniqueId)
|
|
157
119
|
uniqueId = device.getClusterServer(BridgedDeviceBasicInformationCluster)?.attributes.uniqueId?.getLocal() ?? 'Unknown';
|
|
@@ -162,6 +124,8 @@ export async function wsMessageHandler(client, message) {
|
|
|
162
124
|
endpoint: device.number,
|
|
163
125
|
name,
|
|
164
126
|
serial,
|
|
127
|
+
productUrl,
|
|
128
|
+
configUrl: device.configUrl,
|
|
165
129
|
uniqueId,
|
|
166
130
|
cluster: cluster,
|
|
167
131
|
});
|
|
@@ -180,4 +144,3 @@ export async function wsMessageHandler(client, message) {
|
|
|
180
144
|
return;
|
|
181
145
|
}
|
|
182
146
|
}
|
|
183
|
-
//# sourceMappingURL=matterbridgeWebsocket.js.map
|