matterbridge 3.0.2-dev-20250514-175db7e → 3.0.2-dev-20250514-827b4f2
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 +95 -98
- 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,80 +1,82 @@
|
|
|
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`);
|
|
75
77
|
clearInterval(interval);
|
|
76
78
|
resolve();
|
|
77
|
-
},
|
|
79
|
+
}, verifyTimeoutSecs * 1000);
|
|
78
80
|
const interval = setInterval(() => {
|
|
79
81
|
getShelly(api, 10 * 1000)
|
|
80
82
|
.then(async (data) => {
|
|
@@ -91,12 +93,12 @@ async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
91
93
|
}
|
|
92
94
|
})
|
|
93
95
|
.catch((error) => {
|
|
94
|
-
matterbridge.log.
|
|
96
|
+
matterbridge.log.error(`Error getting status of ${name}: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
97
|
clearInterval(interval);
|
|
96
98
|
clearTimeout(timeout);
|
|
97
99
|
resolve();
|
|
98
100
|
});
|
|
99
|
-
},
|
|
101
|
+
}, verifyIntervalSecs * 1000);
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
export async function triggerShellyChangeIp(matterbridge, config) {
|
|
@@ -109,78 +111,73 @@ export async function triggerShellyChangeIp(matterbridge, config) {
|
|
|
109
111
|
data['dns'] = config.dns;
|
|
110
112
|
}
|
|
111
113
|
matterbridge.log.debug(`Triggering Shelly network configuration change: ${debugStringify(config)}`);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
try {
|
|
115
|
+
await postShelly(api, data);
|
|
114
116
|
matterbridge.log.debug(`Triggered Shelly network configuration change: ${debugStringify(config)}`);
|
|
115
117
|
matterbridge.log.notice(`Changed Shelly network configuration`);
|
|
116
118
|
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}`);
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
matterbridge.log.debug(`****Error triggering Shelly network configuration change ${debugStringify(config)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
122
|
+
matterbridge.log.error(`Error changing Shelly network configuration: ${error instanceof Error ? error.message : String(error)}`);
|
|
121
123
|
matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
|
|
122
|
-
}
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
export async function triggerShellyReboot(matterbridge) {
|
|
125
127
|
matterbridge.log.debug(`Triggering Shelly system reboot`);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
try {
|
|
129
|
+
await postShelly('/api/system/reboot', {});
|
|
128
130
|
matterbridge.log.debug(`Triggered Shelly system reboot`);
|
|
129
131
|
matterbridge.log.notice(`Rebooting Shelly board...`);
|
|
130
132
|
matterbridge.frontend.wssSendSnackbarMessage('Rebooting Shelly board...');
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
matterbridge.log.debug(`****Error triggering Shelly system reboot: ${error instanceof Error ? error.message : error}`);
|
|
134
|
-
matterbridge.log.error(`Error rebooting Shelly board: ${error instanceof Error ? error.message : error}`);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
matterbridge.log.debug(`****Error triggering Shelly system reboot: ${error instanceof Error ? error.message : String(error)}`);
|
|
136
|
+
matterbridge.log.error(`Error rebooting Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
135
137
|
matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
|
|
136
|
-
}
|
|
138
|
+
}
|
|
137
139
|
}
|
|
138
140
|
export async function triggerShellySoftReset(matterbridge) {
|
|
139
141
|
matterbridge.log.debug(`Triggering Shelly soft reset`);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
try {
|
|
143
|
+
await getShelly('/api/reset/soft');
|
|
142
144
|
matterbridge.log.debug(`Triggered Shelly soft reset`);
|
|
143
145
|
matterbridge.log.notice(`Resetting the network parameters on Shelly board...`);
|
|
144
146
|
matterbridge.frontend.wssSendSnackbarMessage('Resetting the network parameters on Shelly board...');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
matterbridge.log.debug(`****Error triggering Shelly soft reset: ${error instanceof Error ? error.message : error}`);
|
|
148
|
-
matterbridge.log.error(`Error resetting the network parameters on Shelly board: ${error instanceof Error ? error.message : error}`);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
matterbridge.log.debug(`****Error triggering Shelly soft reset: ${error instanceof Error ? error.message : String(error)}`);
|
|
150
|
+
matterbridge.log.error(`Error resetting the network parameters on Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
149
151
|
matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
|
|
150
|
-
}
|
|
152
|
+
}
|
|
151
153
|
}
|
|
152
154
|
export async function triggerShellyHardReset(matterbridge) {
|
|
153
155
|
matterbridge.log.debug(`Triggering Shelly hard reset`);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
try {
|
|
157
|
+
await getShelly('/api/reset/hard');
|
|
156
158
|
matterbridge.log.debug(`Triggered Shelly hard reset`);
|
|
157
159
|
matterbridge.log.notice(`Factory resetting Shelly board...`);
|
|
158
160
|
matterbridge.frontend.wssSendSnackbarMessage('Factory resetting Shelly board...');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
matterbridge.log.debug(`****Error triggering Shelly hard reset: ${error instanceof Error ? error.message : error}`);
|
|
162
|
-
matterbridge.log.error(`Error while factory resetting the Shelly board: ${error instanceof Error ? error.message : error}`);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
matterbridge.log.debug(`****Error triggering Shelly hard reset: ${error instanceof Error ? error.message : String(error)}`);
|
|
164
|
+
matterbridge.log.error(`Error while factory resetting the Shelly board: ${error instanceof Error ? error.message : String(error)}`);
|
|
163
165
|
matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
|
|
164
|
-
}
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
export async function createShellySystemLog(matterbridge) {
|
|
167
169
|
const { promises: fs } = await import('node:fs');
|
|
168
170
|
const path = await import('node:path');
|
|
169
171
|
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
|
-
});
|
|
172
|
+
try {
|
|
173
|
+
const data = await getShelly('/api/logs/system');
|
|
174
|
+
await fs.writeFile(path.join(matterbridge.matterbridgeDirectory, 'shelly.log'), data);
|
|
175
|
+
matterbridge.log.notice(`Shelly system log ready for download`);
|
|
176
|
+
matterbridge.frontend.wssSendSnackbarMessage('Shelly system log ready for download');
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
matterbridge.log.error(`Error getting Shelly system log: ${error instanceof Error ? error.message : error}`);
|
|
180
|
+
}
|
|
184
181
|
}
|
|
185
182
|
export async function getShelly(api, timeout = 60000) {
|
|
186
183
|
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>
|