homebridge-xbox-tv 3.3.3 → 3.3.4-beta.1
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/localApi/xboxlocalapi.js +18 -14
- package/src/mqtt.js +1 -1
- package/src/webApi/authentication.js +8 -8
- package/src/webApi/xboxwebapi.js +27 -19
- package/src/xboxdevice.js +11 -11
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
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}
|
|
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
|
|
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
|
|
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'}
|
|
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'}
|
|
487
|
-
const debug2 = this.enableDebugMode ? this.emit('debug', `Client pairing state: ${LocalApi.Console.PairingState[pairingState]}
|
|
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'}
|
|
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]}
|
|
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}
|
|
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
|
}
|
|
@@ -100,7 +100,7 @@ class Authentication {
|
|
|
100
100
|
this.tokens.oauth = refreshToken;
|
|
101
101
|
return true;
|
|
102
102
|
} catch (error) {
|
|
103
|
-
throw new Error(`Refresh token error: ${error
|
|
103
|
+
throw new Error(`Refresh token error: ${error}`);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -124,7 +124,7 @@ class Authentication {
|
|
|
124
124
|
this.tokens.xsts = {};
|
|
125
125
|
return true;
|
|
126
126
|
} catch (error) {
|
|
127
|
-
throw new Error(`User token error: ${error
|
|
127
|
+
throw new Error(`User token error: ${error}`);
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -146,7 +146,7 @@ class Authentication {
|
|
|
146
146
|
this.tokens.xsts = xstsToken;
|
|
147
147
|
return true;
|
|
148
148
|
} catch (error) {
|
|
149
|
-
throw new Error(`Xsts token error: ${error
|
|
149
|
+
throw new Error(`Xsts token error: ${error}`);
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -170,7 +170,7 @@ class Authentication {
|
|
|
170
170
|
await this.saveData(this.tokensFile, this.tokens);
|
|
171
171
|
return true;
|
|
172
172
|
} catch (error) {
|
|
173
|
-
throw new Error(`Access token error: ${error
|
|
173
|
+
throw new Error(`Access token error: ${error}`);
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -209,7 +209,7 @@ class Authentication {
|
|
|
209
209
|
const oauth2URI = `${WebApi.Url.oauth2}?${params}`;
|
|
210
210
|
return oauth2URI;
|
|
211
211
|
} catch (error) {
|
|
212
|
-
throw new Error(`Authorization URL error: ${error
|
|
212
|
+
throw new Error(`Authorization URL error: ${error}`);
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -219,7 +219,7 @@ class Authentication {
|
|
|
219
219
|
const tokens = data.length > 0 ? JSON.parse(data) : false;
|
|
220
220
|
return tokens;
|
|
221
221
|
} catch (error) {
|
|
222
|
-
throw new Error(`Read data error: ${error
|
|
222
|
+
throw new Error(`Read data error: ${error}`);
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -229,7 +229,7 @@ class Authentication {
|
|
|
229
229
|
await fsPromises.writeFile(path, data);
|
|
230
230
|
return true;
|
|
231
231
|
} catch (error) {
|
|
232
|
-
throw new Error(`Save data error: ${error
|
|
232
|
+
throw new Error(`Save data error: ${error}`);
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
}
|
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -25,15 +25,16 @@ class XboxWebApi extends EventEmitter {
|
|
|
25
25
|
}
|
|
26
26
|
this.authentication = new Authentication(authConfig);
|
|
27
27
|
|
|
28
|
+
//create impulse generator
|
|
28
29
|
this.impulseGenerator = new ImpulseGenerator();
|
|
29
30
|
this.impulseGenerator.on('checkAuthorization', async () => {
|
|
30
31
|
try {
|
|
31
|
-
await this.checkAuthorization(
|
|
32
|
+
await this.checkAuthorization();
|
|
32
33
|
} catch (error) {
|
|
33
34
|
this.emit('error', error);
|
|
34
35
|
};
|
|
35
36
|
}).on('state', (state) => {
|
|
36
|
-
const emitState = state ? this.emit('success', `Web Api monitoring started
|
|
37
|
+
const emitState = state ? this.emit('success', `Web Api monitoring started`) : this.emit('warn', `Web Api monitoring stopped`);
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -59,18 +60,24 @@ class XboxWebApi extends EventEmitter {
|
|
|
59
60
|
method: 'GET',
|
|
60
61
|
headers: headers
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
//check xbox live data
|
|
65
|
+
try {
|
|
66
|
+
await this.xboxLiveData();
|
|
67
|
+
} catch (error) {
|
|
68
|
+
this.emit('error', `Check xbox live data error: ${error}`);
|
|
69
|
+
};
|
|
63
70
|
|
|
64
71
|
return true;
|
|
65
72
|
} catch (error) {
|
|
66
|
-
throw new Error(`Check authorization error: ${error
|
|
73
|
+
throw new Error(`Check authorization error: ${error}`);
|
|
67
74
|
};
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
async xboxLiveData() {
|
|
71
78
|
try {
|
|
72
79
|
const rmEnabled = await this.consoleStatus();
|
|
73
|
-
const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings
|
|
80
|
+
const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings`) : false;
|
|
74
81
|
//await this.consolesList();
|
|
75
82
|
await this.installedApps();
|
|
76
83
|
//await this.storageDevices();
|
|
@@ -78,7 +85,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
78
85
|
|
|
79
86
|
return true;
|
|
80
87
|
} catch (error) {
|
|
81
|
-
throw new Error(`Xbox live data error: ${error
|
|
88
|
+
throw new Error(`Xbox live data error: ${error}`);
|
|
82
89
|
};
|
|
83
90
|
};
|
|
84
91
|
|
|
@@ -113,7 +120,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
113
120
|
|
|
114
121
|
return remoteManagementEnabled;
|
|
115
122
|
} catch (error) {
|
|
116
|
-
throw new Error(`Status error: ${error
|
|
123
|
+
throw new Error(`Status error: ${error}`);
|
|
117
124
|
};
|
|
118
125
|
}
|
|
119
126
|
|
|
@@ -193,7 +200,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
193
200
|
|
|
194
201
|
return true;
|
|
195
202
|
} catch (error) {
|
|
196
|
-
throw new Error(`Consoles list error: ${error
|
|
203
|
+
throw new Error(`Consoles list error: ${error}`);
|
|
197
204
|
};
|
|
198
205
|
}
|
|
199
206
|
|
|
@@ -245,7 +252,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
245
252
|
|
|
246
253
|
return true;
|
|
247
254
|
} catch (error) {
|
|
248
|
-
throw new Error(`Installed apps error: ${error
|
|
255
|
+
throw new Error(`Installed apps error: ${error}`);
|
|
249
256
|
};
|
|
250
257
|
}
|
|
251
258
|
|
|
@@ -288,7 +295,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
288
295
|
|
|
289
296
|
return true;
|
|
290
297
|
} catch (error) {
|
|
291
|
-
throw new Error(`storage devices error: ${error
|
|
298
|
+
throw new Error(`storage devices error: ${error}`);
|
|
292
299
|
};
|
|
293
300
|
}
|
|
294
301
|
|
|
@@ -331,7 +338,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
331
338
|
|
|
332
339
|
return true;
|
|
333
340
|
} catch (error) {
|
|
334
|
-
throw new Error(`User profile error: ${error
|
|
341
|
+
throw new Error(`User profile error: ${error}`);
|
|
335
342
|
};
|
|
336
343
|
}
|
|
337
344
|
|
|
@@ -342,14 +349,14 @@ class XboxWebApi extends EventEmitter {
|
|
|
342
349
|
const debug = this.enableDebugMode ? this.emit('debug', `Saved data: ${data}`) : false;
|
|
343
350
|
return true;
|
|
344
351
|
} catch (error) {
|
|
345
|
-
throw new Error(`Save data error: ${error
|
|
352
|
+
throw new Error(`Save data error: ${error}`);
|
|
346
353
|
};
|
|
347
354
|
};
|
|
348
355
|
|
|
349
356
|
async next() {
|
|
350
357
|
try {
|
|
351
358
|
await this.send('Media', 'Next');
|
|
352
|
-
return true
|
|
359
|
+
return true;
|
|
353
360
|
} catch (error) {
|
|
354
361
|
throw new Error(error);
|
|
355
362
|
};
|
|
@@ -358,7 +365,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
358
365
|
async previous() {
|
|
359
366
|
try {
|
|
360
367
|
await this.send('Media', 'Previous');
|
|
361
|
-
return true
|
|
368
|
+
return true;
|
|
362
369
|
} catch (error) {
|
|
363
370
|
throw new Error(error);
|
|
364
371
|
};
|
|
@@ -367,7 +374,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
367
374
|
async pause() {
|
|
368
375
|
try {
|
|
369
376
|
await this.send('Media', 'Pause');
|
|
370
|
-
return true
|
|
377
|
+
return true;
|
|
371
378
|
} catch (error) {
|
|
372
379
|
throw new Error(error);
|
|
373
380
|
};
|
|
@@ -376,7 +383,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
376
383
|
async play() {
|
|
377
384
|
try {
|
|
378
385
|
await this.send('Media', 'Play');
|
|
379
|
-
return true
|
|
386
|
+
return true;
|
|
380
387
|
} catch (error) {
|
|
381
388
|
throw new Error(error);
|
|
382
389
|
};
|
|
@@ -385,7 +392,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
385
392
|
async goBack() {
|
|
386
393
|
try {
|
|
387
394
|
await this.send('Shell', 'GoBack');
|
|
388
|
-
return true
|
|
395
|
+
return true;
|
|
389
396
|
} catch (error) {
|
|
390
397
|
throw new Error(error);
|
|
391
398
|
};
|
|
@@ -393,7 +400,8 @@ class XboxWebApi extends EventEmitter {
|
|
|
393
400
|
|
|
394
401
|
async send(commandType, command, payload) {
|
|
395
402
|
if (!this.authorized) {
|
|
396
|
-
|
|
403
|
+
this.emit('warn', `not authorized`);
|
|
404
|
+
return;
|
|
397
405
|
};
|
|
398
406
|
|
|
399
407
|
const sessionid = UuIdv4();
|
|
@@ -407,7 +415,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
407
415
|
"parameters": params,
|
|
408
416
|
"linkedXboxId": this.xboxLiveId
|
|
409
417
|
}
|
|
410
|
-
const debug = this.enableDebugMode ? this.emit('debug', `send, type: ${commandType}, command: ${command}, params: ${params}
|
|
418
|
+
const debug = this.enableDebugMode ? this.emit('debug', `send, type: ${commandType}, command: ${command}, params: ${params}`) : false;
|
|
411
419
|
|
|
412
420
|
try {
|
|
413
421
|
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;
|
|
@@ -129,7 +129,7 @@ class XboxDevice extends EventEmitter {
|
|
|
129
129
|
const debug = this.enableDebugMode ? this.emit('debug', `Saved data: ${data}`) : false;
|
|
130
130
|
return true;
|
|
131
131
|
} catch (error) {
|
|
132
|
-
throw new Error(`Save data error: ${error
|
|
132
|
+
throw new Error(`Save data error: ${error}`);
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -139,7 +139,7 @@ class XboxDevice extends EventEmitter {
|
|
|
139
139
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read data: ${JSON.stringify(data, null, 2)}`);
|
|
140
140
|
return data;
|
|
141
141
|
} catch (error) {
|
|
142
|
-
throw new Error(`Read data error: ${error
|
|
142
|
+
throw new Error(`Read data error: ${error}`);
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -203,7 +203,7 @@ class XboxDevice extends EventEmitter {
|
|
|
203
203
|
};
|
|
204
204
|
return set;
|
|
205
205
|
} catch (error) {
|
|
206
|
-
throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error
|
|
206
|
+
throw new Error(`${integration} set key: ${key}, value: ${value}, error: ${error}`);
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -308,7 +308,7 @@ class XboxDevice extends EventEmitter {
|
|
|
308
308
|
this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
|
|
309
309
|
return true;
|
|
310
310
|
} catch (error) {
|
|
311
|
-
throw new Error(`Display order error: ${error
|
|
311
|
+
throw new Error(`Display order error: ${error}`);
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
|
|
@@ -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
|
};
|
|
@@ -1215,7 +1215,7 @@ class XboxDevice extends EventEmitter {
|
|
|
1215
1215
|
|
|
1216
1216
|
return true;
|
|
1217
1217
|
} catch (error) {
|
|
1218
|
-
throw new Error(`Start error: ${error
|
|
1218
|
+
throw new Error(`Start error: ${error}`);
|
|
1219
1219
|
};
|
|
1220
1220
|
}
|
|
1221
1221
|
};
|