homebridge-xbox-tv 2.7.4 → 2.7.5
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/config.schema.json +1 -1
- package/homebridge-ui/public/index.html +5 -6
- package/homebridge-ui/server.js +3 -2
- package/index.js +18 -28
- package/package.json +1 -1
- package/src/constans.json +33 -5
- package/src/localApi/xboxlocalapi.js +2 -5
- package/src/webApi/authentication.js +4 -4
- package/src/webApi/xboxwebapi.js +28 -27
package/config.schema.json
CHANGED
|
@@ -757,7 +757,7 @@
|
|
|
757
757
|
{
|
|
758
758
|
"key": "devices[].sensorInputs",
|
|
759
759
|
"type": "tabarray",
|
|
760
|
-
"title": "{{ value.name || 'new
|
|
760
|
+
"title": "{{ value.name || 'new sensor' }}",
|
|
761
761
|
"items": [
|
|
762
762
|
"devices[].sensorInputs[].name",
|
|
763
763
|
"devices[].sensorInputs[].reference",
|
|
@@ -147,14 +147,13 @@
|
|
|
147
147
|
|
|
148
148
|
try {
|
|
149
149
|
const host = document.querySelector('#deviceHostInput').value;
|
|
150
|
-
const clientId = this.clientId !== undefined ? this.clientId : '5e5ead27-ed60-482d-b3fc-702b28a97404';
|
|
151
150
|
const webApiToken = document.querySelector('#deviceTokenInput').value;
|
|
152
151
|
const payload = {
|
|
153
152
|
host: host,
|
|
154
|
-
clientId: clientId,
|
|
155
|
-
clientSecret: this.clientSecret,
|
|
156
|
-
userToken: this.userToken,
|
|
157
|
-
uhs: this.uhs,
|
|
153
|
+
clientId: this.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404',
|
|
154
|
+
clientSecret: this.clientSecret || '',
|
|
155
|
+
userToken: this.userToken || '',
|
|
156
|
+
uhs: this.uhs || '',
|
|
158
157
|
webApiToken: webApiToken,
|
|
159
158
|
};
|
|
160
159
|
|
|
@@ -213,4 +212,4 @@
|
|
|
213
212
|
};
|
|
214
213
|
});
|
|
215
214
|
})();
|
|
216
|
-
</script>
|
|
215
|
+
</script>
|
package/homebridge-ui/server.js
CHANGED
|
@@ -48,13 +48,14 @@ class PluginUiServer extends HomebridgePluginUiServer {
|
|
|
48
48
|
const webApiToken = payload.webApiToken;
|
|
49
49
|
const authTokenFile = `${this.homebridgeStoragePath}/xboxTv/authToken_${host.split('.').join('')}`;
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const authenticationConfig = {
|
|
52
52
|
clientId: payload.clientId,
|
|
53
53
|
clientSecret: payload.clientSecret,
|
|
54
54
|
userToken: payload.userToken,
|
|
55
55
|
uhs: payload.uhs,
|
|
56
56
|
tokensFile: authTokenFile
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
|
+
const authentication = new Authentication(authenticationConfig);
|
|
58
59
|
|
|
59
60
|
try {
|
|
60
61
|
await authentication.isAuthenticated();
|
package/index.js
CHANGED
|
@@ -67,16 +67,6 @@ class XBOXDEVICE {
|
|
|
67
67
|
this.host = config.host;
|
|
68
68
|
this.xboxLiveId = config.xboxLiveId;
|
|
69
69
|
this.webApiControl = config.webApiControl || false;
|
|
70
|
-
this.clientId = config.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404';
|
|
71
|
-
this.clientSecret = config.clientSecret;
|
|
72
|
-
this.userToken = config.userToken || '';
|
|
73
|
-
this.uhs = config.uhs || '';
|
|
74
|
-
this.xboxWebApiToken = config.xboxWebApiToken || '';
|
|
75
|
-
this.disableLogInfo = config.disableLogInfo || false;
|
|
76
|
-
this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
|
|
77
|
-
this.enableDebugMode = config.enableDebugMode || false;
|
|
78
|
-
this.volumeControl = config.volumeControl || -1;
|
|
79
|
-
this.infoButtonCommand = config.infoButtonCommand || 'nexus';
|
|
80
70
|
this.getInputsFromDevice = config.getInputsFromDevice || false;
|
|
81
71
|
this.filterGames = config.filterGames || false;
|
|
82
72
|
this.filterApps = config.filterApps || false;
|
|
@@ -88,14 +78,24 @@ class XBOXDEVICE {
|
|
|
88
78
|
this.sensorInput = config.sensorInput || false;
|
|
89
79
|
this.sensorScreenSaver = config.sensorScreenSaver || false;
|
|
90
80
|
this.sensorInputs = config.sensorInputs || [];
|
|
81
|
+
this.xboxWebApiToken = config.xboxWebApiToken || '';
|
|
82
|
+
this.clientId = config.clientId || '5e5ead27-ed60-482d-b3fc-702b28a97404';
|
|
83
|
+
this.clientSecret = config.clientSecret || '';
|
|
84
|
+
this.userToken = config.userToken || '';
|
|
85
|
+
this.uhs = config.uhs || '';
|
|
86
|
+
this.enableDebugMode = config.enableDebugMode || false;
|
|
87
|
+
this.disableLogInfo = config.disableLogInfo || false;
|
|
88
|
+
this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
|
|
89
|
+
this.infoButtonCommand = config.infoButtonCommand || 'nexus';
|
|
90
|
+
this.volumeControl = config.volumeControl >= 0 ? config.volumeControl : -1;
|
|
91
91
|
this.mqttEnabled = config.enableMqtt || false;
|
|
92
|
+
this.mqttDebug = config.mqttDebug || false;
|
|
92
93
|
this.mqttHost = config.mqttHost;
|
|
93
94
|
this.mqttPort = config.mqttPort || 1883;
|
|
94
95
|
this.mqttPrefix = config.mqttPrefix;
|
|
95
96
|
this.mqttAuth = config.mqttAuth || false;
|
|
96
97
|
this.mqttUser = config.mqttUser;
|
|
97
98
|
this.mqttPasswd = config.mqttPasswd;
|
|
98
|
-
this.mqttDebug = config.mqttDebug || false;
|
|
99
99
|
|
|
100
100
|
//add configured inputs to the default inputs
|
|
101
101
|
this.inputs = [...CONSTANS.DefaultInputs, ...this.inputs];
|
|
@@ -312,12 +312,10 @@ class XBOXDEVICE {
|
|
|
312
312
|
userToken: this.userToken,
|
|
313
313
|
uhs: this.uhs,
|
|
314
314
|
tokensFile: this.authTokenFile,
|
|
315
|
-
infoLog: this.disableLogInfo,
|
|
316
315
|
debugLog: this.enableDebugMode
|
|
317
316
|
});
|
|
318
317
|
|
|
319
318
|
this.xboxWebApi.on('authenticated', (status) => {
|
|
320
|
-
|
|
321
319
|
this.webApiEnabled = status;
|
|
322
320
|
})
|
|
323
321
|
.on('consoleStatus', (consoleStatusData, consoleType) => {
|
|
@@ -331,12 +329,9 @@ class XBOXDEVICE {
|
|
|
331
329
|
//this.power = powerState;
|
|
332
330
|
//this.mediaState = playbackState;
|
|
333
331
|
|
|
334
|
-
//mqtt
|
|
335
332
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Status', JSON.stringify(consoleStatusData, null, 2)) : false;
|
|
336
333
|
})
|
|
337
334
|
.on('consolesList', (consolesList) => {
|
|
338
|
-
|
|
339
|
-
//mqtt
|
|
340
335
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Consoles List', JSON.stringify(consolesList, null, 2)) : false;
|
|
341
336
|
})
|
|
342
337
|
.on('appsList', async (appsArray) => {
|
|
@@ -345,20 +340,15 @@ class XBOXDEVICE {
|
|
|
345
340
|
await fsPromises.writeFile(this.inputsFile, apps);
|
|
346
341
|
const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, saved apps: ${apps}`) : false;
|
|
347
342
|
|
|
348
|
-
//mqtt
|
|
349
343
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Apps', JSON.stringify(apps, null, 2)) : false;
|
|
350
344
|
} catch (error) {
|
|
351
345
|
this.log.error(`Device: ${this.host} ${this.name}, save apps error: ${error}`);
|
|
352
346
|
};
|
|
353
347
|
})
|
|
354
348
|
.on('storageDevices', (storageDevices) => {
|
|
355
|
-
|
|
356
|
-
//mqtt
|
|
357
349
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Storages', JSON.stringify(storageDevices, null, 2)) : false;
|
|
358
350
|
})
|
|
359
351
|
.on('userProfile', (profileUsers) => {
|
|
360
|
-
|
|
361
|
-
//mqtt
|
|
362
352
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Profile', JSON.stringify(profileUsers, null, 2)) : false;
|
|
363
353
|
})
|
|
364
354
|
.on('error', (error) => {
|
|
@@ -418,7 +408,7 @@ class XBOXDEVICE {
|
|
|
418
408
|
})
|
|
419
409
|
.onSet(async (state) => {
|
|
420
410
|
try {
|
|
421
|
-
const setPower =
|
|
411
|
+
const setPower = state ? await this.xboxLocalApi.powerOn() : await this.xboxLocalApi.powerOff();
|
|
422
412
|
const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power successful: ${state ? 'ON' : 'OFF'}`);
|
|
423
413
|
} catch (error) {
|
|
424
414
|
this.log.error(`Device: ${this.host} ${accessoryName}, set Power, error: ${error}`);
|
|
@@ -551,7 +541,7 @@ class XBOXDEVICE {
|
|
|
551
541
|
};
|
|
552
542
|
|
|
553
543
|
const channelName = 'systemInput';
|
|
554
|
-
const setPowerModeSelection = this.power
|
|
544
|
+
const setPowerModeSelection = this.power && this.webApiEnabled ? await this.xboxWebApi.sendButtonPress(command) : false;
|
|
555
545
|
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power Mode Selection command successful: ${command}`);
|
|
556
546
|
} catch (error) {
|
|
557
547
|
this.log.error(`Device: ${this.host} ${accessoryName}, set Power Mode Selection command error: ${error}`);
|
|
@@ -766,8 +756,8 @@ class XBOXDEVICE {
|
|
|
766
756
|
const nameIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
|
|
767
757
|
savedInputsNames[nameIdentifier] = name;
|
|
768
758
|
const newCustomName = JSON.stringify(savedInputsNames, null, 2);
|
|
769
|
-
|
|
770
|
-
const logInfo = this.
|
|
759
|
+
fs.writeFileSync(this.inputsNamesFile, newCustomName);
|
|
760
|
+
const logInfo = this.enableDebugMode || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, saved new Input name: ${name}, one store product id: ${inputOneStoreProductId}`);
|
|
771
761
|
} catch (error) {
|
|
772
762
|
this.log.error(`Device: ${this.host} ${accessoryName}, new Input name save error: ${error}`);
|
|
773
763
|
}
|
|
@@ -780,8 +770,8 @@ class XBOXDEVICE {
|
|
|
780
770
|
const targetVisibilityIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
|
|
781
771
|
savedInputsTargetVisibility[targetVisibilityIdentifier] = state;
|
|
782
772
|
const newTargetVisibility = JSON.stringify(savedInputsTargetVisibility, null, 2);
|
|
783
|
-
|
|
784
|
-
const logInfo = this.
|
|
773
|
+
fs.writeFileSync(this.inputsTargetVisibilityFile, newTargetVisibility);
|
|
774
|
+
const logInfo = this.enableDebugMode || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, saved new Input: ${inputName} target visibility state: ${state ? 'HIDEN' : 'SHOWN'}`);
|
|
785
775
|
inputService.setCharacteristic(Characteristic.CurrentVisibilityState, state);
|
|
786
776
|
} catch (error) {
|
|
787
777
|
this.log.error(`Device: ${this.host} ${accessoryName}, new target visibility state save error: ${error}`);
|
|
@@ -918,7 +908,7 @@ class XBOXDEVICE {
|
|
|
918
908
|
}
|
|
919
909
|
break;
|
|
920
910
|
}
|
|
921
|
-
const logInfo = this.
|
|
911
|
+
const logInfo = this.enableDebugMode || this.firstRun || buttonMode === -1 ? false : this.log(`Device: ${this.host} ${accessoryName}, set button successful, name: ${buttonName}, command: ${buttonCommand}`);
|
|
922
912
|
}
|
|
923
913
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
924
914
|
const setChar = this.power && state ? buttonService.updateCharacteristic(Characteristic.On, false) : false;
|
package/package.json
CHANGED
package/src/constans.json
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"Paused": 2,
|
|
20
20
|
"Unknown": 3
|
|
21
21
|
},
|
|
22
|
-
"DefaultInputs": [
|
|
22
|
+
"DefaultInputs": [
|
|
23
|
+
{
|
|
23
24
|
"name": "Screensaver",
|
|
24
25
|
"titleId": "851275400",
|
|
25
26
|
"reference": "Xbox.IdleScreen_8wekyb3d8bbwe!Xbox.IdleScreen.Application",
|
|
@@ -83,7 +84,19 @@
|
|
|
83
84
|
"contentType": "systemApp"
|
|
84
85
|
}
|
|
85
86
|
],
|
|
86
|
-
"InputSourceTypes": [
|
|
87
|
+
"InputSourceTypes": [
|
|
88
|
+
"OTHER",
|
|
89
|
+
"HOME_SCREEN",
|
|
90
|
+
"TUNER",
|
|
91
|
+
"HDMI",
|
|
92
|
+
"COMPOSITE_VIDEO",
|
|
93
|
+
"S_VIDEO",
|
|
94
|
+
"COMPONENT_VIDEO",
|
|
95
|
+
"DVI",
|
|
96
|
+
"AIRPLAY",
|
|
97
|
+
"USB",
|
|
98
|
+
"APPLICATION"
|
|
99
|
+
],
|
|
87
100
|
"SystemMediaCommands": {
|
|
88
101
|
"play": 2,
|
|
89
102
|
"pause": 4,
|
|
@@ -132,8 +145,19 @@
|
|
|
132
145
|
"tvRemote": "d451e3b360bb4c71b3dbf994b1aca3a7",
|
|
133
146
|
"sysConfig": "d451e3b360bb4c71b3dbf994b1aca3a7"
|
|
134
147
|
},
|
|
135
|
-
"ChannelNames": [
|
|
136
|
-
|
|
148
|
+
"ChannelNames": [
|
|
149
|
+
"systemMedia",
|
|
150
|
+
"systemInput",
|
|
151
|
+
"tvRemote",
|
|
152
|
+
"sysConfig"
|
|
153
|
+
],
|
|
154
|
+
"ConfigNames": [
|
|
155
|
+
"GetConfiguration",
|
|
156
|
+
"GetHeadendInfo",
|
|
157
|
+
"GetLiveTVInfo",
|
|
158
|
+
"GetTunerLineups",
|
|
159
|
+
"GetAppChannelLineups"
|
|
160
|
+
],
|
|
137
161
|
"PlaybackStatus": {
|
|
138
162
|
"0": "Closed",
|
|
139
163
|
"1": "Changing",
|
|
@@ -161,5 +185,9 @@
|
|
|
161
185
|
"dd00": "simple.discoveryRequest",
|
|
162
186
|
"dd01": "simple.discoveryResponse",
|
|
163
187
|
"dd02": "simple.powerOn"
|
|
164
|
-
}
|
|
188
|
+
},
|
|
189
|
+
"Scopes": [
|
|
190
|
+
"XboxLive.signin",
|
|
191
|
+
"XboxLive.offline_access"
|
|
192
|
+
]
|
|
165
193
|
}
|
|
@@ -289,8 +289,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
289
289
|
powerOn() {
|
|
290
290
|
return new Promise(async (resolve, reject) => {
|
|
291
291
|
if (this.isConnected) {
|
|
292
|
-
|
|
293
|
-
resolve(true);
|
|
292
|
+
reject('Console already On.');
|
|
294
293
|
return;
|
|
295
294
|
};
|
|
296
295
|
|
|
@@ -326,9 +325,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
326
325
|
powerOff() {
|
|
327
326
|
return new Promise(async (resolve, reject) => {
|
|
328
327
|
if (!this.isConnected) {
|
|
329
|
-
reject(
|
|
330
|
-
status: 'Console already Off.'
|
|
331
|
-
});
|
|
328
|
+
reject('Console already Off.');
|
|
332
329
|
return;
|
|
333
330
|
};
|
|
334
331
|
|
|
@@ -3,6 +3,7 @@ const QueryString = require('querystring');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const fsPromises = fs.promises;
|
|
5
5
|
const HttpClient = require('./httpclient.js');
|
|
6
|
+
const CONSTANS = require('../constans.json');
|
|
6
7
|
|
|
7
8
|
class AUTHENTICATION {
|
|
8
9
|
constructor(config) {
|
|
@@ -12,7 +13,6 @@ class AUTHENTICATION {
|
|
|
12
13
|
this.userToken = config.userToken;
|
|
13
14
|
this.uhs = config.uhs;
|
|
14
15
|
this.tokensFile = config.tokensFile;
|
|
15
|
-
this.scopes = ['XboxLive.signin', 'XboxLive.offline_access'];
|
|
16
16
|
|
|
17
17
|
this.user = {
|
|
18
18
|
gtg: {},
|
|
@@ -142,7 +142,7 @@ class AUTHENTICATION {
|
|
|
142
142
|
const tokenParams = {
|
|
143
143
|
"client_id": this.clientId,
|
|
144
144
|
"grant_type": "refresh_token",
|
|
145
|
-
"scope":
|
|
145
|
+
"scope": CONSTANS.Scopes.join(' '),
|
|
146
146
|
"refresh_token": refreshToken,
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -240,7 +240,7 @@ class AUTHENTICATION {
|
|
|
240
240
|
const tokenParams = {
|
|
241
241
|
"client_id": this.clientId,
|
|
242
242
|
"grant_type": 'authorization_code',
|
|
243
|
-
"scope":
|
|
243
|
+
"scope": CONSTANS.Scopes.join(' '),
|
|
244
244
|
"code": webApiToken,
|
|
245
245
|
"redirect_uri": 'http://localhost:8581/auth/callback'
|
|
246
246
|
}
|
|
@@ -271,7 +271,7 @@ class AUTHENTICATION {
|
|
|
271
271
|
"client_id": this.clientId,
|
|
272
272
|
"response_type": 'code',
|
|
273
273
|
"approval_prompt": 'auto',
|
|
274
|
-
"scope":
|
|
274
|
+
"scope": CONSTANS.Scopes.join(' '),
|
|
275
275
|
"redirect_uri": 'http://localhost:8581/auth/callback'
|
|
276
276
|
}
|
|
277
277
|
const params = QueryString.stringify(paramsObject);
|
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -22,14 +22,17 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
22
22
|
super();
|
|
23
23
|
|
|
24
24
|
this.xboxLiveId = config.xboxLiveId;
|
|
25
|
-
this.
|
|
25
|
+
this.clientId = config.clientId;
|
|
26
|
+
this.clientSecret = config.clientSecret;
|
|
27
|
+
this.userToken = config.userToken;
|
|
28
|
+
this.uhs = config.uhs;
|
|
26
29
|
this.debugLog = config.debugLog;
|
|
27
30
|
|
|
28
31
|
const authenticationConfig = {
|
|
29
|
-
clientId: config.clientId
|
|
30
|
-
clientSecret: config.clientSecret
|
|
31
|
-
userToken: config.userToken
|
|
32
|
-
uhs: config.uhs
|
|
32
|
+
clientId: config.clientId,
|
|
33
|
+
clientSecret: config.clientSecret,
|
|
34
|
+
userToken: config.userToken,
|
|
35
|
+
uhs: config.uhs,
|
|
33
36
|
tokensFile: config.tokensFile
|
|
34
37
|
}
|
|
35
38
|
this.authentication = new Authentication(authenticationConfig);
|
|
@@ -51,18 +54,16 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
this.emit('authenticated', true);
|
|
55
|
-
this.headers = {
|
|
56
|
-
'Authorization': (this.authentication.userToken !== '' && this.authentication.uhs !== '') ? `XBL3.0 x=${this.authentication.uhs};${this.authentication.userToken}` : `XBL3.0 x=${this.authentication.user.uhs};${this.authentication.tokens.xsts.Token}`,
|
|
57
|
-
'Accept-Language': 'en-US',
|
|
58
|
-
'x-xbl-contract-version': '4',
|
|
59
|
-
'x-xbl-client-name': 'XboxApp',
|
|
60
|
-
'x-xbl-client-type': 'UWA',
|
|
61
|
-
'x-xbl-client-version': '39.39.22001.0'
|
|
62
|
-
}
|
|
63
|
-
this.achievements = new Achievements(this, this.headers);
|
|
64
|
-
|
|
65
57
|
try {
|
|
58
|
+
this.emit('authenticated', true);
|
|
59
|
+
this.headers = {
|
|
60
|
+
'Authorization': (this.userToken !== '' && this.uhs !== '') ? `XBL3.0 x=${this.uhs};${this.userToken}` : `XBL3.0 x=${this.authentication.user.uhs};${this.authentication.tokens.xsts.Token}`,
|
|
61
|
+
'Accept-Language': 'en-US',
|
|
62
|
+
'x-xbl-contract-version': '4',
|
|
63
|
+
'x-xbl-client-name': 'XboxApp',
|
|
64
|
+
'x-xbl-client-type': 'UWA',
|
|
65
|
+
'x-xbl-client-version': '39.39.22001.0'
|
|
66
|
+
}
|
|
66
67
|
const debug = this.debugLog ? this.emit(`message', 'authorized and web Api enabled.`) : false;
|
|
67
68
|
const rmEnabled = await this.getWebApiConsoleStatus();
|
|
68
69
|
const debug1 = !rmEnabled ? this.emit('message', `remote management not enabled, please check your console settings!!!.`) : false;
|
|
@@ -361,7 +362,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
361
362
|
powerOn() {
|
|
362
363
|
return new Promise(async (resolve, reject) => {
|
|
363
364
|
try {
|
|
364
|
-
await this.
|
|
365
|
+
await this.send('Power', 'WakeUp')
|
|
365
366
|
resolve(true);
|
|
366
367
|
} catch (error) {
|
|
367
368
|
reject(`power on error: ${error}`);
|
|
@@ -372,7 +373,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
372
373
|
powerOff() {
|
|
373
374
|
return new Promise(async (resolve, reject) => {
|
|
374
375
|
try {
|
|
375
|
-
await this.
|
|
376
|
+
await this.send('Power', 'TurnOff')
|
|
376
377
|
resolve(true);
|
|
377
378
|
} catch (error) {
|
|
378
379
|
reject(`power off error: ${error}`);
|
|
@@ -383,7 +384,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
383
384
|
reboot() {
|
|
384
385
|
return new Promise(async (resolve, reject) => {
|
|
385
386
|
try {
|
|
386
|
-
await this.
|
|
387
|
+
await this.send('Power', 'Reboot')
|
|
387
388
|
resolve(true);
|
|
388
389
|
} catch (error) {
|
|
389
390
|
reject(`reboot error: ${error}`);
|
|
@@ -394,7 +395,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
394
395
|
mute() {
|
|
395
396
|
return new Promise(async (resolve, reject) => {
|
|
396
397
|
try {
|
|
397
|
-
await this.
|
|
398
|
+
await this.send('Audio', 'Mute')
|
|
398
399
|
resolve(true);
|
|
399
400
|
} catch (error) {
|
|
400
401
|
reject(`mute error: ${error}`);
|
|
@@ -405,7 +406,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
405
406
|
unmute() {
|
|
406
407
|
return new Promise(async (resolve, reject) => {
|
|
407
408
|
try {
|
|
408
|
-
await this.
|
|
409
|
+
await this.send('Audio', 'Unmute')
|
|
409
410
|
resolve(true);
|
|
410
411
|
} catch (error) {
|
|
411
412
|
reject(`unmute error: ${error}`);
|
|
@@ -416,7 +417,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
416
417
|
launchApp(oneStoreProductId) {
|
|
417
418
|
return new Promise(async (resolve, reject) => {
|
|
418
419
|
try {
|
|
419
|
-
await this.
|
|
420
|
+
await this.send('Shell', 'ActivateApplicationWithOneStoreProductId', [{
|
|
420
421
|
'oneStoreProductId': oneStoreProductId
|
|
421
422
|
}])
|
|
422
423
|
resolve(true);
|
|
@@ -429,7 +430,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
429
430
|
launchDashboard() {
|
|
430
431
|
return new Promise(async (resolve, reject) => {
|
|
431
432
|
try {
|
|
432
|
-
await this.
|
|
433
|
+
await this.send('Shell', 'GoHome')
|
|
433
434
|
resolve(true);
|
|
434
435
|
} catch (error) {
|
|
435
436
|
reject(`launch dashboard error: ${error}`);
|
|
@@ -440,7 +441,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
440
441
|
openGuideTab() {
|
|
441
442
|
return new Promise(async (resolve, reject) => {
|
|
442
443
|
try {
|
|
443
|
-
await this.
|
|
444
|
+
await this.send('Shell', 'ShowGuideTab', [{
|
|
444
445
|
'tabName': 'Guide'
|
|
445
446
|
}])
|
|
446
447
|
resolve(true);
|
|
@@ -453,7 +454,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
453
454
|
launchOneGuide() {
|
|
454
455
|
return new Promise(async (resolve, reject) => {
|
|
455
456
|
try {
|
|
456
|
-
await this.
|
|
457
|
+
await this.send('TV', 'ShowGuide')
|
|
457
458
|
resolve(true);
|
|
458
459
|
} catch (error) {
|
|
459
460
|
reject(`launch one guide error: ${error}`);
|
|
@@ -464,7 +465,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
464
465
|
sendButtonPress(button) {
|
|
465
466
|
return new Promise(async (resolve, reject) => {
|
|
466
467
|
try {
|
|
467
|
-
await this.
|
|
468
|
+
await this.send('Shell', 'InjectKey', [{
|
|
468
469
|
'keyType': button
|
|
469
470
|
}])
|
|
470
471
|
resolve(true);
|
|
@@ -474,7 +475,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
474
475
|
});
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
|
|
478
|
+
send(commandType, command, params) {
|
|
478
479
|
return new Promise(async (resolve, reject) => {
|
|
479
480
|
try {
|
|
480
481
|
const sessionid = Uuid4();
|