homebridge-xbox-tv 2.12.34 → 2.13.0
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 +6 -0
- package/README.md +23 -7
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/localApi/message.js +1 -1
- package/src/localApi/packets.js +1 -1
- package/src/localApi/xboxlocalapi.js +1 -1
- package/src/mqtt.js +2 -2
- package/src/webApi/authentication.js +1 -1
- package/src/webApi/xboxwebapi.js +1 -1
- package/src/xboxdevice.js +109 -63
- /package/src/{constans.json → constants.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
### NOTE!!!
|
|
8
8
|
## After update to 2.x.x the plugin settings (xboxLiveId) need to be updated.
|
|
9
9
|
|
|
10
|
+
## [2.13.0] - (05.03.2024)
|
|
11
|
+
## Changes
|
|
12
|
+
- added support to subscribe MQTT and control device
|
|
13
|
+
- config schema updated
|
|
14
|
+
- cleanup
|
|
15
|
+
|
|
10
16
|
## [2.12.0] - (02.01.2024)
|
|
11
17
|
## Changes
|
|
12
18
|
- added possibility to disable prefix name for buttons and sensors
|
package/README.md
CHANGED
|
@@ -36,13 +36,7 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox
|
|
|
36
36
|
* Apps, Inputs, Games can be switched if `webApiControl` is enabled and console is authorized.
|
|
37
37
|
* Siri can be used for all functions, some times need to be created legacy buttons/switches/sensors.
|
|
38
38
|
* Automations can be used for all functions, some times need to be created legacy buttons/switches/sensors.
|
|
39
|
-
*
|
|
40
|
-
* Request: `http//homebridge_ip_address:port/path`.
|
|
41
|
-
* Path: `info`, `state`, `consoleslist`, `profile`, `apps`, `storages`, `status`.
|
|
42
|
-
* Respone as JSON data.
|
|
43
|
-
* MQTT client:
|
|
44
|
-
* Topic: `Info`, `State`, `Consoles List`, `Profile`, `Apps`, `Storages`, `Status`.
|
|
45
|
-
* Publish as JSON data.
|
|
39
|
+
* Support external integrations, [RESTFul](https://github.com/grzegorz914/homebridge-xbox-tv?tab=readme-ov-file#restful-integration), [MQTT](https://github.com/grzegorz914/homebridge-xbox-tv?tab=readme-ov-file#mqtt-integration).
|
|
46
40
|
|
|
47
41
|
<p align="center">
|
|
48
42
|
<a href="https://github.com/grzegorz914/homebridge-xbox-tv"><img alt="Accessory tile in the HomeKit app" src="https://raw.githubusercontent.com/grzegorz914/homebridge-xbox-tv/master/graphics/homekit.png" width="382" /></a>
|
|
@@ -139,3 +133,25 @@ Homebridge plugin for Microsoft game Consoles. Tested with Xbox One X/S and Xbox
|
|
|
139
133
|
* Enter custom redirect URI *<http://localhost:8888/auth/callback>*
|
|
140
134
|
* From the overview of your app page, copy *Application (client) ID* to `webApiClientId`
|
|
141
135
|
* Save restart plugin and authorize console again and have fun.
|
|
136
|
+
|
|
137
|
+
### RESTFul Integration
|
|
138
|
+
|
|
139
|
+
* Request: `http//homebridge_ip_address:port/path`.
|
|
140
|
+
* Path: `info`, `state`, `consoleslist`, `profile`, `apps`, `storages`, `status`.
|
|
141
|
+
* Respone as JSON data.
|
|
142
|
+
|
|
143
|
+
### MQTT Integration
|
|
144
|
+
|
|
145
|
+
| Direction | Topic | Message | Payload Data |
|
|
146
|
+
| --- | --- | --- | --- |
|
|
147
|
+
| Publish | `Info`, `State`, `Consoles List`, `Profile`, `Apps`, `Storages`, `Status` | `{power: true, app: Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application}` | JSON object. |
|
|
148
|
+
| Subscribe | `Set` | `{Power: true}` | JSON object. |
|
|
149
|
+
|
|
150
|
+
| Subscribe | Key | Value | Type | Description |
|
|
151
|
+
| --- | --- | --- | --- | --- |
|
|
152
|
+
| Xbox | | | | |
|
|
153
|
+
| | `Power` | `true`, `false` | boolean | Power state. |
|
|
154
|
+
| | `App` | `Xbox.Dashboard_8wekyb3d8bbwe!Xbox.Dashboard.Application` | string | Set app. |
|
|
155
|
+
| | `RcControl` | `fastForward` | string | Send RC command. |
|
|
156
|
+
| | `Volume` | `up`, `down` | string | Set volume. |
|
|
157
|
+
| | `Mute` | `true`, `false` | boolean | Set mute. |
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const XboxDevice = require('./src/xboxdevice.js');
|
|
5
|
-
const CONSTANTS = require('./src/
|
|
5
|
+
const CONSTANTS = require('./src/constants.json');
|
|
6
6
|
|
|
7
7
|
class XboxPlatform {
|
|
8
8
|
constructor(log, config, api) {
|
package/package.json
CHANGED
package/src/localApi/message.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const HexToBin = require('hex-to-binary');
|
|
3
3
|
const Packets = require('./packets.js');
|
|
4
4
|
const Structure = require('./structure');
|
|
5
|
-
const CONSTANTS = require('../
|
|
5
|
+
const CONSTANTS = require('../constants.json');
|
|
6
6
|
|
|
7
7
|
class MESSAGE {
|
|
8
8
|
constructor(type) {
|
package/src/localApi/packets.js
CHANGED
|
@@ -9,7 +9,7 @@ const Ping = require('ping');
|
|
|
9
9
|
const SimplePacket = require('./simple.js');
|
|
10
10
|
const MessagePacket = require('./message.js');
|
|
11
11
|
const SGCrypto = require('./sgcrypto.js');
|
|
12
|
-
const CONSTANTS = require('../
|
|
12
|
+
const CONSTANTS = require('../constants.json');
|
|
13
13
|
|
|
14
14
|
class XBOXLOCALAPI extends EventEmitter {
|
|
15
15
|
constructor(config) {
|
package/src/mqtt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const
|
|
2
|
+
const AsyncMqtt = require("async-mqtt");
|
|
3
3
|
const EventEmitter = require('events');
|
|
4
4
|
|
|
5
5
|
class MQTTCLIENT extends EventEmitter {
|
|
@@ -25,7 +25,7 @@ class MQTTCLIENT extends EventEmitter {
|
|
|
25
25
|
password: this.mqttPasswd
|
|
26
26
|
}
|
|
27
27
|
const url = `mqtt://${this.mqttHost}:${this.mqttPort}`;
|
|
28
|
-
this.mqttClient = await
|
|
28
|
+
this.mqttClient = await AsyncMqtt.connectAsync(url, options);
|
|
29
29
|
this.emit('connected', 'MQTT Connected.');
|
|
30
30
|
this.isConnected = true;
|
|
31
31
|
|
|
@@ -3,7 +3,7 @@ const QueryString = require('querystring');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const fsPromises = fs.promises;
|
|
5
5
|
const axios = require('axios');
|
|
6
|
-
const CONSTANTS = require('../
|
|
6
|
+
const CONSTANTS = require('../constants.json');
|
|
7
7
|
|
|
8
8
|
class AUTHENTICATION {
|
|
9
9
|
constructor(config) {
|
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -17,7 +17,7 @@ const Social = require('./providers/social.js');
|
|
|
17
17
|
const Titlehub = require('./providers/titlehub.js');
|
|
18
18
|
const UserPresence = require('./providers/userpresence.js');
|
|
19
19
|
const UserStats = require('./providers/userstats.js');
|
|
20
|
-
const CONSTANTS = require('../
|
|
20
|
+
const CONSTANTS = require('../constants.json');
|
|
21
21
|
|
|
22
22
|
class XBOXWEBAPI extends EventEmitter {
|
|
23
23
|
constructor(config) {
|
package/src/xboxdevice.js
CHANGED
|
@@ -6,7 +6,7 @@ const RestFul = require('./restful.js');
|
|
|
6
6
|
const Mqtt = require('./mqtt.js');
|
|
7
7
|
const XboxWebApi = require('./webApi/xboxwebapi.js');
|
|
8
8
|
const XboxLocalApi = require('./localApi/xboxlocalapi.js');
|
|
9
|
-
const CONSTANTS = require('./
|
|
9
|
+
const CONSTANTS = require('./constants.json');
|
|
10
10
|
|
|
11
11
|
let Accessory, Characteristic, Service, Categories, Encode, AccessoryUUID;
|
|
12
12
|
|
|
@@ -113,68 +113,6 @@ class XboxDevice extends EventEmitter {
|
|
|
113
113
|
this.emit('error', `prepare files error: ${error}`);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
//RESTFul server
|
|
117
|
-
const restFulEnabled = device.enableRestFul || false;
|
|
118
|
-
if (restFulEnabled) {
|
|
119
|
-
this.restFul = new RestFul({
|
|
120
|
-
port: device.restFulPort || 3000,
|
|
121
|
-
debug: device.restFulDebug || false
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
this.restFul.on('connected', (message) => {
|
|
125
|
-
log(`Device: ${host} ${deviceName}, ${message}`);
|
|
126
|
-
this.restFulConnected = true;
|
|
127
|
-
})
|
|
128
|
-
.on('error', (error) => {
|
|
129
|
-
this.emit('error', error);
|
|
130
|
-
})
|
|
131
|
-
.on('debug', (debug) => {
|
|
132
|
-
this.emit('debug', debug);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//mqtt client
|
|
137
|
-
const mqttEnabled = device.enableMqtt || false;
|
|
138
|
-
if (mqttEnabled) {
|
|
139
|
-
this.mqtt = new Mqtt({
|
|
140
|
-
host: device.mqttHost,
|
|
141
|
-
port: device.mqttPort || 1883,
|
|
142
|
-
clientId: device.mqttClientId || `xbox_${Math.random().toString(16).slice(3)}`,
|
|
143
|
-
prefix: `${device.mqttPrefix}/${device.name}`,
|
|
144
|
-
user: device.mqttUser,
|
|
145
|
-
passwd: device.mqttPasswd,
|
|
146
|
-
debug: device.mqttDebug || false
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
this.mqtt.on('connected', (message) => {
|
|
150
|
-
this.emit('message', message);
|
|
151
|
-
this.mqttConnected = true;
|
|
152
|
-
})
|
|
153
|
-
.on('changeState', (data) => {
|
|
154
|
-
const key = Object.keys(data)[0];
|
|
155
|
-
const value = Object.values(data)[0];
|
|
156
|
-
switch (key) {
|
|
157
|
-
case 'Power':
|
|
158
|
-
break;
|
|
159
|
-
case 'App':
|
|
160
|
-
break;
|
|
161
|
-
case 'Volume':
|
|
162
|
-
break;
|
|
163
|
-
case 'Mute':
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
this.emit('message', `MQTT Received unknown key: ${key}, value: ${value}`);
|
|
167
|
-
break;
|
|
168
|
-
};
|
|
169
|
-
})
|
|
170
|
-
.on('debug', (debug) => {
|
|
171
|
-
this.emit('debug', debug);
|
|
172
|
-
})
|
|
173
|
-
.on('error', (error) => {
|
|
174
|
-
this.emit('error', error);
|
|
175
|
-
});
|
|
176
|
-
};
|
|
177
|
-
|
|
178
116
|
//web api client
|
|
179
117
|
if (this.webApiControl) {
|
|
180
118
|
this.xboxWebApi = new XboxWebApi({
|
|
@@ -333,6 +271,114 @@ class XboxDevice extends EventEmitter {
|
|
|
333
271
|
};
|
|
334
272
|
})
|
|
335
273
|
.on('prepareAccessory', async () => {
|
|
274
|
+
//RESTFul server
|
|
275
|
+
const restFulEnabled = device.enableRestFul || false;
|
|
276
|
+
if (restFulEnabled) {
|
|
277
|
+
this.restFul = new RestFul({
|
|
278
|
+
port: device.restFulPort || 3000,
|
|
279
|
+
debug: device.restFulDebug || false
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
this.restFul.on('connected', (message) => {
|
|
283
|
+
log(`Device: ${host} ${deviceName}, ${message}`);
|
|
284
|
+
this.restFulConnected = true;
|
|
285
|
+
})
|
|
286
|
+
.on('error', (error) => {
|
|
287
|
+
this.emit('error', error);
|
|
288
|
+
})
|
|
289
|
+
.on('debug', (debug) => {
|
|
290
|
+
this.emit('debug', debug);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
//mqtt client
|
|
295
|
+
const mqttEnabled = device.enableMqtt || false;
|
|
296
|
+
if (mqttEnabled) {
|
|
297
|
+
this.mqtt = new Mqtt({
|
|
298
|
+
host: device.mqttHost,
|
|
299
|
+
port: device.mqttPort || 1883,
|
|
300
|
+
clientId: device.mqttClientId || `xbox_${Math.random().toString(16).slice(3)}`,
|
|
301
|
+
prefix: `${device.mqttPrefix}/${device.name}`,
|
|
302
|
+
user: device.mqttUser,
|
|
303
|
+
passwd: device.mqttPasswd,
|
|
304
|
+
debug: device.mqttDebug || false
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
this.mqtt.on('connected', (message) => {
|
|
308
|
+
this.emit('message', message);
|
|
309
|
+
this.mqttConnected = true;
|
|
310
|
+
})
|
|
311
|
+
.on('changeState', async (data) => {
|
|
312
|
+
const key = Object.keys(data)[0];
|
|
313
|
+
const value = Object.values(data)[0];
|
|
314
|
+
try {
|
|
315
|
+
switch (key) {
|
|
316
|
+
case 'Power':
|
|
317
|
+
switch (this.webApiPowerOnOff) {
|
|
318
|
+
case true:
|
|
319
|
+
switch (value) {
|
|
320
|
+
case true: //off
|
|
321
|
+
await this.xboxWebApi.send('Power', 'WakeUp');
|
|
322
|
+
break;
|
|
323
|
+
case false: //on
|
|
324
|
+
await this.xboxWebApi.send('Power', 'TurnOff');
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
case false:
|
|
329
|
+
switch (value) {
|
|
330
|
+
case true: //off
|
|
331
|
+
await this.xboxLocalApi.powerOff();
|
|
332
|
+
break;
|
|
333
|
+
case false: //on
|
|
334
|
+
await this.xboxLocalApi.powerOn();
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
case 'App':
|
|
340
|
+
const payload = [{ 'oneStoreProductId': value }];
|
|
341
|
+
await this.xboxWebApi.send('Shell', 'ActivateApplicationWithOneStoreProductId', payload);
|
|
342
|
+
break;
|
|
343
|
+
case 'Volume':
|
|
344
|
+
switch (value) {
|
|
345
|
+
case 'up': //Up
|
|
346
|
+
await this.xboxWebApi.send('Volume', 'Up');
|
|
347
|
+
break;
|
|
348
|
+
case 'down': //Down
|
|
349
|
+
await this.xboxWebApi.send('Volume', 'Down');
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
case 'Mute':
|
|
354
|
+
switch (value) {
|
|
355
|
+
case true: //Mute
|
|
356
|
+
await this.xboxWebApi.send('Audio', 'Mute');
|
|
357
|
+
break;
|
|
358
|
+
case false: //Unmute;
|
|
359
|
+
await this.xboxWebApi.send('Audio', 'Unmute');
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
break;
|
|
363
|
+
case 'RcControl':
|
|
364
|
+
await this.xboxWebApi.send('Shell', 'InjectKey', [{ 'keyType': value }]);
|
|
365
|
+
break;
|
|
366
|
+
default:
|
|
367
|
+
this.emit('message', `MQTT Received unknown key: ${key}, value: ${value}`);
|
|
368
|
+
break;
|
|
369
|
+
};
|
|
370
|
+
} catch (error) {
|
|
371
|
+
this.emit('error', `set: ${key}, over MQTT, error: ${error}`);
|
|
372
|
+
};
|
|
373
|
+
})
|
|
374
|
+
.on('debug', (debug) => {
|
|
375
|
+
this.emit('debug', debug);
|
|
376
|
+
})
|
|
377
|
+
.on('error', (error) => {
|
|
378
|
+
this.emit('error', error);
|
|
379
|
+
});
|
|
380
|
+
};
|
|
381
|
+
|
|
336
382
|
try {
|
|
337
383
|
//read dev info from file
|
|
338
384
|
const savedInfo = await this.readData(this.devInfoFile);
|
|
File without changes
|