homebridge-xbox-tv 2.7.8 → 2.7.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/index.js +30 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -109,6 +109,7 @@ class XBOXDEVICE {
|
|
|
109
109
|
//setup variables
|
|
110
110
|
this.firstRun = true;
|
|
111
111
|
|
|
112
|
+
this.services = [];
|
|
112
113
|
this.inputsName = [];
|
|
113
114
|
this.inputsReference = [];
|
|
114
115
|
this.inputsOneStoreProductId = [];
|
|
@@ -246,20 +247,20 @@ class XBOXDEVICE {
|
|
|
246
247
|
|
|
247
248
|
if (this.sensorPowerService) {
|
|
248
249
|
this.sensorPowerService
|
|
249
|
-
.updateCharacteristic(Characteristic.
|
|
250
|
+
.updateCharacteristic(Characteristic.ContactSensorState, power)
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
if (this.sensorInputService) {
|
|
253
254
|
const state = power ? (this.inputIdentifier !== inputIdentifier) : false;
|
|
254
255
|
this.sensorInputService
|
|
255
|
-
.updateCharacteristic(Characteristic.
|
|
256
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
256
257
|
this.sensorInputState = state;
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
if (this.sensorScreenSaverService) {
|
|
260
261
|
const state = power ? (reference === 'Xbox.IdleScreen_8wekyb3d8bbwe!Xbox.IdleScreen.Application') : false;
|
|
261
262
|
this.sensorScreenSaverService
|
|
262
|
-
.updateCharacteristic(Characteristic.
|
|
263
|
+
.updateCharacteristic(Characteristic.ContactSensorState, state)
|
|
263
264
|
this.sensorScreenSaverState = state;
|
|
264
265
|
}
|
|
265
266
|
|
|
@@ -384,6 +385,7 @@ class XBOXDEVICE {
|
|
|
384
385
|
.setCharacteristic(Characteristic.Model, this.modelName)
|
|
385
386
|
.setCharacteristic(Characteristic.SerialNumber, this.serialNumber)
|
|
386
387
|
.setCharacteristic(Characteristic.FirmwareRevision, this.firmwareRevision);
|
|
388
|
+
this.services.push(this.informationService);
|
|
387
389
|
|
|
388
390
|
//Prepare television service
|
|
389
391
|
this.log.debug('prepareTelevisionService');
|
|
@@ -563,6 +565,7 @@ class XBOXDEVICE {
|
|
|
563
565
|
};
|
|
564
566
|
});
|
|
565
567
|
|
|
568
|
+
this.services.push(this.televisionService);
|
|
566
569
|
accessory.addService(this.televisionService);
|
|
567
570
|
|
|
568
571
|
//Prepare speaker service
|
|
@@ -629,6 +632,7 @@ class XBOXDEVICE {
|
|
|
629
632
|
};
|
|
630
633
|
});
|
|
631
634
|
|
|
635
|
+
this.services.push(this.speakerService);
|
|
632
636
|
accessory.addService(this.speakerService);
|
|
633
637
|
|
|
634
638
|
//Prepare volume service
|
|
@@ -653,6 +657,7 @@ class XBOXDEVICE {
|
|
|
653
657
|
this.speakerService.setCharacteristic(Characteristic.Mute, !state);
|
|
654
658
|
});
|
|
655
659
|
|
|
660
|
+
this.services.push(this.volumeService);
|
|
656
661
|
accessory.addService(this.volumeService);
|
|
657
662
|
}
|
|
658
663
|
|
|
@@ -675,6 +680,7 @@ class XBOXDEVICE {
|
|
|
675
680
|
this.speakerService.setCharacteristic(Characteristic.Mute, !state);
|
|
676
681
|
});
|
|
677
682
|
|
|
683
|
+
this.services.push(this.volumeServiceFan);
|
|
678
684
|
accessory.addService(this.volumeServiceFan);
|
|
679
685
|
}
|
|
680
686
|
}
|
|
@@ -682,34 +688,40 @@ class XBOXDEVICE {
|
|
|
682
688
|
//prepare sensor service
|
|
683
689
|
if (this.sensorPower) {
|
|
684
690
|
this.log.debug('prepareSensorPowerService')
|
|
685
|
-
this.sensorPowerService = new Service.
|
|
686
|
-
this.sensorPowerService.getCharacteristic(Characteristic.
|
|
691
|
+
this.sensorPowerService = new Service.ContactSensor(`${accessoryName} Power Sensor`, `Power Sensor`);
|
|
692
|
+
this.sensorPowerService.getCharacteristic(Characteristic.ContactSensorState)
|
|
687
693
|
.onGet(async () => {
|
|
688
694
|
const state = this.power;
|
|
689
695
|
return state;
|
|
690
696
|
});
|
|
697
|
+
|
|
698
|
+
this.services.push(this.sensorPowerService);
|
|
691
699
|
accessory.addService(this.sensorPowerService);
|
|
692
700
|
};
|
|
693
701
|
|
|
694
702
|
if (this.sensorInput) {
|
|
695
703
|
this.log.debug('prepareSensorInputService')
|
|
696
|
-
this.sensorInputService = new Service.
|
|
697
|
-
this.sensorInputService.getCharacteristic(Characteristic.
|
|
704
|
+
this.sensorInputService = new Service.ContactSensor(`${accessoryName} Input Sensor`, `Input Sensor`);
|
|
705
|
+
this.sensorInputService.getCharacteristic(Characteristic.ContactSensorState)
|
|
698
706
|
.onGet(async () => {
|
|
699
707
|
const state = this.power ? this.sensorInputState : false;
|
|
700
708
|
return state;
|
|
701
709
|
});
|
|
710
|
+
|
|
711
|
+
this.services.push(this.sensorInputService);
|
|
702
712
|
accessory.addService(this.sensorInputService);
|
|
703
713
|
};
|
|
704
714
|
|
|
705
715
|
if (this.sensorScreenSaver) {
|
|
706
716
|
this.log.debug('prepareSensorScreenSaverService')
|
|
707
|
-
this.sensorScreenSaverService = new Service.
|
|
708
|
-
this.sensorScreenSaverService.getCharacteristic(Characteristic.
|
|
717
|
+
this.sensorScreenSaverService = new Service.ContactSensor(`${accessoryName} Screen Saver Sensor`, `Screen Saver Sensor`);
|
|
718
|
+
this.sensorScreenSaverService.getCharacteristic(Characteristic.ContactSensorState)
|
|
709
719
|
.onGet(async () => {
|
|
710
720
|
const state = this.power ? this.sensorScreenSaverState : false;
|
|
711
721
|
return state;
|
|
712
722
|
});
|
|
723
|
+
|
|
724
|
+
this.services.push(this.sensorScreenSaverService);
|
|
713
725
|
accessory.addService(this.sensorScreenSaverService);
|
|
714
726
|
};
|
|
715
727
|
|
|
@@ -738,7 +750,8 @@ class XBOXDEVICE {
|
|
|
738
750
|
//check possible inputs and possible inputs count (max 80)
|
|
739
751
|
const inputs = filteredInputsArr;
|
|
740
752
|
const inputsCount = inputs.length;
|
|
741
|
-
const
|
|
753
|
+
const possibleInputsCount = 90 - this.services.length;
|
|
754
|
+
const maxInputsCount = inputsCount >= possibleInputsCount ? possibleInputsCount : inputsCount;
|
|
742
755
|
for (let i = 0; i < maxInputsCount; i++) {
|
|
743
756
|
//get input
|
|
744
757
|
const input = inputs[i];
|
|
@@ -812,6 +825,7 @@ class XBOXDEVICE {
|
|
|
812
825
|
this.inputsName.push(inputName);
|
|
813
826
|
|
|
814
827
|
this.televisionService.addLinkedService(inputService);
|
|
828
|
+
this.services.push(inputService);
|
|
815
829
|
accessory.addService(inputService);
|
|
816
830
|
} else {
|
|
817
831
|
this.log(`Device: ${this.host} ${accessoryName}, Input Name: ${inputName ? inputName : 'Missing'}, Reference: ${inputReference ? inputReference : 'Missing'}.`);
|
|
@@ -822,8 +836,8 @@ class XBOXDEVICE {
|
|
|
822
836
|
//prepare sonsor service
|
|
823
837
|
const sensorInputs = this.sensorInputs;
|
|
824
838
|
const sensorInputsCount = sensorInputs.length;
|
|
825
|
-
const possibleSensorInputsCount =
|
|
826
|
-
const maxSensorInputsCount =
|
|
839
|
+
const possibleSensorInputsCount = 90 - this.services.length;
|
|
840
|
+
const maxSensorInputsCount = sensorInputsCount >= possibleSensorInputsCount ? possibleSensorInputsCount : sensorInputsCount;
|
|
827
841
|
if (maxSensorInputsCount > 0) {
|
|
828
842
|
this.log.debug('prepareInputSensorServices');
|
|
829
843
|
for (let i = 0; i < maxSensorInputsCount; i++) {
|
|
@@ -853,6 +867,7 @@ class XBOXDEVICE {
|
|
|
853
867
|
this.sensorInputsReference.push(sensorInputReference);
|
|
854
868
|
this.sensorInputsDisplayType.push(sensorInputDisplayType);
|
|
855
869
|
this.sensorInputsServices.push(sensorInputService);
|
|
870
|
+
this.services.push(sensorInputService);
|
|
856
871
|
accessory.addService(this.sensorInputsServices[i]);
|
|
857
872
|
} else {
|
|
858
873
|
this.log(`Device: ${this.host} ${accessoryName}, Sensor Name: ${sensorInputName ? sensorInputName : 'Missing'}, Reference: ${sensorInputReference ? sensorInputReference : 'Missing'}.`);
|
|
@@ -864,8 +879,8 @@ class XBOXDEVICE {
|
|
|
864
879
|
//Prepare buttons services
|
|
865
880
|
const buttons = this.buttons;
|
|
866
881
|
const buttonsCount = buttons.length;
|
|
867
|
-
const possibleButtonsCount =
|
|
868
|
-
const maxButtonsCount =
|
|
882
|
+
const possibleButtonsCount = 90 - this.services.length;
|
|
883
|
+
const maxButtonsCount = buttonsCount >= possibleButtonsCount ? possibleButtonsCount : buttonsCount;
|
|
869
884
|
if (maxButtonsCount > 0) {
|
|
870
885
|
this.log.debug('prepareInputsButtonService');
|
|
871
886
|
for (let i = 0; i < maxButtonsCount; i++) {
|
|
@@ -953,6 +968,7 @@ class XBOXDEVICE {
|
|
|
953
968
|
};
|
|
954
969
|
});
|
|
955
970
|
this.buttonsServices.push(buttonService);
|
|
971
|
+
this.services.push(buttonService);
|
|
956
972
|
accessory.addService(this.buttonsServices[i]);
|
|
957
973
|
} else {
|
|
958
974
|
this.log(`Device: ${this.host} ${accessoryName}, Button Name: ${buttonName ? buttonName : 'Missing'}, Command: ${buttonCommand ? buttonCommand : 'Missing'}, Mode: ${buttonMode ? buttonMode : 'Missing'}.`);
|
package/package.json
CHANGED