matterbridge 3.3.0 → 3.3.1-dev-20251008-e61b8db
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 +34 -3
- package/README.md +9 -1
- package/dist/broadcastServer.js +73 -0
- package/dist/broadcastServerTypes.js +1 -0
- package/dist/cli.js +38 -99
- package/dist/cliEmitter.js +0 -30
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +44 -98
- 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 -42
- 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 -25
- 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 +233 -634
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.js +4 -57
- package/dist/index.js +2 -41
- 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 +156 -885
- package/dist/matterbridgeAccessoryPlatform.js +0 -36
- package/dist/matterbridgeBehaviors.js +5 -65
- package/dist/matterbridgeDeviceTypes.js +17 -630
- package/dist/matterbridgeDynamicPlatform.js +0 -36
- package/dist/matterbridgeEndpoint.js +58 -1398
- package/dist/matterbridgeEndpointHelpers.js +12 -345
- package/dist/matterbridgePlatform.js +4 -341
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/pluginManager.js +133 -254
- package/dist/shelly.js +11 -172
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -71
- package/dist/utils/colorUtils.js +2 -97
- package/dist/utils/commandLine.js +0 -54
- 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/hex.js +0 -124
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/jestHelpers.js +3 -153
- package/dist/utils/network.js +76 -129
- package/dist/utils/spawn.js +5 -75
- package/dist/utils/wait.js +8 -60
- package/frontend/build/assets/index.js +4 -7
- package/frontend/build/assets/vendor_mui.js +1 -1
- package/frontend/package.json +1 -1
- package/npm-shrinkwrap.json +44 -44
- package/package.json +2 -3
- package/dist/cli.d.ts +0 -26
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -34
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.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 -112
- 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 -75
- 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 -232
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts +0 -514
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/globalMatterbridge.d.ts +0 -59
- package/dist/globalMatterbridge.d.ts.map +0 -1
- package/dist/globalMatterbridge.js +0 -70
- package/dist/globalMatterbridge.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 -33
- 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/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 -430
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -1747
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -761
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1534
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -407
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -402
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -201
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -270
- 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 -99
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -59
- 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/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/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/jestHelpers.d.ts +0 -137
- package/dist/utils/jestHelpers.d.ts.map +0 -1
- package/dist/utils/jestHelpers.js.map +0 -1
- package/dist/utils/network.d.ts +0 -84
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -34
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.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,86 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
// Node.js modules
|
|
1
|
+
if (process.argv.includes('--loader') || process.argv.includes('-loader'))
|
|
2
|
+
console.log('\u001B[32mMatterbridgePlatform loaded.\u001B[40;0m');
|
|
25
3
|
import path from 'node:path';
|
|
26
4
|
import { Descriptor } from '@matter/main/clusters/descriptor';
|
|
27
5
|
import { BridgedDeviceBasicInformation } from '@matter/main/clusters/bridged-device-basic-information';
|
|
28
|
-
// Node AnsiLogger module
|
|
29
6
|
import { CYAN, db, er, nf, wr } from 'node-ansi-logger';
|
|
30
|
-
// Node Storage module
|
|
31
7
|
import { NodeStorageManager } from 'node-persist-manager';
|
|
32
8
|
import { checkNotLatinCharacters } from './matterbridgeEndpointHelpers.js';
|
|
33
9
|
import { bridgedNode } from './matterbridgeDeviceTypes.js';
|
|
34
10
|
import { isValidArray, isValidObject, isValidString } from './utils/isvalid.js';
|
|
35
11
|
import { addVirtualDevice } from './helpers.js';
|
|
36
|
-
/**
|
|
37
|
-
* Represents the base Matterbridge platform. It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
12
|
export class MatterbridgePlatform {
|
|
41
|
-
/** The Matterbridge instance of this Platform. */
|
|
42
13
|
matterbridge;
|
|
43
|
-
/** The logger instance for this platform. */
|
|
44
14
|
log;
|
|
45
|
-
/** The configuration for this platform. */
|
|
46
15
|
config;
|
|
47
|
-
/** The name of the platform. Will be set by the loadPlugin() method using the package.json value. */
|
|
48
16
|
name = '';
|
|
49
|
-
|
|
50
|
-
type = '';
|
|
51
|
-
/** The version of the platform. Will be set by the loadPlugin() method using the package.json value */
|
|
17
|
+
type = 'AnyPlatform';
|
|
52
18
|
version = '1.0.0';
|
|
53
|
-
/** Platform node storage manager in the matterbridgeDirectory. */
|
|
54
19
|
storage;
|
|
55
|
-
/** Platform context in the storage of matterbridgeDirectory. Use await platform.ready to access it early. */
|
|
56
20
|
context;
|
|
57
|
-
// Device and entity select in the plugin config UI
|
|
58
21
|
selectDevice = new Map();
|
|
59
22
|
selectEntity = new Map();
|
|
60
|
-
// Promises for platform initialization. They are grouped in platform.ready with Promise.all.
|
|
61
23
|
contextReady;
|
|
62
24
|
selectDeviceContextReady;
|
|
63
25
|
selectEntityContextReady;
|
|
64
|
-
/** The ready promise for the platform, which resolves when the platform is fully initialized (including context and selects). */
|
|
65
26
|
ready;
|
|
66
|
-
/** Registered MatterbridgeEndpoint Map keyed by uniqueId */
|
|
67
27
|
registeredEndpointsByUniqueId = new Map();
|
|
68
|
-
/** Registered MatterbridgeEndpoint Map keyed by deviceName */
|
|
69
28
|
registeredEndpointsByName = new Map();
|
|
70
|
-
/**
|
|
71
|
-
* Creates an instance of the base MatterbridgePlatform.
|
|
72
|
-
* It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
73
|
-
* Each plugin must extend the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
74
|
-
*
|
|
75
|
-
* @param {PlatformMatterbridge} matterbridge - The Matterbridge instance.
|
|
76
|
-
* @param {AnsiLogger} log - The logger instance.
|
|
77
|
-
* @param {PlatformConfig} config - The platform configuration.
|
|
78
|
-
*/
|
|
79
29
|
constructor(matterbridge, log, config) {
|
|
80
30
|
this.matterbridge = matterbridge;
|
|
81
31
|
this.log = log;
|
|
82
32
|
this.config = config;
|
|
83
|
-
// create the NodeStorageManager for the plugin platform
|
|
84
33
|
if (!isValidString(this.config.name, 1))
|
|
85
34
|
throw new Error('Platform: the plugin name is missing or invalid.');
|
|
86
35
|
this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
|
|
@@ -91,14 +40,12 @@ export class MatterbridgePlatform {
|
|
|
91
40
|
logging: false,
|
|
92
41
|
forgiveParseErrors: true,
|
|
93
42
|
});
|
|
94
|
-
// create the context storage for the plugin platform
|
|
95
43
|
this.log.debug(`Creating context for plugin ${this.config.name}`);
|
|
96
44
|
this.contextReady = this.storage.createStorage('context').then((context) => {
|
|
97
45
|
this.context = context;
|
|
98
46
|
this.log.debug(`Created context for plugin ${this.config.name}`);
|
|
99
47
|
return;
|
|
100
48
|
});
|
|
101
|
-
// create the selectDevice storage for the plugin platform
|
|
102
49
|
this.log.debug(`Loading selectDevice for plugin ${this.config.name}`);
|
|
103
50
|
this.selectDeviceContextReady = this.storage.createStorage('selectDevice').then(async (context) => {
|
|
104
51
|
const selectDevice = await context.get('selectDevice', []);
|
|
@@ -107,7 +54,6 @@ export class MatterbridgePlatform {
|
|
|
107
54
|
this.log.debug(`Loaded ${this.selectDevice.size} selectDevice for plugin ${this.config.name}`);
|
|
108
55
|
return;
|
|
109
56
|
});
|
|
110
|
-
// create the selectEntity storage for the plugin platform
|
|
111
57
|
this.log.debug(`Loading selectEntity for plugin ${this.config.name}`);
|
|
112
58
|
this.selectEntityContextReady = this.storage.createStorage('selectEntity').then(async (context) => {
|
|
113
59
|
const selectEntity = await context.get('selectEntity', []);
|
|
@@ -116,165 +62,59 @@ export class MatterbridgePlatform {
|
|
|
116
62
|
this.log.debug(`Loaded ${this.selectEntity.size} selectEntity for plugin ${this.config.name}`);
|
|
117
63
|
return;
|
|
118
64
|
});
|
|
119
|
-
// Create the `ready` promise for the platform
|
|
120
65
|
this.ready = Promise.all([this.contextReady, this.selectDeviceContextReady, this.selectEntityContextReady]).then(() => {
|
|
121
66
|
this.log.debug(`MatterbridgePlatform for plugin ${this.config.name} is fully initialized`);
|
|
122
67
|
return;
|
|
123
68
|
});
|
|
124
69
|
}
|
|
125
|
-
/**
|
|
126
|
-
* This method shall be overridden in the extended class.
|
|
127
|
-
* It is called when the platform is started.
|
|
128
|
-
* Use this method to create the MatterbridgeEndpoints and call this.registerDevice().
|
|
129
|
-
*
|
|
130
|
-
* @param {string} [reason] - The reason for starting.
|
|
131
|
-
* @throws {Error} - Throws an error if the method is not overridden.
|
|
132
|
-
*/
|
|
133
70
|
async onStart(reason) {
|
|
134
71
|
this.log.error('Plugins must override onStart.', reason);
|
|
135
72
|
throw new Error('Plugins must override onStart.');
|
|
136
73
|
}
|
|
137
|
-
/**
|
|
138
|
-
* This method can be overridden in the extended class. In this case always call super.onConfigure() to save the select and run checkEndpointNumbers().
|
|
139
|
-
* It is called after the platform has started.
|
|
140
|
-
* 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
|
|
141
|
-
* matter storage (i.e. the onOff attribute of the OnOff cluster).
|
|
142
|
-
*/
|
|
143
74
|
async onConfigure() {
|
|
144
75
|
this.log.debug(`Configuring platform ${this.name}`);
|
|
145
|
-
// Save the selectDevice and selectEntity
|
|
146
76
|
await this.saveSelects();
|
|
147
|
-
// Check and update the endpoint numbers
|
|
148
77
|
await this.checkEndpointNumbers();
|
|
149
78
|
}
|
|
150
|
-
/**
|
|
151
|
-
* 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.
|
|
152
|
-
* It is called when the platform is shutting down.
|
|
153
|
-
* Use this method to clean up any resources you used in the constructor or onStart.
|
|
154
|
-
*
|
|
155
|
-
* @param {string} [reason] - The reason for shutting down.
|
|
156
|
-
*/
|
|
157
79
|
async onShutdown(reason) {
|
|
158
80
|
this.log.debug(`Shutting down platform ${this.name}`, reason);
|
|
159
|
-
// Save the selectDevice and selectEntity
|
|
160
81
|
await this.saveSelects();
|
|
161
|
-
// Check and update the endpoint numbers
|
|
162
82
|
await this.checkEndpointNumbers();
|
|
163
|
-
// Cleanup memory
|
|
164
83
|
this.selectDevice.clear();
|
|
165
84
|
this.selectEntity.clear();
|
|
166
85
|
this.registeredEndpointsByUniqueId.clear();
|
|
167
86
|
this.registeredEndpointsByName.clear();
|
|
168
|
-
// Close the storage
|
|
169
87
|
await this.context?.close();
|
|
170
88
|
this.context = undefined;
|
|
171
89
|
await this.storage?.close();
|
|
172
90
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Called when the logger level is changed.
|
|
175
|
-
*
|
|
176
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
177
|
-
*/
|
|
178
91
|
async onChangeLoggerLevel(logLevel) {
|
|
179
92
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
180
93
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Called when a plugin config includes an action button or an action button with text field.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} action The action triggered by the button in plugin config.
|
|
185
|
-
* @param {string} value The value of the field of the action button.
|
|
186
|
-
* @param {string} id The id of the schema associated with the action.
|
|
187
|
-
* @param {PlatformConfig} formData The changed form data of the plugin.
|
|
188
|
-
*
|
|
189
|
-
* @remarks
|
|
190
|
-
* This method can be overridden in the extended class.
|
|
191
|
-
*
|
|
192
|
-
* Use this method to handle the action defined in the plugin schema:
|
|
193
|
-
* ```json
|
|
194
|
-
* "addDevice": {
|
|
195
|
-
* "description": "Manually add a device that has not been discovered with mdns:",
|
|
196
|
-
* "type": "boolean",
|
|
197
|
-
* "buttonText": "ADD", // The text on the button. This is used when the action doesn't include a text field.
|
|
198
|
-
* "buttonField": "ADD", // The text on the button. This is used when the action includes a text field.
|
|
199
|
-
* "buttonClose": false, // optional, default is false. When true, the dialog will close after the action is sent.
|
|
200
|
-
* "buttonSave": false, // optional, default is false. When true, the dialog will close and trigger the restart required after the action is sent.
|
|
201
|
-
* "textPlaceholder": "Enter the device IP address", // optional: the placeholder text for the text field.
|
|
202
|
-
* "default": false
|
|
203
|
-
* },
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
94
|
async onAction(action, value, id, formData) {
|
|
207
95
|
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);
|
|
208
96
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Called when the plugin config has been updated.
|
|
211
|
-
*
|
|
212
|
-
* @param {PlatformConfig} config The new plugin config.
|
|
213
|
-
*/
|
|
214
97
|
async onConfigChanged(config) {
|
|
215
98
|
this.log.debug(`The plugin ${CYAN}${config.name}${db} doesn't override onConfigChanged. Received new config.`);
|
|
216
99
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Save the platform configuration to the platform config JSON.
|
|
219
|
-
*
|
|
220
|
-
* @param {PlatformConfig} [config] - The platform configuration to save.
|
|
221
|
-
* @returns {void}
|
|
222
|
-
*/
|
|
223
100
|
saveConfig(config) {
|
|
224
|
-
// TODO: replace with a message to the matterbridge thread
|
|
225
101
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
226
102
|
if (!plugin) {
|
|
227
103
|
throw new Error(`Plugin ${this.name} not found`);
|
|
228
104
|
}
|
|
229
|
-
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
105
|
+
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
230
106
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Sends a restart required message to the frontend.
|
|
233
|
-
*
|
|
234
|
-
* @param {boolean} [snackbar] - If true, shows a snackbar notification. Default is true.
|
|
235
|
-
* @param {boolean} [fixed] - If true, shows a fixed notification. Default is false.
|
|
236
|
-
* @returns {void}
|
|
237
|
-
*/
|
|
238
107
|
wssSendRestartRequired(snackbar = true, fixed = false) {
|
|
239
|
-
// TODO: replace with a message to the frontend thread
|
|
240
108
|
this.matterbridge.frontend.wssSendRestartRequired(snackbar, fixed);
|
|
241
109
|
}
|
|
242
|
-
/**
|
|
243
|
-
* Retrieves the devices registered with the platform.
|
|
244
|
-
*
|
|
245
|
-
* @returns {MatterbridgeEndpoint[]} The registered devices.
|
|
246
|
-
*/
|
|
247
110
|
getDevices() {
|
|
248
111
|
return Array.from(this.registeredEndpointsByUniqueId.values());
|
|
249
112
|
}
|
|
250
|
-
/**
|
|
251
|
-
* Checks if a device with this name is already registered in the platform.
|
|
252
|
-
*
|
|
253
|
-
* @param {string} deviceName - The device name to check.
|
|
254
|
-
* @returns {boolean} True if the device is already registered, false otherwise.
|
|
255
|
-
*/
|
|
256
113
|
hasDeviceName(deviceName) {
|
|
257
114
|
return this.registeredEndpointsByName.has(deviceName);
|
|
258
115
|
}
|
|
259
|
-
/**
|
|
260
|
-
* Registers a virtual device with the platform aggregator endpoint.
|
|
261
|
-
*
|
|
262
|
-
* The virtual device is created as an instance of `Endpoint` with the provided device type.
|
|
263
|
-
* When the virtual device is turned on, the provided callback function is executed.
|
|
264
|
-
* The onOff state of the virtual device always reverts to false when the device is turned on.
|
|
265
|
-
*
|
|
266
|
-
* @param { string } name - The name of the virtual device.
|
|
267
|
-
* @param { 'light' | 'outlet' | 'switch' | 'mounted_switch' } type - The type of the virtual device.
|
|
268
|
-
* @param { () => Promise<void> } callback - The callback to call when the virtual device is turned on.
|
|
269
|
-
*
|
|
270
|
-
* @returns {Promise<void>} A promise that resolves when the virtual device is registered.
|
|
271
|
-
*
|
|
272
|
-
* @remarks
|
|
273
|
-
* The virtual devices don't show up in the device list of the frontend.
|
|
274
|
-
*/
|
|
275
116
|
async registerVirtualDevice(name, type, callback) {
|
|
276
117
|
let aggregator;
|
|
277
|
-
// TODO: replace with a message to the matterbridge thread
|
|
278
118
|
if (this.matterbridge.bridgeMode === 'bridge') {
|
|
279
119
|
aggregator = this.matterbridge.aggregatorNode;
|
|
280
120
|
}
|
|
@@ -291,25 +131,6 @@ export class MatterbridgePlatform {
|
|
|
291
131
|
}
|
|
292
132
|
}
|
|
293
133
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Registers a device with the Matterbridge platform and performs validation checks.
|
|
296
|
-
*
|
|
297
|
-
* This method also checks if the implementation called createDefaultBasicInformationClusterServer() instead of createDefaultBridgedDeviceBasicInformationClusterServer().
|
|
298
|
-
*
|
|
299
|
-
* This is correct with Accessory platforms so we check if we are running in bridge mode and add the bridgedNode and the BridgedDeviceBasicInformation cluster.
|
|
300
|
-
*
|
|
301
|
-
* If we are in bridge mode, we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
|
|
302
|
-
*
|
|
303
|
-
* If we are in childbridge mode and the plugin is a 'DynamicPlatform', we add the bridgedNode device type and the BridgedDeviceBasicInformation cluster.
|
|
304
|
-
*
|
|
305
|
-
* if we are in childbridge mode and the plugin is a 'AccessoryPlatform', the device is not bridged so no action is taken.
|
|
306
|
-
*
|
|
307
|
-
* If the device.mode = 'server', the device is not bridged so no action is taken.
|
|
308
|
-
*
|
|
309
|
-
* If the device.mode = 'matter', the device is not bridged so no action is taken.
|
|
310
|
-
*
|
|
311
|
-
* @param {MatterbridgeEndpoint} device - The device to register.
|
|
312
|
-
*/
|
|
313
134
|
async registerDevice(device) {
|
|
314
135
|
device.plugin = this.name;
|
|
315
136
|
if (!device.uniqueId) {
|
|
@@ -331,9 +152,7 @@ export class MatterbridgePlatform {
|
|
|
331
152
|
if (checkNotLatinCharacters(device.deviceName)) {
|
|
332
153
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has non latin characters.`);
|
|
333
154
|
}
|
|
334
|
-
// Validate bridgedNode and BridgedDeviceBasicInformation cluster
|
|
335
155
|
if (device.mode === undefined && (this.matterbridge.bridgeMode === 'bridge' || (this.matterbridge.bridgeMode === 'childbridge' && this.type === 'DynamicPlatform'))) {
|
|
336
|
-
// If the device is a bridged device, we add the bridgedNode to the deviceTypes map and to the Descriptor Cluster options
|
|
337
156
|
if (!device.deviceTypes.has(bridgedNode.code)) {
|
|
338
157
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no bridgedNode device type. Adding it...`);
|
|
339
158
|
device.deviceTypes.set(bridgedNode.code, bridgedNode);
|
|
@@ -345,49 +164,27 @@ export class MatterbridgePlatform {
|
|
|
345
164
|
}
|
|
346
165
|
}
|
|
347
166
|
}
|
|
348
|
-
// If the device is a bridged device, we add the BridgedDeviceBasicInformation cluster
|
|
349
167
|
if (!device.hasClusterServer(BridgedDeviceBasicInformation.Cluster.id)) {
|
|
350
168
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no BridgedDeviceBasicInformation cluster. Adding it...`);
|
|
351
169
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
|
|
352
170
|
}
|
|
353
171
|
}
|
|
354
|
-
// TODO: replace with a message to the matterbridge thread
|
|
355
172
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
356
173
|
this.registeredEndpointsByUniqueId.set(device.uniqueId, device);
|
|
357
174
|
this.registeredEndpointsByName.set(device.deviceName, device);
|
|
358
175
|
}
|
|
359
|
-
/**
|
|
360
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
361
|
-
*
|
|
362
|
-
* @param {MatterbridgeEndpoint} device - The device to unregister.
|
|
363
|
-
*/
|
|
364
176
|
async unregisterDevice(device) {
|
|
365
|
-
// TODO: replace with a message to the matterbridge thread
|
|
366
177
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
367
178
|
if (device.uniqueId)
|
|
368
179
|
this.registeredEndpointsByUniqueId.delete(device.uniqueId);
|
|
369
180
|
if (device.deviceName)
|
|
370
181
|
this.registeredEndpointsByName.delete(device.deviceName);
|
|
371
182
|
}
|
|
372
|
-
/**
|
|
373
|
-
* Unregisters all devices registered with the Matterbridge platform.
|
|
374
|
-
*
|
|
375
|
-
* @param {number} [delay] - The delay in milliseconds between removing each bridged endpoint (default: 0).
|
|
376
|
-
*/
|
|
377
183
|
async unregisterAllDevices(delay = 0) {
|
|
378
|
-
// TODO: replace with a message to the matterbridge thread
|
|
379
184
|
await this.matterbridge.removeAllBridgedEndpoints(this.name, delay);
|
|
380
185
|
this.registeredEndpointsByUniqueId.clear();
|
|
381
186
|
this.registeredEndpointsByName.clear();
|
|
382
187
|
}
|
|
383
|
-
/**
|
|
384
|
-
* Saves the select devices and entities to storage.
|
|
385
|
-
*
|
|
386
|
-
* This method saves the current state of `selectDevice` and `selectEntity` maps to their respective storage.
|
|
387
|
-
* It logs the number of items being saved and ensures that the storage is properly closed after saving.
|
|
388
|
-
*
|
|
389
|
-
* @returns {Promise<void>} A promise that resolves when the save operation is complete.
|
|
390
|
-
*/
|
|
391
188
|
async saveSelects() {
|
|
392
189
|
if (this.storage) {
|
|
393
190
|
this.log.debug(`Saving ${this.selectDevice.size} selectDevice...`);
|
|
@@ -400,60 +197,19 @@ export class MatterbridgePlatform {
|
|
|
400
197
|
await selectEntity.close();
|
|
401
198
|
}
|
|
402
199
|
}
|
|
403
|
-
/**
|
|
404
|
-
* Clears all the select device and entity maps.
|
|
405
|
-
*
|
|
406
|
-
* @returns {void}
|
|
407
|
-
*/
|
|
408
200
|
async clearSelect() {
|
|
409
201
|
this.selectDevice.clear();
|
|
410
202
|
this.selectEntity.clear();
|
|
411
203
|
await this.saveSelects();
|
|
412
204
|
}
|
|
413
|
-
/**
|
|
414
|
-
* Clears the select for a single device.
|
|
415
|
-
*
|
|
416
|
-
* @param {string} serial - The serial of the device to clear.
|
|
417
|
-
* @returns {void}
|
|
418
|
-
*/
|
|
419
205
|
async clearDeviceSelect(serial) {
|
|
420
206
|
this.selectDevice.delete(serial);
|
|
421
207
|
await this.saveSelects();
|
|
422
208
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Clears the select for a single entity.
|
|
425
|
-
*
|
|
426
|
-
* @param {string} name - The name of the entity to clear.
|
|
427
|
-
* @returns {void}
|
|
428
|
-
*/
|
|
429
209
|
async clearEntitySelect(name) {
|
|
430
210
|
this.selectEntity.delete(name);
|
|
431
211
|
await this.saveSelects();
|
|
432
212
|
}
|
|
433
|
-
/**
|
|
434
|
-
* Set the select device in the platform map.
|
|
435
|
-
*
|
|
436
|
-
* @param {string} serial - The serial number of the device.
|
|
437
|
-
* @param {string} name - The name of the device.
|
|
438
|
-
* @param {string} [configUrl] - The configuration URL of the device.
|
|
439
|
-
* @param {string} [icon] - The icon of the device: 'wifi', 'ble', 'hub'
|
|
440
|
-
* @param {Array<{ name: string; description: string; icon?: string }>} [entities] - The entities associated with the device.
|
|
441
|
-
* @returns {void}
|
|
442
|
-
*
|
|
443
|
-
* @remarks
|
|
444
|
-
* In the schema use selectFrom: 'serial' or 'name'
|
|
445
|
-
* ```json
|
|
446
|
-
* "whiteList": {
|
|
447
|
-
* "description": "Only the devices in the list will be exposed.",
|
|
448
|
-
* "type": "array",
|
|
449
|
-
* "items": {
|
|
450
|
-
* "type": "string"
|
|
451
|
-
* },
|
|
452
|
-
* "uniqueItems": true,
|
|
453
|
-
* "selectFrom": "name"
|
|
454
|
-
* },
|
|
455
|
-
* ```
|
|
456
|
-
*/
|
|
457
213
|
setSelectDevice(serial, name, configUrl, icon, entities) {
|
|
458
214
|
const device = this.selectDevice.get(serial);
|
|
459
215
|
if (device) {
|
|
@@ -470,35 +226,6 @@ export class MatterbridgePlatform {
|
|
|
470
226
|
this.selectDevice.set(serial, { serial, name, configUrl, icon, entities });
|
|
471
227
|
}
|
|
472
228
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Set the select device entity in the platform map.
|
|
475
|
-
*
|
|
476
|
-
* @param {string} serial - The serial number of the device.
|
|
477
|
-
* @param {string} entityName - The name of the entity.
|
|
478
|
-
* @param {string} entityDescription - The description of the entity.
|
|
479
|
-
* @param {string} [entityIcon] - The icon of the entity: 'wifi', 'ble', 'hub', 'component', 'matter'
|
|
480
|
-
* @returns {void}
|
|
481
|
-
*
|
|
482
|
-
* @remarks
|
|
483
|
-
* In the schema use selectDeviceEntityFrom: 'name' or 'description'
|
|
484
|
-
* ```json
|
|
485
|
-
* "deviceEntityBlackList": {
|
|
486
|
-
* "description": "List of entities not to be exposed for a single device.",
|
|
487
|
-
* "type": "object",
|
|
488
|
-
* "uniqueItems": true,
|
|
489
|
-
* "selectFrom": "name",
|
|
490
|
-
* "additionalProperties": {
|
|
491
|
-
* "description": "List of entities not to be exposed for this device.",
|
|
492
|
-
* "type": "array",
|
|
493
|
-
* "items": {
|
|
494
|
-
* "type": "string"
|
|
495
|
-
* },
|
|
496
|
-
* "uniqueItems": true,
|
|
497
|
-
* "selectDeviceEntityFrom": "name"
|
|
498
|
-
* }
|
|
499
|
-
* },
|
|
500
|
-
* ```
|
|
501
|
-
*/
|
|
502
229
|
setSelectDeviceEntity(serial, entityName, entityDescription, entityIcon) {
|
|
503
230
|
const device = this.selectDevice.get(serial);
|
|
504
231
|
if (device) {
|
|
@@ -508,11 +235,6 @@ export class MatterbridgePlatform {
|
|
|
508
235
|
device.entities.push({ name: entityName, description: entityDescription, icon: entityIcon });
|
|
509
236
|
}
|
|
510
237
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Retrieves the select devices from the platform map.
|
|
513
|
-
*
|
|
514
|
-
* @returns {ApiSelectDevice[]} The selected devices array.
|
|
515
|
-
*/
|
|
516
238
|
getSelectDevices() {
|
|
517
239
|
const selectDevices = [];
|
|
518
240
|
for (const device of this.selectDevice.values()) {
|
|
@@ -520,36 +242,9 @@ export class MatterbridgePlatform {
|
|
|
520
242
|
}
|
|
521
243
|
return selectDevices;
|
|
522
244
|
}
|
|
523
|
-
/**
|
|
524
|
-
* Set the select entity in the platform map.
|
|
525
|
-
*
|
|
526
|
-
* @param {string} name - The entity name.
|
|
527
|
-
* @param {string} description - The entity description.
|
|
528
|
-
* @param {string} [icon] - The entity icon: 'wifi', 'ble', 'hub', 'component', 'matter'
|
|
529
|
-
* @returns {void}
|
|
530
|
-
*
|
|
531
|
-
* @remarks
|
|
532
|
-
* In the schema use selectEntityFrom: 'name' or 'description'
|
|
533
|
-
* ```json
|
|
534
|
-
* "entityBlackList": {
|
|
535
|
-
* "description": "The entities in the list will not be exposed.",
|
|
536
|
-
* "type": "array",
|
|
537
|
-
* "items": {
|
|
538
|
-
* "type": "string"
|
|
539
|
-
* },
|
|
540
|
-
* "uniqueItems": true,
|
|
541
|
-
* "selectEntityFrom": "name"
|
|
542
|
-
* },
|
|
543
|
-
* ```
|
|
544
|
-
*/
|
|
545
245
|
setSelectEntity(name, description, icon) {
|
|
546
246
|
this.selectEntity.set(name, { name, description, icon });
|
|
547
247
|
}
|
|
548
|
-
/**
|
|
549
|
-
* Retrieve the select entities.
|
|
550
|
-
*
|
|
551
|
-
* @returns {ApiSelectEntity[]} The select entities array.
|
|
552
|
-
*/
|
|
553
248
|
getSelectEntities() {
|
|
554
249
|
const selectEntities = [];
|
|
555
250
|
for (const entity of this.selectEntity.values()) {
|
|
@@ -557,12 +252,6 @@ export class MatterbridgePlatform {
|
|
|
557
252
|
}
|
|
558
253
|
return selectEntities;
|
|
559
254
|
}
|
|
560
|
-
/**
|
|
561
|
-
* Verifies if the Matterbridge version meets the required version.
|
|
562
|
-
*
|
|
563
|
-
* @param {string} requiredVersion - The required version to compare against.
|
|
564
|
-
* @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
|
|
565
|
-
*/
|
|
566
255
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
567
256
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
568
257
|
const stripTag = (v) => {
|
|
@@ -587,14 +276,6 @@ export class MatterbridgePlatform {
|
|
|
587
276
|
return false;
|
|
588
277
|
return true;
|
|
589
278
|
}
|
|
590
|
-
/**
|
|
591
|
-
* Validates if a device is allowed based on the whitelist and blacklist configurations.
|
|
592
|
-
* The blacklist has priority over the whitelist.
|
|
593
|
-
*
|
|
594
|
-
* @param {string | string[]} device - The device name(s) to validate.
|
|
595
|
-
* @param {boolean} [log] - Whether to log the validation result.
|
|
596
|
-
* @returns {boolean} - Returns true if the device is allowed, false otherwise.
|
|
597
|
-
*/
|
|
598
279
|
validateDevice(device, log = true) {
|
|
599
280
|
if (!Array.isArray(device))
|
|
600
281
|
device = [device];
|
|
@@ -624,14 +305,6 @@ export class MatterbridgePlatform {
|
|
|
624
305
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
625
306
|
return false;
|
|
626
307
|
}
|
|
627
|
-
/**
|
|
628
|
-
* Validates if an entity is allowed based on the entity blacklist and device-entity blacklist configurations.
|
|
629
|
-
*
|
|
630
|
-
* @param {string} device - The device to which the entity belongs.
|
|
631
|
-
* @param {string} entity - The entity to validate.
|
|
632
|
-
* @param {boolean} [log] - Whether to log the validation result.
|
|
633
|
-
* @returns {boolean} - Returns true if the entity is allowed, false otherwise.
|
|
634
|
-
*/
|
|
635
308
|
validateEntity(device, entity, log = true) {
|
|
636
309
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
637
310
|
if (log)
|
|
@@ -650,15 +323,6 @@ export class MatterbridgePlatform {
|
|
|
650
323
|
}
|
|
651
324
|
return true;
|
|
652
325
|
}
|
|
653
|
-
/**
|
|
654
|
-
* Checks and updates the endpoint numbers for Matterbridge devices.
|
|
655
|
-
*
|
|
656
|
-
* This method retrieves the list of Matterbridge devices and their child endpoints,
|
|
657
|
-
* compares their current endpoint numbers with the stored ones, and updates the storage
|
|
658
|
-
* if there are any changes. It logs the changes and updates the endpoint numbers accordingly.
|
|
659
|
-
*
|
|
660
|
-
* @returns {Promise<number>} The size of the updated endpoint map, or -1 if storage is not available.
|
|
661
|
-
*/
|
|
662
326
|
async checkEndpointNumbers() {
|
|
663
327
|
if (!this.storage)
|
|
664
328
|
return -1;
|
|
@@ -699,4 +363,3 @@ export class MatterbridgePlatform {
|
|
|
699
363
|
return endpointMap.size;
|
|
700
364
|
}
|
|
701
365
|
}
|
|
702
|
-
//# sourceMappingURL=matterbridgePlatform.js.map
|
|
@@ -1,33 +1,7 @@
|
|
|
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
|
-
//# sourceMappingURL=matterbridgeTypes.js.map
|