matterbridge 3.3.8 → 3.3.9-dev-20251118-930cfdb
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 +1 -354
- 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,27 @@ 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
|
-
* Represents the base Matterbridge platform. It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
12
|
export class MatterbridgePlatform {
|
|
44
|
-
/** The Matterbridge instance of this Platform. */
|
|
45
13
|
matterbridge;
|
|
46
|
-
/** The logger instance for this platform. */
|
|
47
14
|
log;
|
|
48
|
-
/** The configuration for this platform. */
|
|
49
15
|
config;
|
|
50
|
-
/** The name of the platform. Will be set by the loadPlugin() method using the package.json value. */
|
|
51
16
|
name = '';
|
|
52
|
-
/** The type of the platform. Will be set by the extending classes. */
|
|
53
17
|
type = 'AnyPlatform';
|
|
54
|
-
/** The version of the platform. Will be set by the loadPlugin() method using the package.json value */
|
|
55
18
|
version = '1.0.0';
|
|
56
|
-
/** Platform node storage manager in the matterbridgeDirectory. */
|
|
57
19
|
storage;
|
|
58
|
-
/** Platform context in the storage of matterbridgeDirectory. Use await platform.ready to access it early. */
|
|
59
20
|
context;
|
|
60
|
-
// Device and entity select in the plugin config UI
|
|
61
21
|
selectDevice = new Map();
|
|
62
22
|
selectEntity = new Map();
|
|
63
|
-
// Promises for platform initialization. They are grouped in platform.ready with Promise.all.
|
|
64
23
|
contextReady;
|
|
65
24
|
selectDeviceContextReady;
|
|
66
25
|
selectEntityContextReady;
|
|
67
|
-
/** The ready promise for the platform, which resolves when the platform is fully initialized (including context and selects). */
|
|
68
26
|
ready;
|
|
69
|
-
/** Registered MatterbridgeEndpoint map keyed by uniqueId */
|
|
70
27
|
registeredEndpointsByUniqueId = new Map();
|
|
71
|
-
/** Registered MatterbridgeEndpoint map keyed by deviceName */
|
|
72
28
|
registeredEndpointsByName = new Map();
|
|
73
|
-
/**
|
|
74
|
-
* Creates an instance of the base MatterbridgePlatform.
|
|
75
|
-
* It is extended by the MatterbridgeAccessoryPlatform and MatterbridgeServicePlatform classes.
|
|
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
|
-
*/
|
|
82
29
|
constructor(matterbridge, log, config) {
|
|
83
30
|
this.matterbridge = matterbridge;
|
|
84
31
|
this.log = log;
|
|
85
32
|
this.config = config;
|
|
86
|
-
// create the NodeStorageManager for the plugin platform
|
|
87
33
|
if (!isValidString(this.config.name, 1))
|
|
88
34
|
throw new Error('Platform: the plugin name is missing or invalid.');
|
|
89
35
|
this.log.debug(`Creating storage for plugin ${this.config.name} in ${path.join(this.matterbridge.matterbridgeDirectory, this.config.name)}`);
|
|
@@ -94,14 +40,12 @@ export class MatterbridgePlatform {
|
|
|
94
40
|
logging: false,
|
|
95
41
|
forgiveParseErrors: true,
|
|
96
42
|
});
|
|
97
|
-
// create the context storage for the plugin platform
|
|
98
43
|
this.log.debug(`Creating context for plugin ${this.config.name}`);
|
|
99
44
|
this.contextReady = this.storage.createStorage('context').then((context) => {
|
|
100
45
|
this.context = context;
|
|
101
46
|
this.log.debug(`Created context for plugin ${this.config.name}`);
|
|
102
47
|
return;
|
|
103
48
|
});
|
|
104
|
-
// create the selectDevice storage for the plugin platform
|
|
105
49
|
this.log.debug(`Loading selectDevice for plugin ${this.config.name}`);
|
|
106
50
|
this.selectDeviceContextReady = this.storage.createStorage('selectDevice').then(async (context) => {
|
|
107
51
|
const selectDevice = await context.get('selectDevice', []);
|
|
@@ -110,7 +54,6 @@ export class MatterbridgePlatform {
|
|
|
110
54
|
this.log.debug(`Loaded ${this.selectDevice.size} selectDevice for plugin ${this.config.name}`);
|
|
111
55
|
return;
|
|
112
56
|
});
|
|
113
|
-
// create the selectEntity storage for the plugin platform
|
|
114
57
|
this.log.debug(`Loading selectEntity for plugin ${this.config.name}`);
|
|
115
58
|
this.selectEntityContextReady = this.storage.createStorage('selectEntity').then(async (context) => {
|
|
116
59
|
const selectEntity = await context.get('selectEntity', []);
|
|
@@ -119,192 +62,73 @@ export class MatterbridgePlatform {
|
|
|
119
62
|
this.log.debug(`Loaded ${this.selectEntity.size} selectEntity for plugin ${this.config.name}`);
|
|
120
63
|
return;
|
|
121
64
|
});
|
|
122
|
-
// Create the `ready` promise for the platform
|
|
123
65
|
this.ready = Promise.all([this.contextReady, this.selectDeviceContextReady, this.selectEntityContextReady]).then(() => {
|
|
124
66
|
this.log.debug(`MatterbridgePlatform for plugin ${this.config.name} is fully initialized`);
|
|
125
67
|
return;
|
|
126
68
|
});
|
|
127
69
|
}
|
|
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
70
|
async onStart(reason) {
|
|
137
71
|
this.log.error('Plugins must override onStart.', reason);
|
|
138
72
|
throw new Error('Plugins must override onStart.');
|
|
139
73
|
}
|
|
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
74
|
async onConfigure() {
|
|
147
75
|
this.log.debug(`Configuring platform ${this.name}`);
|
|
148
|
-
// Save the selectDevice and selectEntity
|
|
149
76
|
await this.saveSelects();
|
|
150
|
-
// Check and update the endpoint numbers
|
|
151
77
|
await this.checkEndpointNumbers();
|
|
152
78
|
}
|
|
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
79
|
async onShutdown(reason) {
|
|
161
80
|
this.log.debug(`Shutting down platform ${this.name}`, reason);
|
|
162
|
-
// Save the selectDevice and selectEntity
|
|
163
81
|
await this.saveSelects();
|
|
164
|
-
// Check and update the endpoint numbers
|
|
165
82
|
await this.checkEndpointNumbers();
|
|
166
|
-
// Cleanup memory
|
|
167
83
|
this.selectDevice.clear();
|
|
168
84
|
this.selectEntity.clear();
|
|
169
85
|
this.registeredEndpointsByUniqueId.clear();
|
|
170
86
|
this.registeredEndpointsByName.clear();
|
|
171
|
-
// Close the storage
|
|
172
87
|
await this.context?.close();
|
|
173
88
|
this.context = undefined;
|
|
174
89
|
await this.storage?.close();
|
|
175
90
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Called when the logger level is changed.
|
|
178
|
-
*
|
|
179
|
-
* @param {LogLevel} logLevel The new logger level.
|
|
180
|
-
*/
|
|
181
91
|
async onChangeLoggerLevel(logLevel) {
|
|
182
92
|
this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
|
|
183
93
|
}
|
|
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
94
|
async onAction(action, value, id, formData) {
|
|
210
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);
|
|
211
96
|
}
|
|
212
|
-
/**
|
|
213
|
-
* Called when the plugin config has been updated.
|
|
214
|
-
*
|
|
215
|
-
* @param {PlatformConfig} config The new plugin config.
|
|
216
|
-
*/
|
|
217
97
|
async onConfigChanged(config) {
|
|
218
98
|
this.log.debug(`The plugin ${CYAN}${config.name}${db} doesn't override onConfigChanged. Received new config.`);
|
|
219
99
|
}
|
|
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
100
|
saveConfig(config) {
|
|
227
|
-
// TODO: replace with a message to the plugins thread
|
|
228
101
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
229
102
|
if (!plugin) {
|
|
230
103
|
throw new Error(`Plugin ${this.name} not found`);
|
|
231
104
|
}
|
|
232
|
-
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
105
|
+
this.matterbridge.plugins.saveConfigFromJson(plugin, config);
|
|
233
106
|
}
|
|
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
107
|
getSchema() {
|
|
240
|
-
// TODO: replace with a message to the plugins thread
|
|
241
108
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
242
109
|
if (!plugin || !isValidObject(plugin.schemaJson)) {
|
|
243
110
|
throw new Error(`Plugin ${this.name} not found`);
|
|
244
111
|
}
|
|
245
112
|
return plugin.schemaJson;
|
|
246
113
|
}
|
|
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
114
|
setSchema(schema) {
|
|
254
|
-
// TODO: replace with a message to the plugins thread
|
|
255
115
|
const plugin = this.matterbridge.plugins.get(this.name);
|
|
256
116
|
if (!plugin) {
|
|
257
117
|
throw new Error(`Plugin ${this.name} not found`);
|
|
258
118
|
}
|
|
259
119
|
plugin.schemaJson = schema;
|
|
260
120
|
}
|
|
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
121
|
wssSendRestartRequired(snackbar = true, fixed = false) {
|
|
269
|
-
// TODO: replace with a message to the frontend thread
|
|
270
122
|
this.matterbridge.frontend.wssSendRestartRequired(snackbar, fixed);
|
|
271
123
|
}
|
|
272
|
-
/**
|
|
273
|
-
* Retrieves the devices registered with the platform.
|
|
274
|
-
*
|
|
275
|
-
* @returns {MatterbridgeEndpoint[]} The registered devices.
|
|
276
|
-
*/
|
|
277
124
|
getDevices() {
|
|
278
125
|
return Array.from(this.registeredEndpointsByUniqueId.values());
|
|
279
126
|
}
|
|
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
127
|
hasDeviceName(deviceName) {
|
|
287
128
|
return this.registeredEndpointsByName.has(deviceName);
|
|
288
129
|
}
|
|
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
130
|
async registerVirtualDevice(name, type, callback) {
|
|
306
131
|
let aggregator;
|
|
307
|
-
// TODO: replace with a message to the matterbridge thread
|
|
308
132
|
if (this.matterbridge.bridgeMode === 'bridge') {
|
|
309
133
|
aggregator = this.matterbridge.aggregatorNode;
|
|
310
134
|
}
|
|
@@ -324,25 +148,6 @@ export class MatterbridgePlatform {
|
|
|
324
148
|
}
|
|
325
149
|
return false;
|
|
326
150
|
}
|
|
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
151
|
async registerDevice(device) {
|
|
347
152
|
device.plugin = this.name;
|
|
348
153
|
if (!device.uniqueId) {
|
|
@@ -364,9 +169,7 @@ export class MatterbridgePlatform {
|
|
|
364
169
|
if (checkNotLatinCharacters(device.deviceName)) {
|
|
365
170
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has non latin characters.`);
|
|
366
171
|
}
|
|
367
|
-
// Validate bridgedNode and BridgedDeviceBasicInformation cluster
|
|
368
172
|
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
173
|
if (!device.deviceTypes.has(bridgedNode.code)) {
|
|
371
174
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no bridgedNode device type. Adding it...`);
|
|
372
175
|
device.deviceTypes.set(bridgedNode.code, bridgedNode);
|
|
@@ -378,49 +181,27 @@ export class MatterbridgePlatform {
|
|
|
378
181
|
}
|
|
379
182
|
}
|
|
380
183
|
}
|
|
381
|
-
// If the device is a bridged device, we add the BridgedDeviceBasicInformation cluster
|
|
382
184
|
if (!device.hasClusterServer(BridgedDeviceBasicInformation.Cluster.id)) {
|
|
383
185
|
this.log.debug(`Device with name ${CYAN}${device.deviceName}${db} has no BridgedDeviceBasicInformation cluster. Adding it...`);
|
|
384
186
|
device.createDefaultBridgedDeviceBasicInformationClusterServer(device.deviceName, device.serialNumber, device.vendorId, device.vendorName, device.productName, device.softwareVersion, device.softwareVersionString, device.hardwareVersion, device.hardwareVersionString);
|
|
385
187
|
}
|
|
386
188
|
}
|
|
387
|
-
// TODO: replace with a message to the matterbridge thread
|
|
388
189
|
await this.matterbridge.addBridgedEndpoint(this.name, device);
|
|
389
190
|
this.registeredEndpointsByUniqueId.set(device.uniqueId, device);
|
|
390
191
|
this.registeredEndpointsByName.set(device.deviceName, device);
|
|
391
192
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Unregisters a device registered with the Matterbridge platform.
|
|
394
|
-
*
|
|
395
|
-
* @param {MatterbridgeEndpoint} device - The device to unregister.
|
|
396
|
-
*/
|
|
397
193
|
async unregisterDevice(device) {
|
|
398
|
-
// TODO: replace with a message to the matterbridge thread
|
|
399
194
|
await this.matterbridge.removeBridgedEndpoint(this.name, device);
|
|
400
195
|
if (device.uniqueId)
|
|
401
196
|
this.registeredEndpointsByUniqueId.delete(device.uniqueId);
|
|
402
197
|
if (device.deviceName)
|
|
403
198
|
this.registeredEndpointsByName.delete(device.deviceName);
|
|
404
199
|
}
|
|
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
200
|
async unregisterAllDevices(delay = 0) {
|
|
411
|
-
// TODO: replace with a message to the matterbridge thread
|
|
412
201
|
await this.matterbridge.removeAllBridgedEndpoints(this.name, delay);
|
|
413
202
|
this.registeredEndpointsByUniqueId.clear();
|
|
414
203
|
this.registeredEndpointsByName.clear();
|
|
415
204
|
}
|
|
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
205
|
async saveSelects() {
|
|
425
206
|
if (this.storage) {
|
|
426
207
|
this.log.debug(`Saving ${this.selectDevice.size} selectDevice...`);
|
|
@@ -433,60 +214,19 @@ export class MatterbridgePlatform {
|
|
|
433
214
|
await selectEntity.close();
|
|
434
215
|
}
|
|
435
216
|
}
|
|
436
|
-
/**
|
|
437
|
-
* Clears all the select device and entity maps.
|
|
438
|
-
*
|
|
439
|
-
* @returns {void}
|
|
440
|
-
*/
|
|
441
217
|
async clearSelect() {
|
|
442
218
|
this.selectDevice.clear();
|
|
443
219
|
this.selectEntity.clear();
|
|
444
220
|
await this.saveSelects();
|
|
445
221
|
}
|
|
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
222
|
async clearDeviceSelect(serial) {
|
|
453
223
|
this.selectDevice.delete(serial);
|
|
454
224
|
await this.saveSelects();
|
|
455
225
|
}
|
|
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
226
|
async clearEntitySelect(name) {
|
|
463
227
|
this.selectEntity.delete(name);
|
|
464
228
|
await this.saveSelects();
|
|
465
229
|
}
|
|
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
230
|
setSelectDevice(serial, name, configUrl, icon, entities) {
|
|
491
231
|
const device = this.selectDevice.get(serial);
|
|
492
232
|
if (device) {
|
|
@@ -503,35 +243,6 @@ export class MatterbridgePlatform {
|
|
|
503
243
|
this.selectDevice.set(serial, { serial, name, configUrl, icon, entities });
|
|
504
244
|
}
|
|
505
245
|
}
|
|
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
246
|
setSelectDeviceEntity(serial, entityName, entityDescription, entityIcon) {
|
|
536
247
|
const device = this.selectDevice.get(serial);
|
|
537
248
|
if (device) {
|
|
@@ -541,11 +252,6 @@ export class MatterbridgePlatform {
|
|
|
541
252
|
device.entities.push({ name: entityName, description: entityDescription, icon: entityIcon });
|
|
542
253
|
}
|
|
543
254
|
}
|
|
544
|
-
/**
|
|
545
|
-
* Retrieves the select devices from the platform map.
|
|
546
|
-
*
|
|
547
|
-
* @returns {ApiSelectDevice[]} The selected devices array.
|
|
548
|
-
*/
|
|
549
255
|
getSelectDevices() {
|
|
550
256
|
const selectDevices = [];
|
|
551
257
|
for (const device of this.selectDevice.values()) {
|
|
@@ -553,36 +259,9 @@ export class MatterbridgePlatform {
|
|
|
553
259
|
}
|
|
554
260
|
return selectDevices;
|
|
555
261
|
}
|
|
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
262
|
setSelectEntity(name, description, icon) {
|
|
579
263
|
this.selectEntity.set(name, { name, description, icon });
|
|
580
264
|
}
|
|
581
|
-
/**
|
|
582
|
-
* Retrieve the select entities.
|
|
583
|
-
*
|
|
584
|
-
* @returns {ApiSelectEntity[]} The select entities array.
|
|
585
|
-
*/
|
|
586
265
|
getSelectEntities() {
|
|
587
266
|
const selectEntities = [];
|
|
588
267
|
for (const entity of this.selectEntity.values()) {
|
|
@@ -590,12 +269,6 @@ export class MatterbridgePlatform {
|
|
|
590
269
|
}
|
|
591
270
|
return selectEntities;
|
|
592
271
|
}
|
|
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
272
|
verifyMatterbridgeVersion(requiredVersion) {
|
|
600
273
|
const compareVersions = (matterbridgeVersion, requiredVersion) => {
|
|
601
274
|
const stripTag = (v) => {
|
|
@@ -620,14 +293,6 @@ export class MatterbridgePlatform {
|
|
|
620
293
|
return false;
|
|
621
294
|
return true;
|
|
622
295
|
}
|
|
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
296
|
validateDevice(device, log = true) {
|
|
632
297
|
if (!Array.isArray(device))
|
|
633
298
|
device = [device];
|
|
@@ -657,14 +322,6 @@ export class MatterbridgePlatform {
|
|
|
657
322
|
this.log.info(`Skipping device ${CYAN}${device.join(', ')}${nf} because not in whitelist`);
|
|
658
323
|
return false;
|
|
659
324
|
}
|
|
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
325
|
validateEntity(device, entity, log = true) {
|
|
669
326
|
if (isValidArray(this.config.entityBlackList, 1) && this.config.entityBlackList.find((e) => e === entity)) {
|
|
670
327
|
if (log)
|
|
@@ -683,15 +340,6 @@ export class MatterbridgePlatform {
|
|
|
683
340
|
}
|
|
684
341
|
return true;
|
|
685
342
|
}
|
|
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
343
|
async checkEndpointNumbers() {
|
|
696
344
|
if (!this.storage)
|
|
697
345
|
return -1;
|
|
@@ -732,4 +380,3 @@ export class MatterbridgePlatform {
|
|
|
732
380
|
return endpointMap.size;
|
|
733
381
|
}
|
|
734
382
|
}
|
|
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
|