homebridge-xbox-tv 3.3.0 → 3.3.2
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 +7 -0
- package/index.js +3 -3
- package/package.json +3 -3
- package/src/restful.js +16 -8
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
10
10
|
- After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
|
|
11
11
|
- After update to v3.0.0 RESTFull and MQTT config settings need to be updated
|
|
12
12
|
|
|
13
|
+
## [3.3.2] - (04.02.2025)
|
|
14
|
+
|
|
15
|
+
## Changes
|
|
16
|
+
|
|
17
|
+
- update RESTFul
|
|
18
|
+
- bump dependencies
|
|
19
|
+
|
|
13
20
|
## [3.3.0] - (19.01.2025)
|
|
14
21
|
|
|
15
22
|
## Changes
|
package/index.js
CHANGED
|
@@ -101,7 +101,7 @@ class XboxPlatform {
|
|
|
101
101
|
const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
|
|
102
102
|
})
|
|
103
103
|
.on('warn', (warn) => {
|
|
104
|
-
const
|
|
104
|
+
const emitLog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
|
|
105
105
|
})
|
|
106
106
|
.on('error', (error) => {
|
|
107
107
|
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
|
|
@@ -112,7 +112,7 @@ class XboxPlatform {
|
|
|
112
112
|
impulseGenerator.on('start', async () => {
|
|
113
113
|
try {
|
|
114
114
|
const startDone = await xboxDevice.start();
|
|
115
|
-
const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
|
|
115
|
+
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
116
116
|
} catch (error) {
|
|
117
117
|
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
118
118
|
};
|
|
@@ -121,7 +121,7 @@ class XboxPlatform {
|
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
//start impulse generator
|
|
124
|
-
impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
124
|
+
await impulseGenerator.start([{ name: 'start', sampling: 45000 }]);
|
|
125
125
|
} catch (error) {
|
|
126
126
|
throw new Error(`Device: ${host} ${deviceName}, Did finish launching error: ${error}.`);
|
|
127
127
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Xbox TV",
|
|
3
3
|
"name": "homebridge-xbox-tv",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.2",
|
|
5
5
|
"description": "Homebridge plugin to control Xbox game consoles.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"LICENSE"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"homebridge": "^1.
|
|
34
|
+
"homebridge": "^1.8.5 || ^2.0.0-beta.0",
|
|
35
35
|
"node": "^18.20.4 || ^20.15.1 || ^22.7.0 || ^23.2.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@homebridge/plugin-ui-utils": "^2.0.
|
|
38
|
+
"@homebridge/plugin-ui-utils": "^2.0.1",
|
|
39
39
|
"async-mqtt": "^2.6.3",
|
|
40
40
|
"elliptic": "^6.6.1",
|
|
41
41
|
"hex-to-binary": "^1.0.1",
|
package/src/restful.js
CHANGED
|
@@ -24,6 +24,8 @@ class RestFul extends EventEmitter {
|
|
|
24
24
|
const restFul = express();
|
|
25
25
|
restFul.set('json spaces', 2);
|
|
26
26
|
restFul.use(json());
|
|
27
|
+
|
|
28
|
+
// GET Routes
|
|
27
29
|
restFul.get('/info', (req, res) => { res.json(this.restFulData.info) });
|
|
28
30
|
restFul.get('/state', (req, res) => { res.json(this.restFulData.state) });
|
|
29
31
|
restFul.get('/consoleslist', (req, res) => { res.json(this.restFulData.consoleslist) });
|
|
@@ -32,24 +34,30 @@ class RestFul extends EventEmitter {
|
|
|
32
34
|
restFul.get('/storages', (req, res) => { res.json(this.restFulData.storages) });
|
|
33
35
|
restFul.get('/status', (req, res) => { res.json(this.restFulData.status) });
|
|
34
36
|
|
|
35
|
-
//
|
|
37
|
+
// POST Route
|
|
36
38
|
restFul.post('/', (req, res) => {
|
|
37
39
|
try {
|
|
38
40
|
const obj = req.body;
|
|
39
|
-
|
|
41
|
+
if (!obj || typeof obj !== 'object' || Object.keys(obj).length === 0) {
|
|
42
|
+
this.emit('warn', `RESTFul Invalid JSON payload`);
|
|
43
|
+
return res.status(400).json({ error: 'RESTFul Invalid JSON payload' });
|
|
44
|
+
}
|
|
40
45
|
const key = Object.keys(obj)[0];
|
|
41
|
-
const value =
|
|
46
|
+
const value = obj[key];
|
|
42
47
|
this.emit('set', key, value);
|
|
43
|
-
|
|
48
|
+
|
|
49
|
+
const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul post data: ${JSON.stringify(obj, null, 2)}`) : false;
|
|
50
|
+
res.json({ success: true, received: obj });
|
|
44
51
|
} catch (error) {
|
|
45
|
-
this.emit('warn', `RESTFul Parse
|
|
46
|
-
|
|
52
|
+
this.emit('warn', `RESTFul Parse error: ${error}`);
|
|
53
|
+
res.status(500).json({ error: 'RESTFul Internal Server Error' });
|
|
54
|
+
}
|
|
47
55
|
});
|
|
48
56
|
|
|
57
|
+
// Start server
|
|
49
58
|
restFul.listen(this.restFulPort, () => {
|
|
50
|
-
this.emit('connected', `RESTful started on port: ${this.restFulPort}`)
|
|
59
|
+
this.emit('connected', `RESTful started on port: ${this.restFulPort}`);
|
|
51
60
|
});
|
|
52
|
-
|
|
53
61
|
} catch (error) {
|
|
54
62
|
this.emit('warn', `RESTful Connect error: ${error}`)
|
|
55
63
|
}
|