matterbridge 3.3.8 → 3.3.9-dev-20251119-ea13a99
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 +18 -0
- package/README-DEV.md +20 -25
- package/dist/broadcastServer.js +1 -93
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/cli.js +1 -97
- package/dist/cliEmitter.js +0 -37
- package/dist/cliHistory.js +0 -38
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +1 -105
- package/dist/devices/airConditioner.js +0 -57
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/cooktop.js +0 -55
- package/dist/devices/dishwasher.js +0 -57
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.js +0 -43
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.js +3 -62
- package/dist/devices/laundryWasher.js +4 -70
- package/dist/devices/microwaveOven.js +5 -88
- package/dist/devices/oven.js +0 -85
- package/dist/devices/refrigerator.js +0 -102
- package/dist/devices/roboticVacuumCleaner.js +9 -100
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/speaker.js +0 -84
- package/dist/devices/temperatureControl.js +3 -24
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/coap.js +13 -126
- package/dist/dgram/dgram.js +2 -114
- package/dist/dgram/mb_coap.js +3 -41
- package/dist/dgram/mb_mdns.js +15 -80
- package/dist/dgram/mdns.js +137 -299
- package/dist/dgram/multicast.js +1 -62
- package/dist/dgram/unicast.js +0 -54
- package/dist/frontend.js +39 -454
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.js +0 -53
- package/dist/index.js +0 -25
- package/dist/jestutils/export.js +0 -1
- package/dist/jestutils/jestHelpers.js +104 -278
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.js +0 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterbridge.js +51 -792
- package/dist/matterbridgeAccessoryPlatform.js +0 -38
- package/dist/matterbridgeBehaviors.js +5 -68
- package/dist/matterbridgeDeviceTypes.js +14 -635
- package/dist/matterbridgeDynamicPlatform.js +0 -38
- package/dist/matterbridgeEndpoint.js +82 -1445
- package/dist/matterbridgeEndpointHelpers.js +21 -483
- package/dist/matterbridgeEndpointTypes.js +0 -25
- package/dist/matterbridgePlatform.js +16 -355
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/pluginManager.js +11 -346
- package/dist/shelly.js +7 -168
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -69
- package/dist/utils/colorUtils.js +2 -97
- package/dist/utils/commandLine.js +0 -60
- package/dist/utils/copyDirectory.js +1 -38
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +0 -41
- package/dist/utils/export.js +0 -1
- package/dist/utils/format.js +0 -49
- package/dist/utils/hex.js +0 -124
- package/dist/utils/inspector.js +1 -69
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/network.js +5 -96
- package/dist/utils/spawn.js +0 -71
- package/dist/utils/tracker.js +1 -64
- package/dist/utils/wait.js +8 -60
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -2
- package/dist/broadcastServer.d.ts +0 -115
- package/dist/broadcastServer.d.ts.map +0 -1
- package/dist/broadcastServer.js.map +0 -1
- package/dist/broadcastServerTypes.d.ts +0 -806
- package/dist/broadcastServerTypes.d.ts.map +0 -1
- package/dist/broadcastServerTypes.js.map +0 -1
- package/dist/cli.d.ts +0 -30
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -50
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/cliHistory.d.ts +0 -48
- package/dist/cliHistory.d.ts.map +0 -1
- package/dist/cliHistory.js.map +0 -1
- package/dist/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -28
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -128
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts +0 -98
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/cooktop.d.ts +0 -60
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts +0 -71
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -76
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -17
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts +0 -46
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -67
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -81
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts +0 -168
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts +0 -105
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts +0 -118
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts +0 -87
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts +0 -166
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/coap.d.ts +0 -205
- package/dist/dgram/coap.d.ts.map +0 -1
- package/dist/dgram/coap.js.map +0 -1
- package/dist/dgram/dgram.d.ts +0 -141
- package/dist/dgram/dgram.d.ts.map +0 -1
- package/dist/dgram/dgram.js.map +0 -1
- package/dist/dgram/mb_coap.d.ts +0 -24
- package/dist/dgram/mb_coap.d.ts.map +0 -1
- package/dist/dgram/mb_coap.js.map +0 -1
- package/dist/dgram/mb_mdns.d.ts +0 -24
- package/dist/dgram/mb_mdns.d.ts.map +0 -1
- package/dist/dgram/mb_mdns.js.map +0 -1
- package/dist/dgram/mdns.d.ts +0 -290
- package/dist/dgram/mdns.d.ts.map +0 -1
- package/dist/dgram/mdns.js.map +0 -1
- package/dist/dgram/multicast.d.ts +0 -67
- package/dist/dgram/multicast.d.ts.map +0 -1
- package/dist/dgram/multicast.js.map +0 -1
- package/dist/dgram/unicast.d.ts +0 -56
- package/dist/dgram/unicast.d.ts.map +0 -1
- package/dist/dgram/unicast.js.map +0 -1
- package/dist/frontend.d.ts +0 -238
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts +0 -529
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jestutils/export.d.ts +0 -2
- package/dist/jestutils/export.d.ts.map +0 -1
- package/dist/jestutils/export.js.map +0 -1
- package/dist/jestutils/jestHelpers.d.ts +0 -250
- package/dist/jestutils/jestHelpers.d.ts.map +0 -1
- package/dist/jestutils/jestHelpers.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/behaviors.d.ts +0 -2
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts +0 -2
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts +0 -2
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts +0 -2
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.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/matter/types.d.ts +0 -3
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -469
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -41
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -2404
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -698
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -41
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1490
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -787
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgeEndpointTypes.d.ts +0 -197
- package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
- package/dist/matterbridgeEndpointTypes.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -415
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -239
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -371
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -174
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.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/update.d.ts +0 -75
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -101
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -66
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -33
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/error.d.ts +0 -44
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js.map +0 -1
- package/dist/utils/export.d.ts +0 -13
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/format.d.ts +0 -53
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -89
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/inspector.d.ts +0 -87
- package/dist/utils/inspector.d.ts.map +0 -1
- package/dist/utils/inspector.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/network.d.ts +0 -101
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -35
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/tracker.d.ts +0 -108
- package/dist/utils/tracker.d.ts.map +0 -1
- package/dist/utils/tracker.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -54
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the types for MatterbridgeEndpoint.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeEndpointTypes.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @created 2025-11-10
|
|
7
|
-
* @version 1.0.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
1
|
if (process.argv.includes('--loader') || process.argv.includes('-loader'))
|
|
26
2
|
console.log('\u001B[32mMatterbridgeEndpointTypes loaded.\u001B[40;0m');
|
|
27
3
|
export {};
|
|
28
|
-
//# sourceMappingURL=matterbridgeEndpointTypes.js.map
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the class MatterbridgePlatform.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgePlatform.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @created 2024-03-21
|
|
7
|
-
* @version 1.3.0
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2024, 2025, 2026 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
1
|
if (process.argv.includes('--loader') || process.argv.includes('-loader'))
|
|
26
2
|
console.log('\u001B[32mMatterbridgePlatform loaded.\u001B[40;0m');
|
|
27
|
-
// Node.js modules
|
|
28
3
|
import path from 'node:path';
|
|
29
|
-
// Node AnsiLogger module
|
|
30
4
|
import { CYAN, db, er, nf, wr } from 'node-ansi-logger';
|
|
31
|
-
// Node Storage module
|
|
32
5
|
import { NodeStorageManager } from 'node-persist-manager';
|
|
33
6
|
import { Descriptor } from '@matter/types/clusters/descriptor';
|
|
34
7
|
import { BridgedDeviceBasicInformation } from '@matter/types/clusters/bridged-device-basic-information';
|
|
@@ -36,54 +9,37 @@ import { checkNotLatinCharacters } from './matterbridgeEndpointHelpers.js';
|
|
|
36
9
|
import { bridgedNode } from './matterbridgeDeviceTypes.js';
|
|
37
10
|
import { isValidArray, isValidObject, isValidString } from './utils/isvalid.js';
|
|
38
11
|
import { addVirtualDevice } from './helpers.js';
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
12
|
+
import { hasParameter } from './utils/commandLine.js';
|
|
13
|
+
import { BroadcastServer } from './broadcastServer.js';
|
|
43
14
|
export class MatterbridgePlatform {
|
|
44
|
-
/** The Matterbridge instance of this Platform. */
|
|
45
15
|
matterbridge;
|
|
46
|
-
/** The logger instance for this platform. */
|
|
47
16
|
log;
|
|
48
|
-
/** The configuration for this platform. */
|
|
49
17
|
config;
|
|
50
|
-
/** The name of the platform. Will be set by the loadPlugin() method using the package.json value. */
|
|
51
18
|
name = '';
|
|
52
|
-
/** The type of the platform. Will be set by the extending classes. */
|
|
53
19
|
type = 'AnyPlatform';
|
|
54
|
-
/** The version of the platform. Will be set by the loadPlugin() method using the package.json value */
|
|
55
20
|
version = '1.0.0';
|
|
56
|
-
/** Platform node storage manager in the matterbridgeDirectory. */
|
|
57
21
|
storage;
|
|
58
|
-
/** Platform context in the storage of matterbridgeDirectory. Use await platform.ready to access it early. */
|
|
59
22
|
context;
|
|
60
|
-
// Device and entity select in the plugin config UI
|
|
61
23
|
selectDevice = new Map();
|
|
62
24
|
selectEntity = new Map();
|
|
63
|
-
// Promises for platform initialization. They are grouped in platform.ready with Promise.all.
|
|
64
25
|
contextReady;
|
|
65
26
|
selectDeviceContextReady;
|
|
66
27
|
selectEntityContextReady;
|
|
67
|
-
/** The ready promise for the platform, which resolves when the platform is fully initialized (including context and selects). */
|
|
68
28
|
ready;
|
|
69
|
-
/** Registered MatterbridgeEndpoint map keyed by uniqueId */
|
|
70
29
|
registeredEndpointsByUniqueId = new Map();
|
|
71
|
-
/** Registered MatterbridgeEndpoint map keyed by deviceName */
|
|
72
30
|
registeredEndpointsByName = new Map();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* Each plugin must extend the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
77
|
-
*
|
|
78
|
-
* @param {PlatformMatterbridge} matterbridge - The Matterbridge instance.
|
|
79
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
80
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
81
|
-
*/
|
|
31
|
+
#server;
|
|
32
|
+
#debug = hasParameter('debug') || hasParameter('verbose');
|
|
33
|
+
#verbose = hasParameter('verbose');
|
|
82
34
|
constructor(matterbridge, log, config) {
|
|
83
35
|
this.matterbridge = matterbridge;
|
|
84
36
|
this.log = log;
|
|
85
37
|
this.config = config;
|
|
86
|
-
|
|
38
|
+
this.#server = new BroadcastServer('platform', this.log);
|
|
39
|
+
if (this.#debug && !this.#verbose)
|
|
40
|
+
this.log.debug(`Creating MatterbridgePlatform for plugin ${this.config.name}`);
|
|
41
|
+
if (this.#verbose)
|
|
42
|
+
this.log.debug(`Creating MatterbridgePlatform for plugin ${this.config.name} with config:\n${JSON.stringify(this.config, null, 2)}\n`);
|
|
87
43
|
if (!isValidString(this.config.name, 1))
|
|
88
44
|
throw new Error('Platform: the plugin name is missing or invalid.');
|
|
89
45
|
this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
|
|
@@ -94,14 +50,12 @@ export class MatterbridgePlatform {
|
|
|
94
50
|
logging: false,
|
|
95
51
|
forgiveParseErrors: true,
|
|
96
52
|
});
|
|
97
|
-
// create the context storage for the plugin platform
|
|
98
53
|
this.log.debug(`Creating context for plugin ${this.config.name}`);
|
|
99
54
|
this.contextReady = this.storage.createStorage('context').then((context) => {
|
|
100
55
|
this.context = context;
|
|
101
56
|
this.log.debug(`Created context for plugin ${this.config.name}`);
|
|
102
57
|
return;
|
|
103
58
|
});
|
|
104
|
-
// create the selectDevice storage for the plugin platform
|
|
105
59
|
this.log.debug(`Loading selectDevice for plugin ${this.config.name}`);
|
|
106
60
|
this.selectDeviceContextReady = this.storage.createStorage('selectDevice').then(async (context) => {
|
|
107
61
|
const selectDevice = await context.get('selectDevice', []);
|
|
@@ -110,7 +64,6 @@ export class MatterbridgePlatform {
|
|
|
110
64
|
this.log.debug(`Loaded ${this.selectDevice.size} selectDevice for plugin ${this.config.name}`);
|
|
111
65
|
return;
|
|
112
66
|
});
|
|
113
|
-
// create the selectEntity storage for the plugin platform
|
|
114
67
|
this.log.debug(`Loading selectEntity for plugin ${this.config.name}`);
|
|
115
68
|
this.selectEntityContextReady = this.storage.createStorage('selectEntity').then(async (context) => {
|
|
116
69
|
const selectEntity = await context.get('selectEntity', []);
|
|
@@ -119,192 +72,77 @@ export class MatterbridgePlatform {
|
|
|
119
72
|
this.log.debug(`Loaded ${this.selectEntity.size} selectEntity for plugin ${this.config.name}`);
|
|
120
73
|
return;
|
|
121
74
|
});
|
|
122
|
-
// Create the `ready` promise for the platform
|
|
123
75
|
this.ready = Promise.all([this.contextReady, this.selectDeviceContextReady, this.selectEntityContextReady]).then(() => {
|
|
124
76
|
this.log.debug(`MatterbridgePlatform for plugin ${this.config.name} is fully initialized`);
|
|
125
77
|
return;
|
|
126
78
|
});
|
|
127
79
|
}
|
|
128
|
-
/**
|
|
129
|
-
* This method shall be overridden in the extended class.
|
|
130
|
-
* It is called when the platform is started.
|
|
131
|
-
* Use this method to create the MatterbridgeEndpoints and call this.registerDevice().
|
|
132
|
-
*
|
|
133
|
-
* @param {string} [reason] - The reason for starting.
|
|
134
|
-
* @throws {Error} - Throws an error if the method is not overridden.
|
|
135
|
-
*/
|
|
136
80
|
async onStart(reason) {
|
|
137
81
|
this.log.error('Plugins must override onStart.', reason);
|
|
138
82
|
throw new Error('Plugins must override onStart.');
|
|
139
83
|
}
|
|
140
|
-
/**
|
|
141
|
-
* This method can be overridden in the extended class. In this case always call super.onConfigure() to save the select and run checkEndpointNumbers().
|
|
142
|
-
* It is called after the platform has started.
|
|
143
|
-
* Use this method to perform any configuration of your devices and to override the value of the attributes that are persistent and stored in the
|
|
144
|
-
* matter storage (i.e. the onOff attribute of the OnOff cluster).
|
|
145
|
-
*/
|
|
146
84
|
async onConfigure() {
|
|
147
85
|
this.log.debug(`Configuring platform ${this.name}`);
|
|
148
|
-
// Save the selectDevice and selectEntity
|
|
149
86
|
await this.saveSelects();
|
|
150
|
-
// Check and update the endpoint numbers
|
|
151
87
|
await this.checkEndpointNumbers();
|
|
152
88
|
}
|
|
153
|
-
/**
|
|
154
|
-
* This method can be overridden in the extended class. In this case always call super.onShutdown() to save the selects, run checkEndpointNumbers() and cleanup memory.
|
|
155
|
-
* It is called when the platform is shutting down.
|
|
156
|
-
* Use this method to clean up any resources you used in the constructor or onStart.
|
|
157
|
-
*
|
|
158
|
-
* @param {string} [reason] - The reason for shutting down.
|
|
159
|
-
*/
|
|
160
89
|
async onShutdown(reason) {
|
|
161
90
|
this.log.debug(`Shutting down platform ${this.name}`, reason);
|
|
162
|
-
// Save the selectDevice and selectEntity
|
|
163
91
|
await this.saveSelects();
|
|
164
|
-
// Check and update the endpoint numbers
|
|
165
92
|
await this.checkEndpointNumbers();
|
|
166
|
-
// Cleanup memory
|
|
167
93
|
this.selectDevice.clear();
|
|
168
94
|
this.selectEntity.clear();
|
|
169
95
|
this.registeredEndpointsByUniqueId.clear();
|
|
170
96
|
this.registeredEndpointsByName.clear();
|
|
171
|
-
// Close the storage
|
|
172
97
|
await this.context?.close();
|
|
173
98
|
this.context = undefined;
|
|
174
99
|
await this.storage?.close();
|
|
100
|
+
this.#server.close();
|
|
175
101
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Called when the logger level is changed.
|
|
178
|
-
*
|
|
179
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
180
|
-
*/
|
|
181
102
|
async onChangeLoggerLevel(logLevel) {
|
|
182
103
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
183
104
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Called when a plugin config includes an action button or an action button with text field.
|
|
186
|
-
*
|
|
187
|
-
* @param {string} action The action triggered by the button in plugin config.
|
|
188
|
-
* @param {string} value The value of the field of the action button.
|
|
189
|
-
* @param {string} id The id of the schema associated with the action.
|
|
190
|
-
* @param {PlatformConfig} formData The changed form data of the plugin.
|
|
191
|
-
*
|
|
192
|
-
* @remarks
|
|
193
|
-
* This method can be overridden in the extended class.
|
|
194
|
-
*
|
|
195
|
-
* Use this method to handle the action defined in the plugin schema:
|
|
196
|
-
* ```json
|
|
197
|
-
* "addDevice": {
|
|
198
|
-
* "description": "Manually add a device that has not been discovered with mdns:",
|
|
199
|
-
* "type": "boolean",
|
|
200
|
-
* "buttonText": "ADD", // The text on the button. This is used when the action doesn't include a text field.
|
|
201
|
-
* "buttonField": "ADD", // The text on the button. This is used when the action includes a text field.
|
|
202
|
-
* "buttonClose": false, // optional, default is false. When true, the dialog will close after the action is sent.
|
|
203
|
-
* "buttonSave": false, // optional, default is false. When true, the dialog will close and trigger the restart required after the action is sent.
|
|
204
|
-
* "textPlaceholder": "Enter the device IP address", // optional: the placeholder text for the text field.
|
|
205
|
-
* "default": false
|
|
206
|
-
* },
|
|
207
|
-
* ```
|
|
208
|
-
*/
|
|
209
105
|
async onAction(action, value, id, formData) {
|
|
210
106
|
this.log.debug(`The plugin ${CYAN}${this.name}${db} doesn't override onAction. Received action ${CYAN}${action}${db}${value ? ' with ' + CYAN + value + db : ''} ${id ? ' for schema ' + CYAN + id + db : ''}`, formData);
|
|
211
107
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Called when the plugin config has been updated.
|
|
214
|
-
*
|
|
215
|
-
* @param {PlatformConfig} config The new plugin config.
|
|
216
|
-
*/
|
|
217
108
|
async onConfigChanged(config) {
|
|
218
109
|
this.log.debug(`The plugin ${CYAN}${config.name}${db} doesn't override onConfigChanged. Received new config.`);
|
|
219
110
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Save the platform configuration to the platform config JSON.
|
|
222
|
-
*
|
|
223
|
-
* @param {PlatformConfig} [config] - The platform configuration to save.
|
|
224
|
-
* @returns {void}
|
|
225
|
-
*/
|
|
226
111
|
saveConfig(config) {
|
|
227
|
-
// TODO: replace with a message to the plugins thread
|
|
228
112
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
229
113
|
if (!plugin) {
|
|
230
114
|
throw new Error(`Plugin ${this.name} not found`);
|
|
231
115
|
}
|
|
232
|
-
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
116
|
+
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
233
117
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Get the platform schema for the config editor. This will retrieve the schema from the Matterbridge plugin manager.
|
|
236
|
-
*
|
|
237
|
-
* @returns {PlatformSchema} The platform schema.
|
|
238
|
-
*/
|
|
239
118
|
getSchema() {
|
|
240
|
-
// TODO: replace with a message to the plugins thread
|
|
241
119
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
242
120
|
if (!plugin || !isValidObject(plugin.schemaJson)) {
|
|
243
121
|
throw new Error(`Plugin ${this.name} not found`);
|
|
244
122
|
}
|
|
245
123
|
return plugin.schemaJson;
|
|
246
124
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Set the platform schema for the config editor. This will update the schema in the Matterbridge plugin manager but will not change the schema file.
|
|
249
|
-
*
|
|
250
|
-
* @param {PlatformSchema} [schema] - The platform schema to set.
|
|
251
|
-
* @returns {void}
|
|
252
|
-
*/
|
|
253
125
|
setSchema(schema) {
|
|
254
|
-
// TODO: replace with a message to the plugins thread
|
|
255
126
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
256
127
|
if (!plugin) {
|
|
257
128
|
throw new Error(`Plugin ${this.name} not found`);
|
|
258
129
|
}
|
|
259
130
|
plugin.schemaJson = schema;
|
|
260
131
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Sends a restart required message to the frontend.
|
|
263
|
-
*
|
|
264
|
-
* @param {boolean} [snackbar] - If true, shows a snackbar notification. Default is true.
|
|
265
|
-
* @param {boolean} [fixed] - If true, shows a fixed notification. Default is false.
|
|
266
|
-
* @returns {void}
|
|
267
|
-
*/
|
|
268
132
|
wssSendRestartRequired(snackbar = true, fixed = false) {
|
|
269
|
-
|
|
270
|
-
|
|
133
|
+
this.#server.request({ type: 'frontend_restartrequired', src: 'platform', dst: 'frontend', params: { snackbar, fixed } });
|
|
134
|
+
}
|
|
135
|
+
wssSendSnackbarMessage(message, timeout, severity) {
|
|
136
|
+
this.#server.request({ type: 'frontend_snackbarmessage', src: 'platform', dst: 'frontend', params: { message, timeout, severity } });
|
|
271
137
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Retrieves the devices registered with the platform.
|
|
274
|
-
*
|
|
275
|
-
* @returns {MatterbridgeEndpoint[]} The registered devices.
|
|
276
|
-
*/
|
|
277
138
|
getDevices() {
|
|
278
139
|
return Array.from(this.registeredEndpointsByUniqueId.values());
|
|
279
140
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Checks if a device with this name is already registered in the platform.
|
|
282
|
-
*
|
|
283
|
-
* @param {string} deviceName - The device name to check.
|
|
284
|
-
* @returns {boolean} True if the device is already registered, false otherwise.
|
|
285
|
-
*/
|
|
286
141
|
hasDeviceName(deviceName) {
|
|
287
142
|
return this.registeredEndpointsByName.has(deviceName);
|
|
288
143
|
}
|
|
289
|
-
/**
|
|
290
|
-
* Registers a virtual device with the platform aggregator endpoint.
|
|
291
|
-
*
|
|
292
|
-
* The virtual device is created as an instance of `Endpoint` with the provided device type.
|
|
293
|
-
* When the virtual device is turned on, the provided callback function is executed.
|
|
294
|
-
* The onOff state of the virtual device always reverts to false when the device is turned on.
|
|
295
|
-
*
|
|
296
|
-
* @param { string } name - The name of the virtual device.
|
|
297
|
-
* @param { 'light' | 'outlet' | 'switch' | 'mounted_switch' } type - The type of the virtual device.
|
|
298
|
-
* @param { () => Promise<void> } callback - The callback to call when the virtual device is turned on.
|
|
299
|
-
*
|
|
300
|
-
* @returns {Promise<boolean>} A promise that resolves to true if the virtual device was successfully registered, false otherwise.
|
|
301
|
-
*
|
|
302
|
-
* @remarks
|
|
303
|
-
* The virtual devices don't show up in the device list of the frontend.
|
|
304
|
-
*/
|
|
305
144
|
async registerVirtualDevice(name, type, callback) {
|
|
306
145
|
let aggregator;
|
|
307
|
-
// TODO: replace with a message to the matterbridge thread
|
|
308
146
|
if (this.matterbridge.bridgeMode === 'bridge') {
|
|
309
147
|
aggregator = this.matterbridge.aggregatorNode;
|
|
310
148
|
}
|
|
@@ -324,25 +162,6 @@ export class MatterbridgePlatform {
|
|
|
324
162
|
}
|
|
325
163
|
return false;
|
|
326
164
|
}
|
|
327
|
-
/**
|
|
328
|
-
* Registers a device with the Matterbridge platform and performs validation checks.
|
|
329
|
-
*
|
|
330
|
-
* This method also checks if the implementation called createDefaultBasicInformationClusterServer() instead of createDefaultBridgedDeviceBasicInformationClusterServer().
|
|
331
|
-
*
|
|
332
|
-
* This is correct with Accessory platforms so we check if we are running in bridge mode and add the bridgedNode and the BridgedDeviceBasicInformation cluster.
|
|
333
|
-
*
|
|
334
|
-
* If we are in bridge mode, we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
|
|
335
|
-
*
|
|
336
|
-
* If we are in childbridge mode and the plugin is a 'DynamicPlatform', we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
|
|
337
|
-
*
|
|
338
|
-
* if we are in childbridge mode and the plugin is a 'AccessoryPlatform', the device is not bridged so no action is taken.
|
|
339
|
-
*
|
|
340
|
-
* If the device.mode = 'server', the device is not bridged so no action is taken.
|
|
341
|
-
*
|
|
342
|
-
* If the device.mode = 'matter', the device is not bridged so no action is taken.
|
|
343
|
-
*
|
|
344
|
-
* @param {MatterbridgeEndpoint} device - The device to register.
|
|
345
|
-
*/
|
|
346
165
|
async registerDevice(device) {
|
|
347
166
|
device.plugin = this.name;
|
|
348
167
|
if (!device.uniqueId) {
|
|
@@ -364,9 +183,7 @@ export class MatterbridgePlatform {
|
|
|
364
183
|
if (checkNotLatinCharacters(device.deviceName)) {
|
|
365
184
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has non latin characters.`);
|
|
366
185
|
}
|
|
367
|
-
// Validate bridgedNode and BridgedDeviceBasicInformation cluster
|
|
368
186
|
if (device.mode === undefined && (this.matterbridge.bridgeMode === 'bridge' || (this.matterbridge.bridgeMode === 'childbridge' && this.type === 'DynamicPlatform'))) {
|
|
369
|
-
// If the device is a bridged device, we add the bridgedNode to the deviceTypes map and to the Descriptor Cluster options
|
|
370
187
|
if (!device.deviceTypes.has(bridgedNode.code)) {
|
|
371
188
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no bridgedNode device type. Adding it...`);
|
|
372
189
|
device.deviceTypes.set(bridgedNode.code, bridgedNode);
|
|
@@ -378,49 +195,27 @@ export class MatterbridgePlatform {
|
|
|
378
195
|
}
|
|
379
196
|
}
|
|
380
197
|
}
|
|
381
|
-
// If the device is a bridged device, we add the BridgedDeviceBasicInformation cluster
|
|
382
198
|
if (!device.hasClusterServer(BridgedDeviceBasicInformation.Cluster.id)) {
|
|
383
199
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no BridgedDeviceBasicInformation cluster. Adding it...`);
|
|
384
200
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
|
|
385
201
|
}
|
|
386
202
|
}
|
|
387
|
-
// TODO: replace with a message to the matterbridge thread
|
|
388
203
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
389
204
|
this.registeredEndpointsByUniqueId.set(device.uniqueId, device);
|
|
390
205
|
this.registeredEndpointsByName.set(device.deviceName, device);
|
|
391
206
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
394
|
-
*
|
|
395
|
-
* @param {MatterbridgeEndpoint} device - The device to unregister.
|
|
396
|
-
*/
|
|
397
207
|
async unregisterDevice(device) {
|
|
398
|
-
// TODO: replace with a message to the matterbridge thread
|
|
399
208
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
400
209
|
if (device.uniqueId)
|
|
401
210
|
this.registeredEndpointsByUniqueId.delete(device.uniqueId);
|
|
402
211
|
if (device.deviceName)
|
|
403
212
|
this.registeredEndpointsByName.delete(device.deviceName);
|
|
404
213
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
407
|
-
*
|
|
408
|
-
* @param {number} [delay] - The delay in milliseconds between removing each bridged endpoint (default: 0).
|
|
409
|
-
*/
|
|
410
214
|
async unregisterAllDevices(delay = 0) {
|
|
411
|
-
// TODO: replace with a message to the matterbridge thread
|
|
412
215
|
await this.matterbridge.removeAllBridgedEndpoints(this.name, delay);
|
|
413
216
|
this.registeredEndpointsByUniqueId.clear();
|
|
414
217
|
this.registeredEndpointsByName.clear();
|
|
415
218
|
}
|
|
416
|
-
/**
|
|
417
|
-
* Saves the select devices and entities to storage.
|
|
418
|
-
*
|
|
419
|
-
* This method saves the current state of `selectDevice` and `selectEntity` maps to their respective storage.
|
|
420
|
-
* It logs the number of items being saved and ensures that the storage is properly closed after saving.
|
|
421
|
-
*
|
|
422
|
-
* @returns {Promise<void>} A promise that resolves when the save operation is complete.
|
|
423
|
-
*/
|
|
424
219
|
async saveSelects() {
|
|
425
220
|
if (this.storage) {
|
|
426
221
|
this.log.debug(`Saving ${this.selectDevice.size} selectDevice...`);
|
|
@@ -433,60 +228,19 @@ export class MatterbridgePlatform {
|
|
|
433
228
|
await selectEntity.close();
|
|
434
229
|
}
|
|
435
230
|
}
|
|
436
|
-
/**
|
|
437
|
-
* Clears all the select device and entity maps.
|
|
438
|
-
*
|
|
439
|
-
* @returns {void}
|
|
440
|
-
*/
|
|
441
231
|
async clearSelect() {
|
|
442
232
|
this.selectDevice.clear();
|
|
443
233
|
this.selectEntity.clear();
|
|
444
234
|
await this.saveSelects();
|
|
445
235
|
}
|
|
446
|
-
/**
|
|
447
|
-
* Clears the select for a single device.
|
|
448
|
-
*
|
|
449
|
-
* @param {string} serial - The serial of the device to clear.
|
|
450
|
-
* @returns {void}
|
|
451
|
-
*/
|
|
452
236
|
async clearDeviceSelect(serial) {
|
|
453
237
|
this.selectDevice.delete(serial);
|
|
454
238
|
await this.saveSelects();
|
|
455
239
|
}
|
|
456
|
-
/**
|
|
457
|
-
* Clears the select for a single entity.
|
|
458
|
-
*
|
|
459
|
-
* @param {string} name - The name of the entity to clear.
|
|
460
|
-
* @returns {void}
|
|
461
|
-
*/
|
|
462
240
|
async clearEntitySelect(name) {
|
|
463
241
|
this.selectEntity.delete(name);
|
|
464
242
|
await this.saveSelects();
|
|
465
243
|
}
|
|
466
|
-
/**
|
|
467
|
-
* Set the select device in the platform map.
|
|
468
|
-
*
|
|
469
|
-
* @param {string} serial - The serial number of the device.
|
|
470
|
-
* @param {string} name - The name of the device.
|
|
471
|
-
* @param {string} [configUrl] - The configuration URL of the device.
|
|
472
|
-
* @param {string} [icon] - The icon of the device: 'wifi', 'ble', 'hub'
|
|
473
|
-
* @param {Array<{ name: string; description: string; icon?: string }>} [entities] - The entities associated with the device.
|
|
474
|
-
* @returns {void}
|
|
475
|
-
*
|
|
476
|
-
* @remarks
|
|
477
|
-
* In the schema use selectFrom: 'serial' or 'name'
|
|
478
|
-
* ```json
|
|
479
|
-
* "whiteList": {
|
|
480
|
-
* "description": "Only the devices in the list will be exposed.",
|
|
481
|
-
* "type": "array",
|
|
482
|
-
* "items": {
|
|
483
|
-
* "type": "string"
|
|
484
|
-
* },
|
|
485
|
-
* "uniqueItems": true,
|
|
486
|
-
* "selectFrom": "name"
|
|
487
|
-
* },
|
|
488
|
-
* ```
|
|
489
|
-
*/
|
|
490
244
|
setSelectDevice(serial, name, configUrl, icon, entities) {
|
|
491
245
|
const device = this.selectDevice.get(serial);
|
|
492
246
|
if (device) {
|
|
@@ -503,35 +257,6 @@ export class MatterbridgePlatform {
|
|
|
503
257
|
this.selectDevice.set(serial, { serial, name, configUrl, icon, entities });
|
|
504
258
|
}
|
|
505
259
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Set the select device entity in the platform map.
|
|
508
|
-
*
|
|
509
|
-
* @param {string} serial - The serial number of the device.
|
|
510
|
-
* @param {string} entityName - The name of the entity.
|
|
511
|
-
* @param {string} entityDescription - The description of the entity.
|
|
512
|
-
* @param {string} [entityIcon] - The icon of the entity: 'wifi', 'ble', 'hub', 'component', 'matter'
|
|
513
|
-
* @returns {void}
|
|
514
|
-
*
|
|
515
|
-
* @remarks
|
|
516
|
-
* In the schema use selectDeviceEntityFrom: 'name' or 'description'
|
|
517
|
-
* ```json
|
|
518
|
-
* "deviceEntityBlackList": {
|
|
519
|
-
* "description": "List of entities not to be exposed for a single device.",
|
|
520
|
-
* "type": "object",
|
|
521
|
-
* "uniqueItems": true,
|
|
522
|
-
* "selectFrom": "name",
|
|
523
|
-
* "additionalProperties": {
|
|
524
|
-
* "description": "List of entities not to be exposed for this device.",
|
|
525
|
-
* "type": "array",
|
|
526
|
-
* "items": {
|
|
527
|
-
* "type": "string"
|
|
528
|
-
* },
|
|
529
|
-
* "uniqueItems": true,
|
|
530
|
-
* "selectDeviceEntityFrom": "name"
|
|
531
|
-
* }
|
|
532
|
-
* },
|
|
533
|
-
* ```
|
|
534
|
-
*/
|
|
535
260
|
setSelectDeviceEntity(serial, entityName, entityDescription, entityIcon) {
|
|
536
261
|
const device = this.selectDevice.get(serial);
|
|
537
262
|
if (device) {
|
|
@@ -541,11 +266,6 @@ export class MatterbridgePlatform {
|
|
|
541
266
|
device.entities.push({ name: entityName, description: entityDescription, icon: entityIcon });
|
|
542
267
|
}
|
|
543
268
|
}
|
|
544
|
-
/**
|
|
545
|
-
* Retrieves the select devices from the platform map.
|
|
546
|
-
*
|
|
547
|
-
* @returns {ApiSelectDevice[]} The selected devices array.
|
|
548
|
-
*/
|
|
549
269
|
getSelectDevices() {
|
|
550
270
|
const selectDevices = [];
|
|
551
271
|
for (const device of this.selectDevice.values()) {
|
|
@@ -553,36 +273,9 @@ export class MatterbridgePlatform {
|
|
|
553
273
|
}
|
|
554
274
|
return selectDevices;
|
|
555
275
|
}
|
|
556
|
-
/**
|
|
557
|
-
* Set the select entity in the platform map.
|
|
558
|
-
*
|
|
559
|
-
* @param {string} name - The entity name.
|
|
560
|
-
* @param {string} description - The entity description.
|
|
561
|
-
* @param {string} [icon] - The entity icon: 'wifi', 'ble', 'hub', 'component', 'matter'
|
|
562
|
-
* @returns {void}
|
|
563
|
-
*
|
|
564
|
-
* @remarks
|
|
565
|
-
* In the schema use selectEntityFrom: 'name' or 'description'
|
|
566
|
-
* ```json
|
|
567
|
-
* "entityBlackList": {
|
|
568
|
-
* "description": "The entities in the list will not be exposed.",
|
|
569
|
-
* "type": "array",
|
|
570
|
-
* "items": {
|
|
571
|
-
* "type": "string"
|
|
572
|
-
* },
|
|
573
|
-
* "uniqueItems": true,
|
|
574
|
-
* "selectEntityFrom": "name"
|
|
575
|
-
* },
|
|
576
|
-
* ```
|
|
577
|
-
*/
|
|
578
276
|
setSelectEntity(name, description, icon) {
|
|
579
277
|
this.selectEntity.set(name, { name, description, icon });
|
|
580
278
|
}
|
|
581
|
-
/**
|
|
582
|
-
* Retrieve the select entities.
|
|
583
|
-
*
|
|
584
|
-
* @returns {ApiSelectEntity[]} The select entities array.
|
|
585
|
-
*/
|
|
586
279
|
getSelectEntities() {
|
|
587
280
|
const selectEntities = [];
|
|
588
281
|
for (const entity of this.selectEntity.values()) {
|
|
@@ -590,12 +283,6 @@ export class MatterbridgePlatform {
|
|
|
590
283
|
}
|
|
591
284
|
return selectEntities;
|
|
592
285
|
}
|
|
593
|
-
/**
|
|
594
|
-
* Verifies if the Matterbridge version meets the required version.
|
|
595
|
-
*
|
|
596
|
-
* @param {string} requiredVersion - The required version to compare against.
|
|
597
|
-
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
598
|
-
*/
|
|
599
286
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
600
287
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
601
288
|
const stripTag = (v) => {
|
|
@@ -620,14 +307,6 @@ export class MatterbridgePlatform {
|
|
|
620
307
|
return false;
|
|
621
308
|
return true;
|
|
622
309
|
}
|
|
623
|
-
/**
|
|
624
|
-
* Validates if a device is allowed based on the whitelist and blacklist configurations.
|
|
625
|
-
* The blacklist has priority over the whitelist.
|
|
626
|
-
*
|
|
627
|
-
* @param {string | string[]} device - The device name(s) to validate.
|
|
628
|
-
* @param {boolean} [log] - Whether to log the validation result.
|
|
629
|
-
* @returns {boolean} - Returns true if the device is allowed, false otherwise.
|
|
630
|
-
*/
|
|
631
310
|
validateDevice(device, log = true) {
|
|
632
311
|
if (!Array.isArray(device))
|
|
633
312
|
device = [device];
|
|
@@ -657,14 +336,6 @@ export class MatterbridgePlatform {
|
|
|
657
336
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
658
337
|
return false;
|
|
659
338
|
}
|
|
660
|
-
/**
|
|
661
|
-
* Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
|
|
662
|
-
*
|
|
663
|
-
* @param {string} device - The device to which the entity belongs.
|
|
664
|
-
* @param {string} entity - The entity to validate.
|
|
665
|
-
* @param {boolean} [log] - Whether to log the validation result.
|
|
666
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
667
|
-
*/
|
|
668
339
|
validateEntity(device, entity, log = true) {
|
|
669
340
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
670
341
|
if (log)
|
|
@@ -683,15 +354,6 @@ export class MatterbridgePlatform {
|
|
|
683
354
|
}
|
|
684
355
|
return true;
|
|
685
356
|
}
|
|
686
|
-
/**
|
|
687
|
-
* Checks and updates the endpoint numbers for Matterbridge devices.
|
|
688
|
-
*
|
|
689
|
-
* This method retrieves the list of Matterbridge devices and their child endpoints,
|
|
690
|
-
* compares their current endpoint numbers with the stored ones, and updates the storage
|
|
691
|
-
* if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
|
|
692
|
-
*
|
|
693
|
-
* @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
|
|
694
|
-
*/
|
|
695
357
|
async checkEndpointNumbers() {
|
|
696
358
|
if (!this.storage)
|
|
697
359
|
return -1;
|
|
@@ -732,4 +394,3 @@ export class MatterbridgePlatform {
|
|
|
732
394
|
return endpointMap.size;
|
|
733
395
|
}
|
|
734
396
|
}
|
|
735
|
-
//# sourceMappingURL=matterbridgePlatform.js.map
|
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file contains the types for Matterbridge.
|
|
3
|
-
*
|
|
4
|
-
* @file matterbridgeTypes.ts
|
|
5
|
-
* @author Luca Liguori
|
|
6
|
-
* @created 2024-07-12
|
|
7
|
-
* @version 1.0.2
|
|
8
|
-
* @license Apache-2.0
|
|
9
|
-
*
|
|
10
|
-
* Copyright 2023, 2024, 2025 Luca Liguori.
|
|
11
|
-
*
|
|
12
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License.
|
|
14
|
-
* You may obtain a copy of the License at
|
|
15
|
-
*
|
|
16
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
* See the License for the specific language governing permissions and
|
|
22
|
-
* limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
// Default colors
|
|
25
1
|
export const plg = '\u001B[38;5;33m';
|
|
26
2
|
export const dev = '\u001B[38;5;79m';
|
|
27
3
|
export const typ = '\u001B[38;5;207m';
|
|
28
|
-
// Default names
|
|
29
4
|
export const MATTERBRIDGE_LOGGER_FILE = 'matterbridge.log';
|
|
30
5
|
export const MATTER_LOGGER_FILE = 'matter.log';
|
|
31
6
|
export const NODE_STORAGE_DIR = 'storage';
|
|
32
7
|
export const MATTER_STORAGE_NAME = 'matterstorage';
|
|
33
8
|
export const MATTERBRIDGE_DIAGNOSTIC_FILE = 'diagnostic.log';
|
|
34
9
|
export const MATTERBRIDGE_HISTORY_FILE = 'history.html';
|
|
35
|
-
//# sourceMappingURL=matterbridgeTypes.js.map
|