homebridge-xbox-tv 3.6.7 → 3.6.9
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 +49 -46
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -298,9 +298,6 @@ class XboxDevice extends EventEmitter {
|
|
|
298
298
|
async displayOrder() {
|
|
299
299
|
try {
|
|
300
300
|
switch (this.inputsDisplayOrder) {
|
|
301
|
-
case 0:
|
|
302
|
-
this.inputsConfigured.sort((a, b) => a.identifier - b.identifier);
|
|
303
|
-
break;
|
|
304
301
|
case 1:
|
|
305
302
|
this.inputsConfigured.sort((a, b) => a.name.localeCompare(b.name));
|
|
306
303
|
break;
|
|
@@ -313,12 +310,14 @@ class XboxDevice extends EventEmitter {
|
|
|
313
310
|
case 4:
|
|
314
311
|
this.inputsConfigured.sort((a, b) => b.reference.localeCompare(a.reference));
|
|
315
312
|
break;
|
|
313
|
+
default:
|
|
314
|
+
return;
|
|
316
315
|
}
|
|
317
|
-
const debug =
|
|
316
|
+
const debug = this.enableDebugMode ? this.emit('debug', `Inputs display order: ${JSON.stringify(this.inputsConfigured, null, 2)}`) : false;
|
|
318
317
|
|
|
319
318
|
const displayOrder = this.inputsConfigured.map(input => input.identifier);
|
|
320
319
|
this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
|
|
321
|
-
return
|
|
320
|
+
return;
|
|
322
321
|
} catch (error) {
|
|
323
322
|
throw new Error(`Display order error: ${error}`);
|
|
324
323
|
}
|
|
@@ -437,47 +436,51 @@ class XboxDevice extends EventEmitter {
|
|
|
437
436
|
})
|
|
438
437
|
.onSet(async (activeIdentifier) => {
|
|
439
438
|
try {
|
|
440
|
-
const input = this.inputsConfigured.find(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
439
|
+
const input = this.inputsConfigured.find(i => i.identifier === activeIdentifier);
|
|
440
|
+
if (!input) {
|
|
441
|
+
this.emit('warn', `Input with identifier ${activeIdentifier} not found`);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const { oneStoreProductId: oneStoreProductId, name: name, reference: reference } = input;
|
|
446
|
+
|
|
447
|
+
if (!this.power) {
|
|
448
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
449
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
450
|
+
if (this.power && this.inputIdentifier !== activeIdentifier) {
|
|
451
|
+
this.televisionService.setCharacteristic(Characteristic.ActiveIdentifier, activeIdentifier);
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
444
457
|
|
|
445
458
|
let channelName;
|
|
446
459
|
let command;
|
|
447
460
|
let payload;
|
|
448
|
-
switch (
|
|
449
|
-
case
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const setInput = this.power && this.inputIdentifier !== activeIdentifier ? this.televisionService.setCharacteristic(Characteristic.ActiveIdentifier, activeIdentifier) : false;
|
|
453
|
-
}
|
|
461
|
+
switch (oneStoreProductId) {
|
|
462
|
+
case 'Dashboard': case 'Settings': case 'SettingsTv': case 'Accessory': case 'Screensaver': case 'NetworkTroubleshooter': case 'MicrosoftStore':
|
|
463
|
+
channelName = 'Shell';
|
|
464
|
+
command = 'GoHome';
|
|
454
465
|
break;
|
|
455
|
-
case
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
payload = [{ 'tabName': 'Guide' }];
|
|
469
|
-
break;
|
|
470
|
-
default:
|
|
471
|
-
channelName = 'Shell';
|
|
472
|
-
command = 'ActivateApplicationWithOneStoreProductId';
|
|
473
|
-
payload = [{ 'oneStoreProductId': inputOneStoreProductId }];
|
|
474
|
-
break;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
await this.xboxWebApi.send(channelName, command, payload);
|
|
478
|
-
const logInfo = this.disableLogInfo ? false : this.emit('info', `set Input: ${inputName}, Reference: ${inputReference}, Product Id: ${inputOneStoreProductId}`);
|
|
466
|
+
case 'Television':
|
|
467
|
+
channelName = 'TV';
|
|
468
|
+
command = 'ShowGuide';
|
|
469
|
+
break;
|
|
470
|
+
case 'XboxGuide':
|
|
471
|
+
channelName = 'Shell';
|
|
472
|
+
command = 'ShowGuideTab';
|
|
473
|
+
payload = [{ 'tabName': 'Guide' }];
|
|
474
|
+
break;
|
|
475
|
+
default:
|
|
476
|
+
channelName = 'Shell';
|
|
477
|
+
command = 'ActivateApplicationWithOneStoreProductId';
|
|
478
|
+
payload = [{ 'oneStoreProductId': oneStoreProductId }];
|
|
479
479
|
break;
|
|
480
480
|
}
|
|
481
|
+
|
|
482
|
+
await this.xboxWebApi.send(channelName, command, payload);
|
|
483
|
+
const logInfo = this.disableLogInfo ? false : this.emit('info', `set Input: ${name}, Reference: ${reference}, Product Id: ${oneStoreProductId}`);
|
|
481
484
|
} catch (error) {
|
|
482
485
|
this.emit('warn', `set Input error: ${JSON.stringify(error, null, 2)}`);
|
|
483
486
|
}
|
|
@@ -1084,6 +1087,13 @@ class XboxDevice extends EventEmitter {
|
|
|
1084
1087
|
const input = this.inputsConfigured.find(input => input.reference === reference || input.titleId === titleId) ?? false;
|
|
1085
1088
|
const inputIdentifier = input ? input.identifier : this.inputIdentifier;
|
|
1086
1089
|
|
|
1090
|
+
this.inputIdentifier = inputIdentifier;
|
|
1091
|
+
this.power = power;
|
|
1092
|
+
this.reference = reference;
|
|
1093
|
+
this.volume = volume;
|
|
1094
|
+
this.mute = mute;
|
|
1095
|
+
this.mediaState = mediaState;
|
|
1096
|
+
|
|
1087
1097
|
//update characteristics
|
|
1088
1098
|
if (this.televisionService) {
|
|
1089
1099
|
this.televisionService
|
|
@@ -1162,13 +1172,6 @@ class XboxDevice extends EventEmitter {
|
|
|
1162
1172
|
}
|
|
1163
1173
|
}
|
|
1164
1174
|
|
|
1165
|
-
this.inputIdentifier = inputIdentifier;
|
|
1166
|
-
this.power = power;
|
|
1167
|
-
this.reference = reference;
|
|
1168
|
-
this.volume = volume;
|
|
1169
|
-
this.mute = mute;
|
|
1170
|
-
this.mediaState = mediaState;
|
|
1171
|
-
|
|
1172
1175
|
if (!this.disableLogInfo) {
|
|
1173
1176
|
const name = input ? input.name : reference;
|
|
1174
1177
|
const productId = input ? input.oneStoreProductId : reference;
|