homebridge-xbox-tv 2.13.13 → 2.13.15
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/package.json +1 -1
- package/src/xboxdevice.js +15 -14
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -84,7 +84,7 @@ class XboxDevice extends EventEmitter {
|
|
|
84
84
|
const sensorInputName = sensor.name ?? false;
|
|
85
85
|
const sensorInputReference = sensor.reference ?? false;
|
|
86
86
|
const sensorInputDisplayType = sensor.displayType ?? 0;
|
|
87
|
-
if (sensorInputName && sensorInputReference
|
|
87
|
+
if (sensorInputName && sensorInputReference && sensorInputDisplayType > 0) {
|
|
88
88
|
sensor.serviceType = ['', Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType];
|
|
89
89
|
sensor.characteristicType = ['', Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorInputDisplayType];
|
|
90
90
|
sensor.state = false;
|
|
@@ -104,7 +104,7 @@ class XboxDevice extends EventEmitter {
|
|
|
104
104
|
const buttonMode = button.mode ?? -1;
|
|
105
105
|
const buttonReferenceCommand = [button.reference, button.command][buttonMode] ?? false;
|
|
106
106
|
const buttonDisplayType = button.displayType ?? 0;
|
|
107
|
-
if (buttonName &&
|
|
107
|
+
if (buttonName && buttonMode >= 0 && buttonReferenceCommand && buttonDisplayType > 0) {
|
|
108
108
|
button.serviceType = ['', Service.Outlet, Service.Switch][buttonDisplayType];
|
|
109
109
|
button.state = false;
|
|
110
110
|
this.buttonsConfigured.push(button);
|
|
@@ -116,18 +116,18 @@ class XboxDevice extends EventEmitter {
|
|
|
116
116
|
|
|
117
117
|
//check files exists, if not then create it
|
|
118
118
|
const postFix = this.host.split('.').join('');
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
const authTokenFile = `${prefDir}/authToken_${postFix}`;
|
|
120
|
+
const devInfoFile = `${prefDir}/devInfo_${postFix}`;
|
|
121
|
+
const inputsFile = `${prefDir}/inputs_${postFix}`;
|
|
122
122
|
this.inputsNamesFile = `${prefDir}/inputsNames_${postFix}`;
|
|
123
123
|
this.inputsTargetVisibilityFile = `${prefDir}/inputsTargetVisibility_${postFix}`;
|
|
124
124
|
|
|
125
125
|
// Create files if it doesn't exist
|
|
126
126
|
try {
|
|
127
127
|
const files = [
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
authTokenFile,
|
|
129
|
+
devInfoFile,
|
|
130
|
+
inputsFile,
|
|
131
131
|
this.inputsNamesFile,
|
|
132
132
|
this.inputsTargetVisibilityFile,
|
|
133
133
|
];
|
|
@@ -147,8 +147,8 @@ class XboxDevice extends EventEmitter {
|
|
|
147
147
|
xboxLiveId: this.xboxLiveId,
|
|
148
148
|
webApiClientId: this.webApiClientId,
|
|
149
149
|
webApiClientSecret: this.webApiClientSecret,
|
|
150
|
-
tokensFile:
|
|
151
|
-
inputsFile:
|
|
150
|
+
tokensFile: authTokenFile,
|
|
151
|
+
inputsFile: inputsFile,
|
|
152
152
|
debugLog: this.enableDebugMode
|
|
153
153
|
});
|
|
154
154
|
|
|
@@ -191,8 +191,8 @@ class XboxDevice extends EventEmitter {
|
|
|
191
191
|
this.xboxLocalApi = new XboxLocalApi({
|
|
192
192
|
host: this.host,
|
|
193
193
|
xboxLiveId: this.xboxLiveId,
|
|
194
|
-
tokensFile:
|
|
195
|
-
devInfoFile:
|
|
194
|
+
tokensFile: authTokenFile,
|
|
195
|
+
devInfoFile: devInfoFile,
|
|
196
196
|
infoLog: this.disableLogInfo,
|
|
197
197
|
debugLog: this.enableDebugMode
|
|
198
198
|
});
|
|
@@ -419,12 +419,12 @@ class XboxDevice extends EventEmitter {
|
|
|
419
419
|
|
|
420
420
|
try {
|
|
421
421
|
//read dev info from file
|
|
422
|
-
const savedInfo = await this.readData(
|
|
422
|
+
const savedInfo = await this.readData(devInfoFile);
|
|
423
423
|
this.savedInfo = savedInfo.toString().trim() !== '' ? JSON.parse(savedInfo) : {};
|
|
424
424
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Info: ${JSON.stringify(this.savedInfo, null, 2)}`);
|
|
425
425
|
|
|
426
426
|
//read inputs file
|
|
427
|
-
const savedInputs = await this.readData(
|
|
427
|
+
const savedInputs = await this.readData(inputsFile);
|
|
428
428
|
this.savedInputs = savedInputs.toString().trim() !== '' ? JSON.parse(savedInputs) : this.inputs;
|
|
429
429
|
const debug2 = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs: ${JSON.stringify(this.savedInputs, null, 2)}`);
|
|
430
430
|
|
|
@@ -1158,6 +1158,7 @@ class XboxDevice extends EventEmitter {
|
|
|
1158
1158
|
}
|
|
1159
1159
|
} catch (error) {
|
|
1160
1160
|
this.emit('error', `set Button error: ${error}`);
|
|
1161
|
+
buttonService.updateCharacteristic(Characteristic.On, false);
|
|
1161
1162
|
};
|
|
1162
1163
|
}
|
|
1163
1164
|
});
|