matterbridge 3.0.6 → 3.0.7-dev-20250614-0d145a8

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 (183) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cli.js +2 -62
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -94
  6. package/dist/evse.js +9 -65
  7. package/dist/frontend.js +16 -374
  8. package/dist/globalMatterbridge.js +0 -20
  9. package/dist/helpers.js +0 -51
  10. package/dist/index.js +1 -28
  11. package/dist/laundryWasher.js +7 -92
  12. package/dist/logger/export.js +0 -1
  13. package/dist/matter/behaviors.js +0 -2
  14. package/dist/matter/clusters.js +0 -2
  15. package/dist/matter/devices.js +0 -2
  16. package/dist/matter/endpoints.js +0 -2
  17. package/dist/matter/export.js +0 -2
  18. package/dist/matter/types.js +0 -2
  19. package/dist/matterbridge.js +46 -748
  20. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  21. package/dist/matterbridgeBehaviors.js +1 -54
  22. package/dist/matterbridgeDeviceTypes.js +15 -578
  23. package/dist/matterbridgeDynamicPlatform.js +0 -34
  24. package/dist/matterbridgeEndpoint.js +43 -997
  25. package/dist/matterbridgeEndpointHelpers.js +10 -204
  26. package/dist/matterbridgePlatform.js +7 -225
  27. package/dist/matterbridgeTypes.js +0 -24
  28. package/dist/pluginManager.js +3 -269
  29. package/dist/roboticVacuumCleaner.js +6 -81
  30. package/dist/shelly.js +7 -155
  31. package/dist/storage/export.js +0 -1
  32. package/dist/update.js +0 -53
  33. package/dist/utils/colorUtils.js +2 -205
  34. package/dist/utils/commandLine.js +0 -53
  35. package/dist/utils/copyDirectory.js +1 -37
  36. package/dist/utils/createDirectory.js +0 -31
  37. package/dist/utils/createZip.js +2 -42
  38. package/dist/utils/deepCopy.js +0 -38
  39. package/dist/utils/deepEqual.js +1 -71
  40. package/dist/utils/export.js +0 -1
  41. package/dist/utils/hex.js +0 -57
  42. package/dist/utils/isvalid.js +0 -100
  43. package/dist/utils/network.js +5 -76
  44. package/dist/utils/spawn.js +0 -16
  45. package/dist/utils/wait.js +9 -58
  46. package/dist/waterHeater.js +2 -62
  47. package/npm-shrinkwrap.json +40 -28
  48. package/package.json +2 -3
  49. package/dist/cli.d.ts +0 -29
  50. package/dist/cli.d.ts.map +0 -1
  51. package/dist/cli.js.map +0 -1
  52. package/dist/cluster/export.d.ts +0 -2
  53. package/dist/cluster/export.d.ts.map +0 -1
  54. package/dist/cluster/export.js.map +0 -1
  55. package/dist/defaultConfigSchema.d.ts +0 -27
  56. package/dist/defaultConfigSchema.d.ts.map +0 -1
  57. package/dist/defaultConfigSchema.js.map +0 -1
  58. package/dist/deviceManager.d.ts +0 -114
  59. package/dist/deviceManager.d.ts.map +0 -1
  60. package/dist/deviceManager.js.map +0 -1
  61. package/dist/evse.d.ts +0 -67
  62. package/dist/evse.d.ts.map +0 -1
  63. package/dist/evse.js.map +0 -1
  64. package/dist/frontend.d.ts +0 -256
  65. package/dist/frontend.d.ts.map +0 -1
  66. package/dist/frontend.js.map +0 -1
  67. package/dist/globalMatterbridge.d.ts +0 -32
  68. package/dist/globalMatterbridge.d.ts.map +0 -1
  69. package/dist/globalMatterbridge.js.map +0 -1
  70. package/dist/helpers.d.ts +0 -47
  71. package/dist/helpers.d.ts.map +0 -1
  72. package/dist/helpers.js.map +0 -1
  73. package/dist/index.d.ts +0 -37
  74. package/dist/index.d.ts.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/laundryWasher.d.ts +0 -243
  77. package/dist/laundryWasher.d.ts.map +0 -1
  78. package/dist/laundryWasher.js.map +0 -1
  79. package/dist/logger/export.d.ts +0 -2
  80. package/dist/logger/export.d.ts.map +0 -1
  81. package/dist/logger/export.js.map +0 -1
  82. package/dist/matter/behaviors.d.ts +0 -2
  83. package/dist/matter/behaviors.d.ts.map +0 -1
  84. package/dist/matter/behaviors.js.map +0 -1
  85. package/dist/matter/clusters.d.ts +0 -2
  86. package/dist/matter/clusters.d.ts.map +0 -1
  87. package/dist/matter/clusters.js.map +0 -1
  88. package/dist/matter/devices.d.ts +0 -2
  89. package/dist/matter/devices.d.ts.map +0 -1
  90. package/dist/matter/devices.js.map +0 -1
  91. package/dist/matter/endpoints.d.ts +0 -2
  92. package/dist/matter/endpoints.d.ts.map +0 -1
  93. package/dist/matter/endpoints.js.map +0 -1
  94. package/dist/matter/export.d.ts +0 -5
  95. package/dist/matter/export.d.ts.map +0 -1
  96. package/dist/matter/export.js.map +0 -1
  97. package/dist/matter/types.d.ts +0 -3
  98. package/dist/matter/types.d.ts.map +0 -1
  99. package/dist/matter/types.js.map +0 -1
  100. package/dist/matterbridge.d.ts +0 -445
  101. package/dist/matterbridge.d.ts.map +0 -1
  102. package/dist/matterbridge.js.map +0 -1
  103. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  104. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  105. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  106. package/dist/matterbridgeBehaviors.d.ts +0 -1333
  107. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  108. package/dist/matterbridgeBehaviors.js.map +0 -1
  109. package/dist/matterbridgeDeviceTypes.d.ts +0 -644
  110. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  111. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  112. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  113. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  114. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  115. package/dist/matterbridgeEndpoint.d.ts +0 -1144
  116. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  117. package/dist/matterbridgeEndpoint.js.map +0 -1
  118. package/dist/matterbridgeEndpointHelpers.d.ts +0 -3083
  119. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  120. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  121. package/dist/matterbridgePlatform.d.ts +0 -294
  122. package/dist/matterbridgePlatform.d.ts.map +0 -1
  123. package/dist/matterbridgePlatform.js.map +0 -1
  124. package/dist/matterbridgeTypes.d.ts +0 -196
  125. package/dist/matterbridgeTypes.d.ts.map +0 -1
  126. package/dist/matterbridgeTypes.js.map +0 -1
  127. package/dist/pluginManager.d.ts +0 -273
  128. package/dist/pluginManager.d.ts.map +0 -1
  129. package/dist/pluginManager.js.map +0 -1
  130. package/dist/roboticVacuumCleaner.d.ts +0 -102
  131. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  132. package/dist/roboticVacuumCleaner.js.map +0 -1
  133. package/dist/shelly.d.ts +0 -161
  134. package/dist/shelly.d.ts.map +0 -1
  135. package/dist/shelly.js.map +0 -1
  136. package/dist/storage/export.d.ts +0 -2
  137. package/dist/storage/export.d.ts.map +0 -1
  138. package/dist/storage/export.js.map +0 -1
  139. package/dist/update.d.ts +0 -58
  140. package/dist/update.d.ts.map +0 -1
  141. package/dist/update.js.map +0 -1
  142. package/dist/utils/colorUtils.d.ts +0 -61
  143. package/dist/utils/colorUtils.d.ts.map +0 -1
  144. package/dist/utils/colorUtils.js.map +0 -1
  145. package/dist/utils/commandLine.d.ts +0 -58
  146. package/dist/utils/commandLine.d.ts.map +0 -1
  147. package/dist/utils/commandLine.js.map +0 -1
  148. package/dist/utils/copyDirectory.d.ts +0 -32
  149. package/dist/utils/copyDirectory.d.ts.map +0 -1
  150. package/dist/utils/copyDirectory.js.map +0 -1
  151. package/dist/utils/createDirectory.d.ts +0 -32
  152. package/dist/utils/createDirectory.d.ts.map +0 -1
  153. package/dist/utils/createDirectory.js.map +0 -1
  154. package/dist/utils/createZip.d.ts +0 -38
  155. package/dist/utils/createZip.d.ts.map +0 -1
  156. package/dist/utils/createZip.js.map +0 -1
  157. package/dist/utils/deepCopy.d.ts +0 -31
  158. package/dist/utils/deepCopy.d.ts.map +0 -1
  159. package/dist/utils/deepCopy.js.map +0 -1
  160. package/dist/utils/deepEqual.d.ts +0 -53
  161. package/dist/utils/deepEqual.d.ts.map +0 -1
  162. package/dist/utils/deepEqual.js.map +0 -1
  163. package/dist/utils/export.d.ts +0 -12
  164. package/dist/utils/export.d.ts.map +0 -1
  165. package/dist/utils/export.js.map +0 -1
  166. package/dist/utils/hex.d.ts +0 -48
  167. package/dist/utils/hex.d.ts.map +0 -1
  168. package/dist/utils/hex.js.map +0 -1
  169. package/dist/utils/isvalid.d.ts +0 -102
  170. package/dist/utils/isvalid.d.ts.map +0 -1
  171. package/dist/utils/isvalid.js.map +0 -1
  172. package/dist/utils/network.d.ts +0 -69
  173. package/dist/utils/network.d.ts.map +0 -1
  174. package/dist/utils/network.js.map +0 -1
  175. package/dist/utils/spawn.d.ts +0 -12
  176. package/dist/utils/spawn.d.ts.map +0 -1
  177. package/dist/utils/spawn.js.map +0 -1
  178. package/dist/utils/wait.d.ts +0 -52
  179. package/dist/utils/wait.d.ts.map +0 -1
  180. package/dist/utils/wait.js.map +0 -1
  181. package/dist/waterHeater.d.ts +0 -90
  182. package/dist/waterHeater.d.ts.map +0 -1
  183. package/dist/waterHeater.js.map +0 -1
@@ -1,26 +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
1
  import { MatterbridgeEndpoint } from './matterbridgeEndpoint.js';
25
2
  import { roboticVacuumCleaner } from './matterbridgeDeviceTypes.js';
26
3
  import { MatterbridgeServer, MatterbridgeServiceAreaServer } from './matterbridgeBehaviors.js';
@@ -34,23 +11,6 @@ import { RvcOperationalState } from '@matter/main/clusters/rvc-operational-state
34
11
  import { ModeBase } from '@matter/main/clusters/mode-base';
35
12
  import { OperationalState } from '@matter/main/clusters/operational-state';
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
- */
23
1
  import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
24
2
  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...`);
@@ -169,15 +101,9 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
169
101
  clearTimeout(timeout);
170
102
  resolve();
171
103
  });
172
- }, verifyIntervalSecs * 1000); // 15 seconds
104
+ }, verifyIntervalSecs * 1000);
173
105
  });
174
106
  }
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
107
  export async function triggerShellyChangeIp(matterbridge, config) {
182
108
  const api = config.type === 'static' ? '/api/network/connection/static' : '/api/network/connection/dynamic';
183
109
  const data = { interface: 'end0' };
@@ -200,11 +126,6 @@ export async function triggerShellyChangeIp(matterbridge, config) {
200
126
  matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
201
127
  }
202
128
  }
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
129
  export async function triggerShellyReboot(matterbridge) {
209
130
  matterbridge.log.debug(`Triggering Shelly system reboot`);
210
131
  try {
@@ -222,13 +143,6 @@ export async function triggerShellyReboot(matterbridge) {
222
143
  matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
223
144
  }
224
145
  }
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
146
  export async function triggerShellySoftReset(matterbridge) {
233
147
  matterbridge.log.debug(`Triggering Shelly soft reset`);
234
148
  try {
@@ -246,13 +160,6 @@ export async function triggerShellySoftReset(matterbridge) {
246
160
  matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
247
161
  }
248
162
  }
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
163
  export async function triggerShellyHardReset(matterbridge) {
257
164
  matterbridge.log.debug(`Triggering Shelly hard reset`);
258
165
  try {
@@ -270,12 +177,6 @@ export async function triggerShellyHardReset(matterbridge) {
270
177
  matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
271
178
  }
272
179
  }
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
180
  export async function createShellySystemLog(matterbridge) {
280
181
  const { promises: fs } = await import('node:fs');
281
182
  const path = await import('node:path');
@@ -290,27 +191,6 @@ export async function createShellySystemLog(matterbridge) {
290
191
  matterbridge.log.error(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
291
192
  }
292
193
  }
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
194
  export async function getShelly(api, timeout = 60000) {
315
195
  const http = await import('node:http');
316
196
  return new Promise((resolve, reject) => {
@@ -324,13 +204,12 @@ export async function getShelly(api, timeout = 60000) {
324
204
  let data = '';
325
205
  if (res.statusCode !== 200) {
326
206
  clearTimeout(timeoutId);
327
- res.resume(); // Discard response data to close the socket properly
328
- req.destroy(); // Forcefully close the request
207
+ res.resume();
208
+ req.destroy();
329
209
  reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
330
210
  return;
331
211
  }
332
212
  res.on('data', (chunk) => {
333
- // console.log(chunk);
334
213
  data += chunk;
335
214
  });
336
215
  res.on('end', () => {
@@ -345,7 +224,6 @@ export async function getShelly(api, timeout = 60000) {
345
224
  }
346
225
  }
347
226
  else {
348
- // console.log(data);
349
227
  resolve(data);
350
228
  }
351
229
  });
@@ -356,29 +234,6 @@ export async function getShelly(api, timeout = 60000) {
356
234
  });
357
235
  });
358
236
  }
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
237
  export async function postShelly(api, data, timeout = 60000) {
383
238
  const http = await import('node:http');
384
239
  return new Promise((resolve, reject) => {
@@ -399,11 +254,10 @@ export async function postShelly(api, data, timeout = 60000) {
399
254
  };
400
255
  const req = http.request(url, options, (res) => {
401
256
  let responseData = '';
402
- // Check for non-success status codes (e.g., 300+)
403
257
  if (res.statusCode && res.statusCode >= 300) {
404
258
  clearTimeout(timeoutId);
405
- res.resume(); // Discard response data to free up memory
406
- req.destroy(); // Close the request
259
+ res.resume();
260
+ req.destroy();
407
261
  return reject(new Error(`Failed to post data. Status code: ${res.statusCode}`));
408
262
  }
409
263
  res.on('data', (chunk) => {
@@ -424,9 +278,7 @@ export async function postShelly(api, data, timeout = 60000) {
424
278
  clearTimeout(timeoutId);
425
279
  reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
426
280
  });
427
- // Send the JSON data
428
281
  req.write(jsonData);
429
282
  req.end();
430
283
  });
431
284
  }
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