homebridge-xbox-tv 2.7.5 → 2.7.6
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 +21 -14
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -719,13 +719,13 @@ class XBOXDEVICE {
|
|
|
719
719
|
const input = inputs[i];
|
|
720
720
|
|
|
721
721
|
//get title Id
|
|
722
|
-
const inputTitleId = input.titleId || '
|
|
722
|
+
const inputTitleId = input.titleId || 'Not set';
|
|
723
723
|
|
|
724
724
|
//get input reference
|
|
725
|
-
const inputReference = input.reference || '
|
|
725
|
+
const inputReference = input.reference || 'Not set';
|
|
726
726
|
|
|
727
727
|
//get input oneStoreProductId
|
|
728
|
-
const inputOneStoreProductId = this.webApiEnabled ? input.oneStoreProductId || '
|
|
728
|
+
const inputOneStoreProductId = this.webApiEnabled ? input.oneStoreProductId || 'Not set' : 'Not set';
|
|
729
729
|
|
|
730
730
|
//get input name
|
|
731
731
|
const inputName = savedInputsNames[inputTitleId] ? savedInputsNames[inputTitleId] : savedInputsNames[inputReference] ? savedInputsNames[inputReference] : savedInputsNames[inputOneStoreProductId] ? savedInputsNames[inputOneStoreProductId] : input.name;
|
|
@@ -743,21 +743,24 @@ class XBOXDEVICE {
|
|
|
743
743
|
const inputService = new Service.InputSource(inputName, `Input ${i}`);
|
|
744
744
|
inputService
|
|
745
745
|
.setCharacteristic(Characteristic.Identifier, i)
|
|
746
|
-
.setCharacteristic(Characteristic.
|
|
746
|
+
.setCharacteristic(Characteristic.Name, inputName)
|
|
747
747
|
.setCharacteristic(Characteristic.IsConfigured, isConfigured)
|
|
748
748
|
.setCharacteristic(Characteristic.InputSourceType, inputType)
|
|
749
749
|
.setCharacteristic(Characteristic.CurrentVisibilityState, currentVisibility)
|
|
750
|
-
.setCharacteristic(Characteristic.TargetVisibilityState, targetVisibility);
|
|
751
750
|
|
|
752
|
-
inputService
|
|
753
|
-
.
|
|
751
|
+
inputService.getCharacteristic(Characteristic.ConfiguredName)
|
|
752
|
+
.onGet(async () => {
|
|
753
|
+
return inputName;
|
|
754
|
+
})
|
|
754
755
|
.onSet(async (name) => {
|
|
755
756
|
try {
|
|
756
757
|
const nameIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
|
|
757
758
|
savedInputsNames[nameIdentifier] = name;
|
|
759
|
+
|
|
758
760
|
const newCustomName = JSON.stringify(savedInputsNames, null, 2);
|
|
759
|
-
|
|
760
|
-
const
|
|
761
|
+
await fsPromises.writeFile(this.inputsNamesFile, newCustomName);
|
|
762
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved new Input name: ${name}, one store product id: ${inputOneStoreProductId}`) : false;
|
|
763
|
+
inputService.setCharacteristic(Characteristic.Name, inputName);
|
|
761
764
|
} catch (error) {
|
|
762
765
|
this.log.error(`Device: ${this.host} ${accessoryName}, new Input name save error: ${error}`);
|
|
763
766
|
}
|
|
@@ -765,13 +768,17 @@ class XBOXDEVICE {
|
|
|
765
768
|
|
|
766
769
|
inputService
|
|
767
770
|
.getCharacteristic(Characteristic.TargetVisibilityState)
|
|
771
|
+
.onGet(async () => {
|
|
772
|
+
return targetVisibility;
|
|
773
|
+
})
|
|
768
774
|
.onSet(async (state) => {
|
|
769
775
|
try {
|
|
770
776
|
const targetVisibilityIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
|
|
771
777
|
savedInputsTargetVisibility[targetVisibilityIdentifier] = state;
|
|
778
|
+
|
|
772
779
|
const newTargetVisibility = JSON.stringify(savedInputsTargetVisibility, null, 2);
|
|
773
|
-
|
|
774
|
-
const
|
|
780
|
+
await fsPromises.writeFile(this.inputsTargetVisibilityFile, newTargetVisibility);
|
|
781
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved new Input: ${inputName} target visibility state: ${state ? 'HIDEN' : 'SHOWN'}`) : false;
|
|
775
782
|
inputService.setCharacteristic(Characteristic.CurrentVisibilityState, state);
|
|
776
783
|
} catch (error) {
|
|
777
784
|
this.log.error(`Device: ${this.host} ${accessoryName}, new target visibility state save error: ${error}`);
|
|
@@ -856,7 +863,7 @@ class XBOXDEVICE {
|
|
|
856
863
|
buttonService.getCharacteristic(Characteristic.On)
|
|
857
864
|
.onGet(async () => {
|
|
858
865
|
const state = false;
|
|
859
|
-
const
|
|
866
|
+
const logDebug = this.disableLogInfo ? this.log(`Device: ${this.host} ${accessoryName}, get Button state successful: ${state}`) : false;
|
|
860
867
|
return state;
|
|
861
868
|
})
|
|
862
869
|
.onSet(async (state) => {
|
|
@@ -908,7 +915,7 @@ class XBOXDEVICE {
|
|
|
908
915
|
}
|
|
909
916
|
break;
|
|
910
917
|
}
|
|
911
|
-
const
|
|
918
|
+
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, set button successful, name: ${buttonName}, command: ${buttonCommand}`) : false;
|
|
912
919
|
}
|
|
913
920
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
914
921
|
const setChar = this.power && state ? buttonService.updateCharacteristic(Characteristic.On, false) : false;
|
|
@@ -925,4 +932,4 @@ class XBOXDEVICE {
|
|
|
925
932
|
this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
|
|
926
933
|
const debug3 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, published as external accessory.`) : false;
|
|
927
934
|
}
|
|
928
|
-
};
|
|
935
|
+
};
|
package/package.json
CHANGED