matterbridge 3.1.0 → 3.1.1-dev-20250629-cfe9124

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 (194) hide show
  1. package/CHANGELOG.md +25 -4
  2. package/README-DEV.md +17 -3
  3. package/README-DOCKER.md +3 -1
  4. package/README-NGINX.md +30 -22
  5. package/README-PODMAN.md +3 -1
  6. package/README-SERVICE.md +8 -2
  7. package/dist/batteryStorage.js +24 -0
  8. package/dist/cli.js +2 -91
  9. package/dist/clusters/export.js +0 -2
  10. package/dist/defaultConfigSchema.js +0 -24
  11. package/dist/deviceManager.js +1 -94
  12. package/dist/devices/export.js +2 -2
  13. package/dist/evse.js +9 -70
  14. package/dist/frontend.js +16 -413
  15. package/dist/globalMatterbridge.js +0 -47
  16. package/dist/helpers.js +0 -53
  17. package/dist/index.js +3 -32
  18. package/dist/laundryWasher.js +7 -92
  19. package/dist/logger/export.js +0 -1
  20. package/dist/matter/behaviors.js +0 -2
  21. package/dist/matter/clusters.js +0 -2
  22. package/dist/matter/devices.js +0 -2
  23. package/dist/matter/endpoints.js +0 -2
  24. package/dist/matter/export.js +0 -3
  25. package/dist/matter/types.js +0 -3
  26. package/dist/matterbridge.js +50 -797
  27. package/dist/matterbridgeAccessoryPlatform.js +0 -36
  28. package/dist/matterbridgeBehaviors.js +16 -55
  29. package/dist/matterbridgeDeviceTypes.js +15 -579
  30. package/dist/matterbridgeDynamicPlatform.js +0 -36
  31. package/dist/matterbridgeEndpoint.js +66 -1025
  32. package/dist/matterbridgeEndpointHelpers.js +12 -322
  33. package/dist/matterbridgePlatform.js +0 -233
  34. package/dist/matterbridgeTypes.js +0 -25
  35. package/dist/pluginManager.js +3 -269
  36. package/dist/roboticVacuumCleaner.js +6 -83
  37. package/dist/shelly.js +7 -168
  38. package/dist/solarPower.js +20 -0
  39. package/dist/storage/export.js +0 -1
  40. package/dist/update.js +0 -54
  41. package/dist/utils/colorUtils.js +2 -263
  42. package/dist/utils/commandLine.js +0 -54
  43. package/dist/utils/copyDirectory.js +1 -38
  44. package/dist/utils/createDirectory.js +0 -33
  45. package/dist/utils/createZip.js +2 -47
  46. package/dist/utils/deepCopy.js +0 -39
  47. package/dist/utils/deepEqual.js +1 -72
  48. package/dist/utils/export.js +0 -1
  49. package/dist/utils/hex.js +0 -58
  50. package/dist/utils/isvalid.js +0 -101
  51. package/dist/utils/network.js +5 -83
  52. package/dist/utils/spawn.js +0 -18
  53. package/dist/utils/wait.js +9 -62
  54. package/dist/waterHeater.js +2 -77
  55. package/npm-shrinkwrap.json +2 -2
  56. package/package.json +1 -2
  57. package/dist/cli.d.ts +0 -29
  58. package/dist/cli.d.ts.map +0 -1
  59. package/dist/cli.js.map +0 -1
  60. package/dist/clusters/export.d.ts +0 -2
  61. package/dist/clusters/export.d.ts.map +0 -1
  62. package/dist/clusters/export.js.map +0 -1
  63. package/dist/defaultConfigSchema.d.ts +0 -28
  64. package/dist/defaultConfigSchema.d.ts.map +0 -1
  65. package/dist/defaultConfigSchema.js.map +0 -1
  66. package/dist/deviceManager.d.ts +0 -112
  67. package/dist/deviceManager.d.ts.map +0 -1
  68. package/dist/deviceManager.js.map +0 -1
  69. package/dist/devices/export.d.ts +0 -5
  70. package/dist/devices/export.d.ts.map +0 -1
  71. package/dist/devices/export.js.map +0 -1
  72. package/dist/evse.d.ts +0 -72
  73. package/dist/evse.d.ts.map +0 -1
  74. package/dist/evse.js.map +0 -1
  75. package/dist/frontend.d.ts +0 -285
  76. package/dist/frontend.d.ts.map +0 -1
  77. package/dist/frontend.js.map +0 -1
  78. package/dist/globalMatterbridge.d.ts +0 -59
  79. package/dist/globalMatterbridge.d.ts.map +0 -1
  80. package/dist/globalMatterbridge.js.map +0 -1
  81. package/dist/helpers.d.ts +0 -48
  82. package/dist/helpers.d.ts.map +0 -1
  83. package/dist/helpers.js.map +0 -1
  84. package/dist/index.d.ts +0 -38
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.js.map +0 -1
  87. package/dist/laundryWasher.d.ts +0 -243
  88. package/dist/laundryWasher.d.ts.map +0 -1
  89. package/dist/laundryWasher.js.map +0 -1
  90. package/dist/logger/export.d.ts +0 -2
  91. package/dist/logger/export.d.ts.map +0 -1
  92. package/dist/logger/export.js.map +0 -1
  93. package/dist/matter/behaviors.d.ts +0 -2
  94. package/dist/matter/behaviors.d.ts.map +0 -1
  95. package/dist/matter/behaviors.js.map +0 -1
  96. package/dist/matter/clusters.d.ts +0 -2
  97. package/dist/matter/clusters.d.ts.map +0 -1
  98. package/dist/matter/clusters.js.map +0 -1
  99. package/dist/matter/devices.d.ts +0 -2
  100. package/dist/matter/devices.d.ts.map +0 -1
  101. package/dist/matter/devices.js.map +0 -1
  102. package/dist/matter/endpoints.d.ts +0 -2
  103. package/dist/matter/endpoints.d.ts.map +0 -1
  104. package/dist/matter/endpoints.js.map +0 -1
  105. package/dist/matter/export.d.ts +0 -5
  106. package/dist/matter/export.d.ts.map +0 -1
  107. package/dist/matter/export.js.map +0 -1
  108. package/dist/matter/types.d.ts +0 -3
  109. package/dist/matter/types.d.ts.map +0 -1
  110. package/dist/matter/types.js.map +0 -1
  111. package/dist/matterbridge.d.ts +0 -450
  112. package/dist/matterbridge.d.ts.map +0 -1
  113. package/dist/matterbridge.js.map +0 -1
  114. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  115. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  116. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  117. package/dist/matterbridgeBehaviors.d.ts +0 -1334
  118. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  119. package/dist/matterbridgeBehaviors.js.map +0 -1
  120. package/dist/matterbridgeDeviceTypes.d.ts +0 -709
  121. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  122. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  123. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  124. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  125. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  126. package/dist/matterbridgeEndpoint.d.ts +0 -1173
  127. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  128. package/dist/matterbridgeEndpoint.js.map +0 -1
  129. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3198
  130. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  131. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  132. package/dist/matterbridgePlatform.d.ts +0 -310
  133. package/dist/matterbridgePlatform.d.ts.map +0 -1
  134. package/dist/matterbridgePlatform.js.map +0 -1
  135. package/dist/matterbridgeTypes.d.ts +0 -184
  136. package/dist/matterbridgeTypes.d.ts.map +0 -1
  137. package/dist/matterbridgeTypes.js.map +0 -1
  138. package/dist/pluginManager.d.ts +0 -291
  139. package/dist/pluginManager.d.ts.map +0 -1
  140. package/dist/pluginManager.js.map +0 -1
  141. package/dist/roboticVacuumCleaner.d.ts +0 -104
  142. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  143. package/dist/roboticVacuumCleaner.js.map +0 -1
  144. package/dist/shelly.d.ts +0 -174
  145. package/dist/shelly.d.ts.map +0 -1
  146. package/dist/shelly.js.map +0 -1
  147. package/dist/storage/export.d.ts +0 -2
  148. package/dist/storage/export.d.ts.map +0 -1
  149. package/dist/storage/export.js.map +0 -1
  150. package/dist/update.d.ts +0 -59
  151. package/dist/update.d.ts.map +0 -1
  152. package/dist/update.js.map +0 -1
  153. package/dist/utils/colorUtils.d.ts +0 -117
  154. package/dist/utils/colorUtils.d.ts.map +0 -1
  155. package/dist/utils/colorUtils.js.map +0 -1
  156. package/dist/utils/commandLine.d.ts +0 -59
  157. package/dist/utils/commandLine.d.ts.map +0 -1
  158. package/dist/utils/commandLine.js.map +0 -1
  159. package/dist/utils/copyDirectory.d.ts +0 -33
  160. package/dist/utils/copyDirectory.d.ts.map +0 -1
  161. package/dist/utils/copyDirectory.js.map +0 -1
  162. package/dist/utils/createDirectory.d.ts +0 -34
  163. package/dist/utils/createDirectory.d.ts.map +0 -1
  164. package/dist/utils/createDirectory.js.map +0 -1
  165. package/dist/utils/createZip.d.ts +0 -39
  166. package/dist/utils/createZip.d.ts.map +0 -1
  167. package/dist/utils/createZip.js.map +0 -1
  168. package/dist/utils/deepCopy.d.ts +0 -32
  169. package/dist/utils/deepCopy.d.ts.map +0 -1
  170. package/dist/utils/deepCopy.js.map +0 -1
  171. package/dist/utils/deepEqual.d.ts +0 -54
  172. package/dist/utils/deepEqual.d.ts.map +0 -1
  173. package/dist/utils/deepEqual.js.map +0 -1
  174. package/dist/utils/export.d.ts +0 -12
  175. package/dist/utils/export.d.ts.map +0 -1
  176. package/dist/utils/export.js.map +0 -1
  177. package/dist/utils/hex.d.ts +0 -49
  178. package/dist/utils/hex.d.ts.map +0 -1
  179. package/dist/utils/hex.js.map +0 -1
  180. package/dist/utils/isvalid.d.ts +0 -103
  181. package/dist/utils/isvalid.d.ts.map +0 -1
  182. package/dist/utils/isvalid.js.map +0 -1
  183. package/dist/utils/network.d.ts +0 -76
  184. package/dist/utils/network.d.ts.map +0 -1
  185. package/dist/utils/network.js.map +0 -1
  186. package/dist/utils/spawn.d.ts +0 -14
  187. package/dist/utils/spawn.d.ts.map +0 -1
  188. package/dist/utils/spawn.js.map +0 -1
  189. package/dist/utils/wait.d.ts +0 -56
  190. package/dist/utils/wait.d.ts.map +0 -1
  191. package/dist/utils/wait.js.map +0 -1
  192. package/dist/waterHeater.d.ts +0 -106
  193. package/dist/waterHeater.d.ts.map +0 -1
  194. package/dist/waterHeater.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -8,21 +8,42 @@ 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.1.1] - 2025-07-??
12
+
13
+ ### Breaking Changes
14
+
15
+ - [devices]: The single devices (i.e. Rvc, Evse etc...) are only 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
+ - [SolarPower]: Added SolarPower class and Jest test. Thanks Ludovic BOUÉ.
20
+ - [BatteryStorage]: Added BatteryStorage class and Jest test. Thanks Ludovic BOUÉ.
21
+ - [DeviceEnergyManagement]: Added MatterbridgeDeviceEnergyManagementServer with power adjustment methods.
22
+
23
+ ### Changed
24
+
25
+ - [package]: Updated dependencies.
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.1.0] - 2025-06-28
12
32
 
13
33
  ### Added
14
34
 
15
- - [DevContainer]: Added support for the **Matterbridge Dev Container** with an optimized named volume for `node_modules`.
35
+ - [DevContainer]: Added support for the [**Matterbridge Dev Container**](https://github.com/Luligu/matterbridge/blob/dev/README-DEV.md#matterbridge-dev-container) with an optimized named volume for `node_modules`.
36
+ - [DevContainer]: Added support for the [**Matterbridge Plugin Dev Container**](https://github.com/Luligu/matterbridge/blob/dev/README-DEV.md#matterbridge-plugin-dev-container) with an optimized named volume for `matterbridge` and `node_modules`.
16
37
  - [GitHub]: Added GitHub issue templates for bug reports and feature requests.
17
- - [Systemd]: Added a systemd service file for Matterbridge in the systemd directory.
38
+ - [Systemd]: Added a systemd service example file for Matterbridge in the systemd directory.
18
39
  - [ESLint]: Refactored ESLint configuration for TypeScript and improved plugin integration.
19
40
  - [ESLint]: Added the plugins `eslint-plugin-promise`, `eslint-plugin-jsdoc`, and `@vitest/eslint-plugin`.
20
- - [Vitest]: Added Vitest for TypeScript project testing. It will replace Jest, which does not work correctly with ESM module mocks.
41
+ - [Vitest]: Added `Vitest` for TypeScript project testing. It will replace Jest, which does not work correctly with ESM module mocks.
21
42
  - [JSDoc]: Added missing JSDoc comments, including `@param` and `@returns` tags.
22
43
  - [MatterbridgeEndpoint]: Add MatterbridgeEndpoint mode='server'. It allows to advertise a single device like an autonomous device with its server node to be paired. The device is not bridged (alpha stage).
23
44
  - [MatterbridgeEndpoint]: Add MatterbridgeEndpoint mode='matter'. It allows to add a single device to the Matterbridge server node next to the aggregator. The device is not bridged (alpha stage).
24
45
  - [storage]: Improved error handling of corrupted storage.
25
- - [test]: Improved test units on Matterbridge classes.
46
+ - [test]: Improved test units on Matterbridge classes (coverage 91%).
26
47
 
27
48
  ### Changed
28
49
 
package/README-DEV.md CHANGED
@@ -1,10 +1,12 @@
1
- # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge development
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
4
  [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
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
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
8
10
 
9
11
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
10
12
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
@@ -28,7 +30,7 @@ The Matterbridge Plugin Template has an already configured Jest / Vitest test un
28
30
 
29
31
  It also has a workflow configured to run on push and pull request that build, lint and test the plugin on node 20, 22 and 24 with ubuntu, macOS and windows.
30
32
 
31
- ## Dev Container
33
+ ## Matterbridge Dev Container
32
34
 
33
35
  Using a Dev Container provides a fully isolated, reproducible, and pre-configured development environment. This ensures that all contributors have the same tools, extensions, and dependencies, eliminating "works on my machine" issues. It also makes onboarding new developers fast and hassle-free, as everything needed is set up automatically.
34
36
 
@@ -36,7 +38,19 @@ For improved efficiency, the setup uses named Docker volumes for `node_modules`.
36
38
 
37
39
  To start the Dev Container, simply open the project folder in [Visual Studio Code](https://code.visualstudio.com/) and, if prompted, click "Reopen in Container". Alternatively, use the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`), search for "Dev Containers: Reopen in Container", and select it. VS Code will automatically build and start the containerized environment for you.
38
40
 
39
- > **Note:** The first time you use the Dev Container, it may take a while to download all the required Docker images and set up the environment. Subsequent starts will be much faster.
41
+ > **Note:** The first time you use the Dev Container, it may take a while to download all the required Docker images and set up the environment. Subsequent starts will be as as fast as from the local folder.
42
+
43
+ Since Dev Container doesn't run in network mode 'host', it is not possible to pair Mattebridge running inside the Dev Container.
44
+
45
+ ## Matterbridge Plugin Dev Container
46
+
47
+ Using a Dev Container provides a fully isolated, reproducible, and pre-configured development environment. This ensures that all contributors have the same tools, extensions, and dependencies, eliminating "works on my machine" issues. It also makes onboarding new developers fast and hassle-free, as everything needed is set up automatically.
48
+
49
+ For improved efficiency, the setup uses named Docker volumes for `matterbridge` and `node_modules`. This means that the dev of matterbridge and the plugin dependencies are installed only once and persist across container rebuilds, making installs and rebuilds much faster than with bind mounts or ephemeral volumes.
50
+
51
+ To start the Dev Container, simply open the project folder in [Visual Studio Code](https://code.visualstudio.com/) and, if prompted, click "Reopen in Container". Alternatively, use the Command Palette (`Ctrl+Shift+P` or `Cmd+Shift+P`), search for "Dev Containers: Reopen in Container", and select it. VS Code will automatically build and start the containerized environment for you.
52
+
53
+ > **Note:** The first time you use the Dev Container, it may take a while to download all the required Docker images and set up the environment. Subsequent starts will be as fast as from the local folder.
40
54
 
41
55
  Since Dev Container doesn't run in network mode 'host', it is not possible to pair Mattebridge running inside the Dev Container.
42
56
 
package/README-DOCKER.md CHANGED
@@ -1,10 +1,12 @@
1
- # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge docker configuration
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
4
  [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
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
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
8
10
 
9
11
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
10
12
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
package/README-NGINX.md CHANGED
@@ -1,10 +1,12 @@
1
- # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge NGINX configuration
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
4
  [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
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
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
8
10
 
9
11
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
10
12
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
@@ -31,7 +33,7 @@ server {
31
33
  server_name _;
32
34
 
33
35
  location / {
34
- # Redirect to Matterbridge frontend
36
+ # Redirect to Matterbridge frontend from http:/server_name:80
35
37
  proxy_pass http://localhost:8283/;
36
38
  proxy_set_header Host $host;
37
39
  proxy_set_header X-Real-IP $remote_addr;
@@ -48,13 +50,13 @@ server {
48
50
 
49
51
  Add matterbridge to enabled sites
50
52
 
51
- ```
53
+ ```bash
52
54
  sudo ln -s /etc/nginx/sites-available/matterbridge /etc/nginx/sites-enabled/
53
55
  ```
54
56
 
55
57
  ### Create a basic nginx configuration file that redirect to http://yourhost:8283/matterbridge
56
58
 
57
- ```
59
+ ```bash
58
60
  sudo nano /etc/nginx/sites-available/matterbridge
59
61
  ```
60
62
 
@@ -67,7 +69,7 @@ server {
67
69
  server_name _;
68
70
 
69
71
  location /matterbridge/ {
70
- # Redirect to Matterbridge frontend
72
+ # Redirect to Matterbridge frontend from http:/server_name/matterbridge:80
71
73
  proxy_pass http://localhost:8283/;
72
74
  proxy_set_header Host $host;
73
75
  proxy_set_header X-Real-IP $remote_addr;
@@ -84,13 +86,20 @@ server {
84
86
 
85
87
  Add matterbridge to enabled sites
86
88
 
87
- ```
89
+ ```bash
88
90
  sudo ln -s /etc/nginx/sites-available/matterbridge /etc/nginx/sites-enabled/
89
91
  ```
90
92
 
91
- ### Create an advanced nginx configuration file that redirect to http://yourhost:8283 with ssl
93
+ Restart nginx and test the configuration
92
94
 
95
+ ```bash
96
+ sudo systemctl restart nginx
97
+ sudo nginx -t
93
98
  ```
99
+
100
+ ### Create an advanced nginx configuration file that redirect to http://yourhost:8283 with ssl
101
+
102
+ ```bash
94
103
  sudo nano /etc/nginx/sites-available/matterbridge
95
104
  ```
96
105
 
@@ -125,7 +134,7 @@ server {
125
134
  ssl_prefer_server_ciphers on;
126
135
 
127
136
  location / {
128
- # Redirect to Matterbridge frontend
137
+ # Redirect to Matterbridge frontend from https:/server_name:443
129
138
  proxy_pass http://localhost:8283/;
130
139
  proxy_set_header Host $host;
131
140
  proxy_set_header X-Real-IP $remote_addr;
@@ -142,13 +151,20 @@ server {
142
151
 
143
152
  Add matterbridge to enabled sites
144
153
 
145
- ```
154
+ ```bash
146
155
  sudo ln -s /etc/nginx/sites-available/matterbridge /etc/nginx/sites-enabled/
147
156
  ```
148
157
 
149
- ### Create an advanced nginx configuration file that redirect to http://yourhost/matterbridge with ssl
158
+ Restart nginx and test the configuration
150
159
 
160
+ ```bash
161
+ sudo systemctl restart nginx
162
+ sudo nginx -t
151
163
  ```
164
+
165
+ ### Create an advanced nginx configuration file that redirect to http://yourhost/matterbridge with ssl
166
+
167
+ ```bash
152
168
  sudo nano /etc/nginx/sites-available/matterbridge
153
169
  ```
154
170
 
@@ -190,7 +206,7 @@ server {
190
206
  }
191
207
 
192
208
  location /matterbridge/ {
193
- # Redirect to Matterbridge frontend
209
+ # Redirect to Matterbridge frontend from https:/server_name/matterbridge:443
194
210
  proxy_pass http://localhost:8283/;
195
211
  proxy_set_header Host $host;
196
212
  proxy_set_header X-Real-IP $remote_addr;
@@ -207,21 +223,13 @@ server {
207
223
 
208
224
  Add matterbridge to enabled sites
209
225
 
210
- ```
226
+ ```bash
211
227
  sudo ln -s /etc/nginx/sites-available/matterbridge /etc/nginx/sites-enabled/
212
228
  ```
213
229
 
214
- ### Restart nginx and test the configuration
230
+ Restart nginx and test the configuration
215
231
 
216
- ```
232
+ ```bash
217
233
  sudo systemctl restart nginx
218
234
  sudo nginx -t
219
235
  ```
220
-
221
- ### Use matterbridge with nginx
222
-
223
- http://ubuntu/matterbridge/
224
-
225
- or
226
-
227
- https://ubuntu/matterbridge/
package/README-PODMAN.md CHANGED
@@ -1,10 +1,12 @@
1
- # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge Podman configuration
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
4
  [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
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
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
8
10
 
9
11
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
10
12
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
package/README-SERVICE.md CHANGED
@@ -1,10 +1,12 @@
1
- # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge
1
+ # <img src="frontend/public/matterbridge.svg" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge systemd configuration
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
4
4
  [![npm downloads](https://img.shields.io/npm/dt/matterbridge.svg)](https://www.npmjs.com/package/matterbridge)
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
+ ![CodeQL](https://github.com/Luligu/matterbridge/actions/workflows/codeql.yml/badge.svg)
9
+ [![codecov](https://codecov.io/gh/Luligu/matterbridge/branch/main/graph/badge.svg)](https://codecov.io/gh/Luligu/matterbridge)
8
10
 
9
11
  [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
10
12
  [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
@@ -16,6 +18,10 @@
16
18
 
17
19
  ## Run matterbridge as a daemon with systemctl (Linux only)
18
20
 
21
+ The easiest way to add systemctl is to use [Matterbridge service cli for linux](https://github.com/Luligu/mb-service-linux).
22
+
23
+ If your setup is too complex or you prefer to do it manually follow this method. You can still use mb-service to manage systemd after.
24
+
19
25
  ### First create the Matterbridge directories
20
26
 
21
27
  This will create the required directories if they don't exist
@@ -75,7 +81,7 @@ If you use the matterbridge-bthome plugin add this:
75
81
  AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_NET_ADMIN
76
82
  ```
77
83
 
78
- If you modify it after, then run:
84
+ If you modify matterbridge.service after, then run:
79
85
 
80
86
  ```bash
81
87
  sudo systemctl daemon-reload
@@ -0,0 +1,24 @@
1
+ import { PowerSourceTag } from '@matter/main';
2
+ import { DeviceEnergyManagement } from '@matter/main/clusters/device-energy-management';
3
+ import { PowerSource } from '@matter/main/clusters/power-source';
4
+ import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
5
+ import { deviceEnergyManagement, electricalSensor, batteryStorage, powerSource } from './matterbridgeDeviceTypes.js';
6
+ export class BatteryStorage extends MatterbridgeEndpoint {
7
+ constructor(name, serial, batPercentRemaining = 100, batChargeLevel = PowerSource.BatChargeLevel.Ok, voltage = null, current = null, power = null, energyImported = null, energyExported = null, absMinPower = 0, absMaxPower = 0) {
8
+ super([batteryStorage, powerSource, electricalSensor, deviceEnergyManagement], {
9
+ tagList: [
10
+ { mfgCode: null, namespaceId: PowerSourceTag.Battery.namespaceId, tag: PowerSourceTag.Battery.tag, label: null },
11
+ { mfgCode: null, namespaceId: PowerSourceTag.Grid.namespaceId, tag: PowerSourceTag.Grid.tag, label: null },
12
+ ],
13
+ id: `${name.replaceAll(' ', '')}-${serial.replaceAll(' ', '')}`,
14
+ }, true);
15
+ this.createDefaultIdentifyClusterServer()
16
+ .createDefaultBasicInformationClusterServer(name, serial, 0xfff1, 'Matterbridge', 0x8000, 'Matterbridge Solar Power')
17
+ .createDefaultPowerSourceWiredBatteryClusterServer(batPercentRemaining, batChargeLevel)
18
+ .createDefaultPowerTopologyClusterServer()
19
+ .createDefaultElectricalPowerMeasurementClusterServer(voltage, current, power)
20
+ .createDefaultElectricalEnergyMeasurementClusterServer(energyImported, energyExported)
21
+ .createDefaultDeviceEnergyManagementClusterServer(DeviceEnergyManagement.EsaType.BatteryStorage, true, DeviceEnergyManagement.EsaState.Online, absMinPower, absMaxPower)
22
+ .addRequiredClusterServers();
23
+ }
24
+ }
package/dist/cli.js CHANGED
@@ -1,46 +1,19 @@
1
- /**
2
- * This file contains the CLI entry point of Matterbridge.
3
- *
4
- * @file cli.ts
5
- * @author Luca Liguori
6
- * @created 2023-12-29
7
- * @version 2.0.1
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
1
  import os from 'node:os';
25
2
  import { EventEmitter } from 'node:events';
26
3
  import { inspect } from 'node:util';
27
- // AnsiLogger module
28
4
  import { AnsiLogger, BRIGHT, CYAN, db, YELLOW } from 'node-ansi-logger';
29
- // Matterbridge
30
5
  import { getIntParameter, hasParameter } from './utils/export.js';
31
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`;
@@ -67,20 +40,14 @@ const formatOsUpTime = (seconds) => {
67
40
  }
68
41
  return `${seconds} second${seconds !== 1 ? 's' : ''}`;
69
42
  };
70
- /**
71
- * Starts the CPU and memory check interval.
72
- */
73
43
  async function startCpuMemoryCheck() {
74
- // const os = await import('node:os');
75
44
  log.debug(`Cpu memory check started`);
76
45
  prevCpus = os.cpus();
77
46
  clearInterval(memoryCheckInterval);
78
47
  const interval = () => {
79
- // Get the os uptime
80
48
  const systemUptime = formatOsUpTime(Math.floor(os.uptime()));
81
49
  const processUptime = formatOsUpTime(Math.floor(process.uptime()));
82
50
  cliEmitter.emit('uptime', systemUptime, processUptime);
83
- // Get the memory usage
84
51
  const totalMememory = formatMemoryUsage(os.totalmem());
85
52
  const freeMemory = formatMemoryUsage(os.freemem());
86
53
  const memoryUsageRaw = process.memoryUsage();
@@ -92,12 +59,10 @@ async function startCpuMemoryCheck() {
92
59
  if (memoryUsageRaw.rss > peakRss)
93
60
  peakRss = memoryUsageRaw.rss;
94
61
  cliEmitter.emit('memory', totalMememory, freeMemory, rss, heapTotal, heapUsed, external, arrayBuffers);
95
- // Get the cpu usage
96
62
  const currCpus = os.cpus();
97
- // log.debug(`Cpus: ${JSON.stringify(currCpus)}`);
98
63
  let cpuUsageLog;
99
64
  if (currCpus.length !== prevCpus.length) {
100
- prevCpus = currCpus; // Reset the previous cpus
65
+ prevCpus = currCpus;
101
66
  log.debug(`Cpu check length failed, resetting previous cpus`);
102
67
  return;
103
68
  }
@@ -123,29 +88,20 @@ async function startCpuMemoryCheck() {
123
88
  cliEmitter.emit('cpu', lastCpuUsage);
124
89
  }
125
90
  prevCpus = currCpus;
126
- // Show the cpu and memory usage
127
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}`);
128
92
  };
129
93
  interval();
130
94
  clearInterval(memoryCheckInterval);
131
95
  memoryCheckInterval = setInterval(interval, getIntParameter('memoryinterval') ?? 10 * 1000).unref();
132
96
  }
133
- /**
134
- * Stops the CPU and memory check interval.
135
- */
136
97
  async function stopCpuMemoryCheck() {
137
98
  log.debug(`***Cpu memory check stopped. Peak cpu: ${CYAN}${peakCpu.toFixed(2)} %${db}. Peak rss: ${CYAN}${formatMemoryUsage(peakRss)}${db}.`);
138
99
  clearInterval(memoryCheckInterval);
139
100
  }
140
- /**
141
- * Starts the inspector for heap sampling.
142
- * This function is called when the -inspect parameter is passed.
143
- */
144
101
  async function startInspector() {
145
102
  const { Session } = await import('node:inspector');
146
103
  const { mkdirSync } = await import('node:fs');
147
104
  log.debug(`***Starting heap sampling...`);
148
- // Create the heap snapshots directory if it doesn't exist
149
105
  mkdirSync('heap_profile', { recursive: true });
150
106
  try {
151
107
  session = new Session();
@@ -154,7 +110,6 @@ async function startInspector() {
154
110
  session?.post('HeapProfiler.startSampling', (err) => (err ? reject(err) : resolve()));
155
111
  });
156
112
  log.debug(`***Started heap sampling`);
157
- // Set an interval to take heap snapshots
158
113
  const interval = getIntParameter('snapshotinterval');
159
114
  if (interval && interval >= 30000) {
160
115
  log.debug(`***Started heap snapshot interval of ${CYAN}${interval}${db} ms`);
@@ -172,19 +127,13 @@ async function startInspector() {
172
127
  return;
173
128
  }
174
129
  }
175
- /**
176
- * Stops the heap sampling and saves the profile to a file.
177
- * This function is called when the inspector is stopped.
178
- */
179
130
  async function stopInspector() {
180
131
  const { writeFileSync } = await import('node:fs');
181
132
  const path = await import('node:path');
182
133
  log.debug(`***Stopping heap sampling...`);
183
134
  if (snapshotInterval) {
184
135
  log.debug(`***Clearing heap snapshot interval...`);
185
- // Clear the snapshot interval if it exists
186
136
  clearInterval(snapshotInterval);
187
- // Take a final heap snapshot before stopping
188
137
  await takeHeapSnapshot();
189
138
  }
190
139
  if (!session) {
@@ -192,7 +141,6 @@ async function stopInspector() {
192
141
  return;
193
142
  }
194
143
  try {
195
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
196
144
  const result = await new Promise((resolve, reject) => {
197
145
  session?.post('HeapProfiler.stopSampling', (err, result) => (err ? reject(err) : resolve(result)));
198
146
  });
@@ -210,13 +158,6 @@ async function stopInspector() {
210
158
  log.debug(`***Stopped heap sampling`);
211
159
  }
212
160
  }
213
- /**
214
- * Takes a heap snapshot and saves it to the file name Heap-snapshot-<timestamp>.heapsnapshot.
215
- * This function is called periodically based on the -snapshotinterval parameter.
216
- * The -snapshotinterval parameter must at least 30000 ms.
217
- * The snapshot is saved in the heap_profile directory that is created in the current working directory.
218
- * The snapshot can be analyzed using vscode or Chrome DevTools or other tools that support heap snapshots.
219
- */
220
161
  async function takeHeapSnapshot() {
221
162
  const { writeFileSync } = await import('node:fs');
222
163
  const path = await import('node:path');
@@ -248,10 +189,6 @@ async function takeHeapSnapshot() {
248
189
  });
249
190
  });
250
191
  }
251
- /**
252
- * Triggers a manual garbage collection.
253
- * This function is working only if the process is started with --expose-gc.
254
- */
255
192
  function triggerGarbageCollection() {
256
193
  if (typeof global.gc === 'function') {
257
194
  global.gc();
@@ -261,9 +198,6 @@ function triggerGarbageCollection() {
261
198
  log.debug('Garbage collection is not exposed. Start Node.js with --expose-gc to enable manual GC.');
262
199
  }
263
200
  }
264
- /**
265
- * Registers event handlers for the Matterbridge instance.
266
- */
267
201
  function registerHandlers() {
268
202
  log.debug('Registering event handlers...');
269
203
  if (instance)
@@ -286,52 +220,32 @@ function registerHandlers() {
286
220
  instance.on('triggergarbagecollection', async () => triggerGarbageCollection());
287
221
  log.debug('Registered event handlers');
288
222
  }
289
- /**
290
- * Shuts down the Matterbridge instance and exits the process.
291
- */
292
223
  async function shutdown() {
293
224
  log.debug('Received shutdown event, exiting...');
294
225
  if (hasParameter('inspect'))
295
226
  await stopInspector();
296
227
  await stopCpuMemoryCheck();
297
228
  cliEmitter.emit('shutdown');
298
- // eslint-disable-next-line n/no-process-exit
299
229
  process.exit(0);
300
230
  }
301
- /**
302
- *
303
- */
304
231
  async function restart() {
305
232
  log.debug('Received restart event, loading...');
306
233
  instance = await Matterbridge.loadInstance(true);
307
234
  registerHandlers();
308
235
  }
309
- /**
310
- *
311
- */
312
236
  async function update() {
313
237
  log.debug('Received update event, updating...');
314
- // TODO: Implement update logic outside of matterbridge
315
238
  instance = await Matterbridge.loadInstance(true);
316
239
  registerHandlers();
317
240
  }
318
- /**
319
- * Starts the CPU and memory check when the -startmemorycheck parameter is passed.
320
- */
321
241
  async function start() {
322
242
  log.debug('Received start memory check event');
323
243
  await startCpuMemoryCheck();
324
244
  }
325
- /**
326
- * Stops the CPU and memory check when the -stopmemorycheck parameter is passed.
327
- */
328
245
  async function stop() {
329
246
  log.debug('Received stop memory check event');
330
247
  await stopCpuMemoryCheck();
331
248
  }
332
- /**
333
- * Main function that initializes the Matterbridge instance and starts the CLI.
334
- */
335
249
  async function main() {
336
250
  log.debug(`Cli main() started`);
337
251
  await startCpuMemoryCheck();
@@ -340,7 +254,6 @@ async function main() {
340
254
  log.debug(`***Matterbridge.loadInstance(true) called`);
341
255
  instance = await Matterbridge.loadInstance(true);
342
256
  log.debug(`***Matterbridge.loadInstance(true) exited`);
343
- // Check if the instance needs to shut down from parseCommandLine()
344
257
  if (!instance || instance.shutdown) {
345
258
  shutdown();
346
259
  }
@@ -349,11 +262,9 @@ async function main() {
349
262
  cliEmitter.emit('ready');
350
263
  }
351
264
  }
352
- // Run the main function
353
265
  process.title = 'matterbridge';
354
266
  main().catch((error) => {
355
267
  const errorMessage = error instanceof Error ? error.message : error;
356
268
  const errorInspect = inspect(error, { depth: 10 });
357
269
  log.error(`Matterbridge.loadInstance() failed with error: ${errorMessage}\nstack: ${errorInspect}`);
358
270
  });
359
- //# 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,26 +1,3 @@
1
- /**
2
- * This file contains the default config for the plugins.
3
- *
4
- * @file defaultConfigSchema.ts
5
- * @author Luca Liguori
6
- * @created 2024-05-07
7
- * @version 1.0.1
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
1
  export const zigbee2mqtt_config = {
25
2
  name: 'matterbridge-zigbee2mqtt',
26
3
  type: 'DynamicPlatform',
@@ -79,4 +56,3 @@ export const shelly_config = {
79
56
  debugWs: false,
80
57
  unregisterOnShutdown: false,
81
58
  };
82
- //# sourceMappingURL=defaultConfigSchema.js.map