matterbridge 3.0.6 → 3.0.7-dev-20250615-2a6da14

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 (187) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README-DEV.md +66 -35
  3. package/README.md +1 -1
  4. package/dist/cli.js +2 -62
  5. package/dist/clusters/export.js +1 -0
  6. package/dist/defaultConfigSchema.js +0 -23
  7. package/dist/deviceManager.js +1 -94
  8. package/dist/devices/export.js +4 -0
  9. package/dist/evse.js +9 -65
  10. package/dist/frontend.js +16 -374
  11. package/dist/globalMatterbridge.js +0 -20
  12. package/dist/helpers.js +0 -51
  13. package/dist/index.js +1 -28
  14. package/dist/laundryWasher.js +7 -92
  15. package/dist/logger/export.js +0 -1
  16. package/dist/matter/behaviors.js +0 -2
  17. package/dist/matter/clusters.js +0 -2
  18. package/dist/matter/devices.js +0 -2
  19. package/dist/matter/endpoints.js +0 -2
  20. package/dist/matter/export.js +0 -2
  21. package/dist/matter/types.js +0 -2
  22. package/dist/matterbridge.js +46 -748
  23. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  24. package/dist/matterbridgeBehaviors.js +1 -54
  25. package/dist/matterbridgeDeviceTypes.js +15 -578
  26. package/dist/matterbridgeDynamicPlatform.js +0 -34
  27. package/dist/matterbridgeEndpoint.js +43 -997
  28. package/dist/matterbridgeEndpointHelpers.js +10 -204
  29. package/dist/matterbridgePlatform.js +7 -225
  30. package/dist/matterbridgeTypes.js +0 -24
  31. package/dist/pluginManager.js +3 -269
  32. package/dist/roboticVacuumCleaner.js +6 -81
  33. package/dist/shelly.js +7 -155
  34. package/dist/storage/export.js +0 -1
  35. package/dist/update.js +0 -53
  36. package/dist/utils/colorUtils.js +2 -205
  37. package/dist/utils/commandLine.js +0 -53
  38. package/dist/utils/copyDirectory.js +1 -37
  39. package/dist/utils/createDirectory.js +0 -31
  40. package/dist/utils/createZip.js +2 -42
  41. package/dist/utils/deepCopy.js +0 -38
  42. package/dist/utils/deepEqual.js +1 -71
  43. package/dist/utils/export.js +0 -1
  44. package/dist/utils/hex.js +0 -57
  45. package/dist/utils/isvalid.js +0 -100
  46. package/dist/utils/network.js +5 -76
  47. package/dist/utils/spawn.js +0 -16
  48. package/dist/utils/wait.js +9 -58
  49. package/dist/waterHeater.js +2 -62
  50. package/npm-shrinkwrap.json +41 -29
  51. package/package.json +23 -20
  52. package/dist/cli.d.ts +0 -29
  53. package/dist/cli.d.ts.map +0 -1
  54. package/dist/cli.js.map +0 -1
  55. package/dist/cluster/export.d.ts +0 -2
  56. package/dist/cluster/export.d.ts.map +0 -1
  57. package/dist/cluster/export.js +0 -3
  58. package/dist/cluster/export.js.map +0 -1
  59. package/dist/defaultConfigSchema.d.ts +0 -27
  60. package/dist/defaultConfigSchema.d.ts.map +0 -1
  61. package/dist/defaultConfigSchema.js.map +0 -1
  62. package/dist/deviceManager.d.ts +0 -114
  63. package/dist/deviceManager.d.ts.map +0 -1
  64. package/dist/deviceManager.js.map +0 -1
  65. package/dist/evse.d.ts +0 -67
  66. package/dist/evse.d.ts.map +0 -1
  67. package/dist/evse.js.map +0 -1
  68. package/dist/frontend.d.ts +0 -256
  69. package/dist/frontend.d.ts.map +0 -1
  70. package/dist/frontend.js.map +0 -1
  71. package/dist/globalMatterbridge.d.ts +0 -32
  72. package/dist/globalMatterbridge.d.ts.map +0 -1
  73. package/dist/globalMatterbridge.js.map +0 -1
  74. package/dist/helpers.d.ts +0 -47
  75. package/dist/helpers.d.ts.map +0 -1
  76. package/dist/helpers.js.map +0 -1
  77. package/dist/index.d.ts +0 -37
  78. package/dist/index.d.ts.map +0 -1
  79. package/dist/index.js.map +0 -1
  80. package/dist/laundryWasher.d.ts +0 -243
  81. package/dist/laundryWasher.d.ts.map +0 -1
  82. package/dist/laundryWasher.js.map +0 -1
  83. package/dist/logger/export.d.ts +0 -2
  84. package/dist/logger/export.d.ts.map +0 -1
  85. package/dist/logger/export.js.map +0 -1
  86. package/dist/matter/behaviors.d.ts +0 -2
  87. package/dist/matter/behaviors.d.ts.map +0 -1
  88. package/dist/matter/behaviors.js.map +0 -1
  89. package/dist/matter/clusters.d.ts +0 -2
  90. package/dist/matter/clusters.d.ts.map +0 -1
  91. package/dist/matter/clusters.js.map +0 -1
  92. package/dist/matter/devices.d.ts +0 -2
  93. package/dist/matter/devices.d.ts.map +0 -1
  94. package/dist/matter/devices.js.map +0 -1
  95. package/dist/matter/endpoints.d.ts +0 -2
  96. package/dist/matter/endpoints.d.ts.map +0 -1
  97. package/dist/matter/endpoints.js.map +0 -1
  98. package/dist/matter/export.d.ts +0 -5
  99. package/dist/matter/export.d.ts.map +0 -1
  100. package/dist/matter/export.js.map +0 -1
  101. package/dist/matter/types.d.ts +0 -3
  102. package/dist/matter/types.d.ts.map +0 -1
  103. package/dist/matter/types.js.map +0 -1
  104. package/dist/matterbridge.d.ts +0 -445
  105. package/dist/matterbridge.d.ts.map +0 -1
  106. package/dist/matterbridge.js.map +0 -1
  107. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  108. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  109. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  110. package/dist/matterbridgeBehaviors.d.ts +0 -1333
  111. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  112. package/dist/matterbridgeBehaviors.js.map +0 -1
  113. package/dist/matterbridgeDeviceTypes.d.ts +0 -644
  114. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  115. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  116. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  117. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  118. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  119. package/dist/matterbridgeEndpoint.d.ts +0 -1144
  120. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  121. package/dist/matterbridgeEndpoint.js.map +0 -1
  122. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
  123. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  124. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  125. package/dist/matterbridgePlatform.d.ts +0 -294
  126. package/dist/matterbridgePlatform.d.ts.map +0 -1
  127. package/dist/matterbridgePlatform.js.map +0 -1
  128. package/dist/matterbridgeTypes.d.ts +0 -196
  129. package/dist/matterbridgeTypes.d.ts.map +0 -1
  130. package/dist/matterbridgeTypes.js.map +0 -1
  131. package/dist/pluginManager.d.ts +0 -273
  132. package/dist/pluginManager.d.ts.map +0 -1
  133. package/dist/pluginManager.js.map +0 -1
  134. package/dist/roboticVacuumCleaner.d.ts +0 -102
  135. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  136. package/dist/roboticVacuumCleaner.js.map +0 -1
  137. package/dist/shelly.d.ts +0 -161
  138. package/dist/shelly.d.ts.map +0 -1
  139. package/dist/shelly.js.map +0 -1
  140. package/dist/storage/export.d.ts +0 -2
  141. package/dist/storage/export.d.ts.map +0 -1
  142. package/dist/storage/export.js.map +0 -1
  143. package/dist/update.d.ts +0 -58
  144. package/dist/update.d.ts.map +0 -1
  145. package/dist/update.js.map +0 -1
  146. package/dist/utils/colorUtils.d.ts +0 -61
  147. package/dist/utils/colorUtils.d.ts.map +0 -1
  148. package/dist/utils/colorUtils.js.map +0 -1
  149. package/dist/utils/commandLine.d.ts +0 -58
  150. package/dist/utils/commandLine.d.ts.map +0 -1
  151. package/dist/utils/commandLine.js.map +0 -1
  152. package/dist/utils/copyDirectory.d.ts +0 -32
  153. package/dist/utils/copyDirectory.d.ts.map +0 -1
  154. package/dist/utils/copyDirectory.js.map +0 -1
  155. package/dist/utils/createDirectory.d.ts +0 -32
  156. package/dist/utils/createDirectory.d.ts.map +0 -1
  157. package/dist/utils/createDirectory.js.map +0 -1
  158. package/dist/utils/createZip.d.ts +0 -38
  159. package/dist/utils/createZip.d.ts.map +0 -1
  160. package/dist/utils/createZip.js.map +0 -1
  161. package/dist/utils/deepCopy.d.ts +0 -31
  162. package/dist/utils/deepCopy.d.ts.map +0 -1
  163. package/dist/utils/deepCopy.js.map +0 -1
  164. package/dist/utils/deepEqual.d.ts +0 -53
  165. package/dist/utils/deepEqual.d.ts.map +0 -1
  166. package/dist/utils/deepEqual.js.map +0 -1
  167. package/dist/utils/export.d.ts +0 -12
  168. package/dist/utils/export.d.ts.map +0 -1
  169. package/dist/utils/export.js.map +0 -1
  170. package/dist/utils/hex.d.ts +0 -48
  171. package/dist/utils/hex.d.ts.map +0 -1
  172. package/dist/utils/hex.js.map +0 -1
  173. package/dist/utils/isvalid.d.ts +0 -102
  174. package/dist/utils/isvalid.d.ts.map +0 -1
  175. package/dist/utils/isvalid.js.map +0 -1
  176. package/dist/utils/network.d.ts +0 -69
  177. package/dist/utils/network.d.ts.map +0 -1
  178. package/dist/utils/network.js.map +0 -1
  179. package/dist/utils/spawn.d.ts +0 -12
  180. package/dist/utils/spawn.d.ts.map +0 -1
  181. package/dist/utils/spawn.js.map +0 -1
  182. package/dist/utils/wait.d.ts +0 -52
  183. package/dist/utils/wait.d.ts.map +0 -1
  184. package/dist/utils/wait.js.map +0 -1
  185. package/dist/waterHeater.d.ts +0 -90
  186. package/dist/waterHeater.d.ts.map +0 -1
  187. package/dist/waterHeater.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -8,6 +8,26 @@ If you like this project and find it useful, please consider giving it a star on
8
8
  <img src="bmc-button.svg" alt="Buy me a coffee" width="120">
9
9
  </a>
10
10
 
11
+ ## [3.0.7] - 2025-06-??
12
+
13
+ ### Breaking Changes
14
+
15
+ - [devices]: The single devices (i.e. Rvc, Evse etc...) are exported from matterbridge/devices. Please update your imports to use the new export path. Refer to the [documentation](README-DEV.md) for details on imports.
16
+
17
+ ### Added
18
+
19
+ ### Changed
20
+
21
+ - [package]: Updated dependencies.
22
+ - [package]: Downgrade jest to 29.7.0.
23
+ - [energy]: Added parameter for cumulativeEnergyExported to the helper. For solar power device.
24
+
25
+ ### Fixed
26
+
27
+ <a href="https://www.buymeacoffee.com/luligugithub">
28
+ <img src="bmc-button.svg" alt="Buy me a coffee" width="80">
29
+ </a>
30
+
11
31
  ## [3.0.6] - 2025-06-13
12
32
 
13
33
  ### Added
package/README-DEV.md CHANGED
@@ -18,49 +18,53 @@
18
18
 
19
19
  Matterbridge exports from:
20
20
 
21
- "matterbridge"
21
+ ### "matterbridge"
22
22
 
23
23
  - Matterbridge and all Matterbridge related classes.
24
24
 
25
- "matterbridge/matter"
25
+ ### "matterbridge/devices"
26
26
 
27
- - All relevant matter.js exports.
27
+ - All single device classes like the Rvc, LaundryWasher, etc...
28
28
 
29
- "matterbridge/matter/behaviors"
29
+ ### "matterbridge/clusters"
30
30
 
31
- - All matter.js behaviors.
31
+ - All clusters not present in matter.js or modified.
32
32
 
33
- "matterbridge/matter/clusters"
33
+ ### "matterbridge/utils"
34
34
 
35
- - All matter.js clusters.
35
+ - All general utils and colorUtils functions.
36
36
 
37
- "matterbridge/matter/devices"
37
+ ### "matterbridge/logger"
38
38
 
39
- - All matter.js devices.
39
+ - AnsiLogger class.
40
40
 
41
- "matterbridge/matter/endpoints"
41
+ ### "matterbridge/storage"
42
42
 
43
- - All matter.js endpoints.
43
+ - NodeStorageManager and NodeStorage classes.
44
44
 
45
- "matterbridge/matter/types"
45
+ ### "matterbridge/matter"
46
46
 
47
- - All matter.js types.
47
+ - All relevant matter.js exports.
48
48
 
49
- "matterbridge/cluster"
49
+ ### "matterbridge/matter/behaviors"
50
50
 
51
- - All clusters not present in matter.js or modified.
51
+ - All matter.js behaviors.
52
52
 
53
- "matterbridge/utils"
53
+ ### "matterbridge/matter/clusters"
54
54
 
55
- - All general utils and colorUtils functions.
55
+ - All matter.js clusters.
56
56
 
57
- "matterbridge/logger"
57
+ ### "matterbridge/matter/devices"
58
58
 
59
- - AnsiLogger class.
59
+ - All matter.js devices.
60
60
 
61
- "matterbridge/storage"
61
+ ### "matterbridge/matter/endpoints"
62
62
 
63
- - NodeStorageManager and NodeStorage classes.
63
+ - All matter.js endpoints.
64
+
65
+ ### "matterbridge/matter/types"
66
+
67
+ - All matter.js types.
64
68
 
65
69
  # \***\*\*\*\*\***
66
70
 
@@ -72,7 +76,7 @@ Additionally, when Matterbridge updates the `matter.js` version, it should be co
72
76
 
73
77
  A plugin must never install Matterbridge (neither as a dependency, devDependency, nor peerDependency).
74
78
 
75
- Matterbridge must be linked to the plugin in development only.
79
+ Matterbridge must be linked to the plugin in development only. At runtime the plugin is loaded directly from the running Mattebridge instance.
76
80
 
77
81
  ```json
78
82
  "scripts": {
@@ -82,9 +86,9 @@ Matterbridge must be linked to the plugin in development only.
82
86
  }
83
87
  ```
84
88
 
85
- On the machine you use for development you should also have matterbridge installed globally or built locally and linked (npm link from the package root).
89
+ On the machine you use for development of your plugin, you need to clone matterbridge, built it locally and link it globally (npm link from the matterbridge package root).
86
90
 
87
- Dev and edge branches of matterbridge are not suitable for developemnt cause they are published for production without types. If you want to develop a plugin using the dev or edge branch of matterbridge, you have to clone the dev or edge branch of matterbridge, build locally and link (npm run deepCleanBuild).
91
+ If you want to develop a plugin using the dev branch of matterbridge, you have to clone the dev branch of matterbridge, build it locally and link it (npm run deepCleanBuild).
88
92
 
89
93
  # \***\*\*\*\*\***
90
94
 
@@ -114,7 +118,7 @@ On windows:
114
118
  cd $HOME\Matterbridge
115
119
  ```
116
120
 
117
- On linux:
121
+ On linux or macOS:
118
122
 
119
123
  ```
120
124
  cd ~/Matterbridge
@@ -126,6 +130,7 @@ then clone the plugin
126
130
  git clone https://github.com/Luligu/matterbridge-example-accessory-platform
127
131
  cd matterbridge-example-accessory-platform
128
132
  npm install
133
+ npm link matterbridge
129
134
  npm run build
130
135
  ```
131
136
 
@@ -150,37 +155,63 @@ The plugin platform type.
150
155
  The plugin config (loaded before the platform constructor is called and saved after onShutdown() is called).
151
156
  Here you can store your plugin configuration (see matterbridge-zigbee2mqtt for example)
152
157
 
158
+ ### constructor(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig)
159
+
160
+ The contructor is called when is plugin is loaded.
161
+
153
162
  ### async onStart(reason?: string)
154
163
 
155
- The method onStart() is where you have to create your MatterbridgeDevice and add all needed clusters and command handlers.
164
+ The method onStart() is where you have to create your MatterbridgeEndpoint and add all needed clusters.
165
+
166
+ After add the command handlers and subscribe to the attributes when needed.
156
167
 
157
- The MatterbridgeDevice class has the create cluster methods already done and all command handlers needed (see plugin examples).
168
+ The MatterbridgeEndpoint class has the create cluster methods already done and all command handlers needed (see plugin examples).
158
169
 
159
170
  The method is called when Matterbridge load the plugin.
160
171
 
161
172
  ### async onConfigure()
162
173
 
163
- The method onConfigure() is where you can configure or initialize your device.
174
+ The method onConfigure() is where you can configure your matter device.
164
175
 
165
- The method is called when the platform is commissioned.
176
+ The method is called when the server node the platform belongs to is online.
177
+
178
+ Since the persistent attributes are loaded from the storage when the server node goes online, you may need to set them in onConfigure().
166
179
 
167
180
  ### async onShutdown(reason?: string)
168
181
 
169
- The method onShutdown() is where you have to eventually cleanup some resources.
182
+ The method onShutdown() is where you have to stop your platform and cleanup all the used resources.
183
+
184
+ The method is called when Matterbridge is shutting down or when the plugin is disabled.
185
+
186
+ Since the frontend can enable and disable the plugin many times, you need to clean all resources (i.e. handlers, intervals, timers...) here.
187
+
188
+ ### async onChangeLoggerLevel(logLevel: LogLevel)
189
+
190
+ It is called when the user changes the logger level in the frontend.
191
+
192
+ ### async onAction(action: string, value?: string, id?: string, formData?: PlatformConfig)
193
+
194
+ It is called when a plugin config includes an action button or an action button with text field.
195
+
196
+ ### async onConfigChanged(config: PlatformConfig)
197
+
198
+ It is called when the plugin config has been updated.
199
+
200
+ ### hasDeviceName(deviceName: string): boolean
170
201
 
171
- The method is called when Matterbridge is shutting down.
202
+ Checks if a device with this name is already registered in the platform.
172
203
 
173
- ### async registerDevice(device: MatterbridgeDevice)
204
+ ### async registerDevice(device: MatterbridgeEndpoint)
174
205
 
175
- After you created your device, add it to the platform.
206
+ After you have created your device, add it to the platform.
176
207
 
177
- ### async unregisterDevice(device: MatterbridgeDevice)
208
+ ### async unregisterDevice(device: MatterbridgeEndpoint)
178
209
 
179
210
  You can unregister one or more device.
180
211
 
181
212
  ### async unregisterAllDevices()
182
213
 
183
- You can unregister all devices you added.
214
+ You can unregister all the devices you added.
184
215
 
185
216
  It can be useful to call this method from onShutdown() if you don't want to keep all the devices during development.
186
217
 
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Docker Version](https://img.shields.io/docker/v/luligu/matterbridge?label=docker%20version&sort=semver)](https://hub.docker.com/r/luligu/matterbridge)
6
6
  [![Docker Pulls](https://img.shields.io/docker/pulls/luligu/matterbridge.svg)](https://hub.docker.com/r/luligu/matterbridge)
7
7
  ![Node.js CI](https://github.com/Luligu/matterbridge/actions/workflows/build.yml/badge.svg)
8
- ![Coverage](https://img.shields.io/badge/Jest%20coverage-88%25-brightgreen)
8
+ ![Coverage](https://img.shields.io/badge/Jest%20coverage-89%25-brightgreen)
9
9
 
10
10
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
11
11
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
package/dist/cli.js CHANGED
@@ -1,46 +1,20 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * This file contains the CLI entry point of Matterbridge.
4
- *
5
- * @file cli.ts
6
- * @author Luca Liguori
7
- * @date 2023-12-29
8
- * @version 2.0.1
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
- // Matterbridge
25
2
  import { Matterbridge } from './matterbridge.js';
26
3
  import { getIntParameter, hasParameter } from './utils/export.js';
27
- // AnsiLogger module
28
4
  import { AnsiLogger, BRIGHT, CYAN, db, YELLOW } from './logger/export.js';
29
5
  import os from 'node:os';
30
6
  import { EventEmitter } from 'node:events';
31
7
  import { inspect } from 'node:util';
32
8
  export const cliEmitter = new EventEmitter();
33
9
  export let instance;
34
- // Inspectop
35
10
  let session;
36
11
  let snapshotInterval;
37
- // Cpu and memory check
38
12
  let memoryCheckInterval;
39
13
  let prevCpus;
40
14
  export let lastCpuUsage = 0;
41
15
  let peakCpu = 0;
42
16
  let peakRss = 0;
43
- const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
17
+ const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
44
18
  const formatMemoryUsage = (bytes) => {
45
19
  if (bytes >= 1024 ** 3) {
46
20
  return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
@@ -68,16 +42,13 @@ const formatOsUpTime = (seconds) => {
68
42
  return `${seconds} second${seconds !== 1 ? 's' : ''}`;
69
43
  };
70
44
  async function startCpuMemoryCheck() {
71
- // const os = await import('node:os');
72
45
  log.debug(`Cpu memory check started`);
73
46
  prevCpus = os.cpus();
74
47
  clearInterval(memoryCheckInterval);
75
48
  const interval = () => {
76
- // Get the os uptime
77
49
  const systemUptime = formatOsUpTime(Math.floor(os.uptime()));
78
50
  const processUptime = formatOsUpTime(Math.floor(process.uptime()));
79
51
  cliEmitter.emit('uptime', systemUptime, processUptime);
80
- // Get the memory usage
81
52
  const totalMememory = formatMemoryUsage(os.totalmem());
82
53
  const freeMemory = formatMemoryUsage(os.freemem());
83
54
  const memoryUsageRaw = process.memoryUsage();
@@ -89,12 +60,10 @@ async function startCpuMemoryCheck() {
89
60
  if (memoryUsageRaw.rss > peakRss)
90
61
  peakRss = memoryUsageRaw.rss;
91
62
  cliEmitter.emit('memory', totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
92
- // Get the cpu usage
93
63
  const currCpus = os.cpus();
94
- // log.debug(`Cpus: ${JSON.stringify(currCpus)}`);
95
64
  let cpuUsageLog;
96
65
  if (currCpus.length !== prevCpus.length) {
97
- prevCpus = currCpus; // Reset the previous cpus
66
+ prevCpus = currCpus;
98
67
  log.debug(`Cpu check length failed, resetting previous cpus`);
99
68
  return;
100
69
  }
@@ -120,7 +89,6 @@ async function startCpuMemoryCheck() {
120
89
  cliEmitter.emit('cpu', lastCpuUsage);
121
90
  }
122
91
  prevCpus = currCpus;
123
- // Show the cpu and memory usage
124
92
  log.debug(`***${YELLOW}${BRIGHT}Cpu usage:${db} ${CYAN}${cpuUsageLog.padStart(6, ' ')} %${db} ${YELLOW}${BRIGHT}Memory usage:${db} rss ${CYAN}${rss}${db} heapTotal ${CYAN}${heapTotal}${db} heapUsed ${CYAN}${heapUsed}${db} external ${external} arrayBuffers ${arrayBuffers}`);
125
93
  };
126
94
  interval();
@@ -131,15 +99,10 @@ async function stopCpuMemoryCheck() {
131
99
  log.debug(`***Cpu memory check stopped. Peak cpu: ${CYAN}${peakCpu.toFixed(2)} %${db}. Peak rss: ${CYAN}${formatMemoryUsage(peakRss)}${db}.`);
132
100
  clearInterval(memoryCheckInterval);
133
101
  }
134
- /**
135
- * Starts the inspector for heap sampling.
136
- * This function is called when the -inspect parameter is passed.
137
- */
138
102
  async function startInspector() {
139
103
  const { Session } = await import('node:inspector');
140
104
  const { mkdirSync } = await import('node:fs');
141
105
  log.debug(`***Starting heap sampling...`);
142
- // Create the heap snapshots directory if it doesn't exist
143
106
  mkdirSync('heap_profile', { recursive: true });
144
107
  try {
145
108
  session = new Session();
@@ -148,7 +111,6 @@ async function startInspector() {
148
111
  session?.post('HeapProfiler.startSampling', (err) => (err ? reject(err) : resolve()));
149
112
  });
150
113
  log.debug(`***Started heap sampling`);
151
- // Set an interval to take heap snapshots
152
114
  const interval = getIntParameter('snapshotinterval');
153
115
  if (interval && interval >= 30000) {
154
116
  log.debug(`***Started heap snapshot interval of ${CYAN}${interval}${db} ms`);
@@ -166,19 +128,13 @@ async function startInspector() {
166
128
  return;
167
129
  }
168
130
  }
169
- /**
170
- * Stops the heap sampling and saves the profile to a file.
171
- * This function is called when the inspector is stopped.
172
- */
173
131
  async function stopInspector() {
174
132
  const { writeFileSync } = await import('node:fs');
175
133
  const path = await import('node:path');
176
134
  log.debug(`***Stopping heap sampling...`);
177
135
  if (snapshotInterval) {
178
136
  log.debug(`***Clearing heap snapshot interval...`);
179
- // Clear the snapshot interval if it exists
180
137
  clearInterval(snapshotInterval);
181
- // Take a final heap snapshot before stopping
182
138
  await takeHeapSnapshot();
183
139
  }
184
140
  if (!session) {
@@ -186,7 +142,6 @@ async function stopInspector() {
186
142
  return;
187
143
  }
188
144
  try {
189
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
145
  const result = await new Promise((resolve, reject) => {
191
146
  session?.post('HeapProfiler.stopSampling', (err, result) => (err ? reject(err) : resolve(result)));
192
147
  });
@@ -204,13 +159,6 @@ async function stopInspector() {
204
159
  log.debug(`***Stopped heap sampling`);
205
160
  }
206
161
  }
207
- /**
208
- * Takes a heap snapshot and saves it to the file name Heap-snapshot-<timestamp>.heapsnapshot.
209
- * This function is called periodically based on the -snapshotinterval parameter.
210
- * The -snapshotinterval parameter must at least 30000 ms.
211
- * The snapshot is saved in the heap_profile directory that is created in the current working directory.
212
- * The snapshot can be analyzed using vscode or Chrome DevTools or other tools that support heap snapshots.
213
- */
214
162
  async function takeHeapSnapshot() {
215
163
  const { writeFileSync } = await import('node:fs');
216
164
  const path = await import('node:path');
@@ -242,10 +190,6 @@ async function takeHeapSnapshot() {
242
190
  });
243
191
  });
244
192
  }
245
- /**
246
- * Triggers a manual garbage collection.
247
- * This function is working only if the process is started with --expose-gc.
248
- */
249
193
  function triggerGarbageCollection() {
250
194
  if (typeof global.gc === 'function') {
251
195
  global.gc();
@@ -292,7 +236,6 @@ async function restart() {
292
236
  }
293
237
  async function update() {
294
238
  log.debug('Received update event, updating...');
295
- // TODO: Implement update logic outside of matterbridge
296
239
  instance = await Matterbridge.loadInstance(true);
297
240
  registerHandlers();
298
241
  }
@@ -312,7 +255,6 @@ async function main() {
312
255
  log.debug(`***Matterbridge.loadInstance(true) called`);
313
256
  instance = await Matterbridge.loadInstance(true);
314
257
  log.debug(`***Matterbridge.loadInstance(true) exited`);
315
- // Check if the instance needs to shut down from parseCommandLine()
316
258
  if (!instance || instance.shutdown) {
317
259
  shutdown();
318
260
  }
@@ -321,11 +263,9 @@ async function main() {
321
263
  cliEmitter.emit('ready');
322
264
  }
323
265
  }
324
- // Run the main function
325
266
  process.title = 'matterbridge';
326
267
  main().catch((error) => {
327
268
  const errorMessage = error instanceof Error ? error.message : error;
328
269
  const errorInspect = inspect(error, { depth: 10 });
329
270
  log.error(`Matterbridge.loadInstance() failed with error: ${errorMessage}\nstack: ${errorInspect}`);
330
271
  });
331
- //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -1,25 +1,3 @@
1
- /**
2
- * This file contains the default config for the plugins.
3
- *
4
- * @file defaultConfigSchema.ts
5
- * @author Luca Liguori
6
- * @date 2024-05-07
7
- * @version 1.0.1
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
  export const zigbee2mqtt_config = {
24
2
  name: 'matterbridge-zigbee2mqtt',
25
3
  type: 'DynamicPlatform',
@@ -78,4 +56,3 @@ export const shelly_config = {
78
56
  debugWs: false,
79
57
  unregisterOnShutdown: false,
80
58
  };
81
- //# sourceMappingURL=defaultConfigSchema.js.map
@@ -1,89 +1,28 @@
1
- /**
2
- * This file contains the DeviceManager class.
3
- *
4
- * @file devices.ts
5
- * @author Luca Liguori
6
- * @date 2024-07-26
7
- * @version 1.0.10
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
- // AnsiLogger module
24
1
  import { AnsiLogger, BLUE, er } from './logger/export.js';
25
2
  import { dev } from './matterbridgeTypes.js';
26
- /**
27
- * Manages Matterbridge devices.
28
- */
29
3
  export class DeviceManager {
30
4
  _devices = new Map();
31
5
  matterbridge;
32
6
  nodeContext;
33
7
  log;
34
- /**
35
- * Creates an instance of DeviceManager.
36
- *
37
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
38
- * @param {NodeStorage} nodeContext - The node storage context.
39
- */
40
8
  constructor(matterbridge, nodeContext) {
41
9
  this.matterbridge = matterbridge;
42
10
  this.nodeContext = nodeContext;
43
- this.log = new AnsiLogger({ logName: 'DeviceManager', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: matterbridge.log.logLevel });
11
+ this.log = new AnsiLogger({ logName: 'DeviceManager', logTimestampFormat: 4, logLevel: matterbridge.log.logLevel });
44
12
  this.log.debug('Matterbridge device manager starting...');
45
13
  }
46
- /**
47
- * Gets the number of devices.
48
- *
49
- * @returns {number} The number of devices.
50
- */
51
14
  get length() {
52
15
  return this._devices.size;
53
16
  }
54
- /**
55
- * Gets the number of devices.
56
- *
57
- * @returns {number} The number of devices.
58
- */
59
17
  get size() {
60
18
  return this._devices.size;
61
19
  }
62
- /**
63
- * Checks if a device with the specified unique ID exists.
64
- *
65
- * @param {string} uniqueId - The unique ID of the device.
66
- * @returns {boolean} True if the device exists, false otherwise.
67
- */
68
20
  has(uniqueId) {
69
21
  return this._devices.has(uniqueId);
70
22
  }
71
- /**
72
- * Gets a device by its unique ID.
73
- *
74
- * @param {string} uniqueId - The unique ID of the device.
75
- * @returns {MatterbridgeEndpoint | undefined} The device, or undefined if not found.
76
- */
77
23
  get(uniqueId) {
78
24
  return this._devices.get(uniqueId);
79
25
  }
80
- /**
81
- * Adds a device to the manager.
82
- *
83
- * @param {MatterbridgeEndpoint} device - The device to add.
84
- * @returns {MatterbridgeEndpoint} The added device.
85
- * @throws {Error} If the device does not have a unique ID.
86
- */
87
26
  set(device) {
88
27
  if (!device.uniqueId)
89
28
  throw new Error(`The device ${dev}${device.deviceName}${er} has not been initialized: uniqueId is required`);
@@ -92,13 +31,6 @@ export class DeviceManager {
92
31
  this._devices.set(device.uniqueId, device);
93
32
  return device;
94
33
  }
95
- /**
96
- * Removes a device from the manager.
97
- *
98
- * @param {MatterbridgeEndpoint} device - The device to remove.
99
- * @returns {boolean} True if the device was removed, false otherwise.
100
- * @throws {Error} If the device does not have a unique ID.
101
- */
102
34
  remove(device) {
103
35
  if (!device.uniqueId)
104
36
  throw new Error(`The device ${dev}${device.deviceName}${er} has not been initialized: uniqueId is required`);
@@ -106,34 +38,15 @@ export class DeviceManager {
106
38
  this.log.error(`The device ${dev}${device.deviceName}${er} with uniqueId ${BLUE}${device.uniqueId}${er} serialNumber ${BLUE}${device.serialNumber}${er} is not registered in the device manager`);
107
39
  return this._devices.delete(device.uniqueId);
108
40
  }
109
- /**
110
- * Clears all devices from the manager.
111
- */
112
41
  clear() {
113
42
  this._devices.clear();
114
43
  }
115
- /**
116
- * Gets an array of all devices.
117
- *
118
- * @returns {MatterbridgeEndpoint[]} An array of all devices.
119
- */
120
44
  array() {
121
45
  return Array.from(this._devices.values());
122
46
  }
123
- /**
124
- * Iterates over all devices.
125
- *
126
- * @returns {IterableIterator<MatterbridgeEndpoint>} An iterator for the devices.
127
- */
128
47
  [Symbol.iterator]() {
129
48
  return this._devices.values();
130
49
  }
131
- /**
132
- * Asynchronously iterates over each device and calls the provided callback function.
133
- *
134
- * @param {(device: MatterbridgeEndpoint) => Promise<void>} callback - The callback function to call with each device.
135
- * @returns {Promise<void>} A promise that resolves when all callbacks have been called.
136
- */
137
50
  async forEach(callback) {
138
51
  if (this.size === 0)
139
52
  return;
@@ -147,13 +60,7 @@ export class DeviceManager {
147
60
  });
148
61
  await Promise.all(tasks);
149
62
  }
150
- /**
151
- * Sets the log level.
152
- *
153
- * @param {LogLevel} logLevel - The log level to set.
154
- */
155
63
  set logLevel(logLevel) {
156
64
  this.log.logLevel = logLevel;
157
65
  }
158
66
  }
159
- //# sourceMappingURL=deviceManager.js.map
@@ -0,0 +1,4 @@
1
+ export * from '../roboticVacuumCleaner.js';
2
+ export * from '../laundryWasher.js';
3
+ export * from '../waterHeater.js';
4
+ export * from '../evse.js';