matterbridge 1.6.5 → 1.6.6-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cli.js +0 -26
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -26
  6. package/dist/index.js +0 -30
  7. package/dist/logger/export.js +0 -1
  8. package/dist/matter/export.js +0 -1
  9. package/dist/matterbridge.js +62 -702
  10. package/dist/matterbridgeAccessoryPlatform.js +0 -33
  11. package/dist/matterbridgeBehaviors.js +1 -29
  12. package/dist/matterbridgeDevice.js +39 -933
  13. package/dist/matterbridgeDeviceTypes.js +21 -41
  14. package/dist/matterbridgeDynamicPlatform.js +0 -33
  15. package/dist/matterbridgeEdge.js +0 -525
  16. package/dist/matterbridgeEndpoint.js +61 -1027
  17. package/dist/matterbridgePlatform.js +3 -74
  18. package/dist/matterbridgeTypes.js +0 -24
  19. package/dist/matterbridgeWebsocket.js +0 -45
  20. package/dist/pluginManager.js +3 -237
  21. package/dist/storage/export.js +0 -1
  22. package/dist/utils/colorUtils.js +2 -78
  23. package/dist/utils/export.js +0 -1
  24. package/dist/utils/utils.js +7 -252
  25. package/npm-shrinkwrap.json +12 -15
  26. package/package.json +2 -2
  27. package/dist/cli.d.ts +0 -25
  28. package/dist/cli.d.ts.map +0 -1
  29. package/dist/cli.js.map +0 -1
  30. package/dist/cluster/export.d.ts +0 -2
  31. package/dist/cluster/export.d.ts.map +0 -1
  32. package/dist/cluster/export.js.map +0 -1
  33. package/dist/defaultConfigSchema.d.ts +0 -27
  34. package/dist/defaultConfigSchema.d.ts.map +0 -1
  35. package/dist/defaultConfigSchema.js.map +0 -1
  36. package/dist/deviceManager.d.ts +0 -46
  37. package/dist/deviceManager.d.ts.map +0 -1
  38. package/dist/deviceManager.js.map +0 -1
  39. package/dist/index.d.ts +0 -40
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/logger/export.d.ts +0 -2
  43. package/dist/logger/export.d.ts.map +0 -1
  44. package/dist/logger/export.js.map +0 -1
  45. package/dist/matter/export.d.ts +0 -5
  46. package/dist/matter/export.d.ts.map +0 -1
  47. package/dist/matter/export.js.map +0 -1
  48. package/dist/matterbridge.d.ts +0 -466
  49. package/dist/matterbridge.d.ts.map +0 -1
  50. package/dist/matterbridge.js.map +0 -1
  51. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -39
  52. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  53. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  54. package/dist/matterbridgeBehaviors.d.ts +0 -934
  55. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  56. package/dist/matterbridgeBehaviors.js.map +0 -1
  57. package/dist/matterbridgeDevice.d.ts +0 -6504
  58. package/dist/matterbridgeDevice.d.ts.map +0 -1
  59. package/dist/matterbridgeDevice.js.map +0 -1
  60. package/dist/matterbridgeDeviceTypes.d.ts +0 -65
  61. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  62. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  63. package/dist/matterbridgeDynamicPlatform.d.ts +0 -39
  64. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  65. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  66. package/dist/matterbridgeEdge.d.ts +0 -89
  67. package/dist/matterbridgeEdge.d.ts.map +0 -1
  68. package/dist/matterbridgeEdge.js.map +0 -1
  69. package/dist/matterbridgeEndpoint.d.ts +0 -8529
  70. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  71. package/dist/matterbridgeEndpoint.js.map +0 -1
  72. package/dist/matterbridgePlatform.d.ts +0 -96
  73. package/dist/matterbridgePlatform.d.ts.map +0 -1
  74. package/dist/matterbridgePlatform.js.map +0 -1
  75. package/dist/matterbridgeTypes.d.ts +0 -147
  76. package/dist/matterbridgeTypes.d.ts.map +0 -1
  77. package/dist/matterbridgeTypes.js.map +0 -1
  78. package/dist/matterbridgeWebsocket.d.ts +0 -49
  79. package/dist/matterbridgeWebsocket.d.ts.map +0 -1
  80. package/dist/matterbridgeWebsocket.js.map +0 -1
  81. package/dist/pluginManager.d.ts +0 -238
  82. package/dist/pluginManager.d.ts.map +0 -1
  83. package/dist/pluginManager.js.map +0 -1
  84. package/dist/storage/export.d.ts +0 -2
  85. package/dist/storage/export.d.ts.map +0 -1
  86. package/dist/storage/export.js.map +0 -1
  87. package/dist/utils/colorUtils.d.ts +0 -61
  88. package/dist/utils/colorUtils.d.ts.map +0 -1
  89. package/dist/utils/colorUtils.js.map +0 -1
  90. package/dist/utils/export.d.ts +0 -3
  91. package/dist/utils/export.d.ts.map +0 -1
  92. package/dist/utils/export.js.map +0 -1
  93. package/dist/utils/utils.d.ts +0 -221
  94. package/dist/utils/utils.d.ts.map +0 -1
  95. package/dist/utils/utils.js.map +0 -1
@@ -1,88 +1,30 @@
1
- /**
2
- * This file contains the class MatterbridgeAccessoryPlatform.
3
- *
4
- * @file matterbridgePlatform.ts
5
- * @author Luca Liguori
6
- * @date 2024-03-21
7
- * @version 1.0.0
8
- *
9
- * Copyright 2024, 2025, 2026 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
1
  import { MatterbridgeDevice } from './matterbridgeDevice.js';
24
2
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
25
- /**
26
- * Represents the base Matterbridge platform.
27
- *
28
- */
29
3
  export class MatterbridgePlatform {
30
4
  matterbridge;
31
5
  log;
32
6
  config = {};
33
- name = ''; // Will be set by the loadPlugin() method using the package.json value.
34
- type = ''; // Will be set by the extending classes.
35
- version = ''; // Will be set by the loadPlugin() method using the package.json value.
36
- /**
37
- * Creates an instance of the base MatterbridgePlatform.
38
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
39
- * @param {AnsiLogger} log - The logger instance.
40
- * @param {PlatformConfig} config - The platform configuration.
41
- */
7
+ name = '';
8
+ type = '';
9
+ version = '';
42
10
  constructor(matterbridge, log, config) {
43
11
  this.matterbridge = matterbridge;
44
12
  this.log = log;
45
13
  this.config = config;
46
14
  }
47
- /**
48
- * This method must be overridden in the extended class.
49
- * It is called when the platform is started.
50
- * Use this method to create the MatterbridgeDevice and call this.registerDevice().
51
- * @param {string} [reason] - The reason for starting.
52
- * @throws {Error} - Throws an error if the method is not overridden.
53
- */
54
15
  async onStart(reason) {
55
16
  this.log.error('Plugins must override onStart.', reason);
56
17
  throw new Error('Plugins must override onStart.');
57
18
  }
58
- /**
59
- * This method can be overridden in the extended class.
60
- * It is called after the platform has been commissioned.
61
- * Use this method to perform any configuration of your devices.
62
- */
63
19
  async onConfigure() {
64
20
  this.log.debug("The plugin doesn't override onConfigure.");
65
21
  }
66
- /**
67
- * This method can be overridden in the extended class.
68
- * It is called when the platform is shutting down.
69
- * Use this method to clean up any resources.
70
- * @param {string} [reason] - The reason for shutting down.
71
- */
72
22
  async onShutdown(reason) {
73
23
  this.log.debug("The plugin doesn't override onShutdown.", reason);
74
24
  }
75
- /**
76
- * Sets the logger level and logs a debug message indicating that the plugin doesn't override this method.
77
- * @param {LogLevel} logLevel The new logger level.
78
- */
79
25
  async onChangeLoggerLevel(logLevel) {
80
26
  this.log.debug(`The plugin doesn't override onChangeLoggerLevel. Logger level set to: ${logLevel}`);
81
27
  }
82
- /**
83
- * Registers a device with the Matterbridge platform.
84
- * @param {MatterbridgeDevice} device - The device to register.
85
- */
86
28
  async registerDevice(device) {
87
29
  device.plugin = this.name;
88
30
  if (device instanceof MatterbridgeDevice)
@@ -90,27 +32,15 @@ export class MatterbridgePlatform {
90
32
  if (device instanceof MatterbridgeEndpoint)
91
33
  await this.matterbridge.addBridgedEndpoint(this.name, device);
92
34
  }
93
- /**
94
- * Unregisters a device registered with the Matterbridge platform.
95
- * @param {MatterbridgeDevice} device - The device to unregister.
96
- */
97
35
  async unregisterDevice(device) {
98
36
  if (device instanceof MatterbridgeDevice)
99
37
  await this.matterbridge.removeBridgedDevice(this.name, device);
100
38
  if (device instanceof MatterbridgeEndpoint)
101
39
  await this.matterbridge.removeBridgedEndpoint(this.name, device);
102
40
  }
103
- /**
104
- * Unregisters all devices registered with the Matterbridge platform.
105
- */
106
41
  async unregisterAllDevices() {
107
42
  await this.matterbridge.removeAllBridgedDevices(this.name);
108
43
  }
109
- /**
110
- * Verifies if the Matterbridge version meets the required version.
111
- * @param {string} requiredVersion - The required version to compare against.
112
- * @returns {boolean} True if the Matterbridge version meets or exceeds the required version, false otherwise.
113
- */
114
44
  verifyMatterbridgeVersion(requiredVersion) {
115
45
  const compareVersions = (matterbridgeVersion, requiredVersion) => {
116
46
  const stripTag = (v) => {
@@ -136,4 +66,3 @@ export class MatterbridgePlatform {
136
66
  return true;
137
67
  }
138
68
  }
139
- //# sourceMappingURL=matterbridgePlatform.js.map
@@ -1,27 +1,3 @@
1
- /**
2
- * This file contains the types for Matterbridge.
3
- *
4
- * @file matterbridgeTypes.ts
5
- * @author Luca Liguori
6
- * @date 2024-07-12
7
- * @version 1.0.2
8
- *
9
- * Copyright 2023, 2024, 2025 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // Default colors
24
1
  export const plg = '\u001B[38;5;33m';
25
2
  export const dev = '\u001B[38;5;79m';
26
3
  export const typ = '\u001B[38;5;207m';
27
- //# sourceMappingURL=matterbridgeTypes.js.map
@@ -1,54 +1,10 @@
1
- /**
2
- * This file contains the function matterbridgeMessageHandler.
3
- *
4
- * @file matterbridgeWebsocket.ts
5
- * @author Luca Liguori
6
- * @date 2024-10-16
7
- * @version 1.0.0
8
- *
9
- * Copyright 2024, 2025, 2026 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
1
  import { isValidNumber, isValidObject, isValidString } from './utils/utils.js';
24
- // AnsiLogger module
25
2
  import { debugStringify } from 'node-ansi-logger';
26
- // @matter
27
3
  import { Logger } from '@matter/main';
28
4
  import { BasicInformationCluster, BridgedDeviceBasicInformationCluster } from '@matter/main/clusters';
29
- /**
30
- * Websocket message ID for logging.
31
- * @constant {number}
32
- */
33
5
  export const WS_ID_LOG = 0;
34
- /**
35
- * Websocket message ID indicating a refresh is needed.
36
- * @constant {number}
37
- */
38
6
  export const WS_ID_REFRESH_NEEDED = 1;
39
- /**
40
- * Websocket message ID indicating a restart is needed.
41
- * @constant {number}
42
- */
43
7
  export const WS_ID_RESTART_NEEDED = 2;
44
- /**
45
- * Handles incoming websocket messages for the Matterbridge.
46
- *
47
- * @param {Matterbridge} this - The Matterbridge instance.
48
- * @param {WebSocket} client - The websocket client that sent the message.
49
- * @param {WebSocket.RawData} message - The raw data of the message received from the client.
50
- * @returns {Promise<void>} A promise that resolves when the message has been handled.
51
- */
52
8
  export async function wsMessageHandler(client, message) {
53
9
  let data;
54
10
  try {
@@ -180,4 +136,3 @@ export async function wsMessageHandler(client, message) {
180
136
  return;
181
137
  }
182
138
  }
183
- //# sourceMappingURL=matterbridgeWebsocket.js.map