homebridge-xbox-tv 2.7.7-beta.9 → 2.7.8
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 +35 -4
- package/index.js +169 -136
- package/package.json +1 -1
- package/src/localApi/xboxlocalapi.js +1 -3
- package/src/webApi/xboxwebapi.js +1 -1
package/config.schema.json
CHANGED
|
@@ -556,16 +556,47 @@
|
|
|
556
556
|
"type": "string",
|
|
557
557
|
"oneOf": [
|
|
558
558
|
{
|
|
559
|
-
"title": "View",
|
|
559
|
+
"title": "Game Pad View",
|
|
560
560
|
"enum": [
|
|
561
561
|
"view"
|
|
562
562
|
]
|
|
563
563
|
},
|
|
564
564
|
{
|
|
565
|
-
"title": "Nexus",
|
|
565
|
+
"title": "Game Pad Nexus",
|
|
566
566
|
"enum": [
|
|
567
567
|
"nexus"
|
|
568
568
|
]
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"title": "Game Pad Menu",
|
|
572
|
+
"enum": [
|
|
573
|
+
"menu1"
|
|
574
|
+
]
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"title": "Game Pad A",
|
|
578
|
+
"enum": [
|
|
579
|
+
"a"
|
|
580
|
+
]
|
|
581
|
+
}
|
|
582
|
+
,
|
|
583
|
+
{
|
|
584
|
+
"title": "Game Pad B",
|
|
585
|
+
"enum": [
|
|
586
|
+
"b"
|
|
587
|
+
]
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
"title": "Game Pad X",
|
|
591
|
+
"enum": [
|
|
592
|
+
"x"
|
|
593
|
+
]
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"title": "Game Pad Y",
|
|
597
|
+
"enum": [
|
|
598
|
+
"y"
|
|
599
|
+
]
|
|
569
600
|
}
|
|
570
601
|
],
|
|
571
602
|
"description": "Here select the function of info button in RC.",
|
|
@@ -805,13 +836,13 @@
|
|
|
805
836
|
"expanded": false,
|
|
806
837
|
"items": [
|
|
807
838
|
"devices[].enableMqtt",
|
|
839
|
+
"devices[].mqttDebug",
|
|
808
840
|
"devices[].mqttHost",
|
|
809
841
|
"devices[].mqttPort",
|
|
810
842
|
"devices[].mqttPrefix",
|
|
811
843
|
"devices[].mqttAuth",
|
|
812
844
|
"devices[].mqttUser",
|
|
813
|
-
"devices[].mqttPasswd"
|
|
814
|
-
"devices[].mqttDebug"
|
|
845
|
+
"devices[].mqttPasswd"
|
|
815
846
|
]
|
|
816
847
|
}
|
|
817
848
|
]
|
package/index.js
CHANGED
|
@@ -113,8 +113,11 @@ class XBOXDEVICE {
|
|
|
113
113
|
this.inputsReference = [];
|
|
114
114
|
this.inputsOneStoreProductId = [];
|
|
115
115
|
|
|
116
|
+
this.sensorInputsServices = [];
|
|
116
117
|
this.sensorInputsReference = [];
|
|
117
118
|
this.sensorInputsDisplayType = [];
|
|
119
|
+
this.buttonsServices = [];
|
|
120
|
+
|
|
118
121
|
|
|
119
122
|
this.power = false;
|
|
120
123
|
this.volume = 0;
|
|
@@ -369,7 +372,6 @@ class XBOXDEVICE {
|
|
|
369
372
|
//Prepare accessory
|
|
370
373
|
prepareAccessory() {
|
|
371
374
|
this.log.debug('prepareAccessory');
|
|
372
|
-
|
|
373
375
|
//accessory
|
|
374
376
|
const accessoryName = this.name;
|
|
375
377
|
const accessoryUUID = UUID.generate(this.xboxLiveId);
|
|
@@ -377,38 +379,52 @@ class XBOXDEVICE {
|
|
|
377
379
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
378
380
|
|
|
379
381
|
//Pinformation service
|
|
380
|
-
this.log.debug('prepareInformationService');
|
|
381
|
-
const manufacturer = this.manufacturer;
|
|
382
|
-
const modelName = this.modelName;
|
|
383
|
-
const serialNumber = this.serialNumber;
|
|
384
|
-
const firmwareRevision = this.firmwareRevision;
|
|
385
|
-
|
|
386
382
|
this.informationService = accessory.getService(Service.AccessoryInformation)
|
|
387
|
-
.setCharacteristic(Characteristic.Manufacturer, manufacturer)
|
|
388
|
-
.setCharacteristic(Characteristic.Model, modelName)
|
|
389
|
-
.setCharacteristic(Characteristic.SerialNumber, serialNumber)
|
|
390
|
-
.setCharacteristic(Characteristic.FirmwareRevision, firmwareRevision);
|
|
383
|
+
.setCharacteristic(Characteristic.Manufacturer, this.manufacturer)
|
|
384
|
+
.setCharacteristic(Characteristic.Model, this.modelName)
|
|
385
|
+
.setCharacteristic(Characteristic.SerialNumber, this.serialNumber)
|
|
386
|
+
.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
|
|
391
387
|
|
|
392
388
|
//Prepare television service
|
|
393
389
|
this.log.debug('prepareTelevisionService');
|
|
394
390
|
this.televisionService = new Service.Television(`${accessoryName} Television`, 'Television');
|
|
395
|
-
this.televisionService.
|
|
391
|
+
this.televisionService.getCharacteristic(Characteristic.ConfiguredName)
|
|
392
|
+
.onGet(async () => {
|
|
393
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} Accessory Nane: ${accessoryName}.`);
|
|
394
|
+
return accessoryName;
|
|
395
|
+
})
|
|
396
|
+
.onSet(async (value) => {
|
|
397
|
+
try {
|
|
398
|
+
this.name = value;
|
|
399
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Accessory Name: ${value}`);
|
|
400
|
+
} catch (error) {
|
|
401
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Brightness error: ${error}`);
|
|
402
|
+
};
|
|
403
|
+
});
|
|
396
404
|
this.televisionService.getCharacteristic(Characteristic.SleepDiscoveryMode)
|
|
397
405
|
.onGet(async () => {
|
|
398
|
-
const state = 1;
|
|
406
|
+
const state = 1;
|
|
407
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Discovery Mode: ${state ? 'Always Discoverable' : 'Not Discoverable'}`);
|
|
399
408
|
return state;
|
|
400
409
|
})
|
|
410
|
+
.onSet(async (state) => {
|
|
411
|
+
try {
|
|
412
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Discovery Mode: ${state ? 'Always Discoverable' : 'Not Discoverable'}`);
|
|
413
|
+
} catch (error) {
|
|
414
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Discovery Mode error: ${error}`);
|
|
415
|
+
};
|
|
416
|
+
});
|
|
401
417
|
|
|
402
418
|
this.televisionService.getCharacteristic(Characteristic.Active)
|
|
403
419
|
.onGet(async () => {
|
|
404
420
|
const state = this.power;
|
|
405
|
-
const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
421
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Power: ${state ? 'ON' : 'OFF'}`);
|
|
406
422
|
return state;
|
|
407
423
|
})
|
|
408
424
|
.onSet(async (state) => {
|
|
409
425
|
try {
|
|
410
426
|
const setPower = state ? await this.xboxLocalApi.powerOn() : await this.xboxLocalApi.powerOff();
|
|
411
|
-
const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power
|
|
427
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power: ${state ? 'ON' : 'OFF'}`);
|
|
412
428
|
} catch (error) {
|
|
413
429
|
this.log.error(`Device: ${this.host} ${accessoryName}, set Power, error: ${error}`);
|
|
414
430
|
};
|
|
@@ -420,7 +436,7 @@ class XBOXDEVICE {
|
|
|
420
436
|
const inputName = this.inputsName[inputIdentifier];
|
|
421
437
|
const inputReference = this.inputsReference[inputIdentifier];
|
|
422
438
|
const inputOneStoreProductId = this.inputsOneStoreProductId[inputIdentifier];
|
|
423
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
439
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Input: ${inputName}, Reference: ${inputReference}, Product Id: ${inputOneStoreProductId}`);
|
|
424
440
|
return inputIdentifier;
|
|
425
441
|
})
|
|
426
442
|
.onSet(async (inputIdentifier) => {
|
|
@@ -443,7 +459,7 @@ class XBOXDEVICE {
|
|
|
443
459
|
await this.xboxWebApi.launchApp(inputOneStoreProductId);
|
|
444
460
|
break;
|
|
445
461
|
}
|
|
446
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Input
|
|
462
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Input: ${inputName}, Reference: ${inputReference}, Product Id: ${inputOneStoreProductId}`);
|
|
447
463
|
} catch (error) {
|
|
448
464
|
this.log.error(`Device: ${this.host} ${accessoryName}, set Input error: ${JSON.stringify(error, null, 2)}`);
|
|
449
465
|
};
|
|
@@ -495,9 +511,9 @@ class XBOXDEVICE {
|
|
|
495
511
|
};
|
|
496
512
|
|
|
497
513
|
await this.xboxWebApi.sendButtonPress(command);
|
|
498
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Remote Key
|
|
514
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Remote Key: ${command}`);
|
|
499
515
|
} catch (error) {
|
|
500
|
-
this.log.error(`Device: ${this.host} ${accessoryName}, set Remote Key
|
|
516
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Remote Key error: ${JSON.stringify(error, null, 2)}`);
|
|
501
517
|
};
|
|
502
518
|
});
|
|
503
519
|
|
|
@@ -506,7 +522,7 @@ class XBOXDEVICE {
|
|
|
506
522
|
//apple, 0 - PLAY, 1 - PAUSE, 2 - STOP, 3 - LOADING, 4 - INTERRUPTED
|
|
507
523
|
//xbox, 0 - STOP, 1 - PLAY, 2 - PAUSE
|
|
508
524
|
const value = [2, 0, 1, 3, 4][this.mediaState];
|
|
509
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
525
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Current Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
|
|
510
526
|
return value;
|
|
511
527
|
});
|
|
512
528
|
|
|
@@ -514,16 +530,16 @@ class XBOXDEVICE {
|
|
|
514
530
|
.onGet(async () => {
|
|
515
531
|
//0 - PLAY, 1 - PAUSE, 2 - STOP
|
|
516
532
|
const value = [2, 0, 1, 3, 4][this.mediaState];
|
|
517
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
533
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Target Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
|
|
518
534
|
return value;
|
|
519
535
|
})
|
|
520
536
|
.onSet(async (value) => {
|
|
521
537
|
try {
|
|
522
538
|
const newMediaState = value;
|
|
523
539
|
const setMediaState = this.power ? false : false;
|
|
524
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Target Media
|
|
540
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Target Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
|
|
525
541
|
} catch (error) {
|
|
526
|
-
this.log.error(`Device: ${this.host} ${accessoryName} set Target Media
|
|
542
|
+
this.log.error(`Device: ${this.host} ${accessoryName} set Target Media error: ${error}`);
|
|
527
543
|
};
|
|
528
544
|
});
|
|
529
545
|
|
|
@@ -541,9 +557,9 @@ class XBOXDEVICE {
|
|
|
541
557
|
|
|
542
558
|
const channelName = 'systemInput';
|
|
543
559
|
await this.xboxWebApi.sendButtonPress(command);
|
|
544
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power Mode Selection command
|
|
560
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power Mode Selection: ${command === 'nexus' ? 'SHOW' : 'HIDE'}`);
|
|
545
561
|
} catch (error) {
|
|
546
|
-
this.log.error(`Device: ${this.host} ${accessoryName}, set Power Mode Selection
|
|
562
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Power Mode Selection error: ${error}`);
|
|
547
563
|
};
|
|
548
564
|
});
|
|
549
565
|
|
|
@@ -552,10 +568,21 @@ class XBOXDEVICE {
|
|
|
552
568
|
//Prepare speaker service
|
|
553
569
|
this.log.debug('prepareSpeakerService');
|
|
554
570
|
this.speakerService = new Service.TelevisionSpeaker(`${accessoryName} Speaker`, 'Speaker');
|
|
555
|
-
this.speakerService
|
|
556
|
-
.
|
|
557
|
-
|
|
558
|
-
|
|
571
|
+
this.speakerService.getCharacteristic(Characteristic.Active)
|
|
572
|
+
.onGet(async () => {
|
|
573
|
+
const state = this.power;
|
|
574
|
+
return state;
|
|
575
|
+
})
|
|
576
|
+
.onSet(async (state) => {
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
this.speakerService.getCharacteristic(Characteristic.VolumeControlType)
|
|
580
|
+
.onGet(async () => {
|
|
581
|
+
const state = 3; //none, relative, relative with current, absolute
|
|
582
|
+
return state;
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
this.speakerService.getCharacteristic(Characteristic.VolumeSelector)
|
|
559
586
|
.onSet(async (command) => {
|
|
560
587
|
try {
|
|
561
588
|
switch (command) {
|
|
@@ -568,35 +595,35 @@ class XBOXDEVICE {
|
|
|
568
595
|
};
|
|
569
596
|
|
|
570
597
|
await this.xboxWebApi.sendButtonPress(command);
|
|
571
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Volume
|
|
598
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Volume Selector: ${command}`);
|
|
572
599
|
} catch (error) {
|
|
573
|
-
this.log.error(`Device: ${this.host} ${accessoryName}, set Volume
|
|
600
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Volume Selector error: ${error}`);
|
|
574
601
|
};
|
|
575
|
-
})
|
|
602
|
+
})
|
|
576
603
|
|
|
577
604
|
this.speakerService.getCharacteristic(Characteristic.Volume)
|
|
578
605
|
.onGet(async () => {
|
|
579
606
|
const volume = this.volume;
|
|
580
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
607
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, Volume: ${volume}`);
|
|
581
608
|
return volume;
|
|
582
609
|
})
|
|
583
610
|
.onSet(async (volume) => {
|
|
584
611
|
if (volume === 0 || volume === 100) {
|
|
585
612
|
volume = this.volume;
|
|
586
613
|
};
|
|
587
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Volume
|
|
614
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Volume: ${volume}`);
|
|
588
615
|
});
|
|
589
616
|
|
|
590
617
|
this.speakerService.getCharacteristic(Characteristic.Mute)
|
|
591
618
|
.onGet(async () => {
|
|
592
619
|
const state = this.mute;
|
|
593
|
-
const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName},
|
|
620
|
+
const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, Mute: ${state ? 'ON' : 'OFF'}`);
|
|
594
621
|
return state;
|
|
595
622
|
})
|
|
596
623
|
.onSet(async (state) => {
|
|
597
624
|
try {
|
|
598
625
|
const toggleMute = state ? await this.xboxWebApi.mute() : await this.xboxWebApi.unmute();
|
|
599
|
-
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Mute
|
|
626
|
+
const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Mute: ${state ? 'ON' : 'OFF'}`);
|
|
600
627
|
} catch (error) {
|
|
601
628
|
this.log.error(`Device: ${this.host} ${accessoryName}, set Mute error: ${error}`);
|
|
602
629
|
};
|
|
@@ -692,10 +719,10 @@ class XBOXDEVICE {
|
|
|
692
719
|
const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs: ${JSON.stringify(savedInputs, null, 2)}`) : false;
|
|
693
720
|
|
|
694
721
|
const savedInputsNames = fs.readFileSync(this.inputsNamesFile).length > 2 ? JSON.parse(fs.readFileSync(this.inputsNamesFile)) : {};
|
|
695
|
-
const debug1 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs
|
|
722
|
+
const debug1 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs Nnames: ${JSON.stringify(savedInputsNames, null, 2)}`) : false;
|
|
696
723
|
|
|
697
724
|
const savedInputsTargetVisibility = fs.readFileSync(this.inputsTargetVisibilityFile).length > 2 ? JSON.parse(fs.readFileSync(this.inputsTargetVisibilityFile)) : {};
|
|
698
|
-
const debug2 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs Target Visibility
|
|
725
|
+
const debug2 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs Target Visibility: ${JSON.stringify(savedInputsTargetVisibility, null, 2)}`) : false;
|
|
699
726
|
|
|
700
727
|
//check possible inputs and filter custom unnecessary inputs
|
|
701
728
|
const filteredInputsArr = [];
|
|
@@ -732,40 +759,39 @@ class XBOXDEVICE {
|
|
|
732
759
|
const isConfigured = 1;
|
|
733
760
|
|
|
734
761
|
//get input visibility state
|
|
735
|
-
const currentVisibility = savedInputsTargetVisibility[inputReference] || savedInputsTargetVisibility[inputOneStoreProductId];
|
|
736
|
-
const targetVisibility = currentVisibility;
|
|
762
|
+
const currentVisibility = savedInputsTargetVisibility[inputReference] || savedInputsTargetVisibility[inputOneStoreProductId] || 0;
|
|
737
763
|
|
|
738
764
|
if (inputReference && inputName) {
|
|
739
765
|
const inputService = new Service.InputSource(inputName, `Input ${i}`);
|
|
740
766
|
inputService
|
|
741
767
|
.setCharacteristic(Characteristic.Identifier, i)
|
|
742
768
|
.setCharacteristic(Characteristic.Name, inputName)
|
|
743
|
-
.setCharacteristic(Characteristic.IsConfigured, isConfigured)
|
|
744
769
|
.setCharacteristic(Characteristic.InputSourceType, inputType)
|
|
770
|
+
.setCharacteristic(Characteristic.IsConfigured, isConfigured)
|
|
745
771
|
.setCharacteristic(Characteristic.CurrentVisibilityState, currentVisibility)
|
|
746
772
|
|
|
747
773
|
inputService.getCharacteristic(Characteristic.ConfiguredName)
|
|
748
774
|
.onGet(async () => {
|
|
749
775
|
return inputName;
|
|
750
776
|
})
|
|
751
|
-
.onSet(async (
|
|
777
|
+
.onSet(async (value) => {
|
|
752
778
|
try {
|
|
753
779
|
const nameIdentifier = inputReference || inputOneStoreProductId;
|
|
754
|
-
savedInputsNames[nameIdentifier] =
|
|
780
|
+
savedInputsNames[nameIdentifier] = value;
|
|
755
781
|
|
|
756
782
|
const newCustomName = JSON.stringify(savedInputsNames, null, 2);
|
|
757
783
|
await fsPromises.writeFile(this.inputsNamesFile, newCustomName);
|
|
758
|
-
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved
|
|
759
|
-
inputService.setCharacteristic(Characteristic.Name,
|
|
784
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved Input Name: ${value}, Reference: ${nameIdentifier}.`) : false;
|
|
785
|
+
inputService.setCharacteristic(Characteristic.Name, value);
|
|
760
786
|
} catch (error) {
|
|
761
|
-
this.log.error(`Device: ${this.host} ${accessoryName},
|
|
787
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, save Input Name error: ${error}`);
|
|
762
788
|
}
|
|
763
789
|
});
|
|
764
790
|
|
|
765
791
|
inputService
|
|
766
792
|
.getCharacteristic(Characteristic.TargetVisibilityState)
|
|
767
793
|
.onGet(async () => {
|
|
768
|
-
return
|
|
794
|
+
return currentVisibility;
|
|
769
795
|
})
|
|
770
796
|
.onSet(async (state) => {
|
|
771
797
|
try {
|
|
@@ -774,10 +800,10 @@ class XBOXDEVICE {
|
|
|
774
800
|
|
|
775
801
|
const newTargetVisibility = JSON.stringify(savedInputsTargetVisibility, null, 2);
|
|
776
802
|
await fsPromises.writeFile(this.inputsTargetVisibilityFile, newTargetVisibility);
|
|
777
|
-
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved
|
|
803
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved Input: ${inputName} Target Visibility: ${state ? 'HIDEN' : 'SHOWN'}`) : false;
|
|
778
804
|
inputService.setCharacteristic(Characteristic.CurrentVisibilityState, state);
|
|
779
805
|
} catch (error) {
|
|
780
|
-
this.log.error(`Device: ${this.host} ${accessoryName},
|
|
806
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, save Target Visibility error: ${error}`);
|
|
781
807
|
}
|
|
782
808
|
});
|
|
783
809
|
|
|
@@ -788,13 +814,12 @@ class XBOXDEVICE {
|
|
|
788
814
|
this.televisionService.addLinkedService(inputService);
|
|
789
815
|
accessory.addService(inputService);
|
|
790
816
|
} else {
|
|
791
|
-
this.log(`Device: ${this.host} ${accessoryName}, Input
|
|
817
|
+
this.log(`Device: ${this.host} ${accessoryName}, Input Name: ${inputName ? inputName : 'Missing'}, Reference: ${inputReference ? inputReference : 'Missing'}.`);
|
|
792
818
|
|
|
793
819
|
};
|
|
794
820
|
}
|
|
795
821
|
|
|
796
822
|
//prepare sonsor service
|
|
797
|
-
this.sensorInputsServices = [];
|
|
798
823
|
const sensorInputs = this.sensorInputs;
|
|
799
824
|
const sensorInputsCount = sensorInputs.length;
|
|
800
825
|
const possibleSensorInputsCount = 80 - this.inputsReference.length;
|
|
@@ -806,34 +831,37 @@ class XBOXDEVICE {
|
|
|
806
831
|
const sensorInput = sensorInputs[i];
|
|
807
832
|
|
|
808
833
|
//get sensor name
|
|
809
|
-
const sensorInputName = sensorInput.name
|
|
834
|
+
const sensorInputName = sensorInput.name;
|
|
810
835
|
|
|
811
836
|
//get sensor reference
|
|
812
|
-
const sensorInputReference = sensorInput.reference
|
|
837
|
+
const sensorInputReference = sensorInput.reference;
|
|
813
838
|
|
|
814
839
|
//get sensor display type
|
|
815
840
|
const sensorInputDisplayType = sensorInput.displayType >= 0 ? sensorInput.displayType : -1;
|
|
816
841
|
|
|
817
842
|
if (sensorInputDisplayType >= 0) {
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
.
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
843
|
+
if (sensorInputName && sensorInputReference) {
|
|
844
|
+
const serviceType = [Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType];
|
|
845
|
+
const characteristicType = [Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorInputDisplayType];
|
|
846
|
+
const sensorInputService = new serviceType(`${accessoryName} ${sensorInputName}`, `Sensor ${i}`);
|
|
847
|
+
sensorInputService.getCharacteristic(characteristicType)
|
|
848
|
+
.onGet(async () => {
|
|
849
|
+
const state = this.power ? (this.reference === sensorInputReference) : false;
|
|
850
|
+
return state;
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
this.sensorInputsReference.push(sensorInputReference);
|
|
854
|
+
this.sensorInputsDisplayType.push(sensorInputDisplayType);
|
|
855
|
+
this.sensorInputsServices.push(sensorInputService);
|
|
856
|
+
accessory.addService(this.sensorInputsServices[i]);
|
|
857
|
+
} else {
|
|
858
|
+
this.log(`Device: ${this.host} ${accessoryName}, Sensor Name: ${sensorInputName ? sensorInputName : 'Missing'}, Reference: ${sensorInputReference ? sensorInputReference : 'Missing'}.`);
|
|
859
|
+
};
|
|
831
860
|
}
|
|
832
861
|
}
|
|
833
862
|
}
|
|
834
863
|
|
|
835
864
|
//Prepare buttons services
|
|
836
|
-
this.buttonsServices = [];
|
|
837
865
|
const buttons = this.buttons;
|
|
838
866
|
const buttonsCount = buttons.length;
|
|
839
867
|
const possibleButtonsCount = 80 - (this.inputsReference.length + this.sensorInputsServices.length);
|
|
@@ -845,85 +873,90 @@ class XBOXDEVICE {
|
|
|
845
873
|
const button = buttons[i];
|
|
846
874
|
|
|
847
875
|
//get button name
|
|
848
|
-
const buttonName = button.name
|
|
876
|
+
const buttonName = button.name;
|
|
849
877
|
|
|
850
878
|
//get button command
|
|
851
|
-
const buttonCommand = button.command
|
|
879
|
+
const buttonCommand = button.command;
|
|
880
|
+
|
|
881
|
+
//get button mode
|
|
882
|
+
let mode;
|
|
883
|
+
if (buttonCommand in CONSTANS.SystemMediaCommands) {
|
|
884
|
+
mode = 0;
|
|
885
|
+
} else if (buttonCommand in CONSTANS.SystemInputCommands) {
|
|
886
|
+
mode = 1;
|
|
887
|
+
} else if (buttonCommand in CONSTANS.TvRemoteCommands) {
|
|
888
|
+
mode = 2;
|
|
889
|
+
} else if (buttonCommand === 'recordGameDvr') {
|
|
890
|
+
mode = 3;
|
|
891
|
+
} else if (buttonCommand === 'reboot') {
|
|
892
|
+
mode = 4;
|
|
893
|
+
} else if (buttonCommand === 'switchAppGame') {
|
|
894
|
+
mode = 5;
|
|
895
|
+
};
|
|
896
|
+
const buttonMode = mode >= 0 ? mode : -1;
|
|
852
897
|
|
|
853
898
|
//get button inputOneStoreProductId
|
|
854
|
-
const buttonOneStoreProductId = button.oneStoreProductId
|
|
899
|
+
const buttonOneStoreProductId = button.oneStoreProductId;
|
|
855
900
|
|
|
856
901
|
//get button display type
|
|
857
902
|
const buttonDisplayType = button.displayType >= 0 ? button.displayType : -1;
|
|
858
903
|
|
|
859
904
|
if (buttonDisplayType >= 0) {
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
.
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
await this.xboxWebApi.launchOneGuide();
|
|
904
|
-
break;
|
|
905
|
-
case 'XboxGuide':
|
|
906
|
-
await this.xboxWebApi.openGuideTab();
|
|
907
|
-
break;
|
|
908
|
-
case 'Not set': case 'Web api disabled':
|
|
909
|
-
this.log(`Device: ${this.host} ${accessoryName}, trying to launch app/game with one store product id: ${buttonOneStoreProductId}.`);
|
|
910
|
-
break;
|
|
911
|
-
default:
|
|
912
|
-
await this.xboxWebApi.launchApp(buttonOneStoreProductId);
|
|
913
|
-
break;
|
|
914
|
-
}
|
|
915
|
-
break;
|
|
905
|
+
if (buttonName && buttonCommand && buttonMode) {
|
|
906
|
+
const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType];
|
|
907
|
+
const buttonService = new serviceType(`${accessoryName} ${buttonName}`, `Button ${i}`);
|
|
908
|
+
buttonService.getCharacteristic(Characteristic.On)
|
|
909
|
+
.onGet(async () => {
|
|
910
|
+
const state = false;
|
|
911
|
+
const logDebug = this.disableLogInfo ? this.log(`Device: ${this.host} ${accessoryName}, Button state: ${state}`) : false;
|
|
912
|
+
return state;
|
|
913
|
+
})
|
|
914
|
+
.onSet(async (state) => {
|
|
915
|
+
try {
|
|
916
|
+
if (state) {
|
|
917
|
+
switch (buttonMode) {
|
|
918
|
+
case 0: case 1: case 2:
|
|
919
|
+
await this.xboxWebApi.sendButtonPress(buttonCommand);
|
|
920
|
+
break;
|
|
921
|
+
case 3:
|
|
922
|
+
await this.xboxLocalApi.recordGameDvr();
|
|
923
|
+
break;
|
|
924
|
+
case 4:
|
|
925
|
+
await this.xboxWebApi.reboot();
|
|
926
|
+
break;
|
|
927
|
+
case 5:
|
|
928
|
+
switch (buttonOneStoreProductId) {
|
|
929
|
+
case 'Dashboard': case 'Settings': case 'SettingsTv': case 'Accessory': case 'Screensaver': case 'NetworkTroubleshooter': case 'MicrosoftStore':
|
|
930
|
+
await this.xboxWebApi.launchDashboard();
|
|
931
|
+
break;
|
|
932
|
+
case 'Television':
|
|
933
|
+
await this.xboxWebApi.launchOneGuide();
|
|
934
|
+
break;
|
|
935
|
+
case 'XboxGuide':
|
|
936
|
+
await this.xboxWebApi.openGuideTab();
|
|
937
|
+
break;
|
|
938
|
+
case 'Not set': case 'Web api disabled':
|
|
939
|
+
this.log(`Device: ${this.host} ${accessoryName}, trying to launch App/Game with one store product id: ${buttonOneStoreProductId}.`);
|
|
940
|
+
break;
|
|
941
|
+
default:
|
|
942
|
+
await this.xboxWebApi.launchApp(buttonOneStoreProductId);
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, set Button Name: ${buttonName}, Command: ${buttonCommand}`) : false;
|
|
916
948
|
}
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
949
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
950
|
+
const setChar = state ? buttonService.updateCharacteristic(Characteristic.On, false) : false;
|
|
951
|
+
} catch (error) {
|
|
952
|
+
this.log.error(`Device: ${this.host} ${accessoryName}, set Button error: ${error}`);
|
|
953
|
+
};
|
|
954
|
+
});
|
|
955
|
+
this.buttonsServices.push(buttonService);
|
|
956
|
+
accessory.addService(this.buttonsServices[i]);
|
|
957
|
+
} else {
|
|
958
|
+
this.log(`Device: ${this.host} ${accessoryName}, Button Name: ${buttonName ? buttonName : 'Missing'}, Command: ${buttonCommand ? buttonCommand : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}.`);
|
|
959
|
+
};
|
|
927
960
|
}
|
|
928
961
|
}
|
|
929
962
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Xbox TV",
|
|
3
3
|
"name": "homebridge-xbox-tv",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.8",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -348,9 +348,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
348
348
|
recordGameDvr() {
|
|
349
349
|
return new Promise(async (resolve, reject) => {
|
|
350
350
|
if (!this.isConnected || !this.isAuthorized) {
|
|
351
|
-
reject({
|
|
352
|
-
status: `Send record game ignored, connection state: ${this.isConnected}, authorization state: ${this.isAuthorized}`
|
|
353
|
-
});
|
|
351
|
+
reject(`Send record game ignored, connection state: ${this.isConnected}, authorization state: ${this.isAuthorized}`);
|
|
354
352
|
return;
|
|
355
353
|
};
|
|
356
354
|
|
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -67,7 +67,7 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
67
67
|
}
|
|
68
68
|
const debug = this.debugLog ? this.emit(`message', 'authorized and web Api enabled.`) : false;
|
|
69
69
|
const rmEnabled = await this.getWebApiConsoleStatus();
|
|
70
|
-
const debug1 = !rmEnabled ? this.emit('message', `remote management not enabled, please check your console settings
|
|
70
|
+
const debug1 = !rmEnabled ? this.emit('message', `remote management not enabled, please check your console settings.`) : false;
|
|
71
71
|
//await this.getWebApiConsolesList();
|
|
72
72
|
await this.getWebApiInstalledApps();
|
|
73
73
|
//await this.getWebApiStorageDevices();
|