homebridge-xbox-tv 3.4.1 → 3.4.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/package.json +1 -1
- package/src/xboxdevice.js +61 -79
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -186,30 +186,30 @@ class XboxDevice extends EventEmitter {
|
|
|
186
186
|
break;
|
|
187
187
|
case 'App':
|
|
188
188
|
const payload = [{ 'oneStoreProductId': value }];
|
|
189
|
-
set =
|
|
189
|
+
set = await this.xboxWebApi.send('Shell', 'ActivateApplicationWithOneStoreProductId', payload);
|
|
190
190
|
break;
|
|
191
191
|
case 'Volume':
|
|
192
192
|
switch (value) {
|
|
193
193
|
case 'up': //Up
|
|
194
|
-
set =
|
|
194
|
+
set = await this.xboxWebApi.send('Volume', 'Up');
|
|
195
195
|
break;
|
|
196
196
|
case 'down': //Down
|
|
197
|
-
set =
|
|
197
|
+
set = await this.xboxWebApi.send('Volume', 'Down');
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
200
|
break;
|
|
201
201
|
case 'Mute':
|
|
202
202
|
switch (value) {
|
|
203
203
|
case true: //Mute
|
|
204
|
-
set =
|
|
204
|
+
set = await this.xboxWebApi.send('Audio', 'Mute');
|
|
205
205
|
break;
|
|
206
206
|
case false: //Unmute;
|
|
207
|
-
set =
|
|
207
|
+
set = await this.xboxWebApi.send('Audio', 'Unmute');
|
|
208
208
|
break;
|
|
209
209
|
}
|
|
210
210
|
break;
|
|
211
211
|
case 'RcControl':
|
|
212
|
-
set =
|
|
212
|
+
set = await this.xboxWebApi.send('Shell', 'InjectKey', [{ 'keyType': value }]);
|
|
213
213
|
break;
|
|
214
214
|
default:
|
|
215
215
|
this.emit('warn', `${integration}, received key: ${key}, value: ${value}`);
|
|
@@ -438,11 +438,6 @@ class XboxDevice extends EventEmitter {
|
|
|
438
438
|
return inputIdentifier;
|
|
439
439
|
})
|
|
440
440
|
.onSet(async (activeIdentifier) => {
|
|
441
|
-
if (!this.consoleAuthorized) {
|
|
442
|
-
this.emit('warn', `not authorized`);
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
441
|
try {
|
|
447
442
|
const input = this.inputsConfigured.find(input => input.identifier === activeIdentifier);
|
|
448
443
|
const inputOneStoreProductId = input.oneStoreProductId;
|
|
@@ -582,11 +577,6 @@ class XboxDevice extends EventEmitter {
|
|
|
582
577
|
|
|
583
578
|
this.televisionService.getCharacteristic(Characteristic.PowerModeSelection)
|
|
584
579
|
.onSet(async (powerModeSelection) => {
|
|
585
|
-
if (!this.consoleAuthorized) {
|
|
586
|
-
this.emit('warn', `not authorized`);
|
|
587
|
-
return;
|
|
588
|
-
}
|
|
589
|
-
|
|
590
580
|
try {
|
|
591
581
|
switch (powerModeSelection) {
|
|
592
582
|
case 0: //SHOW
|
|
@@ -622,11 +612,6 @@ class XboxDevice extends EventEmitter {
|
|
|
622
612
|
|
|
623
613
|
this.speakerService.getCharacteristic(Characteristic.VolumeSelector)
|
|
624
614
|
.onSet(async (volumeSelector) => {
|
|
625
|
-
if (!this.consoleAuthorized) {
|
|
626
|
-
this.emit('warn', `not authorized`);
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
615
|
try {
|
|
631
616
|
switch (volumeSelector) {
|
|
632
617
|
case 0: //Up
|
|
@@ -657,11 +642,6 @@ class XboxDevice extends EventEmitter {
|
|
|
657
642
|
return state;
|
|
658
643
|
})
|
|
659
644
|
.onSet(async (state) => {
|
|
660
|
-
if (!this.consoleAuthorized) {
|
|
661
|
-
this.emit('warn', `not authorized`);
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
664
|
-
|
|
665
645
|
try {
|
|
666
646
|
switch (state) {
|
|
667
647
|
case 0: //Mute
|
|
@@ -939,34 +919,39 @@ class XboxDevice extends EventEmitter {
|
|
|
939
919
|
return state;
|
|
940
920
|
})
|
|
941
921
|
.onSet(async (state) => {
|
|
922
|
+
if (!this.power) {
|
|
923
|
+
this.emit('warn', `console is off`);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
|
|
942
927
|
try {
|
|
943
928
|
switch (buttonMode) {
|
|
944
929
|
case 0: case 1: case 2:
|
|
945
|
-
const send =
|
|
930
|
+
const send = state ? await this.xboxWebApi.send('Shell', 'InjectKey', [{ 'keyType': buttonCommand }]) : false;
|
|
946
931
|
break;
|
|
947
932
|
case 3:
|
|
948
933
|
switch (buttonCommand) {
|
|
949
934
|
case 'reboot':
|
|
950
|
-
const send =
|
|
935
|
+
const send = state ? await this.xboxWebApi.send('Power', 'Reboot') : false;
|
|
951
936
|
break;
|
|
952
937
|
case 'recordGameDvr':
|
|
953
|
-
const send1 =
|
|
938
|
+
const send1 = state ? await this.xboxLocalApi.recordGameDvr() : false;
|
|
954
939
|
break;
|
|
955
940
|
}
|
|
956
941
|
break;
|
|
957
942
|
case 4:
|
|
958
943
|
switch (buttonCommand) {
|
|
959
944
|
case 'Dashboard': case 'Settings': case 'SettingsTv': case 'Accessory': case 'Screensaver': case 'NetworkTroubleshooter': case 'MicrosoftStore':
|
|
960
|
-
const send3 =
|
|
945
|
+
const send3 = state ? await this.xboxWebApi.send('Shell', 'GoHome') : false;
|
|
961
946
|
break;
|
|
962
947
|
case 'Television':
|
|
963
|
-
const send4 =
|
|
948
|
+
const send4 = state ? await this.xboxWebApi.send('TV', 'ShowGuide') : false;
|
|
964
949
|
break;
|
|
965
950
|
case 'XboxGuide':
|
|
966
|
-
const send5 =
|
|
951
|
+
const send5 = state ? await this.xboxWebApi.send('Shell', 'ShowGuideTab', [{ 'tabName': 'Guide' }]) : false;
|
|
967
952
|
break;
|
|
968
953
|
default:
|
|
969
|
-
const send6 =
|
|
954
|
+
const send6 = state ? await this.xboxWebApi.send('Shell', 'ActivateApplicationWithOneStoreProductId', [{ 'oneStoreProductId': buttonCommand }]) : false;
|
|
970
955
|
break;
|
|
971
956
|
}
|
|
972
957
|
break;
|
|
@@ -994,56 +979,53 @@ class XboxDevice extends EventEmitter {
|
|
|
994
979
|
async start() {
|
|
995
980
|
try {
|
|
996
981
|
//web api client
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
this.
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
});
|
|
982
|
+
try {
|
|
983
|
+
this.xboxWebApi = new XboxWebApi({
|
|
984
|
+
xboxLiveId: this.xboxLiveId,
|
|
985
|
+
webApiClientId: this.webApiClientId,
|
|
986
|
+
webApiClientSecret: this.webApiClientSecret,
|
|
987
|
+
tokensFile: this.authTokenFile,
|
|
988
|
+
inputsFile: this.inputsFile,
|
|
989
|
+
enableDebugMode: this.enableDebugMode
|
|
990
|
+
});
|
|
1007
991
|
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
992
|
+
this.xboxWebApi.on('consoleStatus', (consoleType) => {
|
|
993
|
+
if (this.informationService) {
|
|
994
|
+
this.informationService
|
|
995
|
+
.setCharacteristic(Characteristic.Model, consoleType)
|
|
996
|
+
};
|
|
1013
997
|
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
998
|
+
//this.serialNumber = id;
|
|
999
|
+
this.modelName = consoleType;
|
|
1000
|
+
//this.power = powerState;
|
|
1001
|
+
//this.mediaState = playbackState;
|
|
1002
|
+
})
|
|
1003
|
+
.on('success', (success) => {
|
|
1004
|
+
this.emit('success', success);
|
|
1018
1005
|
})
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
.on('mqtt', (topic, message) => {
|
|
1038
|
-
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1039
|
-
});
|
|
1006
|
+
.on('info', (info) => {
|
|
1007
|
+
this.emit('info', info);
|
|
1008
|
+
})
|
|
1009
|
+
.on('debug', (debug) => {
|
|
1010
|
+
this.emit('debug', debug);
|
|
1011
|
+
})
|
|
1012
|
+
.on('warn', (warn) => {
|
|
1013
|
+
this.emit('warn', warn);
|
|
1014
|
+
})
|
|
1015
|
+
.on('error', (error) => {
|
|
1016
|
+
this.emit('error', error);
|
|
1017
|
+
})
|
|
1018
|
+
.on('restFul', (path, data) => {
|
|
1019
|
+
const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;
|
|
1020
|
+
})
|
|
1021
|
+
.on('mqtt', (topic, message) => {
|
|
1022
|
+
const mqtt = this.mqttConnected ? this.mqtt1.emit('publish', topic, message) : false;
|
|
1023
|
+
});
|
|
1040
1024
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
this.emit('error', `Start web api error: ${error}`);
|
|
1046
|
-
};
|
|
1025
|
+
//check authorization
|
|
1026
|
+
this.consoleAuthorized = this.webApiControl ? await this.xboxWebApi.checkAuthorization() : false;
|
|
1027
|
+
} catch (error) {
|
|
1028
|
+
this.emit('error', `Start web api error: ${error}`);
|
|
1047
1029
|
};
|
|
1048
1030
|
|
|
1049
1031
|
//xbox local client
|