homebridge-xbox-tv 2.7.7 → 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/index.js +94 -85
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -782,7 +782,7 @@ class XBOXDEVICE {
|
|
|
782
782
|
const newCustomName = JSON.stringify(savedInputsNames, null, 2);
|
|
783
783
|
await fsPromises.writeFile(this.inputsNamesFile, newCustomName);
|
|
784
784
|
const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved Input Name: ${value}, Reference: ${nameIdentifier}.`) : false;
|
|
785
|
-
inputService.setCharacteristic(Characteristic.Name,
|
|
785
|
+
inputService.setCharacteristic(Characteristic.Name, value);
|
|
786
786
|
} catch (error) {
|
|
787
787
|
this.log.error(`Device: ${this.host} ${accessoryName}, save Input Name error: ${error}`);
|
|
788
788
|
}
|
|
@@ -831,28 +831,32 @@ class XBOXDEVICE {
|
|
|
831
831
|
const sensorInput = sensorInputs[i];
|
|
832
832
|
|
|
833
833
|
//get sensor name
|
|
834
|
-
const sensorInputName = sensorInput.name
|
|
834
|
+
const sensorInputName = sensorInput.name;
|
|
835
835
|
|
|
836
836
|
//get sensor reference
|
|
837
|
-
const sensorInputReference = sensorInput.reference
|
|
837
|
+
const sensorInputReference = sensorInput.reference;
|
|
838
838
|
|
|
839
839
|
//get sensor display type
|
|
840
840
|
const sensorInputDisplayType = sensorInput.displayType >= 0 ? sensorInput.displayType : -1;
|
|
841
841
|
|
|
842
842
|
if (sensorInputDisplayType >= 0) {
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
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
|
+
};
|
|
856
860
|
}
|
|
857
861
|
}
|
|
858
862
|
}
|
|
@@ -869,85 +873,90 @@ class XBOXDEVICE {
|
|
|
869
873
|
const button = buttons[i];
|
|
870
874
|
|
|
871
875
|
//get button name
|
|
872
|
-
const buttonName = button.name
|
|
876
|
+
const buttonName = button.name;
|
|
873
877
|
|
|
874
878
|
//get button command
|
|
875
|
-
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;
|
|
876
897
|
|
|
877
898
|
//get button inputOneStoreProductId
|
|
878
|
-
const buttonOneStoreProductId = button.oneStoreProductId
|
|
899
|
+
const buttonOneStoreProductId = button.oneStoreProductId;
|
|
879
900
|
|
|
880
901
|
//get button display type
|
|
881
902
|
const buttonDisplayType = button.displayType >= 0 ? button.displayType : -1;
|
|
882
903
|
|
|
883
904
|
if (buttonDisplayType >= 0) {
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
.
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
await this.xboxWebApi.launchOneGuide();
|
|
928
|
-
break;
|
|
929
|
-
case 'XboxGuide':
|
|
930
|
-
await this.xboxWebApi.openGuideTab();
|
|
931
|
-
break;
|
|
932
|
-
case 'Not set': case 'Web api disabled':
|
|
933
|
-
this.log(`Device: ${this.host} ${accessoryName}, trying to launch App/Game with one store product id: ${buttonOneStoreProductId}.`);
|
|
934
|
-
break;
|
|
935
|
-
default:
|
|
936
|
-
await this.xboxWebApi.launchApp(buttonOneStoreProductId);
|
|
937
|
-
break;
|
|
938
|
-
}
|
|
939
|
-
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;
|
|
940
948
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
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
|
+
};
|
|
951
960
|
}
|
|
952
961
|
}
|
|
953
962
|
}
|
package/package.json
CHANGED