homebridge-xbox-tv 3.3.8 → 3.3.9-beta.1
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/CHANGELOG.md +1 -1
- package/index.js +3 -0
- package/package.json +1 -1
- package/src/xboxdevice.js +39 -33
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -113,6 +113,9 @@ class XboxPlatform {
|
|
|
113
113
|
try {
|
|
114
114
|
const startDone = await xboxDevice.start();
|
|
115
115
|
const stopImpulseGenerator = startDone ? await impulseGenerator.stop() : false;
|
|
116
|
+
|
|
117
|
+
//start xbox device impulse generator
|
|
118
|
+
const startImpulseGenerator = startDone ? await xboxDevice.startImpulseGenerator() : false;
|
|
116
119
|
} catch (error) {
|
|
117
120
|
const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
|
|
118
121
|
};
|
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -41,18 +41,17 @@ class XboxDevice extends EventEmitter {
|
|
|
41
41
|
this.sensorInputs = device.sensorInputs || [];
|
|
42
42
|
this.webApiClientId = device.webApiClientId;
|
|
43
43
|
this.webApiClientSecret = device.webApiClientSecret;
|
|
44
|
-
this.enableDebugMode = device.enableDebugMode || false;
|
|
45
|
-
this.disableLogInfo = device.disableLogInfo || false;
|
|
46
44
|
this.infoButtonCommand = device.infoButtonCommand || 'nexus';
|
|
47
45
|
this.volumeControl = device.volumeControl || false;
|
|
48
46
|
this.volumeControlNamePrefix = device.volumeControlNamePrefix || false;
|
|
49
47
|
this.volumeControlName = device.volumeControlName || 'Volume';
|
|
48
|
+
this.enableDebugMode = device.enableDebugMode || false;
|
|
49
|
+
this.disableLogInfo = device.disableLogInfo || false;
|
|
50
50
|
this.authTokenFile = authTokenFile;
|
|
51
51
|
this.devInfoFile = devInfoFile;
|
|
52
52
|
this.inputsFile = inputsFile;
|
|
53
53
|
this.inputsNamesFile = inputsNamesFile;
|
|
54
54
|
this.inputsTargetVisibilityFile = inputsTargetVisibilityFile;
|
|
55
|
-
this.startPrepareAccessory = true;
|
|
56
55
|
|
|
57
56
|
//external integrations
|
|
58
57
|
this.restFul = device.restFul ?? {};
|
|
@@ -60,10 +59,6 @@ class XboxDevice extends EventEmitter {
|
|
|
60
59
|
this.mqtt = device.mqtt ?? {};
|
|
61
60
|
this.mqttConnected = false;
|
|
62
61
|
|
|
63
|
-
//accessory services
|
|
64
|
-
this.allServices = [];
|
|
65
|
-
this.sensorsInputsServices = [];
|
|
66
|
-
this.buttonsServices = [];
|
|
67
62
|
|
|
68
63
|
//add configured inputs to the default inputs and chack duplicated inputs
|
|
69
64
|
const tempInputs = [...DefaultInputs, ...this.inputs];
|
|
@@ -76,17 +71,7 @@ class XboxDevice extends EventEmitter {
|
|
|
76
71
|
}
|
|
77
72
|
this.inputs = inputsArr;
|
|
78
73
|
|
|
79
|
-
|
|
80
|
-
this.inputIdentifier = 1;
|
|
81
|
-
|
|
82
|
-
//state variable
|
|
83
|
-
this.power = false;
|
|
84
|
-
this.volume = 0;
|
|
85
|
-
this.mute = true;
|
|
86
|
-
this.mediaState = 0;
|
|
87
|
-
this.reference = '';
|
|
88
|
-
|
|
89
|
-
//sensors variable
|
|
74
|
+
//sensors
|
|
90
75
|
this.sensorsInputsConfigured = [];
|
|
91
76
|
for (const sensor of this.sensorInputs) {
|
|
92
77
|
const sensorInputName = sensor.name ?? false;
|
|
@@ -102,10 +87,8 @@ class XboxDevice extends EventEmitter {
|
|
|
102
87
|
};
|
|
103
88
|
}
|
|
104
89
|
this.sensorsInputsConfiguredCount = this.sensorsInputsConfigured.length || 0;
|
|
105
|
-
this.sensorScreenSaverState = false;
|
|
106
|
-
this.sensorInputState = false;
|
|
107
90
|
|
|
108
|
-
//buttons
|
|
91
|
+
//buttons
|
|
109
92
|
this.buttonsConfigured = [];
|
|
110
93
|
for (const button of this.buttons) {
|
|
111
94
|
const buttonName = button.name ?? false;
|
|
@@ -121,6 +104,22 @@ class XboxDevice extends EventEmitter {
|
|
|
121
104
|
};
|
|
122
105
|
}
|
|
123
106
|
this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
|
|
107
|
+
|
|
108
|
+
//variable
|
|
109
|
+
this.allServices = [];
|
|
110
|
+
this.sensorsInputsServices = [];
|
|
111
|
+
this.buttonsServices = [];
|
|
112
|
+
this.inputsConfigured = [];
|
|
113
|
+
this.inputIdentifier = 1;
|
|
114
|
+
this.startPrepareAccessory = true;
|
|
115
|
+
this.power = false;
|
|
116
|
+
this.volume = 0;
|
|
117
|
+
this.mute = true;
|
|
118
|
+
this.mediaState = 0;
|
|
119
|
+
this.reference = '';
|
|
120
|
+
this.sensorScreenSaverState = false;
|
|
121
|
+
this.sensorInputState = false;
|
|
122
|
+
this.consoleAuthorized = false;
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
async saveData(path, data) {
|
|
@@ -357,17 +356,30 @@ class XboxDevice extends EventEmitter {
|
|
|
357
356
|
}
|
|
358
357
|
}
|
|
359
358
|
|
|
359
|
+
async startImpulseGenerator() {
|
|
360
|
+
try {
|
|
361
|
+
//start web api impulse generator
|
|
362
|
+
const startImpulseGenerator = this.consoleAuthorized ? await this.xboxWebApi.impulseGenerator.start([{ name: 'checkAuthorization', sampling: 900000 }]) : false;
|
|
363
|
+
|
|
364
|
+
//start local api impulse generator
|
|
365
|
+
await this.xboxLocalApi.impulseGenerator.start([{ name: 'heartBeat', sampling: 10000 }]);
|
|
366
|
+
return true;
|
|
367
|
+
} catch (error) {
|
|
368
|
+
throw new Error(`Impulse generator start error: ${error}`);
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
360
372
|
//Prepare accessory
|
|
361
373
|
async prepareAccessory() {
|
|
362
374
|
try {
|
|
363
|
-
//
|
|
375
|
+
//Accessory
|
|
364
376
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Prepare accessory`);
|
|
365
377
|
const accessoryName = this.name;
|
|
366
378
|
const accessoryUUID = AccessoryUUID.generate(this.xboxLiveId);
|
|
367
379
|
const accessoryCategory = Categories.TV_SET_TOP_BOX;
|
|
368
380
|
const accessory = new Accessory(accessoryName, accessoryUUID, accessoryCategory);
|
|
369
381
|
|
|
370
|
-
//
|
|
382
|
+
//Prepare information service
|
|
371
383
|
this.informationService = accessory.getService(Service.AccessoryInformation)
|
|
372
384
|
.setCharacteristic(Characteristic.Manufacturer, this.savedInfo.manufacturer ?? 'Microsoft')
|
|
373
385
|
.setCharacteristic(Characteristic.Model, this.savedInfo.modelName ?? 'Xbox')
|
|
@@ -653,7 +665,7 @@ class XboxDevice extends EventEmitter {
|
|
|
653
665
|
}
|
|
654
666
|
|
|
655
667
|
try {
|
|
656
|
-
switch (
|
|
668
|
+
switch (state) {
|
|
657
669
|
case 0: //Mute
|
|
658
670
|
await this.xboxWebApi.send('Audio', 'Mute');
|
|
659
671
|
break;
|
|
@@ -885,7 +897,7 @@ class XboxDevice extends EventEmitter {
|
|
|
885
897
|
sensorInputService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
886
898
|
sensorInputService.getCharacteristic(characteristicType)
|
|
887
899
|
.onGet(async () => {
|
|
888
|
-
const state = sensorInput.state
|
|
900
|
+
const state = sensorInput.state;
|
|
889
901
|
return state;
|
|
890
902
|
});
|
|
891
903
|
this.sensorsInputsServices.push(sensorInputService);
|
|
@@ -1045,11 +1057,8 @@ class XboxDevice extends EventEmitter {
|
|
|
1045
1057
|
});
|
|
1046
1058
|
|
|
1047
1059
|
//check authorization
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
//start impulse generator
|
|
1051
|
-
const timers = [{ name: 'checkAuthorization', sampling: 900000 }];
|
|
1052
|
-
const startImpulseGenerator = checkAuthorization ? await this.xboxWebApi.impulseGenerator.start(timers) : false;
|
|
1060
|
+
const consoleAuthorized = await this.xboxWebApi.checkAuthorization();
|
|
1061
|
+
this.consoleAuthorized = consoleAuthorized;
|
|
1053
1062
|
} catch (error) {
|
|
1054
1063
|
this.emit('error', `Start web api error: ${error}`);
|
|
1055
1064
|
};
|
|
@@ -1209,9 +1218,6 @@ class XboxDevice extends EventEmitter {
|
|
|
1209
1218
|
const accessory = await this.prepareAccessory();
|
|
1210
1219
|
this.emit('publishAccessory', accessory);
|
|
1211
1220
|
this.startPrepareAccessory = false;
|
|
1212
|
-
|
|
1213
|
-
//start impulse generator
|
|
1214
|
-
await this.xboxLocalApi.impulseGenerator.start([{ name: 'heartBeat', sampling: 10000 }]);
|
|
1215
1221
|
}
|
|
1216
1222
|
|
|
1217
1223
|
return true;
|