homebridge-xbox-tv 2.7.7-beta.2 → 2.7.7-beta.4
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 +24 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -129,17 +129,23 @@ class XBOXDEVICE {
|
|
|
129
129
|
|
|
130
130
|
this.prefDir = path.join(api.user.storagePath(), 'xboxTv');
|
|
131
131
|
this.authTokenFile = `${this.prefDir}/authToken_${this.host.split('.').join('')}`;
|
|
132
|
+
this.inputsFile = `${this.prefDir}/inputs_${this.host.split('.').join('')}`;
|
|
132
133
|
this.inputsNamesFile = `${this.prefDir}/inputsNames_${this.host.split('.').join('')}`;
|
|
133
134
|
this.inputsTargetVisibilityFile = `${this.prefDir}/inputsTargetVisibility_${this.host.split('.').join('')}`;
|
|
134
135
|
|
|
135
136
|
//check if the directory or files exists, if not then create it
|
|
136
137
|
const object = JSON.stringify({});
|
|
138
|
+
const array = JSON.stringify([]);
|
|
139
|
+
|
|
137
140
|
if (!fs.existsSync(this.prefDir)) {
|
|
138
141
|
fs.mkdirSync(this.prefDir);
|
|
139
142
|
}
|
|
140
143
|
if (!fs.existsSync(this.authTokenFile)) {
|
|
141
144
|
fs.writeFileSync(this.authTokenFile, object);
|
|
142
145
|
}
|
|
146
|
+
if (!fs.existsSync(this.inputsFile)) {
|
|
147
|
+
fs.writeFileSync(this.inputsFile, array);
|
|
148
|
+
}
|
|
143
149
|
if (!fs.existsSync(this.inputsNamesFile)) {
|
|
144
150
|
fs.writeFileSync(this.inputsNamesFile, object);
|
|
145
151
|
}
|
|
@@ -326,7 +332,14 @@ class XBOXDEVICE {
|
|
|
326
332
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Consoles List', JSON.stringify(consolesList, null, 2)) : false;
|
|
327
333
|
})
|
|
328
334
|
.on('appsList', async (appsArray) => {
|
|
329
|
-
|
|
335
|
+
try {
|
|
336
|
+
const apps = JSON.stringify([...CONSTANS.DefaultInputs, ...appsArray], null, 2);
|
|
337
|
+
await fsPromises.writeFile(this.inputsFile, apps);
|
|
338
|
+
const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, saved apps: ${apps}`) : false;
|
|
339
|
+
const mqtt = this.mqttEnabled ? this.mqtt.send('Apps', JSON.stringify(apps, null, 2)) : false;
|
|
340
|
+
} catch (error) {
|
|
341
|
+
this.log.error(`Device: ${this.host} ${this.name}, save apps error: ${error}`);
|
|
342
|
+
};
|
|
330
343
|
})
|
|
331
344
|
.on('storageDevices', (storageDevices) => {
|
|
332
345
|
const mqtt = this.mqttEnabled ? this.mqtt.send('Storages', JSON.stringify(storageDevices, null, 2)) : false;
|
|
@@ -381,7 +394,11 @@ class XBOXDEVICE {
|
|
|
381
394
|
this.log.debug('prepareTelevisionService');
|
|
382
395
|
this.televisionService = new Service.Television(`${accessoryName} Television`, 'Television');
|
|
383
396
|
this.televisionService.setCharacteristic(Characteristic.ConfiguredName, accessoryName);
|
|
384
|
-
this.televisionService.setCharacteristic(Characteristic.SleepDiscoveryMode
|
|
397
|
+
this.televisionService.setCharacteristic(Characteristic.SleepDiscoveryMode)
|
|
398
|
+
.onGet(async () => {
|
|
399
|
+
const state = 1; //not discoverable, alvays discoverable
|
|
400
|
+
return state;
|
|
401
|
+
})
|
|
385
402
|
|
|
386
403
|
this.televisionService.getCharacteristic(Characteristic.Active)
|
|
387
404
|
.onGet(async () => {
|
|
@@ -672,6 +689,9 @@ class XBOXDEVICE {
|
|
|
672
689
|
|
|
673
690
|
//Prepare inputs services
|
|
674
691
|
this.log.debug('prepareInputServices');
|
|
692
|
+
const savedInputs = this.getInputsFromDevice ? fs.readFileSync(this.inputsFile).length > 2 ? JSON.parse(fs.readFileSync(this.inputsFile)) : this.inputs : this.inputs;
|
|
693
|
+
const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs: ${JSON.stringify(savedInputs, null, 2)}`) : false;
|
|
694
|
+
|
|
675
695
|
const savedInputsNames = fs.readFileSync(this.inputsNamesFile).length > 2 ? JSON.parse(fs.readFileSync(this.inputsNamesFile)) : {};
|
|
676
696
|
const debug1 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, read saved Inputs names: ${JSON.stringify(savedInputsNames, null, 2)}`) : false;
|
|
677
697
|
|
|
@@ -680,7 +700,7 @@ class XBOXDEVICE {
|
|
|
680
700
|
|
|
681
701
|
//check possible inputs and filter custom unnecessary inputs
|
|
682
702
|
const filteredInputsArr = [];
|
|
683
|
-
for (const input of
|
|
703
|
+
for (const input of savedInputs) {
|
|
684
704
|
const contentType = input.contentType;
|
|
685
705
|
const filterGames = this.filterGames ? (contentType === 'Game') : false;
|
|
686
706
|
const filterApps = this.filterApps ? (contentType === 'App') : false;
|
|
@@ -773,7 +793,7 @@ class XBOXDEVICE {
|
|
|
773
793
|
this.televisionService.addLinkedService(inputService);
|
|
774
794
|
accessory.addService(inputService);
|
|
775
795
|
} else {
|
|
776
|
-
this.log(`Device: ${this.host} ${accessoryName}, name: ${inputName}, reference: ${inputReference}
|
|
796
|
+
this.log(`Device: ${this.host} ${accessoryName}, Input name: ${inputName ? inputName : 'Missing'}, reference: ${inputReference ? inputReference : 'Missing'}.`);
|
|
777
797
|
|
|
778
798
|
};
|
|
779
799
|
}
|
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.7-beta.
|
|
4
|
+
"version": "2.7.7-beta.4",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|