matterbridge 3.0.2-dev-20250514-175db7e → 3.0.2-dev-20250514-6ffb970
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.
- package/CHANGELOG.md +3 -0
- package/dist/shelly.js +111 -102
- package/frontend/build/asset-manifest.json +3 -3
- package/frontend/build/index.html +1 -1
- package/frontend/build/static/js/{main.15906009.js → main.f6e0f736.js} +3 -3
- package/frontend/build/static/js/{main.15906009.js.map → main.f6e0f736.js.map} +1 -1
- package/npm-shrinkwrap.json +8 -8
- package/package.json +1 -1
- /package/frontend/build/static/js/{main.15906009.js.LICENSE.txt → main.f6e0f736.js.LICENSE.txt} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,7 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
14
14
|
|
|
15
15
|
- [virtual] Added virtual devices Restart Matterbridge and Update Matterbridge and full Jest tests.
|
|
16
16
|
- [virtual] Added virtual devices Reboot Matterbridge for Shelly board and full Jest tests.
|
|
17
|
+
- [shelly] Refactor shelly api and added full Jest test.
|
|
17
18
|
|
|
18
19
|
### Changed
|
|
19
20
|
|
|
@@ -24,6 +25,8 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
24
25
|
|
|
25
26
|
### Fixed
|
|
26
27
|
|
|
28
|
+
- [frontend]: Fixed refresh of start/stop sharing.
|
|
29
|
+
|
|
27
30
|
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
28
31
|
<img src="bmc-button.svg" alt="Buy me a coffee" width="80">
|
|
29
32
|
</a>
|
package/dist/shelly.js
CHANGED
|
@@ -1,89 +1,93 @@
|
|
|
1
1
|
import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
|
|
2
2
|
import { debugStringify } from './logger/export.js';
|
|
3
|
+
let verifyIntervalSecs = 15;
|
|
4
|
+
let verifyTimeoutSecs = 600;
|
|
5
|
+
export function setVerifyIntervalSecs(seconds) {
|
|
6
|
+
verifyIntervalSecs = seconds;
|
|
7
|
+
}
|
|
8
|
+
export function setVerifyTimeoutSecs(seconds) {
|
|
9
|
+
verifyTimeoutSecs = seconds;
|
|
10
|
+
}
|
|
3
11
|
export async function getShellySysUpdate(matterbridge) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
try {
|
|
13
|
+
const updates = (await getShelly('/api/updates/sys/check'));
|
|
14
|
+
if (updates.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
matterbridge.matterbridgeInformation.shellySysUpdate = true;
|
|
17
|
+
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_SYS_UPDATE, 'shelly-sys-update', { available: true });
|
|
18
|
+
for (const { name } of updates) {
|
|
19
|
+
if (!name)
|
|
20
|
+
continue;
|
|
21
|
+
matterbridge.log.notice(`Shelly system update available: ${name}`);
|
|
22
|
+
matterbridge.frontend.wssSendSnackbarMessage(`Shelly system update available: ${name}`, 10);
|
|
15
23
|
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
matterbridge.log.
|
|
19
|
-
}
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
matterbridge.log.error(`Error getting Shelly system updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
27
|
+
}
|
|
20
28
|
}
|
|
21
29
|
export async function triggerShellySysUpdate(matterbridge) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
matterbridge.log.
|
|
25
|
-
})
|
|
26
|
-
.catch((error) => {
|
|
27
|
-
matterbridge.log.debug(`****Error triggering Shelly system updates: ${error instanceof Error ? error.message : error}`);
|
|
28
|
-
})
|
|
29
|
-
.finally(() => {
|
|
30
|
+
try {
|
|
31
|
+
await getShelly('/api/updates/sys/perform');
|
|
32
|
+
matterbridge.log.notice('Installing Shelly system update...');
|
|
30
33
|
matterbridge.matterbridgeInformation.shellySysUpdate = false;
|
|
31
|
-
matterbridge.log.notice(`Installing Shelly system update...`);
|
|
32
34
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly system update...', 15);
|
|
33
35
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_SYS_UPDATE, 'shelly-sys-update', { available: false });
|
|
34
|
-
verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
|
|
35
|
-
}
|
|
36
|
+
await verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
matterbridge.log.error(`Error triggering Shelly system update: ${err instanceof Error ? err.message : String(err)}`);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
export async function getShellyMainUpdate(matterbridge) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
43
|
+
try {
|
|
44
|
+
const updates = (await getShelly('/api/updates/main/check'));
|
|
45
|
+
if (updates.length === 0)
|
|
46
|
+
return;
|
|
47
|
+
matterbridge.matterbridgeInformation.shellyMainUpdate = true;
|
|
48
|
+
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_MAIN_UPDATE, 'shelly-main-update', { available: true });
|
|
49
|
+
for (const { name } of updates) {
|
|
50
|
+
if (!name)
|
|
51
|
+
continue;
|
|
52
|
+
matterbridge.log.notice(`Shelly software update available: ${name}`);
|
|
53
|
+
matterbridge.frontend.wssSendSnackbarMessage(`Shelly software update available: ${name}`, 10);
|
|
49
54
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
matterbridge.log.
|
|
53
|
-
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
matterbridge.log.error(`Error getting Shelly main updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
export async function triggerShellyMainUpdate(matterbridge) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
matterbridge.log.
|
|
59
|
-
})
|
|
60
|
-
.catch((error) => {
|
|
61
|
-
matterbridge.log.debug(`****Error triggering Shelly main updates: ${error instanceof Error ? error.message : error}`);
|
|
62
|
-
})
|
|
63
|
-
.finally(() => {
|
|
61
|
+
try {
|
|
62
|
+
await getShelly('/api/updates/main/perform');
|
|
63
|
+
matterbridge.log.notice('Installing Shelly software update...');
|
|
64
64
|
matterbridge.matterbridgeInformation.shellyMainUpdate = false;
|
|
65
|
-
matterbridge.log.notice(`Installing Shelly software update...`);
|
|
66
65
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly software update...', 15);
|
|
67
66
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_MAIN_UPDATE, 'shelly-main-update', { available: false });
|
|
68
|
-
verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
|
|
69
|
-
}
|
|
67
|
+
await verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
matterbridge.log.error(`Error triggering Shelly main update: ${err instanceof Error ? err.message : String(err)}`);
|
|
71
|
+
}
|
|
70
72
|
}
|
|
71
73
|
async function verifyShellyUpdate(matterbridge, api, name) {
|
|
72
74
|
return new Promise((resolve) => {
|
|
73
75
|
const timeout = setTimeout(() => {
|
|
74
|
-
matterbridge.log.
|
|
76
|
+
matterbridge.log.error(`${name} check timed out`);
|
|
77
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
|
|
75
78
|
clearInterval(interval);
|
|
76
79
|
resolve();
|
|
77
|
-
},
|
|
80
|
+
}, verifyTimeoutSecs * 1000);
|
|
78
81
|
const interval = setInterval(() => {
|
|
79
82
|
getShelly(api, 10 * 1000)
|
|
80
83
|
.then(async (data) => {
|
|
81
84
|
if (data.updatingInProgress) {
|
|
82
85
|
matterbridge.log.debug(`${name} in progress...`);
|
|
83
|
-
matterbridge.frontend.wssSendSnackbarMessage(`${name} in progress...`,
|
|
86
|
+
matterbridge.frontend.wssSendSnackbarMessage(`${name} in progress...`, 0);
|
|
84
87
|
}
|
|
85
88
|
else {
|
|
86
89
|
matterbridge.log.notice(`${name} installed`);
|
|
90
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
|
|
87
91
|
matterbridge.frontend.wssSendSnackbarMessage(`${name} installed`, 20);
|
|
88
92
|
clearInterval(interval);
|
|
89
93
|
clearTimeout(timeout);
|
|
@@ -91,12 +95,13 @@ async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
91
95
|
}
|
|
92
96
|
})
|
|
93
97
|
.catch((error) => {
|
|
94
|
-
matterbridge.log.
|
|
98
|
+
matterbridge.log.error(`Error getting status of ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
|
|
95
100
|
clearInterval(interval);
|
|
96
101
|
clearTimeout(timeout);
|
|
97
102
|
resolve();
|
|
98
103
|
});
|
|
99
|
-
},
|
|
104
|
+
}, verifyIntervalSecs * 1000);
|
|
100
105
|
});
|
|
101
106
|
}
|
|
102
107
|
export async function triggerShellyChangeIp(matterbridge, config) {
|
|
@@ -109,78 +114,82 @@ export async function triggerShellyChangeIp(matterbridge, config) {
|
|
|
109
114
|
data['dns'] = config.dns;
|
|
110
115
|
}
|
|
111
116
|
matterbridge.log.debug(`Triggering Shelly network configuration change: ${debugStringify(config)}`);
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
try {
|
|
118
|
+
await postShelly(api, data);
|
|
114
119
|
matterbridge.log.debug(`Triggered Shelly network configuration change: ${debugStringify(config)}`);
|
|
115
120
|
matterbridge.log.notice(`Changed Shelly network configuration`);
|
|
116
121
|
matterbridge.frontend.wssSendSnackbarMessage('Changed Shelly network configuration');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
matterbridge.log.debug(`****Error triggering Shelly network configuration change: ${error instanceof Error ? error.message : error}`);
|
|
120
|
-
matterbridge.log.error(`Error changing Shelly network configuration: ${error instanceof Error ? error.message : error}`);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
matterbridge.log.debug(`****Error triggering Shelly network configuration change ${debugStringify(config)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
125
|
+
matterbridge.log.error(`Error changing Shelly network configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
121
126
|
matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
|
|
122
|
-
}
|
|
127
|
+
}
|
|
123
128
|
}
|
|
124
129
|
export async function triggerShellyReboot(matterbridge) {
|
|
125
130
|
matterbridge.log.debug(`Triggering Shelly system reboot`);
|
|
126
|
-
|
|
127
|
-
.
|
|
131
|
+
try {
|
|
132
|
+
matterbridge.frontend.wssSendSnackbarMessage('Rebooting Shelly board...', 0);
|
|
133
|
+
await postShelly('/api/system/reboot', {});
|
|
128
134
|
matterbridge.log.debug(`Triggered Shelly system reboot`);
|
|
129
135
|
matterbridge.log.notice(`Rebooting Shelly board...`);
|
|
130
|
-
matterbridge.frontend.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
matterbridge.log.
|
|
136
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Rebooting Shelly board...');
|
|
137
|
+
matterbridge.frontend.wssSendSnackbarMessage('Reboot of Shelly board started!', 5, 'success');
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
matterbridge.log.debug(`****Error triggering Shelly system reboot: ${error instanceof Error ? error.message : String(error)}`);
|
|
141
|
+
matterbridge.log.error(`Error rebooting Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
142
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Rebooting Shelly board...');
|
|
135
143
|
matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
|
|
136
|
-
}
|
|
144
|
+
}
|
|
137
145
|
}
|
|
138
146
|
export async function triggerShellySoftReset(matterbridge) {
|
|
139
147
|
matterbridge.log.debug(`Triggering Shelly soft reset`);
|
|
140
|
-
|
|
141
|
-
.
|
|
148
|
+
try {
|
|
149
|
+
matterbridge.frontend.wssSendSnackbarMessage('Resetting the network parameters on Shelly board...', 0);
|
|
150
|
+
await getShelly('/api/reset/soft');
|
|
142
151
|
matterbridge.log.debug(`Triggered Shelly soft reset`);
|
|
143
152
|
matterbridge.log.notice(`Resetting the network parameters on Shelly board...`);
|
|
144
|
-
matterbridge.frontend.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
matterbridge.log.
|
|
153
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Resetting the network parameters on Shelly board...');
|
|
154
|
+
matterbridge.frontend.wssSendSnackbarMessage('Reset of the network parameters on Shelly board done!', 5, 'success');
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
matterbridge.log.debug(`****Error triggering Shelly soft reset: ${error instanceof Error ? error.message : String(error)}`);
|
|
158
|
+
matterbridge.log.error(`Error resetting the network parameters on Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
159
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Resetting the network parameters on Shelly board...');
|
|
149
160
|
matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
|
|
150
|
-
}
|
|
161
|
+
}
|
|
151
162
|
}
|
|
152
163
|
export async function triggerShellyHardReset(matterbridge) {
|
|
153
164
|
matterbridge.log.debug(`Triggering Shelly hard reset`);
|
|
154
|
-
|
|
155
|
-
.
|
|
165
|
+
try {
|
|
166
|
+
matterbridge.frontend.wssSendSnackbarMessage('Factory resetting Shelly board...', 0);
|
|
167
|
+
await getShelly('/api/reset/hard');
|
|
156
168
|
matterbridge.log.debug(`Triggered Shelly hard reset`);
|
|
157
169
|
matterbridge.log.notice(`Factory resetting Shelly board...`);
|
|
158
|
-
matterbridge.frontend.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
matterbridge.log.
|
|
170
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Factory resetting Shelly board...');
|
|
171
|
+
matterbridge.frontend.wssSendSnackbarMessage('Factory reset of Shelly board done!', 5, 'success');
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
matterbridge.log.debug(`****Error triggering Shelly hard reset: ${error instanceof Error ? error.message : String(error)}`);
|
|
175
|
+
matterbridge.log.error(`Error while factory resetting the Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
176
|
+
matterbridge.frontend.wssSendCloseSnackbarMessage('Factory resetting Shelly board...');
|
|
163
177
|
matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
|
|
164
|
-
}
|
|
178
|
+
}
|
|
165
179
|
}
|
|
166
180
|
export async function createShellySystemLog(matterbridge) {
|
|
167
181
|
const { promises: fs } = await import('node:fs');
|
|
168
182
|
const path = await import('node:path');
|
|
169
183
|
matterbridge.log.debug(`Downloading Shelly system log...`);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
fs.writeFile(path.join(matterbridge.matterbridgeDirectory, 'shelly.log'), data)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
})
|
|
181
|
-
.catch((error) => {
|
|
182
|
-
matterbridge.log.warn(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
|
|
183
|
-
});
|
|
184
|
+
try {
|
|
185
|
+
const data = await getShelly('/api/logs/system');
|
|
186
|
+
await fs.writeFile(path.join(matterbridge.matterbridgeDirectory, 'shelly.log'), data);
|
|
187
|
+
matterbridge.log.notice(`Shelly system log ready for download`);
|
|
188
|
+
matterbridge.frontend.wssSendSnackbarMessage('Shelly system log ready for download');
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
matterbridge.log.error(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
|
|
192
|
+
}
|
|
184
193
|
}
|
|
185
194
|
export async function getShelly(api, timeout = 60000) {
|
|
186
195
|
const http = await import('node:http');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "./static/css/main.944b63c3.css",
|
|
4
|
-
"main.js": "./static/js/main.
|
|
4
|
+
"main.js": "./static/js/main.f6e0f736.js",
|
|
5
5
|
"static/js/453.d855a71b.chunk.js": "./static/js/453.d855a71b.chunk.js",
|
|
6
6
|
"static/media/roboto-latin-700-normal.woff2": "./static/media/roboto-latin-700-normal.c4d6cab43bec89049809.woff2",
|
|
7
7
|
"static/media/roboto-latin-500-normal.woff2": "./static/media/roboto-latin-500-normal.599f66a60bdf974e578e.woff2",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"static/media/roboto-greek-ext-300-normal.woff": "./static/media/roboto-greek-ext-300-normal.60729cafbded24073dfb.woff",
|
|
78
78
|
"index.html": "./index.html",
|
|
79
79
|
"main.944b63c3.css.map": "./static/css/main.944b63c3.css.map",
|
|
80
|
-
"main.
|
|
80
|
+
"main.f6e0f736.js.map": "./static/js/main.f6e0f736.js.map",
|
|
81
81
|
"453.d855a71b.chunk.js.map": "./static/js/453.d855a71b.chunk.js.map"
|
|
82
82
|
},
|
|
83
83
|
"entrypoints": [
|
|
84
84
|
"static/css/main.944b63c3.css",
|
|
85
|
-
"static/js/main.
|
|
85
|
+
"static/js/main.f6e0f736.js"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><base href="./"><link rel="icon" href="./matterbridge 32x32.png"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>Matterbridge</title><link rel="manifest" href="./manifest.json"/><script defer="defer" src="./static/js/main.f6e0f736.js"></script><link href="./static/css/main.944b63c3.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|