homebridge-xbox-tv 2.12.6 → 2.12.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "2.12.6",
4
+ "version": "2.12.8",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -251,7 +251,7 @@ class XBOXLOCALAPI extends EventEmitter {
251
251
  const power = true;
252
252
  const volume = 0;
253
253
  const mute = power ? power : true;
254
- const mediaState = 0;
254
+ const mediaState = 2;
255
255
  const titleId = appsCount === 2 ? packet.payloadProtected.activeTitles[0].titleId : packet.payloadProtected.activeTitles[0].titleId;
256
256
  const reference = appsCount === 2 ? packet.payloadProtected.activeTitles[0].aumId : packet.payloadProtected.activeTitles[0].aumId;
257
257
 
package/src/xboxdevice.js CHANGED
@@ -360,6 +360,19 @@ class XboxDevice extends EventEmitter {
360
360
  };
361
361
  const restFul = this.restFulConnected ? this.restFul.update('state', obj) : false;
362
362
  const mqtt = this.mqttConnected ? this.mqtt.send('State', obj) : false;
363
+
364
+ if (!this.disableLogInfo) {
365
+ const name = index !== -1 ? this.inputsConfigured[index].name : reference;
366
+ const productId = index !== -1 ? this.inputsConfigured[index].oneStoreProductId : reference;
367
+ this.emit('message', `Power: ${power ? 'ON' : 'OFF'}`);
368
+ this.emit('message', `Input Name: ${name}`);
369
+ this.emit('message', `Reference: ${reference}`);
370
+ this.emit('message', `Title Id: ${titleId}`);
371
+ this.emit('message', `Product Id: ${productId}`);
372
+ this.emit('message', `Volume: ${volume}%`);
373
+ this.emit('message', `Mute: ${mute ? 'ON' : 'OFF'}`);
374
+ this.emit('message', `Media State: ${['PLAY', 'PAUSE', 'STOPPED', 'LOADING', 'INTERRUPTED'][mediaState]}`);
375
+ };
363
376
  })
364
377
  .on('prepareAccessory', async () => {
365
378
  try {
@@ -368,7 +381,7 @@ class XboxDevice extends EventEmitter {
368
381
  try {
369
382
  const data = await fsPromises.readFile(this.devInfoFile);
370
383
  this.savedInfo = data.length > 0 ? JSON.parse(data) : {};
371
- const debug = this.enableDebugMode ? this.emit('debug', `Read saved Info: ${JSON.stringify(this.savedInfo, null, 2)}`) : false;
384
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Info: ${JSON.stringify(this.savedInfo, null, 2)}`);
372
385
  } catch (error) {
373
386
  this.emit('error', `read saved Info error: ${error}`);
374
387
  };
@@ -377,7 +390,7 @@ class XboxDevice extends EventEmitter {
377
390
  try {
378
391
  const data = await fsPromises.readFile(this.inputsFile);
379
392
  this.savedInputs = data.length > 0 ? JSON.parse(data) : this.inputs;
380
- const debug = this.enableDebugMode ? this.emit('debug', `Read saved Inputs: ${JSON.stringify(this.savedInputs, null, 2)}`) : false;
393
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs: ${JSON.stringify(this.savedInputs, null, 2)}`);
381
394
  } catch (error) {
382
395
  this.emit('error', `read saved Inputs error: ${error}`);
383
396
  };
@@ -386,18 +399,18 @@ class XboxDevice extends EventEmitter {
386
399
  try {
387
400
  const data = await fsPromises.readFile(this.inputsNamesFile);
388
401
  this.savedInputsNames = data.length > 0 ? JSON.parse(data) : {};
389
- const debug = this.enableDebugMode ? this.emit('debug', `Read saved Inputs Names: ${JSON.stringify(this.savedInputsNames, null, 2)}`) : false;
402
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs Names: ${JSON.stringify(this.savedInputsNames, null, 2)}`);
390
403
  } catch (error) {
391
- this.emit('error', `read saved Inputs/Channels Names error: ${error}`);
404
+ this.emit('error', `read saved Inputs Names error: ${error}`);
392
405
  };
393
406
 
394
407
  //read inputs visibility from file
395
408
  try {
396
409
  const data = await fsPromises.readFile(this.inputsTargetVisibilityFile);
397
410
  this.savedInputsTargetVisibility = data.length > 0 ? JSON.parse(data) : {};
398
- const debug = this.enableDebugMode ? this.emit('debug', `Read saved Inputs Target Visibility: ${JSON.stringify(this.savedInputsTargetVisibility, null, 2)}`) : false;
411
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Read saved Inputs Target Visibility: ${JSON.stringify(this.savedInputsTargetVisibility, null, 2)}`);
399
412
  } catch (error) {
400
- this.emit('error', `read saved Inputs/Channels Target Visibility error: ${error}`);
413
+ this.emit('error', `read saved Inputs Target Visibility error: ${error}`);
401
414
  };
402
415
 
403
416
  await new Promise(resolve => setTimeout(resolve, 2500));
@@ -445,7 +458,7 @@ class XboxDevice extends EventEmitter {
445
458
  this.inputsConfigured.sort((a, b) => b.reference.localeCompare(a.reference));
446
459
  break;
447
460
  }
448
- const debug = this.enableDebugMode ? this.emit('debug', `Inputs display order: ${JSON.stringify(this.inputsConfigured, null, 2)}`) : false;
461
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Inputs display order: ${JSON.stringify(this.inputsConfigured, null, 2)}`);
449
462
 
450
463
  const displayOrder = this.inputsConfigured.map(input => input.identifier);
451
464
  this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
@@ -485,7 +498,6 @@ class XboxDevice extends EventEmitter {
485
498
  this.televisionService.getCharacteristic(Characteristic.Active)
486
499
  .onGet(async () => {
487
500
  const state = this.power;
488
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Power: ${state ? 'ON' : 'OFF'}`);
489
501
  return state;
490
502
  })
491
503
  .onSet(async (state) => {
@@ -532,11 +544,6 @@ class XboxDevice extends EventEmitter {
532
544
  this.televisionService.getCharacteristic(Characteristic.ActiveIdentifier)
533
545
  .onGet(async () => {
534
546
  const inputIdentifier = this.inputIdentifier;
535
- const index = this.inputsConfigured.findIndex(input => input.identifier === inputIdentifier);
536
- const inputOneStoreProductId = this.inputsConfigured[index].oneStoreProductId;
537
- const inputReference = this.inputsConfigured[index].reference;
538
- const inputName = this.inputsConfigured[index].name;
539
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Input: ${inputName}, Reference: ${inputReference}, Product Id: ${inputOneStoreProductId}`);
540
547
  return inputIdentifier;
541
548
  })
542
549
  .onSet(async (activeIdentifier) => {
@@ -658,7 +665,6 @@ class XboxDevice extends EventEmitter {
658
665
  //apple, 0 - PLAY, 1 - PAUSE, 2 - STOP, 3 - LOADING, 4 - INTERRUPTED
659
666
  //xbox, 0 - STOP, 1 - PLAY, 2 - PAUSE
660
667
  const value = [2, 0, 1, 3, 4][this.mediaState];
661
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Current Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
662
668
  return value;
663
669
  });
664
670
 
@@ -666,7 +672,6 @@ class XboxDevice extends EventEmitter {
666
672
  .onGet(async () => {
667
673
  //0 - PLAY, 1 - PAUSE, 2 - STOP
668
674
  const value = [2, 0, 1, 3, 4][this.mediaState];
669
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Target Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
670
675
  return value;
671
676
  })
672
677
  .onSet(async (value) => {
@@ -748,7 +753,6 @@ class XboxDevice extends EventEmitter {
748
753
  this.speakerService.getCharacteristic(Characteristic.Volume)
749
754
  .onGet(async () => {
750
755
  const volume = this.volume;
751
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Volume: ${volume}`);
752
756
  return volume;
753
757
  })
754
758
  .onSet(async (volume) => {
@@ -761,7 +765,6 @@ class XboxDevice extends EventEmitter {
761
765
  this.speakerService.getCharacteristic(Characteristic.Mute)
762
766
  .onGet(async () => {
763
767
  const state = this.mute;
764
- const logInfo = this.disableLogInfo ? false : this.emit('message', `Mute: ${state ? 'ON' : 'OFF'}`);
765
768
  return state;
766
769
  })
767
770
  .onSet(async (state) => {
@@ -860,7 +863,7 @@ class XboxDevice extends EventEmitter {
860
863
  try {
861
864
  this.savedInputsNames[inputReference] = value;
862
865
  await fsPromises.writeFile(this.inputsNamesFile, JSON.stringify(this.savedInputsNames, null, 2));
863
- const debug = this.enableDebugMode ? this.emit('debug', `Saved Input Name: ${value}, Reference: ${nameIdentifier}.`) : false;
866
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved Input Name: ${value}, Reference: ${nameIdentifier}.`);
864
867
 
865
868
  //sort inputs
866
869
  const index = this.inputsConfigured.findIndex(input => input.reference === inputReference);
@@ -883,7 +886,7 @@ class XboxDevice extends EventEmitter {
883
886
  try {
884
887
  this.savedInputsTargetVisibility[inputReference] = state;
885
888
  await fsPromises.writeFile(this.inputsTargetVisibilityFile, JSON.stringify(this.savedInputsTargetVisibility, null, 2));
886
- const debug = this.enableDebugMode ? this.emit('debug', `Saved Input: ${inputName} Target Visibility: ${state ? 'HIDEN' : 'SHOWN'}`) : false;
889
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved Input: ${inputName} Target Visibility: ${state ? 'HIDEN' : 'SHOWN'}`);
887
890
  } catch (error) {
888
891
  this.emit('error', `save Target Visibility error: ${error}`);
889
892
  }