homebridge-xbox-tv 3.3.3 → 3.3.4-beta.0

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": "3.3.3",
4
+ "version": "3.3.4-beta.0",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -52,7 +52,7 @@ class XboxLocalApi extends EventEmitter {
52
52
  if (this.isConnected) {
53
53
  const debug = this.enableDebugMode ? this.emit('debug', `Socket send heartbeat`) : false;
54
54
  const elapse = (Date.now() - this.heartBeatStartTime) / 1000;
55
- const debug1 = this.enableDebugMode && elapse >= 12 ? this.emit('debug', `Last message was: ${elapse} sec ago.`) : false;
55
+ const debug1 = this.enableDebugMode && elapse >= 12 ? this.emit('debug', `Last message was: ${elapse} sec ago`) : false;
56
56
  const disconnect = elapse >= 12 ? await this.disconnect() : false;
57
57
  };
58
58
  } catch (error) {
@@ -110,7 +110,7 @@ class XboxLocalApi extends EventEmitter {
110
110
  }
111
111
 
112
112
  async channelOpen(channelRequestId, service) {
113
- const debug = this.enableDebugMode ? this.emit('debug', `Received channel Id: ${channelRequestId}, request open.`) : false;
113
+ const debug = this.enableDebugMode ? this.emit('debug', `Received channel Id: ${channelRequestId}, request open`) : false;
114
114
  this.channelRequestId = channelRequestId;
115
115
 
116
116
  try {
@@ -131,6 +131,7 @@ class XboxLocalApi extends EventEmitter {
131
131
  async powerOn() {
132
132
  if (this.isConnected) {
133
133
  this.emit('warn', 'Console already On.');
134
+ return;
134
135
  };
135
136
 
136
137
  const info = this.disableLogInfo ? false : this.emit('info', 'Send power On.');
@@ -158,6 +159,7 @@ class XboxLocalApi extends EventEmitter {
158
159
  async powerOff() {
159
160
  if (!this.isConnected) {
160
161
  this.emit('warn', 'Console already Off.');
162
+ return;
161
163
  };
162
164
 
163
165
  const info = this.disableLogInfo ? false : this.emit('info', 'Send power Off.');
@@ -180,6 +182,7 @@ class XboxLocalApi extends EventEmitter {
180
182
  async recordGameDvr() {
181
183
  if (!this.isConnected || !this.isAuthorized) {
182
184
  this.emit('warn', `Send record game ignored, connection state: ${this.isConnected}, authorization state: ${this.isAuthorized}`);
185
+ return;
183
186
  };
184
187
 
185
188
  const info = this.disableLogInfo ? false : this.emit('info', 'Send record game.');
@@ -198,7 +201,8 @@ class XboxLocalApi extends EventEmitter {
198
201
 
199
202
  async sendButtonPress(channelName, command) {
200
203
  if (!this.isConnected) {
201
- this.emit('waarn', `Send command ignored, connection state: ${this.isConnected ? 'Not Connected' : 'Connected'}.`);
204
+ this.emit('waarn', `Send command ignored, connection state: ${this.isConnected ? 'Not Connected' : 'Connected'}`);
205
+ return;
202
206
  };
203
207
 
204
208
  const channelRequestId = LocalApi.Channels.System[channelName].Id
@@ -206,11 +210,11 @@ class XboxLocalApi extends EventEmitter {
206
210
  const channelOpen = this.channels[requestId].open;
207
211
 
208
212
  if (channelCommunicationId === -1 || !channelOpen) {
209
- this.emit('warn', `Channel Id: ${channelCommunicationId}, state: ${channelOpen ? 'Open' : 'Closed'}, trying to open it.`);
213
+ this.emit('warn', `Channel Id: ${channelCommunicationId}, state: ${channelOpen ? 'Open' : 'Closed'}, trying to open it`);
210
214
  };
211
215
 
212
216
  command = LocalApi.Channels.System[channelName][command];
213
- const debug = this.enableDebugMode ? this.emit('debug', `Channel communication Id: ${channelCommunicationId}, name: ${channelName} opened, send command; ${command}.`) : false;
217
+ const debug = this.enableDebugMode ? this.emit('debug', `Channel communication Id: ${channelCommunicationId}, name: ${channelName} opened, send command; ${command}`) : false;
214
218
 
215
219
  switch (channelRequestId) {
216
220
  case 0:
@@ -317,7 +321,7 @@ class XboxLocalApi extends EventEmitter {
317
321
  throw new Error(error);
318
322
  }
319
323
 
320
- const debug = this.enableDebugMode ? this.emit('debug', `Socket send: ${type}, ${bytes}B.`) : false;
324
+ const debug = this.enableDebugMode ? this.emit('debug', `Socket send: ${type}, ${bytes}B`) : false;
321
325
  return true;
322
326
  });
323
327
  } catch (error) {
@@ -378,7 +382,7 @@ class XboxLocalApi extends EventEmitter {
378
382
  const debug4 = this.enableDebugMode ? this.emit('debug', `Received packet: ${JSON.stringify(packet, null, 2)}`) : false;
379
383
 
380
384
  if (messageType === 'message' && packet.targetParticipantId !== this.sourceParticipantId) {
381
- const debug = this.enableDebugMode ? this.emit('debug', `Participant Id: ${packet.targetParticipantId} !== ${this.sourceParticipantId}. Ignoring packet.`) : false;
385
+ const debug = this.enableDebugMode ? this.emit('debug', `Participant Id: ${packet.targetParticipantId} !== ${this.sourceParticipantId}. Ignoring packet`) : false;
382
386
  return;
383
387
  };
384
388
 
@@ -449,7 +453,7 @@ class XboxLocalApi extends EventEmitter {
449
453
  connectRequest.set('jwt', parseTokenData.xsts.Token, true);
450
454
  this.isAuthorized = true;
451
455
  }
452
- const debug = this.enableDebugMode ? this.emit('debug', `Client connecting using: ${this.isAuthorized ? 'XSTS token' : 'Anonymous'}.`) : false;
456
+ const debug = this.enableDebugMode ? this.emit('debug', `Client connecting using: ${this.isAuthorized ? 'XSTS token' : 'Anonymous'}`) : false;
453
457
 
454
458
  const message = connectRequest.pack(this.crypto);
455
459
  await this.sendSocketMessage(message, 'connectRequest');
@@ -483,8 +487,8 @@ class XboxLocalApi extends EventEmitter {
483
487
  }
484
488
  this.isConnected = true;
485
489
  this.sourceParticipantId = sourceParticipantId;
486
- const debug1 = this.enableDebugMode ? this.emit('debug', `Client connect state: ${this.isConnected ? 'Connected' : 'Not Connected'}.`) : false;
487
- const debug2 = this.enableDebugMode ? this.emit('debug', `Client pairing state: ${LocalApi.Console.PairingState[pairingState]}.`) : false;
490
+ const debug1 = this.enableDebugMode ? this.emit('debug', `Client connect state: ${this.isConnected ? 'Connected' : 'Not Connected'}`) : false;
491
+ const debug2 = this.enableDebugMode ? this.emit('debug', `Client pairing state: ${LocalApi.Console.PairingState[pairingState]}`) : false;
488
492
 
489
493
  try {
490
494
  const localJoin = new MessagePacket('localJoin');
@@ -532,7 +536,7 @@ class XboxLocalApi extends EventEmitter {
532
536
 
533
537
  if (this.emitDevInfo) {
534
538
  //connect to deice success
535
- this.emit('success', `Connect Success.`)
539
+ this.emit('success', `Connect Success`)
536
540
 
537
541
  const majorVersion = packet.payloadProtected.majorVersion;
538
542
  const minorVersion = packet.payloadProtected.minorVersion;
@@ -605,17 +609,17 @@ class XboxLocalApi extends EventEmitter {
605
609
  open: channelState
606
610
  }
607
611
  const pushChannel = channelCommunicationId !== -1 ? this.channels.push(channel) : false;
608
- const debug3 = this.enableDebugMode ? this.emit('debug', `Channel communication Id: ${channelCommunicationId}, state: ${channelState ? 'Open' : 'Closed'}.`) : false;
612
+ const debug3 = this.enableDebugMode ? this.emit('debug', `Channel communication Id: ${channelCommunicationId}, state: ${channelState ? 'Open' : 'Closed'}`) : false;
609
613
  break;
610
614
  case 'pairedIdentityStateChanged':
611
615
  const pairingState1 = packet.payloadProtected.pairingState || 0;
612
- const debug4 = this.enableDebugMode ? this.emit('debug', `Client pairing state: ${LocalApi.Console.PairingState[pairingState1]}.`) : false;
616
+ const debug4 = this.enableDebugMode ? this.emit('debug', `Client pairing state: ${LocalApi.Console.PairingState[pairingState1]}`) : false;
613
617
  break;
614
618
  };
615
619
  }).on('listening', async () => {
616
620
  //socket.setBroadcast(true);
617
621
  const address = socket.address();
618
- const debug = this.enableDebugMode ? this.emit('debug', `Server start listening: ${address.address}:${address.port}.`) : false;
622
+ const debug = this.enableDebugMode ? this.emit('debug', `Server start listening: ${address.address}:${address.port}`) : false;
619
623
  this.socket = socket;
620
624
  this.emitDevInfo = true;
621
625
 
package/src/mqtt.js CHANGED
@@ -21,7 +21,7 @@ class Mqtt extends EventEmitter {
21
21
 
22
22
  //subscribe
23
23
  await this.mqttClient.subscribe(subscribeTopic);
24
- this.emit('subscribed', `MQTT Subscribe topic: ${subscribeTopic}.`);
24
+ this.emit('subscribed', `MQTT Subscribe topic: ${subscribeTopic}`);
25
25
 
26
26
  //subscribed message
27
27
  this.mqttClient.on('message', (topic, message) => {
@@ -77,7 +77,7 @@ class Authentication {
77
77
  }
78
78
  break;
79
79
  default:
80
- throw new Error(`Unknow refresh token type: ${type}.`);
80
+ throw new Error(`Unknow refresh token type: ${type}`);
81
81
  break;
82
82
  }
83
83
  }
@@ -33,7 +33,7 @@ class XboxWebApi extends EventEmitter {
33
33
  this.emit('error', error);
34
34
  };
35
35
  }).on('state', (state) => {
36
- const emitState = state ? this.emit('success', `Web Api monitoring started.`) : this.emit('warn', `Web Api monitoring stopped.`);
36
+ const emitState = state ? this.emit('success', `Web Api monitoring started`) : this.emit('warn', `Web Api monitoring stopped`);
37
37
  });
38
38
  }
39
39
 
@@ -70,7 +70,7 @@ class XboxWebApi extends EventEmitter {
70
70
  async xboxLiveData() {
71
71
  try {
72
72
  const rmEnabled = await this.consoleStatus();
73
- const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings.`) : false;
73
+ const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings`) : false;
74
74
  //await this.consolesList();
75
75
  await this.installedApps();
76
76
  //await this.storageDevices();
@@ -349,7 +349,7 @@ class XboxWebApi extends EventEmitter {
349
349
  async next() {
350
350
  try {
351
351
  await this.send('Media', 'Next');
352
- return true;;
352
+ return true;
353
353
  } catch (error) {
354
354
  throw new Error(error);
355
355
  };
@@ -358,7 +358,7 @@ class XboxWebApi extends EventEmitter {
358
358
  async previous() {
359
359
  try {
360
360
  await this.send('Media', 'Previous');
361
- return true;;
361
+ return true;
362
362
  } catch (error) {
363
363
  throw new Error(error);
364
364
  };
@@ -367,7 +367,7 @@ class XboxWebApi extends EventEmitter {
367
367
  async pause() {
368
368
  try {
369
369
  await this.send('Media', 'Pause');
370
- return true;;
370
+ return true;
371
371
  } catch (error) {
372
372
  throw new Error(error);
373
373
  };
@@ -376,7 +376,7 @@ class XboxWebApi extends EventEmitter {
376
376
  async play() {
377
377
  try {
378
378
  await this.send('Media', 'Play');
379
- return true;;
379
+ return true;
380
380
  } catch (error) {
381
381
  throw new Error(error);
382
382
  };
@@ -385,7 +385,7 @@ class XboxWebApi extends EventEmitter {
385
385
  async goBack() {
386
386
  try {
387
387
  await this.send('Shell', 'GoBack');
388
- return true;;
388
+ return true;
389
389
  } catch (error) {
390
390
  throw new Error(error);
391
391
  };
@@ -393,7 +393,8 @@ class XboxWebApi extends EventEmitter {
393
393
 
394
394
  async send(commandType, command, payload) {
395
395
  if (!this.authorized) {
396
- throw new Error('not authorized.');
396
+ this.emit('warn', `not authorized`);
397
+ return;
397
398
  };
398
399
 
399
400
  const sessionid = UuIdv4();
@@ -407,7 +408,7 @@ class XboxWebApi extends EventEmitter {
407
408
  "parameters": params,
408
409
  "linkedXboxId": this.xboxLiveId
409
410
  }
410
- const debug = this.enableDebugMode ? this.emit('debug', `send, type: ${commandType}, command: ${command}, params: ${params}.`) : false;
411
+ const debug = this.enableDebugMode ? this.emit('debug', `send, type: ${commandType}, command: ${command}, params: ${params}`) : false;
411
412
 
412
413
  try {
413
414
  const stringifyPostParam = JSON.stringify(postParams);
package/src/xboxdevice.js CHANGED
@@ -97,7 +97,7 @@ class XboxDevice extends EventEmitter {
97
97
  sensor.state = false;
98
98
  this.sensorsInputsConfigured.push(sensor);
99
99
  } else {
100
- const log = sensorInputDisplayType === 0 ? false : this.emit('info', `Sensor Name: ${sensorInputName ? sensorInputName : 'Missing'}, Reference: ${sensorInputReference ? sensorInputReference : 'Missing'}.`);
100
+ const log = sensorInputDisplayType === 0 ? false : this.emit('info', `Sensor Name: ${sensorInputName ? sensorInputName : 'Missing'}, Reference: ${sensorInputReference ? sensorInputReference : 'Missing'}`);
101
101
  };
102
102
  }
103
103
  this.sensorsInputsConfiguredCount = this.sensorsInputsConfigured.length || 0;
@@ -116,7 +116,7 @@ class XboxDevice extends EventEmitter {
116
116
  button.state = false;
117
117
  this.buttonsConfigured.push(button);
118
118
  } else {
119
- const log = buttonDisplayType === 0 ? false : this.emit('info', `Button Name: ${buttonName ? buttonName : 'Missing'}, Command: ${buttonCommand ? buttonCommand : 'Missing'}, Reference: ${buttonReference ? buttonReference : 'Missing'}.`);
119
+ const log = buttonDisplayType === 0 ? false : this.emit('info', `Button Name: ${buttonName ? buttonName : 'Missing'}, Command: ${buttonCommand ? buttonCommand : 'Missing'}, Reference: ${buttonReference ? buttonReference : 'Missing'}`);
120
120
  };
121
121
  }
122
122
  this.buttonsConfiguredCount = this.buttonsConfigured.length || 0;
@@ -721,7 +721,7 @@ class XboxDevice extends EventEmitter {
721
721
  input.name = value;
722
722
  this.savedInputsNames[inputReference] = value;
723
723
  await this.saveData(this.inputsNamesFile, this.savedInputsNames);
724
- const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved Input Name: ${value}, Reference: ${inputReference}.`);
724
+ const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved Input Name: ${value}, Reference: ${inputReference}`);
725
725
 
726
726
  //sort inputs
727
727
  const index = this.inputsConfigured.findIndex(input => input.reference === inputReference);
@@ -954,7 +954,7 @@ class XboxDevice extends EventEmitter {
954
954
  const send5 = this.power && state ? await this.xboxWebApi.send('Shell', 'ShowGuideTab', [{ 'tabName': 'Guide' }]) : false;
955
955
  break;
956
956
  case 'Not set': case 'Web api disabled':
957
- this.emit('info', `trying to launch App/Game with one store product id: ${buttonOneStoreProductId}.`);
957
+ this.emit('info', `trying to launch App/Game with one store product id: ${buttonOneStoreProductId}`);
958
958
  break;
959
959
  default:
960
960
  const send6 = this.power && state ? await this.xboxWebApi.send('Shell', 'ActivateApplicationWithOneStoreProductId', [{ 'oneStoreProductId': buttonOneStoreProductId }]) : false;
@@ -1037,11 +1037,11 @@ class XboxDevice extends EventEmitter {
1037
1037
  });
1038
1038
 
1039
1039
  //check authorization
1040
- await this.xboxWebApi.checkAuthorization();
1040
+ const checkAuthorization = await this.xboxWebApi.checkAuthorization();
1041
1041
 
1042
1042
  //start impulse generator
1043
1043
  const timers = [{ name: 'checkAuthorization', sampling: 900000 }];
1044
- await this.xboxWebApi.impulseGenerator.start(timers);
1044
+ const startImpulseGenerator = checkAuthorization ? await this.xboxWebApi.impulseGenerator.start(timers) : false;
1045
1045
  } catch (error) {
1046
1046
  this.emit('error', error);
1047
1047
  };