matterbridge 3.0.7 → 3.0.8-dev-20250622-9a6255a

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 (207) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/bin/matterbridge +2 -0
  3. package/dist/cli.js +5 -66
  4. package/dist/clusters/export.js +0 -2
  5. package/dist/defaultConfigSchema.js +0 -23
  6. package/dist/deviceManager.js +2 -95
  7. package/dist/devices/export.js +0 -2
  8. package/dist/evse.js +9 -65
  9. package/dist/frontend.js +47 -383
  10. package/dist/globalMatterbridge.js +0 -20
  11. package/dist/helpers.js +4 -52
  12. package/dist/index.js +2 -29
  13. package/dist/laundryWasher.js +7 -92
  14. package/dist/logger/export.js +0 -1
  15. package/dist/matter/behaviors.js +0 -2
  16. package/dist/matter/clusters.js +0 -2
  17. package/dist/matter/devices.js +0 -2
  18. package/dist/matter/endpoints.js +0 -2
  19. package/dist/matter/export.js +0 -2
  20. package/dist/matter/types.js +0 -2
  21. package/dist/matterbridge.js +53 -755
  22. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  23. package/dist/matterbridgeBehaviors.js +1 -54
  24. package/dist/matterbridgeDeviceTypes.js +15 -578
  25. package/dist/matterbridgeDynamicPlatform.js +0 -34
  26. package/dist/matterbridgeEndpoint.js +45 -1000
  27. package/dist/matterbridgeEndpointHelpers.js +12 -206
  28. package/dist/matterbridgePlatform.js +13 -225
  29. package/dist/matterbridgeTypes.js +0 -24
  30. package/dist/pluginManager.js +4 -270
  31. package/dist/roboticVacuumCleaner.js +9 -84
  32. package/dist/shelly.js +9 -156
  33. package/dist/storage/export.js +0 -1
  34. package/dist/update.js +0 -53
  35. package/dist/utils/colorUtils.js +2 -205
  36. package/dist/utils/commandLine.js +0 -53
  37. package/dist/utils/copyDirectory.js +1 -37
  38. package/dist/utils/createDirectory.js +0 -31
  39. package/dist/utils/createZip.js +2 -42
  40. package/dist/utils/deepCopy.js +0 -38
  41. package/dist/utils/deepEqual.js +1 -71
  42. package/dist/utils/export.js +0 -1
  43. package/dist/utils/hex.js +0 -57
  44. package/dist/utils/isvalid.js +0 -100
  45. package/dist/utils/network.js +6 -77
  46. package/dist/utils/spawn.js +0 -16
  47. package/dist/utils/wait.js +10 -58
  48. package/dist/waterHeater.js +5 -65
  49. package/frontend/build/matterbridge 1250x1250.png +0 -0
  50. package/frontend/build/matterbridge 624x624.png +0 -0
  51. package/frontend/package-lock.json +19176 -0
  52. package/frontend/package.json +79 -0
  53. package/frontend/public/Shelly.svg +1 -0
  54. package/frontend/public/bmc-button.svg +22 -0
  55. package/frontend/public/discord.svg +5 -0
  56. package/frontend/public/favicon.ico +0 -0
  57. package/frontend/public/index.html +19 -0
  58. package/frontend/public/manifest.json +15 -0
  59. package/frontend/public/matter.png +0 -0
  60. package/frontend/public/matterbridge 1250x1250.png +0 -0
  61. package/frontend/public/matterbridge 32x32.png +0 -0
  62. package/frontend/public/matterbridge 624x624.png +0 -0
  63. package/frontend/public/matterbridge 64x64.png +0 -0
  64. package/frontend/public/matterbridge.svg +50 -0
  65. package/frontend/public/robots.txt +3 -0
  66. package/npm-shrinkwrap.json +33 -42
  67. package/package.json +3 -4
  68. package/dist/cli.d.ts +0 -29
  69. package/dist/cli.d.ts.map +0 -1
  70. package/dist/cli.js.map +0 -1
  71. package/dist/clusters/export.d.ts +0 -2
  72. package/dist/clusters/export.d.ts.map +0 -1
  73. package/dist/clusters/export.js.map +0 -1
  74. package/dist/defaultConfigSchema.d.ts +0 -27
  75. package/dist/defaultConfigSchema.d.ts.map +0 -1
  76. package/dist/defaultConfigSchema.js.map +0 -1
  77. package/dist/deviceManager.d.ts +0 -114
  78. package/dist/deviceManager.d.ts.map +0 -1
  79. package/dist/deviceManager.js.map +0 -1
  80. package/dist/devices/export.d.ts +0 -5
  81. package/dist/devices/export.d.ts.map +0 -1
  82. package/dist/devices/export.js.map +0 -1
  83. package/dist/evse.d.ts +0 -67
  84. package/dist/evse.d.ts.map +0 -1
  85. package/dist/evse.js.map +0 -1
  86. package/dist/frontend.d.ts +0 -256
  87. package/dist/frontend.d.ts.map +0 -1
  88. package/dist/frontend.js.map +0 -1
  89. package/dist/globalMatterbridge.d.ts +0 -32
  90. package/dist/globalMatterbridge.d.ts.map +0 -1
  91. package/dist/globalMatterbridge.js.map +0 -1
  92. package/dist/helpers.d.ts +0 -47
  93. package/dist/helpers.d.ts.map +0 -1
  94. package/dist/helpers.js.map +0 -1
  95. package/dist/index.d.ts +0 -37
  96. package/dist/index.d.ts.map +0 -1
  97. package/dist/index.js.map +0 -1
  98. package/dist/laundryWasher.d.ts +0 -243
  99. package/dist/laundryWasher.d.ts.map +0 -1
  100. package/dist/laundryWasher.js.map +0 -1
  101. package/dist/logger/export.d.ts +0 -2
  102. package/dist/logger/export.d.ts.map +0 -1
  103. package/dist/logger/export.js.map +0 -1
  104. package/dist/matter/behaviors.d.ts +0 -2
  105. package/dist/matter/behaviors.d.ts.map +0 -1
  106. package/dist/matter/behaviors.js.map +0 -1
  107. package/dist/matter/clusters.d.ts +0 -2
  108. package/dist/matter/clusters.d.ts.map +0 -1
  109. package/dist/matter/clusters.js.map +0 -1
  110. package/dist/matter/devices.d.ts +0 -2
  111. package/dist/matter/devices.d.ts.map +0 -1
  112. package/dist/matter/devices.js.map +0 -1
  113. package/dist/matter/endpoints.d.ts +0 -2
  114. package/dist/matter/endpoints.d.ts.map +0 -1
  115. package/dist/matter/endpoints.js.map +0 -1
  116. package/dist/matter/export.d.ts +0 -5
  117. package/dist/matter/export.d.ts.map +0 -1
  118. package/dist/matter/export.js.map +0 -1
  119. package/dist/matter/types.d.ts +0 -3
  120. package/dist/matter/types.d.ts.map +0 -1
  121. package/dist/matter/types.js.map +0 -1
  122. package/dist/matterbridge.d.ts +0 -445
  123. package/dist/matterbridge.d.ts.map +0 -1
  124. package/dist/matterbridge.js.map +0 -1
  125. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  126. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  127. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  128. package/dist/matterbridgeBehaviors.d.ts +0 -1333
  129. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  130. package/dist/matterbridgeBehaviors.js.map +0 -1
  131. package/dist/matterbridgeDeviceTypes.d.ts +0 -644
  132. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  133. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  134. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  135. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  136. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  137. package/dist/matterbridgeEndpoint.d.ts +0 -1145
  138. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  139. package/dist/matterbridgeEndpoint.js.map +0 -1
  140. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
  141. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  142. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  143. package/dist/matterbridgePlatform.d.ts +0 -290
  144. package/dist/matterbridgePlatform.d.ts.map +0 -1
  145. package/dist/matterbridgePlatform.js.map +0 -1
  146. package/dist/matterbridgeTypes.d.ts +0 -196
  147. package/dist/matterbridgeTypes.d.ts.map +0 -1
  148. package/dist/matterbridgeTypes.js.map +0 -1
  149. package/dist/pluginManager.d.ts +0 -273
  150. package/dist/pluginManager.d.ts.map +0 -1
  151. package/dist/pluginManager.js.map +0 -1
  152. package/dist/roboticVacuumCleaner.d.ts +0 -102
  153. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  154. package/dist/roboticVacuumCleaner.js.map +0 -1
  155. package/dist/shelly.d.ts +0 -161
  156. package/dist/shelly.d.ts.map +0 -1
  157. package/dist/shelly.js.map +0 -1
  158. package/dist/storage/export.d.ts +0 -2
  159. package/dist/storage/export.d.ts.map +0 -1
  160. package/dist/storage/export.js.map +0 -1
  161. package/dist/update.d.ts +0 -58
  162. package/dist/update.d.ts.map +0 -1
  163. package/dist/update.js.map +0 -1
  164. package/dist/utils/colorUtils.d.ts +0 -61
  165. package/dist/utils/colorUtils.d.ts.map +0 -1
  166. package/dist/utils/colorUtils.js.map +0 -1
  167. package/dist/utils/commandLine.d.ts +0 -58
  168. package/dist/utils/commandLine.d.ts.map +0 -1
  169. package/dist/utils/commandLine.js.map +0 -1
  170. package/dist/utils/copyDirectory.d.ts +0 -32
  171. package/dist/utils/copyDirectory.d.ts.map +0 -1
  172. package/dist/utils/copyDirectory.js.map +0 -1
  173. package/dist/utils/createDirectory.d.ts +0 -32
  174. package/dist/utils/createDirectory.d.ts.map +0 -1
  175. package/dist/utils/createDirectory.js.map +0 -1
  176. package/dist/utils/createZip.d.ts +0 -38
  177. package/dist/utils/createZip.d.ts.map +0 -1
  178. package/dist/utils/createZip.js.map +0 -1
  179. package/dist/utils/deepCopy.d.ts +0 -31
  180. package/dist/utils/deepCopy.d.ts.map +0 -1
  181. package/dist/utils/deepCopy.js.map +0 -1
  182. package/dist/utils/deepEqual.d.ts +0 -53
  183. package/dist/utils/deepEqual.d.ts.map +0 -1
  184. package/dist/utils/deepEqual.js.map +0 -1
  185. package/dist/utils/export.d.ts +0 -12
  186. package/dist/utils/export.d.ts.map +0 -1
  187. package/dist/utils/export.js.map +0 -1
  188. package/dist/utils/hex.d.ts +0 -48
  189. package/dist/utils/hex.d.ts.map +0 -1
  190. package/dist/utils/hex.js.map +0 -1
  191. package/dist/utils/isvalid.d.ts +0 -102
  192. package/dist/utils/isvalid.d.ts.map +0 -1
  193. package/dist/utils/isvalid.js.map +0 -1
  194. package/dist/utils/network.d.ts +0 -69
  195. package/dist/utils/network.d.ts.map +0 -1
  196. package/dist/utils/network.js.map +0 -1
  197. package/dist/utils/spawn.d.ts +0 -12
  198. package/dist/utils/spawn.d.ts.map +0 -1
  199. package/dist/utils/spawn.js.map +0 -1
  200. package/dist/utils/wait.d.ts +0 -52
  201. package/dist/utils/wait.d.ts.map +0 -1
  202. package/dist/utils/wait.js.map +0 -1
  203. package/dist/waterHeater.d.ts +0 -90
  204. package/dist/waterHeater.d.ts.map +0 -1
  205. package/dist/waterHeater.js.map +0 -1
  206. package/tsconfig.jest.json +0 -8
  207. package/tsconfig.production.json +0 -13
package/CHANGELOG.md CHANGED
@@ -8,6 +8,31 @@ 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.8] - 2025-06-??
12
+
13
+ ### Breaking Changes
14
+
15
+ ### Added
16
+
17
+ - [DevContainer]: Added support for the **Matterbridge Dev Container** with an optimized named volume for `node_modules`.
18
+ - [GitHub]: Added GitHub issue templates for bug reports and feature requests.
19
+ - [Systemd]: Added a systemd service file for Matterbridge.
20
+ - [ESLint]: Refactored ESLint configuration for TypeScript and improved plugin integration.
21
+ - [ESLint]: Added the plugins `eslint-plugin-promise`, `eslint-plugin-jsdoc`, and `@vitest/eslint-plugin`.
22
+ - [Vitest]: Added Vitest for TypeScript project testing. It will replace Jest, which does not work correctly with ESM module mocks.
23
+ - [JSDoc]: Added missing JSDoc comments, including `@param` and `@returns` tags.
24
+
25
+ ### Changed
26
+
27
+ - [package]: Updated dependencies and refactored scripts.
28
+ - [storage]: Bumped `node-storage-manager` to 2.0.0.
29
+
30
+ ### Fixed
31
+
32
+ <a href="https://www.buymeacoffee.com/luligugithub">
33
+ <img src="bmc-button.svg" alt="Buy me a coffee" width="80">
34
+ </a>
35
+
11
36
  ## [3.0.7] - 2025-06-21
12
37
 
13
38
  ### Breaking Changes
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import('../dist/cli.js');
package/dist/cli.js CHANGED
@@ -1,46 +1,19 @@
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
- import { Matterbridge } from './matterbridge.js';
26
- import { getIntParameter, hasParameter } from './utils/export.js';
27
- // AnsiLogger module
28
- import { AnsiLogger, BRIGHT, CYAN, db, YELLOW } from './logger/export.js';
29
1
  import os from 'node:os';
30
2
  import { EventEmitter } from 'node:events';
31
3
  import { inspect } from 'node:util';
4
+ import { AnsiLogger, BRIGHT, CYAN, db, YELLOW } from 'node-ansi-logger';
5
+ import { getIntParameter, hasParameter } from './utils/export.js';
6
+ import { Matterbridge } from './matterbridge.js';
32
7
  export const cliEmitter = new EventEmitter();
33
8
  export let instance;
34
- // Inspectop
35
9
  let session;
36
10
  let snapshotInterval;
37
- // Cpu and memory check
38
11
  let memoryCheckInterval;
39
12
  let prevCpus;
40
13
  export let lastCpuUsage = 0;
41
14
  let peakCpu = 0;
42
15
  let peakRss = 0;
43
- const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
16
+ const log = new AnsiLogger({ logName: 'Cli', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
44
17
  const formatMemoryUsage = (bytes) => {
45
18
  if (bytes >= 1024 ** 3) {
46
19
  return `${(bytes / 1024 ** 3).toFixed(2)} GB`;
@@ -68,16 +41,13 @@ const formatOsUpTime = (seconds) => {
68
41
  return `${seconds} second${seconds !== 1 ? 's' : ''}`;
69
42
  };
70
43
  async function startCpuMemoryCheck() {
71
- // const os = await import('node:os');
72
44
  log.debug(`Cpu memory check started`);
73
45
  prevCpus = os.cpus();
74
46
  clearInterval(memoryCheckInterval);
75
47
  const interval = () => {
76
- // Get the os uptime
77
48
  const systemUptime = formatOsUpTime(Math.floor(os.uptime()));
78
49
  const processUptime = formatOsUpTime(Math.floor(process.uptime()));
79
50
  cliEmitter.emit('uptime', systemUptime, processUptime);
80
- // Get the memory usage
81
51
  const totalMememory = formatMemoryUsage(os.totalmem());
82
52
  const freeMemory = formatMemoryUsage(os.freemem());
83
53
  const memoryUsageRaw = process.memoryUsage();
@@ -89,12 +59,10 @@ async function startCpuMemoryCheck() {
89
59
  if (memoryUsageRaw.rss > peakRss)
90
60
  peakRss = memoryUsageRaw.rss;
91
61
  cliEmitter.emit('memory', totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
92
- // Get the cpu usage
93
62
  const currCpus = os.cpus();
94
- // log.debug(`Cpus: ${JSON.stringify(currCpus)}`);
95
63
  let cpuUsageLog;
96
64
  if (currCpus.length !== prevCpus.length) {
97
- prevCpus = currCpus; // Reset the previous cpus
65
+ prevCpus = currCpus;
98
66
  log.debug(`Cpu check length failed, resetting previous cpus`);
99
67
  return;
100
68
  }
@@ -120,7 +88,6 @@ async function startCpuMemoryCheck() {
120
88
  cliEmitter.emit('cpu', lastCpuUsage);
121
89
  }
122
90
  prevCpus = currCpus;
123
- // Show the cpu and memory usage
124
91
  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
92
  };
126
93
  interval();
@@ -131,15 +98,10 @@ async function stopCpuMemoryCheck() {
131
98
  log.debug(`***Cpu memory check stopped. Peak cpu: ${CYAN}${peakCpu.toFixed(2)} %${db}. Peak rss: ${CYAN}${formatMemoryUsage(peakRss)}${db}.`);
132
99
  clearInterval(memoryCheckInterval);
133
100
  }
134
- /**
135
- * Starts the inspector for heap sampling.
136
- * This function is called when the -inspect parameter is passed.
137
- */
138
101
  async function startInspector() {
139
102
  const { Session } = await import('node:inspector');
140
103
  const { mkdirSync } = await import('node:fs');
141
104
  log.debug(`***Starting heap sampling...`);
142
- // Create the heap snapshots directory if it doesn't exist
143
105
  mkdirSync('heap_profile', { recursive: true });
144
106
  try {
145
107
  session = new Session();
@@ -148,7 +110,6 @@ async function startInspector() {
148
110
  session?.post('HeapProfiler.startSampling', (err) => (err ? reject(err) : resolve()));
149
111
  });
150
112
  log.debug(`***Started heap sampling`);
151
- // Set an interval to take heap snapshots
152
113
  const interval = getIntParameter('snapshotinterval');
153
114
  if (interval && interval >= 30000) {
154
115
  log.debug(`***Started heap snapshot interval of ${CYAN}${interval}${db} ms`);
@@ -166,19 +127,13 @@ async function startInspector() {
166
127
  return;
167
128
  }
168
129
  }
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
130
  async function stopInspector() {
174
131
  const { writeFileSync } = await import('node:fs');
175
132
  const path = await import('node:path');
176
133
  log.debug(`***Stopping heap sampling...`);
177
134
  if (snapshotInterval) {
178
135
  log.debug(`***Clearing heap snapshot interval...`);
179
- // Clear the snapshot interval if it exists
180
136
  clearInterval(snapshotInterval);
181
- // Take a final heap snapshot before stopping
182
137
  await takeHeapSnapshot();
183
138
  }
184
139
  if (!session) {
@@ -186,7 +141,6 @@ async function stopInspector() {
186
141
  return;
187
142
  }
188
143
  try {
189
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
144
  const result = await new Promise((resolve, reject) => {
191
145
  session?.post('HeapProfiler.stopSampling', (err, result) => (err ? reject(err) : resolve(result)));
192
146
  });
@@ -204,13 +158,6 @@ async function stopInspector() {
204
158
  log.debug(`***Stopped heap sampling`);
205
159
  }
206
160
  }
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
161
  async function takeHeapSnapshot() {
215
162
  const { writeFileSync } = await import('node:fs');
216
163
  const path = await import('node:path');
@@ -242,10 +189,6 @@ async function takeHeapSnapshot() {
242
189
  });
243
190
  });
244
191
  }
245
- /**
246
- * Triggers a manual garbage collection.
247
- * This function is working only if the process is started with --expose-gc.
248
- */
249
192
  function triggerGarbageCollection() {
250
193
  if (typeof global.gc === 'function') {
251
194
  global.gc();
@@ -292,7 +235,6 @@ async function restart() {
292
235
  }
293
236
  async function update() {
294
237
  log.debug('Received update event, updating...');
295
- // TODO: Implement update logic outside of matterbridge
296
238
  instance = await Matterbridge.loadInstance(true);
297
239
  registerHandlers();
298
240
  }
@@ -312,7 +254,6 @@ async function main() {
312
254
  log.debug(`***Matterbridge.loadInstance(true) called`);
313
255
  instance = await Matterbridge.loadInstance(true);
314
256
  log.debug(`***Matterbridge.loadInstance(true) exited`);
315
- // Check if the instance needs to shut down from parseCommandLine()
316
257
  if (!instance || instance.shutdown) {
317
258
  shutdown();
318
259
  }
@@ -321,11 +262,9 @@ async function main() {
321
262
  cliEmitter.emit('ready');
322
263
  }
323
264
  }
324
- // Run the main function
325
265
  process.title = 'matterbridge';
326
266
  main().catch((error) => {
327
267
  const errorMessage = error instanceof Error ? error.message : error;
328
268
  const errorInspect = inspect(error, { depth: 10 });
329
269
  log.error(`Matterbridge.loadInstance() failed with error: ${errorMessage}\nstack: ${errorInspect}`);
330
270
  });
331
- //# sourceMappingURL=cli.js.map
@@ -1,3 +1 @@
1
1
  export {};
2
- // Nothing to export right now, but this file is here to make it easier to add exports in the future
3
- //# sourceMappingURL=export.js.map
@@ -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
- import { AnsiLogger, BLUE, er } from './logger/export.js';
1
+ import { AnsiLogger, BLUE, er } from 'node-ansi-logger';
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
@@ -1,6 +1,4 @@
1
- // Single class device types
2
1
  export * from '../roboticVacuumCleaner.js';
3
2
  export * from '../laundryWasher.js';
4
3
  export * from '../waterHeater.js';
5
4
  export * from '../evse.js';
6
- //# sourceMappingURL=export.js.map
package/dist/evse.js CHANGED
@@ -1,49 +1,12 @@
1
- /**
2
- * This file contains the Evse class.
3
- *
4
- * @file energy-evse.ts
5
- * @author Luca Liguori
6
- * @contributor Ludovic BOUÉ
7
- * @date 2025-05-27
8
- * @version 1.1.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
1
  import { EnergyEvseServer } from '@matter/main/behaviors/energy-evse';
25
2
  import { EnergyEvseModeServer } from '@matter/main/behaviors/energy-evse-mode';
26
3
  import { EnergyEvse, EnergyEvseMode } from '@matter/main/clusters';
27
4
  import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
28
5
  import { ModeBase } from '@matter/main/clusters/mode-base';
29
- // Matterbridge
30
6
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
31
7
  import { MatterbridgeServer } from './matterbridgeBehaviors.js';
32
8
  import { deviceEnergyManagement, electricalSensor, evse, powerSource } from './matterbridgeDeviceTypes.js';
33
9
  export class Evse extends MatterbridgeEndpoint {
34
- /**
35
- * Creates an instance of the EVSE class.
36
- *
37
- * @param {string} name - The name of the EVSE.
38
- * @param {string} serial - The serial number of the EVSE.
39
- * @param {number} [currentMode] - The current mode of the EnergyEvseMode cluster. Defaults to mode 1 (EnergyEvseMode.ModeTag.Manual).
40
- * @param {EnergyEvseMode.ModeOption[]} [supportedModes] - The supported modes for the EnergyEvseMode cluster. This is a fixed attribute that defaults to a predefined set of EnergyEvseMode cluster modes.
41
- * @param {EnergyEvse.State} [state] - The current state of the EVSE. Defaults to NotPluggedIn.
42
- * @param {EnergyEvse.SupplyState} [supplyState] - The supply state of the EVSE. Defaults to Disabled.
43
- * @param {EnergyEvse.FaultState} [faultState] - The fault state of the EVSE. Defaults to NoError.
44
- * @param {number} [absMinPower=0] - Indicate the minimum electrical power that the ESA can consume when switched on. Defaults to `0` if not provided.
45
- * @param {number} [absMaxPower=0] - Indicate the maximum electrical power that the ESA can consume when switched on. Defaults to `0` if not provided.
46
- */
47
10
  constructor(name, serial, currentMode, supportedModes, state, supplyState, faultState, absMinPower, absMaxPower) {
48
11
  super([evse, powerSource, electricalSensor, deviceEnergyManagement], { uniqueStorageKey: `${name.replaceAll(' ', '')}-${serial.replaceAll(' ', '')}` }, true);
49
12
  this.createDefaultIdentifyClusterServer()
@@ -57,42 +20,29 @@ export class Evse extends MatterbridgeEndpoint {
57
20
  .createDefaultEnergyEvseModeClusterServer(currentMode, supportedModes)
58
21
  .addRequiredClusterServers();
59
22
  }
60
- /**
61
- * Creates a default EnergyEvseServer Cluster Server.
62
- *
63
- */
64
23
  createDefaultEnergyEvseClusterServer(state, supplyState, faultState) {
65
24
  this.behaviors.require(MatterbridgeEnergyEvseServer, {
66
25
  state: state ?? EnergyEvse.State.NotPluggedIn,
67
26
  supplyState: supplyState ?? EnergyEvse.SupplyState.ChargingEnabled,
68
27
  faultState: faultState ?? EnergyEvse.FaultState.NoError,
69
- chargingEnabledUntil: 0, // Persistent attribute
70
- circuitCapacity: 0, // Persistent attribute in mA
71
- minimumChargeCurrent: 6000, // Persistent attribute in mA
72
- maximumChargeCurrent: 0, // Persistent attribute in mA
73
- sessionId: null, // Persistent attribute
74
- sessionDuration: 0, // Persistent attribute
75
- sessionEnergyCharged: 0, // Persistent attribute
28
+ chargingEnabledUntil: 0,
29
+ circuitCapacity: 0,
30
+ minimumChargeCurrent: 6000,
31
+ maximumChargeCurrent: 0,
32
+ sessionId: null,
33
+ sessionDuration: 0,
34
+ sessionEnergyCharged: 0,
76
35
  });
77
36
  return this;
78
37
  }
79
- /**
80
- * Creates a default EnergyEvseMode Cluster Server.
81
- *
82
- * @param {number} [currentMode] - The current mode of the EnergyEvseMode cluster. Defaults to mode 1 (EnergyEvseMode.ModeTag.Manual).
83
- * @param {EnergyEvseMode.ModeOption[]} [supportedModes] - The supported modes for the EnergyEvseMode cluster. Defaults all EnergyEvseMode cluster modes.
84
- *
85
- * @returns {this} The current MatterbridgeEndpoint instance for chaining.
86
- */
87
38
  createDefaultEnergyEvseModeClusterServer(currentMode, supportedModes) {
88
39
  this.behaviors.require(MatterbridgeEnergyEvseModeServer, {
89
40
  supportedModes: supportedModes ?? [
90
41
  { label: 'On demand', mode: 1, modeTags: [{ value: EnergyEvseMode.ModeTag.Manual }] },
91
42
  { label: 'Scheduled', mode: 2, modeTags: [{ value: EnergyEvseMode.ModeTag.TimeOfUse }] },
92
43
  { label: 'Solar charging', mode: 3, modeTags: [{ value: EnergyEvseMode.ModeTag.SolarCharging }] },
93
- // { label: 'Home to vehicle and Vehicle to home', mode: 4, modeTags: [{ value: EnergyEvseMode.ModeTag.V2X }] }, // This mode is not valid in charging only EVSEs
94
- ], // FixedAttribute
95
- currentMode: currentMode ?? 1, // Persistent attribute
44
+ ],
45
+ currentMode: currentMode ?? 1,
96
46
  });
97
47
  return this;
98
48
  }
@@ -108,8 +58,6 @@ export class MatterbridgeEnergyEvseServer extends EnergyEvseServer {
108
58
  this.state.state = EnergyEvse.State.PluggedInDemand;
109
59
  }
110
60
  this.state.chargingEnabledUntil = 0;
111
- // super.disable();
112
- // disable is not implemented in matter.js
113
61
  }
114
62
  enableCharging(request) {
115
63
  const device = this.endpoint.stateOf(MatterbridgeServer);
@@ -123,9 +71,6 @@ export class MatterbridgeEnergyEvseServer extends EnergyEvseServer {
123
71
  this.state.chargingEnabledUntil = request.chargingEnabledUntil;
124
72
  this.state.minimumChargeCurrent = request.minimumChargeCurrent;
125
73
  this.state.maximumChargeCurrent = request.maximumChargeCurrent;
126
- // The implementation should also stop the charging session at the required time and update the sessionId, sessionDuration, and sessionEnergyCharged attributes if needed.
127
- // super.enableCharging();
128
- // enableCharging is not implemented in matter.js
129
74
  }
130
75
  }
131
76
  export class MatterbridgeEnergyEvseModeServer extends EnergyEvseModeServer {
@@ -143,4 +88,3 @@ export class MatterbridgeEnergyEvseModeServer extends EnergyEvseModeServer {
143
88
  return { status: ModeBase.ModeChangeStatus.Success, statusText: 'Success' };
144
89
  }
145
90
  }
146
- //# sourceMappingURL=evse.js.map