homebridge-xbox-tv 2.12.13 → 2.12.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 +11 -12
package/package.json
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -274,8 +274,6 @@ class XboxDevice extends EventEmitter {
|
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
if (reference !== undefined) {
|
|
277
|
-
this.reference = reference;
|
|
278
|
-
|
|
279
277
|
if (this.sensorScreenSaverService) {
|
|
280
278
|
const state = power ? (reference === 'Xbox.IdleScreen_8wekyb3d8bbwe!Xbox.IdleScreen.Application') : false;
|
|
281
279
|
this.sensorScreenSaverService
|
|
@@ -293,6 +291,7 @@ class XboxDevice extends EventEmitter {
|
|
|
293
291
|
.updateCharacteristic(characteristicType, state);
|
|
294
292
|
}
|
|
295
293
|
}
|
|
294
|
+
this.reference = reference;
|
|
296
295
|
}
|
|
297
296
|
|
|
298
297
|
this.inputIdentifier = inputIdentifier;
|
|
@@ -320,7 +319,7 @@ class XboxDevice extends EventEmitter {
|
|
|
320
319
|
//read dev info from file
|
|
321
320
|
try {
|
|
322
321
|
const data = await fsPromises.readFile(this.devInfoFile);
|
|
323
|
-
this.savedInfo = data.
|
|
322
|
+
this.savedInfo = data.toString().trim() !== '' ? JSON.parse(data) : {};
|
|
324
323
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Info: ${JSON.stringify(this.savedInfo, null, 2)}`);
|
|
325
324
|
} catch (error) {
|
|
326
325
|
this.emit('error', `read saved Info error: ${error}`);
|
|
@@ -329,7 +328,7 @@ class XboxDevice extends EventEmitter {
|
|
|
329
328
|
//read inputs file
|
|
330
329
|
try {
|
|
331
330
|
const data = await fsPromises.readFile(this.inputsFile);
|
|
332
|
-
this.savedInputs = data.
|
|
331
|
+
this.savedInputs = data.toString().trim() !== '' ? JSON.parse(data) : this.inputs;
|
|
333
332
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs: ${JSON.stringify(this.savedInputs, null, 2)}`);
|
|
334
333
|
} catch (error) {
|
|
335
334
|
this.emit('error', `read saved Inputs error: ${error}`);
|
|
@@ -338,7 +337,7 @@ class XboxDevice extends EventEmitter {
|
|
|
338
337
|
//read inputs names from file
|
|
339
338
|
try {
|
|
340
339
|
const data = await fsPromises.readFile(this.inputsNamesFile);
|
|
341
|
-
this.savedInputsNames = data.
|
|
340
|
+
this.savedInputsNames = data.toString().trim() !== '' ? JSON.parse(data) : {};
|
|
342
341
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs Names: ${JSON.stringify(this.savedInputsNames, null, 2)}`);
|
|
343
342
|
} catch (error) {
|
|
344
343
|
this.emit('error', `read saved Inputs Names error: ${error}`);
|
|
@@ -347,7 +346,7 @@ class XboxDevice extends EventEmitter {
|
|
|
347
346
|
//read inputs visibility from file
|
|
348
347
|
try {
|
|
349
348
|
const data = await fsPromises.readFile(this.inputsTargetVisibilityFile);
|
|
350
|
-
this.savedInputsTargetVisibility = data.
|
|
349
|
+
this.savedInputsTargetVisibility = data.toString().trim() !== '' ? JSON.parse(data) : {};
|
|
351
350
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs Target Visibility: ${JSON.stringify(this.savedInputsTargetVisibility, null, 2)}`);
|
|
352
351
|
} catch (error) {
|
|
353
352
|
this.emit('error', `read saved Inputs Target Visibility error: ${error}`);
|
|
@@ -977,12 +976,12 @@ class XboxDevice extends EventEmitter {
|
|
|
977
976
|
|
|
978
977
|
if (sensorInputDisplayType >= 0) {
|
|
979
978
|
if (sensorInputName && sensorInputReference) {
|
|
979
|
+
const serviceName = namePrefix ? `${accessoryName} ${sensorInputName}` : sensorInputName;
|
|
980
980
|
const serviceType = [Service.MotionSensor, Service.OccupancySensor, Service.ContactSensor][sensorInputDisplayType];
|
|
981
|
-
const name = namePrefix ? `${accessoryName} ${sensorInputName}` : sensorInputName;
|
|
982
981
|
const characteristicType = [Characteristic.MotionDetected, Characteristic.OccupancyDetected, Characteristic.ContactSensorState][sensorInputDisplayType];
|
|
983
|
-
const sensorInputService = new serviceType(
|
|
982
|
+
const sensorInputService = new serviceType(serviceName, `Sensor ${i}`);
|
|
984
983
|
sensorInputService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
985
|
-
sensorInputService.setCharacteristic(Characteristic.ConfiguredName,
|
|
984
|
+
sensorInputService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
986
985
|
sensorInputService.getCharacteristic(characteristicType)
|
|
987
986
|
.onGet(async () => {
|
|
988
987
|
const state = this.power ? (this.reference === sensorInputReference) : false;
|
|
@@ -1045,11 +1044,11 @@ class XboxDevice extends EventEmitter {
|
|
|
1045
1044
|
|
|
1046
1045
|
if (buttonDisplayType >= 0) {
|
|
1047
1046
|
if (buttonName && buttonCommand && buttonMode) {
|
|
1047
|
+
const serviceName = namePrefix ? `${accessoryName} ${buttonName}` : buttonName;
|
|
1048
1048
|
const serviceType = [Service.Outlet, Service.Switch][buttonDisplayType];
|
|
1049
|
-
const
|
|
1050
|
-
const buttonService = new serviceType(`${accessoryName} ${buttonName}`, `Button ${i}`);
|
|
1049
|
+
const buttonService = new serviceType(serviceName, `Button ${i}`);
|
|
1051
1050
|
buttonService.addOptionalCharacteristic(Characteristic.ConfiguredName);
|
|
1052
|
-
buttonService.setCharacteristic(Characteristic.ConfiguredName,
|
|
1051
|
+
buttonService.setCharacteristic(Characteristic.ConfiguredName, serviceName);
|
|
1053
1052
|
buttonService.getCharacteristic(Characteristic.On)
|
|
1054
1053
|
.onGet(async () => {
|
|
1055
1054
|
const state = false;
|