matterbridge 3.0.1-dev-20250507-a182295 → 3.0.1

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 (146) hide show
  1. package/dist/cli.d.ts +29 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +37 -2
  4. package/dist/cli.js.map +1 -0
  5. package/dist/cluster/export.d.ts +2 -0
  6. package/dist/cluster/export.d.ts.map +1 -0
  7. package/dist/cluster/export.js +2 -0
  8. package/dist/cluster/export.js.map +1 -0
  9. package/dist/defaultConfigSchema.d.ts +27 -0
  10. package/dist/defaultConfigSchema.d.ts.map +1 -0
  11. package/dist/defaultConfigSchema.js +23 -0
  12. package/dist/defaultConfigSchema.js.map +1 -0
  13. package/dist/deviceManager.d.ts +114 -0
  14. package/dist/deviceManager.d.ts.map +1 -0
  15. package/dist/deviceManager.js +94 -1
  16. package/dist/deviceManager.js.map +1 -0
  17. package/dist/frontend.d.ts +240 -0
  18. package/dist/frontend.d.ts.map +1 -0
  19. package/dist/frontend.js +328 -15
  20. package/dist/frontend.js.map +1 -0
  21. package/dist/index.d.ts +35 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +28 -1
  24. package/dist/index.js.map +1 -0
  25. package/dist/logger/export.d.ts +2 -0
  26. package/dist/logger/export.d.ts.map +1 -0
  27. package/dist/logger/export.js +1 -0
  28. package/dist/logger/export.js.map +1 -0
  29. package/dist/matter/behaviors.d.ts +2 -0
  30. package/dist/matter/behaviors.d.ts.map +1 -0
  31. package/dist/matter/behaviors.js +2 -0
  32. package/dist/matter/behaviors.js.map +1 -0
  33. package/dist/matter/clusters.d.ts +2 -0
  34. package/dist/matter/clusters.d.ts.map +1 -0
  35. package/dist/matter/clusters.js +2 -0
  36. package/dist/matter/clusters.js.map +1 -0
  37. package/dist/matter/devices.d.ts +2 -0
  38. package/dist/matter/devices.d.ts.map +1 -0
  39. package/dist/matter/devices.js +2 -0
  40. package/dist/matter/devices.js.map +1 -0
  41. package/dist/matter/endpoints.d.ts +2 -0
  42. package/dist/matter/endpoints.d.ts.map +1 -0
  43. package/dist/matter/endpoints.js +2 -0
  44. package/dist/matter/endpoints.js.map +1 -0
  45. package/dist/matter/export.d.ts +5 -0
  46. package/dist/matter/export.d.ts.map +1 -0
  47. package/dist/matter/export.js +2 -0
  48. package/dist/matter/export.js.map +1 -0
  49. package/dist/matter/types.d.ts +3 -0
  50. package/dist/matter/types.d.ts.map +1 -0
  51. package/dist/matter/types.js +2 -0
  52. package/dist/matter/types.js.map +1 -0
  53. package/dist/matterbridge.d.ts +433 -0
  54. package/dist/matterbridge.d.ts.map +1 -0
  55. package/dist/matterbridge.js +747 -46
  56. package/dist/matterbridge.js.map +1 -0
  57. package/dist/matterbridgeAccessoryPlatform.d.ts +40 -0
  58. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  59. package/dist/matterbridgeAccessoryPlatform.js +34 -0
  60. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  61. package/dist/matterbridgeBehaviors.d.ts +1166 -0
  62. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  63. package/dist/matterbridgeBehaviors.js +48 -1
  64. package/dist/matterbridgeBehaviors.js.map +1 -0
  65. package/dist/matterbridgeDeviceTypes.d.ts +494 -0
  66. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  67. package/dist/matterbridgeDeviceTypes.js +431 -12
  68. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  69. package/dist/matterbridgeDynamicPlatform.d.ts +40 -0
  70. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  71. package/dist/matterbridgeDynamicPlatform.js +34 -0
  72. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  73. package/dist/matterbridgeEndpoint.d.ts +956 -0
  74. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  75. package/dist/matterbridgeEndpoint.js +801 -11
  76. package/dist/matterbridgeEndpoint.js.map +1 -0
  77. package/dist/matterbridgeEndpointHelpers.d.ts +2706 -0
  78. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  79. package/dist/matterbridgeEndpointHelpers.js +142 -9
  80. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  81. package/dist/matterbridgePlatform.d.ts +294 -0
  82. package/dist/matterbridgePlatform.d.ts.map +1 -0
  83. package/dist/matterbridgePlatform.js +225 -7
  84. package/dist/matterbridgePlatform.js.map +1 -0
  85. package/dist/matterbridgeTypes.d.ts +187 -0
  86. package/dist/matterbridgeTypes.d.ts.map +1 -0
  87. package/dist/matterbridgeTypes.js +24 -0
  88. package/dist/matterbridgeTypes.js.map +1 -0
  89. package/dist/pluginManager.d.ts +273 -0
  90. package/dist/pluginManager.d.ts.map +1 -0
  91. package/dist/pluginManager.js +264 -3
  92. package/dist/pluginManager.js.map +1 -0
  93. package/dist/shelly.d.ts +92 -0
  94. package/dist/shelly.d.ts.map +1 -0
  95. package/dist/shelly.js +146 -6
  96. package/dist/shelly.js.map +1 -0
  97. package/dist/storage/export.d.ts +2 -0
  98. package/dist/storage/export.d.ts.map +1 -0
  99. package/dist/storage/export.js +1 -0
  100. package/dist/storage/export.js.map +1 -0
  101. package/dist/update.d.ts +32 -0
  102. package/dist/update.d.ts.map +1 -0
  103. package/dist/update.js +52 -0
  104. package/dist/update.js.map +1 -0
  105. package/dist/utils/colorUtils.d.ts +61 -0
  106. package/dist/utils/colorUtils.d.ts.map +1 -0
  107. package/dist/utils/colorUtils.js +205 -2
  108. package/dist/utils/colorUtils.js.map +1 -0
  109. package/dist/utils/copyDirectory.d.ts +32 -0
  110. package/dist/utils/copyDirectory.d.ts.map +1 -0
  111. package/dist/utils/copyDirectory.js +37 -1
  112. package/dist/utils/copyDirectory.js.map +1 -0
  113. package/dist/utils/createZip.d.ts +38 -0
  114. package/dist/utils/createZip.d.ts.map +1 -0
  115. package/dist/utils/createZip.js +42 -2
  116. package/dist/utils/createZip.js.map +1 -0
  117. package/dist/utils/deepCopy.d.ts +31 -0
  118. package/dist/utils/deepCopy.d.ts.map +1 -0
  119. package/dist/utils/deepCopy.js +40 -0
  120. package/dist/utils/deepCopy.js.map +1 -0
  121. package/dist/utils/deepEqual.d.ts +53 -0
  122. package/dist/utils/deepEqual.d.ts.map +1 -0
  123. package/dist/utils/deepEqual.js +65 -1
  124. package/dist/utils/deepEqual.js.map +1 -0
  125. package/dist/utils/export.d.ts +10 -0
  126. package/dist/utils/export.d.ts.map +1 -0
  127. package/dist/utils/export.js +1 -0
  128. package/dist/utils/export.js.map +1 -0
  129. package/dist/utils/isvalid.d.ts +95 -0
  130. package/dist/utils/isvalid.d.ts.map +1 -0
  131. package/dist/utils/isvalid.js +93 -0
  132. package/dist/utils/isvalid.js.map +1 -0
  133. package/dist/utils/network.d.ts +69 -0
  134. package/dist/utils/network.d.ts.map +1 -0
  135. package/dist/utils/network.js +76 -5
  136. package/dist/utils/network.js.map +1 -0
  137. package/dist/utils/parameter.d.ts +58 -0
  138. package/dist/utils/parameter.d.ts.map +1 -0
  139. package/dist/utils/parameter.js +53 -0
  140. package/dist/utils/parameter.js.map +1 -0
  141. package/dist/utils/wait.d.ts +43 -0
  142. package/dist/utils/wait.d.ts.map +1 -0
  143. package/dist/utils/wait.js +48 -5
  144. package/dist/utils/wait.js.map +1 -0
  145. package/npm-shrinkwrap.json +2 -2
  146. package/package.json +2 -1
@@ -0,0 +1,92 @@
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.0.3
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
+ import { Matterbridge } from './matterbridge.js';
24
+ /**
25
+ * Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
26
+ *
27
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
28
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
29
+ */
30
+ export declare function getShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
31
+ /**
32
+ * Triggers Shelly system updates.
33
+ *
34
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
35
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
36
+ */
37
+ export declare function triggerShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
38
+ /**
39
+ * Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
40
+ *
41
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
42
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
43
+ */
44
+ export declare function getShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
45
+ /**
46
+ * Triggers Shelly main updates.
47
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
48
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
49
+ */
50
+ export declare function triggerShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
51
+ /**
52
+ * Triggers Shelly change network configuration.
53
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
54
+ * @param {object} config - The network configuration.
55
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
56
+ */
57
+ export declare function triggerShellyChangeIp(matterbridge: Matterbridge, config: {
58
+ type: 'static' | 'dhcp';
59
+ ip: string;
60
+ subnet: string;
61
+ gateway: string;
62
+ dns: string;
63
+ }): Promise<void>;
64
+ /**
65
+ * Triggers Shelly system reboot.
66
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
67
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
68
+ */
69
+ export declare function triggerShellyReboot(matterbridge: Matterbridge): Promise<void>;
70
+ /**
71
+ * Triggers Shelly soft reset.
72
+ * It will replaces network config with default one (edn0 on dhcp).
73
+ *
74
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
75
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
76
+ */
77
+ export declare function triggerShellySoftReset(matterbridge: Matterbridge): Promise<void>;
78
+ /**
79
+ * Triggers Shelly hard reset.
80
+ * It will do a hard reset and will remove both directories .matterbridge Matterbridge.
81
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
82
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
83
+ */
84
+ export declare function triggerShellyHardReset(matterbridge: Matterbridge): Promise<void>;
85
+ /**
86
+ * Fetches Shelly system log and write it to shelly.log.
87
+ *
88
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
89
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
90
+ */
91
+ export declare function createShellySystemLog(matterbridge: Matterbridge): Promise<void>;
92
+ //# sourceMappingURL=shelly.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shelly.d.ts","sourceRoot":"","sources":["../src/shelly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAelF;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAetF;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAenF;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBvF;AAwCD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE;IAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BpL;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBnF;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBtF;AACD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBtF;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrF"}
package/dist/shelly.js CHANGED
@@ -1,5 +1,33 @@
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.0.3
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
23
  import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
2
24
  import { debugStringify } from './logger/export.js';
25
+ /**
26
+ * Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
27
+ *
28
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
29
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
30
+ */
3
31
  export async function getShellySysUpdate(matterbridge) {
4
32
  getShelly('/api/updates/sys/check', 60 * 1000)
5
33
  .then(async (data) => {
@@ -18,6 +46,12 @@ export async function getShellySysUpdate(matterbridge) {
18
46
  matterbridge.log.warn(`Error getting Shelly system updates: ${error instanceof Error ? error.message : error}`);
19
47
  });
20
48
  }
49
+ /**
50
+ * Triggers Shelly system updates.
51
+ *
52
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
53
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
54
+ */
21
55
  export async function triggerShellySysUpdate(matterbridge) {
22
56
  getShelly('/api/updates/sys/perform', 10 * 1000)
23
57
  .then(async () => {
@@ -34,6 +68,12 @@ export async function triggerShellySysUpdate(matterbridge) {
34
68
  verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
35
69
  });
36
70
  }
71
+ /**
72
+ * Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
73
+ *
74
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
75
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
76
+ */
37
77
  export async function getShellyMainUpdate(matterbridge) {
38
78
  getShelly('/api/updates/main/check', 60 * 1000)
39
79
  .then(async (data) => {
@@ -52,9 +92,15 @@ export async function getShellyMainUpdate(matterbridge) {
52
92
  matterbridge.log.warn(`Error getting Shelly main updates: ${error instanceof Error ? error.message : error}`);
53
93
  });
54
94
  }
95
+ /**
96
+ * Triggers Shelly main updates.
97
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
98
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
99
+ */
55
100
  export async function triggerShellyMainUpdate(matterbridge) {
56
101
  getShelly('/api/updates/main/perform', 10 * 1000)
57
102
  .then(async () => {
103
+ // {"updatingInProgress":true} or {"updatingInProgress":false}
58
104
  matterbridge.log.debug(`Triggered Shelly main updates`);
59
105
  })
60
106
  .catch((error) => {
@@ -68,13 +114,20 @@ export async function triggerShellyMainUpdate(matterbridge) {
68
114
  verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
69
115
  });
70
116
  }
117
+ /**
118
+ * Verifies Shelly update.
119
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
120
+ * @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
121
+ * @param {string} name - The name of the update.
122
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
123
+ */
71
124
  async function verifyShellyUpdate(matterbridge, api, name) {
72
125
  return new Promise((resolve) => {
73
126
  const timeout = setTimeout(() => {
74
127
  matterbridge.log.warn(`${name} check timed out`);
75
128
  clearInterval(interval);
76
129
  resolve();
77
- }, 600 * 1000);
130
+ }, 600 * 1000); // 10 minutes
78
131
  const interval = setInterval(() => {
79
132
  getShelly(api, 10 * 1000)
80
133
  .then(async (data) => {
@@ -96,9 +149,15 @@ async function verifyShellyUpdate(matterbridge, api, name) {
96
149
  clearTimeout(timeout);
97
150
  resolve();
98
151
  });
99
- }, 15 * 1000);
152
+ }, 15 * 1000); // 15 seconds
100
153
  });
101
154
  }
155
+ /**
156
+ * Triggers Shelly change network configuration.
157
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
158
+ * @param {object} config - The network configuration.
159
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
160
+ */
102
161
  export async function triggerShellyChangeIp(matterbridge, config) {
103
162
  const api = config.type === 'static' ? '/api/network/connection/static' : '/api/network/connection/dynamic';
104
163
  const data = { interface: 'end0' };
@@ -121,8 +180,15 @@ export async function triggerShellyChangeIp(matterbridge, config) {
121
180
  matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
122
181
  })
123
182
  .finally(() => {
183
+ // matterbridge.log.notice(`Changed Shelly network configuration`);
184
+ // matterbridge.frontend.wssSendSnackbarMessage('Changed Shelly network configuration');
124
185
  });
125
186
  }
187
+ /**
188
+ * Triggers Shelly system reboot.
189
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
190
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
191
+ */
126
192
  export async function triggerShellyReboot(matterbridge) {
127
193
  matterbridge.log.debug(`Triggering Shelly system reboot`);
128
194
  postShelly('/api/system/reboot', {}, 60 * 1000)
@@ -137,8 +203,17 @@ export async function triggerShellyReboot(matterbridge) {
137
203
  matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
138
204
  })
139
205
  .finally(() => {
206
+ // matterbridge.log.notice(`Rebooting Shelly board...`);
207
+ // matterbridge.frontend.wssSendSnackbarMessage('Rebooting Shelly board...');
140
208
  });
141
209
  }
210
+ /**
211
+ * Triggers Shelly soft reset.
212
+ * It will replaces network config with default one (edn0 on dhcp).
213
+ *
214
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
215
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
216
+ */
142
217
  export async function triggerShellySoftReset(matterbridge) {
143
218
  matterbridge.log.debug(`Triggering Shelly soft reset`);
144
219
  getShelly('/api/reset/soft', 60 * 1000)
@@ -153,8 +228,16 @@ export async function triggerShellySoftReset(matterbridge) {
153
228
  matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
154
229
  })
155
230
  .finally(() => {
231
+ // matterbridge.log.notice(`Resetting the network parameters on Shelly board...`);
232
+ // matterbridge.frontend.wssSendSnackbarMessage('Resetting the network parameters on Shelly board...');
156
233
  });
157
234
  }
235
+ /**
236
+ * Triggers Shelly hard reset.
237
+ * It will do a hard reset and will remove both directories .matterbridge Matterbridge.
238
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
239
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
240
+ */
158
241
  export async function triggerShellyHardReset(matterbridge) {
159
242
  matterbridge.log.debug(`Triggering Shelly hard reset`);
160
243
  getShelly('/api/reset/hard', 60 * 1000)
@@ -169,8 +252,16 @@ export async function triggerShellyHardReset(matterbridge) {
169
252
  matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
170
253
  })
171
254
  .finally(() => {
255
+ // matterbridge.log.notice(`Factory resetting Shelly board...`);
256
+ // matterbridge.frontend.wssSendSnackbarMessage('Factory resetting Shelly board...');
172
257
  });
173
258
  }
259
+ /**
260
+ * Fetches Shelly system log and write it to shelly.log.
261
+ *
262
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
263
+ * @returns {Promise<void>} A promise that resolves when the operation is complete.
264
+ */
174
265
  export async function createShellySystemLog(matterbridge) {
175
266
  const { promises: fs } = await import('node:fs');
176
267
  const path = await import('node:path');
@@ -190,6 +281,27 @@ export async function createShellySystemLog(matterbridge) {
190
281
  matterbridge.log.warn(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
191
282
  });
192
283
  }
284
+ /**
285
+ * Perform a GET to Shelly board apis.
286
+ * @param {string} api - The api to call:
287
+ *
288
+ * /api/updates/sys/check => [{name:string; ...}]
289
+ * /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
290
+ * /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
291
+ * /api/updates/main/check => [{name:string; ...}]
292
+ * /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
293
+ * /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
294
+ *
295
+ * /api/logs/system => text
296
+ *
297
+ * /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
298
+ * /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
299
+ *
300
+ *
301
+ * @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 60000ms).
302
+ * @returns {Promise<any>} A promise that resolves to the response.
303
+ * @throws {Error} If the request fails.
304
+ */
193
305
  async function getShelly(api, timeout = 60000) {
194
306
  const http = await import('node:http');
195
307
  return new Promise((resolve, reject) => {
@@ -203,12 +315,13 @@ async function getShelly(api, timeout = 60000) {
203
315
  let data = '';
204
316
  if (res.statusCode !== 200) {
205
317
  clearTimeout(timeoutId);
206
- res.resume();
207
- req.destroy();
318
+ res.resume(); // Discard response data to close the socket properly
319
+ req.destroy(); // Forcefully close the request
208
320
  reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
209
321
  return;
210
322
  }
211
323
  res.on('data', (chunk) => {
324
+ // console.log(chunk);
212
325
  data += chunk;
213
326
  });
214
327
  res.on('end', () => {
@@ -223,6 +336,7 @@ async function getShelly(api, timeout = 60000) {
223
336
  }
224
337
  }
225
338
  else {
339
+ // console.log(data);
226
340
  resolve(data);
227
341
  }
228
342
  });
@@ -233,6 +347,29 @@ async function getShelly(api, timeout = 60000) {
233
347
  });
234
348
  });
235
349
  }
350
+ /**
351
+ * Perform a POST request to Shelly board apis.
352
+ * @param {string} api - The api to call:
353
+ *
354
+ * Set static ip
355
+ * /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"}' => {}
356
+ *
357
+ * Set dhcp
358
+ * /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
359
+ *
360
+ * Reboot
361
+ * /api/system/reboot => {"success":true}
362
+ *
363
+ * curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
364
+ * -d '{"interface": "end0"}'
365
+ *
366
+ * curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
367
+ * -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
368
+ *
369
+ * @param {number} [timeout=5000] - The timeout duration in milliseconds (default is 60000ms).
370
+ * @returns {Promise<any>} A promise that resolves to the response.
371
+ * @throws {Error} If the request fails.
372
+ */
236
373
  async function postShelly(api, data, timeout = 60000) {
237
374
  const http = await import('node:http');
238
375
  return new Promise((resolve, reject) => {
@@ -253,10 +390,11 @@ async function postShelly(api, data, timeout = 60000) {
253
390
  };
254
391
  const req = http.request(url, options, (res) => {
255
392
  let responseData = '';
393
+ // Check for non-success status codes (e.g., 300+)
256
394
  if (res.statusCode && res.statusCode >= 300) {
257
395
  clearTimeout(timeoutId);
258
- res.resume();
259
- req.destroy();
396
+ res.resume(); // Discard response data to free up memory
397
+ req.destroy(); // Close the request
260
398
  return reject(new Error(`Failed to post data. Status code: ${res.statusCode}`));
261
399
  }
262
400
  res.on('data', (chunk) => {
@@ -277,7 +415,9 @@ async function postShelly(api, data, timeout = 60000) {
277
415
  clearTimeout(timeoutId);
278
416
  reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
279
417
  });
418
+ // Send the JSON data
280
419
  req.write(jsonData);
281
420
  req.end();
282
421
  });
283
422
  }
423
+ //# sourceMappingURL=shelly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shelly.js","sourceRoot":"","sources":["../src/shelly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,YAA0B;IACjE,SAAS,CAAC,wBAAwB,EAAE,EAAE,GAAG,IAAI,CAAC;SAC3C,IAAI,CAAC,KAAK,EAAE,IAAwB,EAAE,EAAE;QACvC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,YAAY,CAAC,uBAAuB,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5D,YAAY,CAAC,QAAQ,CAAC,mBAAmB,CAAC,uBAAu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ACpB,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from 'node-persist-manager';
2
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -1 +1,2 @@
1
1
  export * from 'node-persist-manager';
2
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,32 @@
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
+ import { Matterbridge } from './matterbridge.js';
24
+ /**
25
+ * Checks for updates for Matterbridge and its plugins.
26
+ * If the 'shelly' parameter is present, also checks for Shelly updates.
27
+ *
28
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
29
+ * @returns {Promise<void>} A promise that resolves when the update checks are complete.
30
+ */
31
+ export declare function checkUpdates(matterbridge: Matterbridge): Promise<void>;
32
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAa5E"}
package/dist/update.js CHANGED
@@ -1,5 +1,34 @@
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
+ */
1
23
  import { plg } from './matterbridgeTypes.js';
2
24
  import { db, nt, wr } from './logger/export.js';
25
+ /**
26
+ * Checks for updates for Matterbridge and its plugins.
27
+ * If the 'shelly' parameter is present, also checks for Shelly updates.
28
+ *
29
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
30
+ * @returns {Promise<void>} A promise that resolves when the update checks are complete.
31
+ */
3
32
  export async function checkUpdates(matterbridge) {
4
33
  const { hasParameter } = await import('./utils/parameter.js');
5
34
  getMatterbridgeLatestVersion(matterbridge);
@@ -13,6 +42,13 @@ export async function checkUpdates(matterbridge) {
13
42
  getShellyMainUpdate(matterbridge);
14
43
  }
15
44
  }
45
+ /**
46
+ * Retrieves the latest version of Matterbridge and updates the matterbridgeLatestVersion property.
47
+ * If there is an error retrieving the latest version, logs an error message.
48
+ *
49
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
50
+ * @returns {Promise<void>} A promise that resolves when the latest version is retrieved.
51
+ */
16
52
  async function getMatterbridgeLatestVersion(matterbridge) {
17
53
  const { getNpmPackageVersion } = await import('./utils/network.js');
18
54
  getNpmPackageVersion('matterbridge')
@@ -33,6 +69,13 @@ async function getMatterbridgeLatestVersion(matterbridge) {
33
69
  matterbridge.log.warn(`Error getting Matterbridge latest version: ${error.message}`);
34
70
  });
35
71
  }
72
+ /**
73
+ * Retrieves the latest dev version of Matterbridge and updates the matterbridgeDevVersion property.
74
+ * If there is an error retrieving the latest version, logs an error message.
75
+ *
76
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
77
+ * @returns {Promise<void>} A promise that resolves when the latest dev version is retrieved.
78
+ */
36
79
  async function getMatterbridgeDevVersion(matterbridge) {
37
80
  const { getNpmPackageVersion } = await import('./utils/network.js');
38
81
  getNpmPackageVersion('matterbridge', 'dev')
@@ -50,6 +93,14 @@ async function getMatterbridgeDevVersion(matterbridge) {
50
93
  matterbridge.log.warn(`Error getting Matterbridge latest dev version: ${error.message}`);
51
94
  });
52
95
  }
96
+ /**
97
+ * Retrieves the latest version of a plugin and updates the plugin's latestVersion property.
98
+ * If there is an error retrieving the latest version, logs an error message.
99
+ *
100
+ * @param {Matterbridge} matterbridge - The Matterbridge instance.
101
+ * @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
102
+ * @returns {Promise<void>} A promise that resolves when the latest version is retrieved.
103
+ */
53
104
  async function getPluginLatestVersion(matterbridge, plugin) {
54
105
  const { getNpmPackageVersion } = await import('./utils/network.js');
55
106
  getNpmPackageVersion(plugin.name)
@@ -67,3 +118,4 @@ async function getPluginLatestVersion(matterbridge, plugin) {
67
118
  matterbridge.log.warn(`Error getting ${plg}${plugin.name}${wr} latest version: ${error.message}`);
68
119
  });
69
120
  }
121
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":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AC,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * This file contains the color utilities.
3
+ *
4
+ * @file colorUtils.ts
5
+ * @author Luca Liguori
6
+ * @date 2023-10-05
7
+ * @version 1.3.0
8
+ *
9
+ * Copyright 2023, 2024, 2025 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
+ export interface RGB {
24
+ r: number;
25
+ g: number;
26
+ b: number;
27
+ }
28
+ export interface XY {
29
+ x: number;
30
+ y: number;
31
+ }
32
+ export interface HSL {
33
+ h: number;
34
+ s: number;
35
+ l: number;
36
+ }
37
+ export declare function hslColorToRgbColor(hue: number, saturation: number, luminance: number): RGB;
38
+ export declare function rgbColorToXYColor(rgb: RGB): XY;
39
+ export declare function xyColorToRgbColor(x: number, y: number, brightness?: number): RGB;
40
+ export declare function rgbColorToHslColor(rgb: RGB): HSL;
41
+ export declare function xyToHsl(x: number, y: number): HSL;
42
+ export declare function miredToKelvin(mired: number): number;
43
+ export declare function kelvinToMired(kelvin: number): number;
44
+ export declare function kelvinToRGB(kelvin: number): RGB;
45
+ /**
46
+ * Converts CIE color space to RGB color space
47
+ * @param {Number} x
48
+ * @param {Number} y
49
+ * @param {Number} brightness - Ranges from 1 to 254
50
+ * @return {Array} Array that contains the color values for red, green and blue
51
+ * From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
52
+ */
53
+ /**
54
+ * Converts RGB color space to CIE color space
55
+ * @param {Number} red
56
+ * @param {Number} green
57
+ * @param {Number} blue
58
+ * @return {Array} Array that contains the CIE color values for x and y
59
+ * From: https://github.com/usolved/cie-rgb-converter/blob/master/cie_rgb_converter.js
60
+ */
61
+ //# sourceMappingURL=colorUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../../src/utils/colorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,EAAE;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CA+C1F;AAGD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CA6B9C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,SAAM,GAAG,GAAG,CAgD7E;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAmChD;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG,CAGjD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAsC/C;AAwDD;;;;;;;GAOG;AAsDH;;;;;;;GAOG"}