homebridge-xbox-tv 2.7.5-beta.0 → 2.7.6

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.
@@ -757,7 +757,7 @@
757
757
  {
758
758
  "key": "devices[].sensorInputs",
759
759
  "type": "tabarray",
760
- "title": "{{ value.name || 'new input sensor' }}",
760
+ "title": "{{ value.name || 'new sensor' }}",
761
761
  "items": [
762
762
  "devices[].sensorInputs[].name",
763
763
  "devices[].sensorInputs[].reference",
package/index.js CHANGED
@@ -87,7 +87,7 @@ class XBOXDEVICE {
87
87
  this.disableLogInfo = config.disableLogInfo || false;
88
88
  this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
89
89
  this.infoButtonCommand = config.infoButtonCommand || 'nexus';
90
- this.volumeControl = config.volumeControl || -1;
90
+ this.volumeControl = config.volumeControl >= 0 ? config.volumeControl : -1;
91
91
  this.mqttEnabled = config.enableMqtt || false;
92
92
  this.mqttDebug = config.mqttDebug || false;
93
93
  this.mqttHost = config.mqttHost;
@@ -408,7 +408,7 @@ class XBOXDEVICE {
408
408
  })
409
409
  .onSet(async (state) => {
410
410
  try {
411
- const setPower = !this.power && state ? await this.xboxLocalApi.powerOn() : this.power && !state ? await this.xboxLocalApi.powerOff() : false;
411
+ const setPower = state ? await this.xboxLocalApi.powerOn() : await this.xboxLocalApi.powerOff();
412
412
  const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power successful: ${state ? 'ON' : 'OFF'}`);
413
413
  } catch (error) {
414
414
  this.log.error(`Device: ${this.host} ${accessoryName}, set Power, error: ${error}`);
@@ -541,7 +541,7 @@ class XBOXDEVICE {
541
541
  };
542
542
 
543
543
  const channelName = 'systemInput';
544
- const setPowerModeSelection = this.power ? this.webApiEnabled ? await this.xboxWebApi.sendButtonPress(command) : await this.xboxWebApi.sendButtonPress(command) : false;
544
+ const setPowerModeSelection = this.power && this.webApiEnabled ? await this.xboxWebApi.sendButtonPress(command) : false;
545
545
  const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, set Power Mode Selection command successful: ${command}`);
546
546
  } catch (error) {
547
547
  this.log.error(`Device: ${this.host} ${accessoryName}, set Power Mode Selection command error: ${error}`);
@@ -719,13 +719,13 @@ class XBOXDEVICE {
719
719
  const input = inputs[i];
720
720
 
721
721
  //get title Id
722
- const inputTitleId = input.titleId || 'undefined';
722
+ const inputTitleId = input.titleId || 'Not set';
723
723
 
724
724
  //get input reference
725
- const inputReference = input.reference || 'undefined';
725
+ const inputReference = input.reference || 'Not set';
726
726
 
727
727
  //get input oneStoreProductId
728
- const inputOneStoreProductId = this.webApiEnabled ? input.oneStoreProductId || 'undefined' : 'undefined';
728
+ const inputOneStoreProductId = this.webApiEnabled ? input.oneStoreProductId || 'Not set' : 'Not set';
729
729
 
730
730
  //get input name
731
731
  const inputName = savedInputsNames[inputTitleId] ? savedInputsNames[inputTitleId] : savedInputsNames[inputReference] ? savedInputsNames[inputReference] : savedInputsNames[inputOneStoreProductId] ? savedInputsNames[inputOneStoreProductId] : input.name;
@@ -743,21 +743,24 @@ class XBOXDEVICE {
743
743
  const inputService = new Service.InputSource(inputName, `Input ${i}`);
744
744
  inputService
745
745
  .setCharacteristic(Characteristic.Identifier, i)
746
- .setCharacteristic(Characteristic.ConfiguredName, inputName)
746
+ .setCharacteristic(Characteristic.Name, inputName)
747
747
  .setCharacteristic(Characteristic.IsConfigured, isConfigured)
748
748
  .setCharacteristic(Characteristic.InputSourceType, inputType)
749
749
  .setCharacteristic(Characteristic.CurrentVisibilityState, currentVisibility)
750
- .setCharacteristic(Characteristic.TargetVisibilityState, targetVisibility);
751
750
 
752
- inputService
753
- .getCharacteristic(Characteristic.ConfiguredName)
751
+ inputService.getCharacteristic(Characteristic.ConfiguredName)
752
+ .onGet(async () => {
753
+ return inputName;
754
+ })
754
755
  .onSet(async (name) => {
755
756
  try {
756
757
  const nameIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
757
758
  savedInputsNames[nameIdentifier] = name;
759
+
758
760
  const newCustomName = JSON.stringify(savedInputsNames, null, 2);
759
- const writeNewCustomName = nameIdentifier ? await fsPromises.writeFile(this.inputsNamesFile, newCustomName) : false;
760
- const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, saved new Input name: ${name}, one store product id: ${inputOneStoreProductId}`);
761
+ await fsPromises.writeFile(this.inputsNamesFile, newCustomName);
762
+ const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved new Input name: ${name}, one store product id: ${inputOneStoreProductId}`) : false;
763
+ inputService.setCharacteristic(Characteristic.Name, inputName);
761
764
  } catch (error) {
762
765
  this.log.error(`Device: ${this.host} ${accessoryName}, new Input name save error: ${error}`);
763
766
  }
@@ -765,13 +768,17 @@ class XBOXDEVICE {
765
768
 
766
769
  inputService
767
770
  .getCharacteristic(Characteristic.TargetVisibilityState)
771
+ .onGet(async () => {
772
+ return targetVisibility;
773
+ })
768
774
  .onSet(async (state) => {
769
775
  try {
770
776
  const targetVisibilityIdentifier = inputTitleId ? inputTitleId : inputReference ? inputReference : inputOneStoreProductId ? inputOneStoreProductId : false;
771
777
  savedInputsTargetVisibility[targetVisibilityIdentifier] = state;
778
+
772
779
  const newTargetVisibility = JSON.stringify(savedInputsTargetVisibility, null, 2);
773
- const writeNewTargetVisibility = targetVisibilityIdentifier ? await fsPromises.writeFile(this.inputsTargetVisibilityFile, newTargetVisibility) : false;
774
- const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, saved new Input: ${inputName} target visibility state: ${state ? 'HIDEN' : 'SHOWN'}`);
780
+ await fsPromises.writeFile(this.inputsTargetVisibilityFile, newTargetVisibility);
781
+ const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, saved new Input: ${inputName} target visibility state: ${state ? 'HIDEN' : 'SHOWN'}`) : false;
775
782
  inputService.setCharacteristic(Characteristic.CurrentVisibilityState, state);
776
783
  } catch (error) {
777
784
  this.log.error(`Device: ${this.host} ${accessoryName}, new target visibility state save error: ${error}`);
@@ -856,7 +863,7 @@ class XBOXDEVICE {
856
863
  buttonService.getCharacteristic(Characteristic.On)
857
864
  .onGet(async () => {
858
865
  const state = false;
859
- const logInfo = this.disableLogInfo || this.firstRun ? false : this.log(`Device: ${this.host} ${accessoryName}, get Button state successful: ${state}`);
866
+ const logDebug = this.disableLogInfo ? this.log(`Device: ${this.host} ${accessoryName}, get Button state successful: ${state}`) : false;
860
867
  return state;
861
868
  })
862
869
  .onSet(async (state) => {
@@ -908,7 +915,7 @@ class XBOXDEVICE {
908
915
  }
909
916
  break;
910
917
  }
911
- const logInfo = this.disableLogInfo || this.firstRun || buttonMode === -1 ? false : this.log(`Device: ${this.host} ${accessoryName}, set button successful, name: ${buttonName}, command: ${buttonCommand}`);
918
+ const logDebug = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, set button successful, name: ${buttonName}, command: ${buttonCommand}`) : false;
912
919
  }
913
920
  await new Promise(resolve => setTimeout(resolve, 300));
914
921
  const setChar = this.power && state ? buttonService.updateCharacteristic(Characteristic.On, false) : false;
@@ -925,4 +932,4 @@ class XBOXDEVICE {
925
932
  this.api.publishExternalAccessories(PLUGIN_NAME, [accessory]);
926
933
  const debug3 = this.enableDebugMode ? this.log(`Device: ${this.host} ${accessoryName}, published as external accessory.`) : false;
927
934
  }
928
- };
935
+ };
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.5-beta.0",
4
+ "version": "2.7.6",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -289,8 +289,7 @@ class XBOXLOCALAPI extends EventEmitter {
289
289
  powerOn() {
290
290
  return new Promise(async (resolve, reject) => {
291
291
  if (this.isConnected) {
292
- this.emit('message', 'Console already On.');
293
- resolve(true);
292
+ reject('Console already On.');
294
293
  return;
295
294
  };
296
295
 
@@ -326,9 +325,7 @@ class XBOXLOCALAPI extends EventEmitter {
326
325
  powerOff() {
327
326
  return new Promise(async (resolve, reject) => {
328
327
  if (!this.isConnected) {
329
- reject({
330
- status: 'Console already Off.'
331
- });
328
+ reject('Console already Off.');
332
329
  return;
333
330
  };
334
331
 
@@ -362,7 +362,7 @@ class XBOXWEBAPI extends EventEmitter {
362
362
  powerOn() {
363
363
  return new Promise(async (resolve, reject) => {
364
364
  try {
365
- await this.sendCommand('Power', 'WakeUp')
365
+ await this.send('Power', 'WakeUp')
366
366
  resolve(true);
367
367
  } catch (error) {
368
368
  reject(`power on error: ${error}`);
@@ -373,7 +373,7 @@ class XBOXWEBAPI extends EventEmitter {
373
373
  powerOff() {
374
374
  return new Promise(async (resolve, reject) => {
375
375
  try {
376
- await this.sendCommand('Power', 'TurnOff')
376
+ await this.send('Power', 'TurnOff')
377
377
  resolve(true);
378
378
  } catch (error) {
379
379
  reject(`power off error: ${error}`);
@@ -384,7 +384,7 @@ class XBOXWEBAPI extends EventEmitter {
384
384
  reboot() {
385
385
  return new Promise(async (resolve, reject) => {
386
386
  try {
387
- await this.sendCommand('Power', 'Reboot')
387
+ await this.send('Power', 'Reboot')
388
388
  resolve(true);
389
389
  } catch (error) {
390
390
  reject(`reboot error: ${error}`);
@@ -395,7 +395,7 @@ class XBOXWEBAPI extends EventEmitter {
395
395
  mute() {
396
396
  return new Promise(async (resolve, reject) => {
397
397
  try {
398
- await this.sendCommand('Audio', 'Mute')
398
+ await this.send('Audio', 'Mute')
399
399
  resolve(true);
400
400
  } catch (error) {
401
401
  reject(`mute error: ${error}`);
@@ -406,7 +406,7 @@ class XBOXWEBAPI extends EventEmitter {
406
406
  unmute() {
407
407
  return new Promise(async (resolve, reject) => {
408
408
  try {
409
- await this.sendCommand('Audio', 'Unmute')
409
+ await this.send('Audio', 'Unmute')
410
410
  resolve(true);
411
411
  } catch (error) {
412
412
  reject(`unmute error: ${error}`);
@@ -417,7 +417,7 @@ class XBOXWEBAPI extends EventEmitter {
417
417
  launchApp(oneStoreProductId) {
418
418
  return new Promise(async (resolve, reject) => {
419
419
  try {
420
- await this.sendCommand('Shell', 'ActivateApplicationWithOneStoreProductId', [{
420
+ await this.send('Shell', 'ActivateApplicationWithOneStoreProductId', [{
421
421
  'oneStoreProductId': oneStoreProductId
422
422
  }])
423
423
  resolve(true);
@@ -430,7 +430,7 @@ class XBOXWEBAPI extends EventEmitter {
430
430
  launchDashboard() {
431
431
  return new Promise(async (resolve, reject) => {
432
432
  try {
433
- await this.sendCommand('Shell', 'GoHome')
433
+ await this.send('Shell', 'GoHome')
434
434
  resolve(true);
435
435
  } catch (error) {
436
436
  reject(`launch dashboard error: ${error}`);
@@ -441,7 +441,7 @@ class XBOXWEBAPI extends EventEmitter {
441
441
  openGuideTab() {
442
442
  return new Promise(async (resolve, reject) => {
443
443
  try {
444
- await this.sendCommand('Shell', 'ShowGuideTab', [{
444
+ await this.send('Shell', 'ShowGuideTab', [{
445
445
  'tabName': 'Guide'
446
446
  }])
447
447
  resolve(true);
@@ -454,7 +454,7 @@ class XBOXWEBAPI extends EventEmitter {
454
454
  launchOneGuide() {
455
455
  return new Promise(async (resolve, reject) => {
456
456
  try {
457
- await this.sendCommand('TV', 'ShowGuide')
457
+ await this.send('TV', 'ShowGuide')
458
458
  resolve(true);
459
459
  } catch (error) {
460
460
  reject(`launch one guide error: ${error}`);
@@ -465,7 +465,7 @@ class XBOXWEBAPI extends EventEmitter {
465
465
  sendButtonPress(button) {
466
466
  return new Promise(async (resolve, reject) => {
467
467
  try {
468
- await this.sendCommand('Shell', 'InjectKey', [{
468
+ await this.send('Shell', 'InjectKey', [{
469
469
  'keyType': button
470
470
  }])
471
471
  resolve(true);
@@ -475,7 +475,7 @@ class XBOXWEBAPI extends EventEmitter {
475
475
  });
476
476
  }
477
477
 
478
- sendCommand(commandType, command, params) {
478
+ send(commandType, command, params) {
479
479
  return new Promise(async (resolve, reject) => {
480
480
  try {
481
481
  const sessionid = Uuid4();