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
@@ -1,29 +1,3 @@
1
- /**
2
- * This file contains the RoboticVacuumCleaner class.
3
- *
4
- * @file roboticVacuumCleaner.ts
5
- * @author Luca Liguori
6
- * @date 2025-05-01
7
- * @version 1.1.0
8
- *
9
- * Copyright 2025, 2026, 2027 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
- // Matterbridge
24
- import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
25
- import { roboticVacuumCleaner } from './matterbridgeDeviceTypes.js';
26
- import { MatterbridgeServer, MatterbridgeServiceAreaServer } from './matterbridgeBehaviors.js';
27
1
  import { RvcRunModeServer } from '@matter/main/behaviors/rvc-run-mode';
28
2
  import { RvcOperationalStateServer } from '@matter/main/behaviors/rvc-operational-state';
29
3
  import { RvcCleanModeServer } from '@matter/main/behaviors/rvc-clean-mode';
@@ -33,24 +7,10 @@ import { RvcCleanMode } from '@matter/main/clusters/rvc-clean-mode';
33
7
  import { RvcOperationalState } from '@matter/main/clusters/rvc-operational-state';
34
8
  import { ModeBase } from '@matter/main/clusters/mode-base';
35
9
  import { OperationalState } from '@matter/main/clusters/operational-state';
10
+ import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
11
+ import { roboticVacuumCleaner } from './matterbridgeDeviceTypes.js';
12
+ import { MatterbridgeServer, MatterbridgeServiceAreaServer } from './matterbridgeBehaviors.js';
36
13
  export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
37
- /**
38
- * Creates an instance of the RoboticVacuumCleaner class.
39
- *
40
- * @param {string} name - The name of the robotic vacuum cleaner.
41
- * @param {string} serial - The serial number of the robotic vacuum cleaner.
42
- * @param {number} [currentRunMode] - The current run mode of the robotic vacuum cleaner. Defaults to 1 (Idle).
43
- * @param {RvcRunMode.ModeOption[]} [supportedRunModes] - The supported run modes for the robotic vacuum cleaner. Defaults to a predefined set of modes.
44
- * @param {number} [currentCleanMode] - The current clean mode of the robotic vacuum cleaner. Defaults to 1 (Vacuum).
45
- * @param {RvcCleanMode.ModeOption[]} [supportedCleanModes] - The supported clean modes for the robotic vacuum cleaner. Defaults to a predefined set of modes.
46
- * @param {number | null} [currentPhase] - The current phase of the robotic vacuum cleaner. Defaults to null.
47
- * @param {string[] | null} [phaseList] - The list of phases for the robotic vacuum cleaner. Defaults to null.
48
- * @param {RvcOperationalState.OperationalState} [operationalState] - The current operational state of the robotic vacuum cleaner. Defaults to Docked.
49
- * @param {RvcOperationalState.OperationalStateStruct[]} [operationalStateList] - The list of operational states for the robotic vacuum cleaner. Defaults to a predefined set of states.
50
- * @param {ServiceArea.Area[]} [supportedAreas] - The supported areas for the robotic vacuum cleaner. Defaults to a predefined set of areas.
51
- * @param {number[]} [selectedAreas] - The selected areas for the robotic vacuum cleaner. Defaults to an empty array (all areas allowed).
52
- * @param {number} [currentArea] - The current area of the robotic vacuum cleaner. Defaults to 1 (Living).
53
- */
54
14
  constructor(name, serial, currentRunMode, supportedRunModes, currentCleanMode, supportedCleanModes, currentPhase = null, phaseList = null, operationalState, operationalStateList, supportedAreas, selectedAreas, currentArea) {
55
15
  super(roboticVacuumCleaner, { uniqueStorageKey: `${name.replaceAll(' ', '')}-${serial.replaceAll(' ', '')}` }, true);
56
16
  this.createDefaultIdentifyClusterServer()
@@ -61,14 +21,6 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
61
21
  .createDefaultRvcOperationalStateClusterServer(phaseList, currentPhase, operationalStateList, operationalState)
62
22
  .createDefaultServiceAreaClusterServer(supportedAreas, selectedAreas, currentArea);
63
23
  }
64
- /**
65
- * Creates a default RvcRunMode Cluster Server.
66
- *
67
- * @param {number} [currentMode] - The current mode of the RvcRunMode cluster. Defaults to 1 (Idle).
68
- * @param {RvcRunMode.ModeOption[]} [supportedModes] - The supported modes for the RvcRunMode cluster. Defaults to a predefined set of modes.
69
- *
70
- * @returns {this} The current MatterbridgeEndpoint instance for chaining.
71
- */
72
24
  createDefaultRvcRunModeClusterServer(currentMode, supportedModes) {
73
25
  this.behaviors.require(MatterbridgeRvcRunModeServer, {
74
26
  supportedModes: supportedModes ?? [
@@ -81,14 +33,6 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
81
33
  });
82
34
  return this;
83
35
  }
84
- /**
85
- * Creates a default RvcCleanMode Cluster Server.
86
- *
87
- * @param {number} [currentMode] - The current mode of the RvcCleanMode cluster. Defaults to 1 (Vacuum).
88
- * @param {RvcCleanMode.ModeOption[]} [supportedModes] - The supported modes for the RvcCleanMode cluster. Defaults to a predefined set of modes.
89
- *
90
- * @returns {this} The current MatterbridgeEndpoint instance for chaining.
91
- */
92
36
  createDefaultRvcCleanModeClusterServer(currentMode, supportedModes) {
93
37
  this.behaviors.require(MatterbridgeRvcCleanModeServer, {
94
38
  supportedModes: supportedModes ?? [
@@ -100,13 +44,6 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
100
44
  });
101
45
  return this;
102
46
  }
103
- /**
104
- * Creates a default ServiceArea Cluster Server.
105
- *
106
- * @param {ServiceArea.Area[]} [supportedAreas] - The supported areas for the ServiceArea cluster. Defaults to a predefined set of areas.
107
- * @param {number[]} [selectedAreas] - The selected areas for the ServiceArea cluster. Defaults to an empty array (all areas allowed).
108
- * @returns {this} The current MatterbridgeEndpoint instance for chaining.
109
- */
110
47
  createDefaultServiceAreaClusterServer(supportedAreas, selectedAreas, currentArea) {
111
48
  this.behaviors.require(MatterbridgeServiceAreaServer, {
112
49
  supportedAreas: supportedAreas ?? [
@@ -137,16 +74,6 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
137
74
  });
138
75
  return this;
139
76
  }
140
- /**
141
- * Creates a default RvcOperationalState Cluster Server.
142
- *
143
- * @param {string[] | null} [phaseList] - The list of phases for the RvcOperationalState cluster. Defaults to null.
144
- * @param {number | null} [currentPhase] - The current phase of the RvcOperationalState cluster. Defaults to null.
145
- * @param {RvcOperationalState.OperationalStateStruct[]} [operationalStateList] - The list of operational states for the RvcOperationalState cluster. Defaults to a predefined set of states.
146
- * @param {RvcOperationalState.OperationalState} [operationalState] - The current operational state of the RvcOperationalState cluster. Defaults to Docked.
147
- * @param {RvcOperationalState.ErrorStateStruct} [operationalError] - The current operational error of the RvcOperationalState cluster. Defaults to NoError.
148
- * @returns {this} The current MatterbridgeEndpoint instance for chaining.
149
- */
150
77
  createDefaultRvcOperationalStateClusterServer(phaseList = null, currentPhase = null, operationalStateList, operationalState, operationalError) {
151
78
  this.behaviors.require(MatterbridgeRvcOperationalStateServer, {
152
79
  phaseList,
@@ -156,9 +83,9 @@ export class RoboticVacuumCleaner extends MatterbridgeEndpoint {
156
83
  { operationalStateId: RvcOperationalState.OperationalState.Running, operationalStateLabel: 'Running' },
157
84
  { operationalStateId: RvcOperationalState.OperationalState.Paused, operationalStateLabel: 'Paused' },
158
85
  { operationalStateId: RvcOperationalState.OperationalState.Error, operationalStateLabel: 'Error' },
159
- { operationalStateId: RvcOperationalState.OperationalState.SeekingCharger, operationalStateLabel: 'SeekingCharger' }, // Y RVC Pause Compatibility N RVC Resume Compatibility
160
- { operationalStateId: RvcOperationalState.OperationalState.Charging, operationalStateLabel: 'Charging' }, // N RVC Pause Compatibility Y RVC Resume Compatibility
161
- { operationalStateId: RvcOperationalState.OperationalState.Docked, operationalStateLabel: 'Docked' }, // N RVC Pause Compatibility Y RVC Resume Compatibility
86
+ { operationalStateId: RvcOperationalState.OperationalState.SeekingCharger, operationalStateLabel: 'SeekingCharger' },
87
+ { operationalStateId: RvcOperationalState.OperationalState.Charging, operationalStateLabel: 'Charging' },
88
+ { operationalStateId: RvcOperationalState.OperationalState.Docked, operationalStateLabel: 'Docked' },
162
89
  ],
163
90
  operationalState: operationalState ?? RvcOperationalState.OperationalState.Docked,
164
91
  operationalError: operationalError ?? { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' },
@@ -213,7 +140,7 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
213
140
  device.log.info(`Pause (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
214
141
  device.commandHandler.executeHandler('pause', { request: {}, cluster: RvcOperationalStateServer.id, attributes: this.state, endpoint: this.endpoint });
215
142
  device.log.debug('MatterbridgeRvcOperationalStateServer: pause called setting operational state to Paused and currentMode to Idle');
216
- this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1; // RvcRunMode.ModeTag.Idle
143
+ this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
217
144
  this.state.operationalState = RvcOperationalState.OperationalState.Paused;
218
145
  this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
219
146
  return {
@@ -225,7 +152,7 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
225
152
  device.log.info(`Resume (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
226
153
  device.commandHandler.executeHandler('resume', { request: {}, cluster: RvcOperationalStateServer.id, attributes: this.state, endpoint: this.endpoint });
227
154
  device.log.debug('MatterbridgeRvcOperationalStateServer: resume called setting operational state to Running and currentMode to Cleaning');
228
- this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2; // RvcRunMode.ModeTag.Cleaning
155
+ this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 2;
229
156
  this.state.operationalState = RvcOperationalState.OperationalState.Running;
230
157
  this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
231
158
  return {
@@ -233,12 +160,11 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
233
160
  };
234
161
  }
235
162
  goHome() {
236
- // const device = this.agent.get(MatterbridgeServer).state.deviceCommand;
237
163
  const device = this.endpoint.stateOf(MatterbridgeServer);
238
164
  device.log.info(`GoHome (endpoint ${this.endpoint.maybeId}.${this.endpoint.maybeNumber})`);
239
165
  device.commandHandler.executeHandler('goHome', { request: {}, cluster: RvcOperationalStateServer.id, attributes: this.state, endpoint: this.endpoint });
240
166
  device.log.debug('MatterbridgeRvcOperationalStateServer: goHome called setting operational state to Docked and currentMode to Idle');
241
- this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1; // RvcRunMode.ModeTag.Idle
167
+ this.agent.get(MatterbridgeRvcRunModeServer).state.currentMode = 1;
242
168
  this.state.operationalState = RvcOperationalState.OperationalState.Docked;
243
169
  this.state.operationalError = { errorStateId: RvcOperationalState.ErrorState.NoError, errorStateLabel: 'No Error', errorStateDetails: 'Fully operational' };
244
170
  return {
@@ -246,4 +172,3 @@ export class MatterbridgeRvcOperationalStateServer extends RvcOperationalStateSe
246
172
  };
247
173
  }
248
174
  }
249
- //# sourceMappingURL=roboticVacuumCleaner.js.map
package/dist/shelly.js CHANGED
@@ -1,53 +1,13 @@
1
- /**
2
- * This file contains the shelly api functions.
3
- *
4
- * @file shelly.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-19
7
- * @version 1.1.0
8
- *
9
- * Copyright 2025, 2026, 2027 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
- */
1
+ import { debugStringify } from 'node-ansi-logger';
23
2
  import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
24
- import { debugStringify } from './logger/export.js';
25
3
  let verifyIntervalSecs = 15;
26
4
  let verifyTimeoutSecs = 600;
27
- /**
28
- * Sets the interval for verification in seconds.
29
- *
30
- * @param {number} seconds - The interval in seconds.
31
- * @returns {void}
32
- */
33
5
  export function setVerifyIntervalSecs(seconds) {
34
6
  verifyIntervalSecs = seconds;
35
7
  }
36
- /**
37
- * Sets the timeout for verification in seconds.
38
- *
39
- * @param {number} seconds - The timeout in seconds.
40
- * @returns {void}
41
- */
42
8
  export function setVerifyTimeoutSecs(seconds) {
43
9
  verifyTimeoutSecs = seconds;
44
10
  }
45
- /**
46
- * Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
47
- *
48
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
49
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
50
- */
51
11
  export async function getShellySysUpdate(matterbridge) {
52
12
  try {
53
13
  const updates = (await getShelly('/api/updates/sys/check'));
@@ -66,33 +26,19 @@ export async function getShellySysUpdate(matterbridge) {
66
26
  matterbridge.log.error(`Error getting Shelly system updates: ${err instanceof Error ? err.message : String(err)}`);
67
27
  }
68
28
  }
69
- /**
70
- * Triggers Shelly system updates.
71
- *
72
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
73
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
74
- */
75
29
  export async function triggerShellySysUpdate(matterbridge) {
76
30
  try {
77
- // Trigger the update request
78
31
  await getShelly('/api/updates/sys/perform');
79
32
  matterbridge.log.notice('Installing Shelly system update...');
80
33
  matterbridge.matterbridgeInformation.shellySysUpdate = false;
81
34
  matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly system update...', 15);
82
35
  matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_SYS_UPDATE, 'shelly-sys-update', { available: false });
83
- // Begin polling update status
84
36
  await verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
85
37
  }
86
38
  catch (err) {
87
39
  matterbridge.log.error(`Error triggering Shelly system update: ${err instanceof Error ? err.message : String(err)}`);
88
40
  }
89
41
  }
90
- /**
91
- * Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
92
- *
93
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
94
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
95
- */
96
42
  export async function getShellyMainUpdate(matterbridge) {
97
43
  try {
98
44
  const updates = (await getShelly('/api/updates/main/check'));
@@ -111,33 +57,19 @@ export async function getShellyMainUpdate(matterbridge) {
111
57
  matterbridge.log.error(`Error getting Shelly main updates: ${err instanceof Error ? err.message : String(err)}`);
112
58
  }
113
59
  }
114
- /**
115
- * Triggers Shelly main updates.
116
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
117
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
118
- */
119
60
  export async function triggerShellyMainUpdate(matterbridge) {
120
61
  try {
121
- // Trigger the perform-update request
122
62
  await getShelly('/api/updates/main/perform');
123
63
  matterbridge.log.notice('Installing Shelly software update...');
124
64
  matterbridge.matterbridgeInformation.shellyMainUpdate = false;
125
65
  matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly software update...', 15);
126
66
  matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_MAIN_UPDATE, 'shelly-main-update', { available: false });
127
- // Begin polling the update status
128
67
  await verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
129
68
  }
130
69
  catch (err) {
131
70
  matterbridge.log.error(`Error triggering Shelly main update: ${err instanceof Error ? err.message : String(err)}`);
132
71
  }
133
72
  }
134
- /**
135
- * Verifies Shelly update.
136
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
137
- * @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
138
- * @param {string} name - The name of the update.
139
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
140
- */
141
73
  export async function verifyShellyUpdate(matterbridge, api, name) {
142
74
  return new Promise((resolve) => {
143
75
  const timeout = setTimeout(() => {
@@ -145,9 +77,9 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
145
77
  matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
146
78
  clearInterval(interval);
147
79
  resolve();
148
- }, verifyTimeoutSecs * 1000); // 10 minutes
80
+ }, verifyTimeoutSecs * 1000);
149
81
  const interval = setInterval(() => {
150
- getShelly(api, 10 * 1000) // 10 seconds
82
+ getShelly(api, 10 * 1000)
151
83
  .then(async (data) => {
152
84
  if (data.updatingInProgress) {
153
85
  matterbridge.log.debug(`${name} in progress...`);
@@ -161,6 +93,7 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
161
93
  clearTimeout(timeout);
162
94
  resolve();
163
95
  }
96
+ return;
164
97
  })
165
98
  .catch((error) => {
166
99
  matterbridge.log.error(`Error getting status of ${name}: ${error instanceof Error ? error.message : String(error)}`);
@@ -169,15 +102,9 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
169
102
  clearTimeout(timeout);
170
103
  resolve();
171
104
  });
172
- }, verifyIntervalSecs * 1000); // 15 seconds
105
+ }, verifyIntervalSecs * 1000);
173
106
  });
174
107
  }
175
- /**
176
- * Triggers Shelly change network configuration.
177
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
178
- * @param {object} config - The network configuration.
179
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
180
- */
181
108
  export async function triggerShellyChangeIp(matterbridge, config) {
182
109
  const api = config.type === 'static' ? '/api/network/connection/static' : '/api/network/connection/dynamic';
183
110
  const data = { interface: 'end0' };
@@ -200,11 +127,6 @@ export async function triggerShellyChangeIp(matterbridge, config) {
200
127
  matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
201
128
  }
202
129
  }
203
- /**
204
- * Triggers Shelly system reboot.
205
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
206
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
207
- */
208
130
  export async function triggerShellyReboot(matterbridge) {
209
131
  matterbridge.log.debug(`Triggering Shelly system reboot`);
210
132
  try {
@@ -222,13 +144,6 @@ export async function triggerShellyReboot(matterbridge) {
222
144
  matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
223
145
  }
224
146
  }
225
- /**
226
- * Triggers Shelly soft reset.
227
- * It will replaces network config with the default one (edn0 on dhcp).
228
- *
229
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
230
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
231
- */
232
147
  export async function triggerShellySoftReset(matterbridge) {
233
148
  matterbridge.log.debug(`Triggering Shelly soft reset`);
234
149
  try {
@@ -246,13 +161,6 @@ export async function triggerShellySoftReset(matterbridge) {
246
161
  matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
247
162
  }
248
163
  }
249
- /**
250
- * Triggers Shelly hard reset.
251
- * It will do a hard reset and will remove both directories .matterbridge Matterbridge.
252
- *
253
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
254
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
255
- */
256
164
  export async function triggerShellyHardReset(matterbridge) {
257
165
  matterbridge.log.debug(`Triggering Shelly hard reset`);
258
166
  try {
@@ -270,12 +178,6 @@ export async function triggerShellyHardReset(matterbridge) {
270
178
  matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
271
179
  }
272
180
  }
273
- /**
274
- * Fetches Shelly system log and write it to shelly.log.
275
- *
276
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
277
- * @returns {Promise<void>} A promise that resolves when the operation is complete.
278
- */
279
181
  export async function createShellySystemLog(matterbridge) {
280
182
  const { promises: fs } = await import('node:fs');
281
183
  const path = await import('node:path');
@@ -290,27 +192,6 @@ export async function createShellySystemLog(matterbridge) {
290
192
  matterbridge.log.error(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
291
193
  }
292
194
  }
293
- /**
294
- * Perform a GET to Shelly board apis.
295
- * @param {string} api - The api to call:
296
- *
297
- * /api/updates/sys/check => [{name:string; ...}]
298
- * /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
299
- * /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
300
- * /api/updates/main/check => [{name:string; ...}]
301
- * /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
302
- * /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
303
- *
304
- * /api/logs/system => text
305
- *
306
- * /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
307
- * /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
308
- *
309
- *
310
- * @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
311
- * @returns {Promise<any>} A promise that resolves to the response.
312
- * @throws {Error} If the request fails.
313
- */
314
195
  export async function getShelly(api, timeout = 60000) {
315
196
  const http = await import('node:http');
316
197
  return new Promise((resolve, reject) => {
@@ -324,13 +205,12 @@ export async function getShelly(api, timeout = 60000) {
324
205
  let data = '';
325
206
  if (res.statusCode !== 200) {
326
207
  clearTimeout(timeoutId);
327
- res.resume(); // Discard response data to close the socket properly
328
- req.destroy(); // Forcefully close the request
208
+ res.resume();
209
+ req.destroy();
329
210
  reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
330
211
  return;
331
212
  }
332
213
  res.on('data', (chunk) => {
333
- // console.log(chunk);
334
214
  data += chunk;
335
215
  });
336
216
  res.on('end', () => {
@@ -345,7 +225,6 @@ export async function getShelly(api, timeout = 60000) {
345
225
  }
346
226
  }
347
227
  else {
348
- // console.log(data);
349
228
  resolve(data);
350
229
  }
351
230
  });
@@ -356,29 +235,6 @@ export async function getShelly(api, timeout = 60000) {
356
235
  });
357
236
  });
358
237
  }
359
- /**
360
- * Perform a POST request to Shelly board apis.
361
- * @param {string} api - The api to call:
362
- *
363
- * Set static ip
364
- * /api/network/connection/static -d '{"interface": "end0", "addr": "10.11.12.101", "mask": "255.255.255.0", "gw": "10.11.12.1", "dns": "1.1.1.1"}' => {}
365
- *
366
- * Set dhcp
367
- * /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
368
- *
369
- * Reboot
370
- * /api/system/reboot => {"success":true}
371
- *
372
- * curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
373
- * -d '{"interface": "end0"}'
374
- *
375
- * curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
376
- * -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
377
- *
378
- * @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
379
- * @returns {Promise<any>} A promise that resolves to the response.
380
- * @throws {Error} If the request fails.
381
- */
382
238
  export async function postShelly(api, data, timeout = 60000) {
383
239
  const http = await import('node:http');
384
240
  return new Promise((resolve, reject) => {
@@ -399,11 +255,10 @@ export async function postShelly(api, data, timeout = 60000) {
399
255
  };
400
256
  const req = http.request(url, options, (res) => {
401
257
  let responseData = '';
402
- // Check for non-success status codes (e.g., 300+)
403
258
  if (res.statusCode && res.statusCode >= 300) {
404
259
  clearTimeout(timeoutId);
405
- res.resume(); // Discard response data to free up memory
406
- req.destroy(); // Close the request
260
+ res.resume();
261
+ req.destroy();
407
262
  return reject(new Error(`Failed to post data. Status code: ${res.statusCode}`));
408
263
  }
409
264
  res.on('data', (chunk) => {
@@ -424,9 +279,7 @@ export async function postShelly(api, data, timeout = 60000) {
424
279
  clearTimeout(timeoutId);
425
280
  reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
426
281
  });
427
- // Send the JSON data
428
282
  req.write(jsonData);
429
283
  req.end();
430
284
  });
431
285
  }
432
- //# sourceMappingURL=shelly.js.map
@@ -1,2 +1 @@
1
1
  export * from 'node-persist-manager';
2
- //# sourceMappingURL=export.js.map
package/dist/update.js CHANGED
@@ -1,35 +1,5 @@
1
- /**
2
- * This file contains the check updates functions.
3
- *
4
- * @file update.ts
5
- * @author Luca Liguori
6
- * @date 2025-02-24
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 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 { db, nt, wr } from 'node-ansi-logger';
25
2
  import { plg } from './matterbridgeTypes.js';
26
- /**
27
- * Checks for updates for Matterbridge and its plugins.
28
- * If the 'shelly' parameter is present, also checks for Shelly updates.
29
- *
30
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
31
- * @returns {Promise<void>} A promise that resolves when the update checks are complete.
32
- */
33
3
  export async function checkUpdates(matterbridge) {
34
4
  const { hasParameter } = await import('./utils/commandLine.js');
35
5
  const latestVersion = getMatterbridgeLatestVersion(matterbridge);
@@ -49,13 +19,6 @@ export async function checkUpdates(matterbridge) {
49
19
  }
50
20
  await Promise.all([latestVersion, devVersion, ...pluginsVersions, ...shellyUpdates]);
51
21
  }
52
- /**
53
- * Retrieves the latest version of Matterbridge and updates the matterbridgeLatestVersion property.
54
- * If there is an error retrieving the latest version, logs an error message.
55
- *
56
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
57
- * @returns {Promise<String | undefined>} A promise that resolves when the latest version is retrieved.
58
- */
59
22
  export async function getMatterbridgeLatestVersion(matterbridge) {
60
23
  const { getNpmPackageVersion } = await import('./utils/network.js');
61
24
  try {
@@ -77,13 +40,6 @@ export async function getMatterbridgeLatestVersion(matterbridge) {
77
40
  matterbridge.log.warn(`Error getting Matterbridge latest version: ${error instanceof Error ? error.message : error}`);
78
41
  }
79
42
  }
80
- /**
81
- * Retrieves the latest dev version of Matterbridge and updates the matterbridgeDevVersion property.
82
- * If there is an error retrieving the latest version, logs an error message.
83
- *
84
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
85
- * @returns {Promise<string | undefined>} A promise that resolves when the latest dev version is retrieved.
86
- */
87
43
  export async function getMatterbridgeDevVersion(matterbridge) {
88
44
  const { getNpmPackageVersion } = await import('./utils/network.js');
89
45
  try {
@@ -105,14 +61,6 @@ export async function getMatterbridgeDevVersion(matterbridge) {
105
61
  matterbridge.log.warn(`Error getting Matterbridge latest dev version: ${error instanceof Error ? error.message : error}`);
106
62
  }
107
63
  }
108
- /**
109
- * Retrieves the latest version of a plugin and updates the plugin's latestVersion property.
110
- * If there is an error retrieving the latest version, logs an error message.
111
- *
112
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
113
- * @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
114
- * @returns {Promise<string | undefined>} A promise that resolves when the latest version is retrieved.
115
- */
116
64
  export async function getPluginLatestVersion(matterbridge, plugin) {
117
65
  const { getNpmPackageVersion } = await import('./utils/network.js');
118
66
  try {
@@ -131,4 +79,3 @@ export async function getPluginLatestVersion(matterbridge, plugin) {
131
79
  matterbridge.log.warn(`Error getting plugin ${plg}${plugin.name}${wr} latest version: ${error instanceof Error ? error.message : error}`);
132
80
  }
133
81
  }
134
- //# sourceMappingURL=update.js.map