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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/xboxdevice.js +15 -14
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "2.13.13",
4
+ "version": "2.13.15",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
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 >= 0 && sensorInputDisplayType > 0) {
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 && buttonReferenceCommand && buttonMode >= 0 && buttonDisplayType > 0) {
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
- this.authTokenFile = `${prefDir}/authToken_${postFix}`;
120
- this.devInfoFile = `${prefDir}/devInfo_${postFix}`;
121
- this.inputsFile = `${prefDir}/inputs_${postFix}`;
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
- this.authTokenFile,
129
- this.devInfoFile,
130
- this.inputsFile,
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: this.authTokenFile,
151
- inputsFile: this.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: this.authTokenFile,
195
- devInfoFile: this.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(this.devInfoFile);
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(this.inputsFile);
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
  });