homebridge-xbox-tv 3.0.2 → 3.0.4
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/index.js +10 -7
- package/package.json +1 -1
- package/src/localApi/xboxlocalapi.js +8 -8
- package/src/restful.js +2 -2
- package/src/webApi/xboxwebapi.js +1 -1
- package/src/xboxdevice.js +27 -20
package/index.js
CHANGED
|
@@ -32,7 +32,7 @@ class XboxPlatform {
|
|
|
32
32
|
|
|
33
33
|
//debug config
|
|
34
34
|
const debugMode = device.enableDebugMode;
|
|
35
|
-
const debug = debugMode ? log(`Device: ${deviceHost} ${deviceName}, did finish launching.`) : false;
|
|
35
|
+
const debug = debugMode ? log.info(`Device: ${deviceHost} ${deviceName}, did finish launching.`) : false;
|
|
36
36
|
const config = {
|
|
37
37
|
...device,
|
|
38
38
|
xboxLiveId: 'removed',
|
|
@@ -41,24 +41,27 @@ class XboxPlatform {
|
|
|
41
41
|
mqtt: {
|
|
42
42
|
...device.mqtt,
|
|
43
43
|
passwd: 'removed'
|
|
44
|
-
|
|
44
|
+
}
|
|
45
45
|
};
|
|
46
|
-
const debug1 = debugMode ? log(`Device: ${deviceHost} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}`) : false;
|
|
46
|
+
const debug1 = debugMode ? log.info(`Device: ${deviceHost} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}`) : false;
|
|
47
47
|
|
|
48
48
|
//xbox device
|
|
49
49
|
const xboxDevice = new XboxDevice(api, prefDir, device);
|
|
50
50
|
xboxDevice.on('publishAccessory', (accessory) => {
|
|
51
51
|
api.publishExternalAccessories(CONSTANTS.PluginName, [accessory]);
|
|
52
|
-
|
|
52
|
+
log.success(`Device: ${deviceHost} ${deviceName}, published as external accessory.`);
|
|
53
53
|
})
|
|
54
54
|
.on('devInfo', (devInfo) => {
|
|
55
|
-
log(devInfo);
|
|
55
|
+
log.info(devInfo);
|
|
56
56
|
})
|
|
57
57
|
.on('message', (message) => {
|
|
58
|
-
log(`Device: ${deviceHost} ${deviceName}, ${message}`);
|
|
58
|
+
log.info(`Device: ${deviceHost} ${deviceName}, ${message}`);
|
|
59
59
|
})
|
|
60
60
|
.on('debug', (debug) => {
|
|
61
|
-
log(`Device: ${deviceHost} ${deviceName}, debug: ${debug}`);
|
|
61
|
+
log.info(`Device: ${deviceHost} ${deviceName}, debug: ${debug}`);
|
|
62
|
+
})
|
|
63
|
+
.on('warn', (warn) => {
|
|
64
|
+
log.warn(`warn: ${deviceHost} ${deviceName}, ${warn}`);
|
|
62
65
|
})
|
|
63
66
|
.on('error', (error) => {
|
|
64
67
|
log.error(`Device: ${deviceHost} ${deviceName}, ${error}`);
|
package/package.json
CHANGED
|
@@ -430,7 +430,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
430
430
|
|
|
431
431
|
async powerOn() {
|
|
432
432
|
if (this.isConnected) {
|
|
433
|
-
this.emit('
|
|
433
|
+
this.emit('warn', 'Console already On.');
|
|
434
434
|
};
|
|
435
435
|
|
|
436
436
|
const info = this.infoLog ? false : this.emit('message', 'Send power On.');
|
|
@@ -457,7 +457,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
457
457
|
|
|
458
458
|
async powerOff() {
|
|
459
459
|
if (!this.isConnected) {
|
|
460
|
-
this.emit('
|
|
460
|
+
this.emit('warn', 'Console already Off.');
|
|
461
461
|
};
|
|
462
462
|
|
|
463
463
|
const info = this.infoLog ? false : this.emit('message', 'Send power Off.');
|
|
@@ -479,7 +479,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
479
479
|
|
|
480
480
|
async recordGameDvr() {
|
|
481
481
|
if (!this.isConnected || !this.isAuthorized) {
|
|
482
|
-
this.emit('
|
|
482
|
+
this.emit('warn', `Send record game ignored, connection state: ${this.isConnected}, authorization state: ${this.isAuthorized}`);
|
|
483
483
|
};
|
|
484
484
|
|
|
485
485
|
const info = this.infoLog ? false : this.emit('message', 'Send record game.');
|
|
@@ -498,7 +498,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
498
498
|
|
|
499
499
|
async sendButtonPress(channelName, command) {
|
|
500
500
|
if (!this.isConnected) {
|
|
501
|
-
this.emit('
|
|
501
|
+
this.emit('waarn', `Send command ignored, connection state: ${this.isConnected ? 'Not Connected' : 'Connected'}.`);
|
|
502
502
|
};
|
|
503
503
|
|
|
504
504
|
const channelRequestId = CONSTANTS.LocalApi.Channels.System[channelName].Id
|
|
@@ -506,7 +506,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
506
506
|
const channelOpen = this.channels[requestId].open;
|
|
507
507
|
|
|
508
508
|
if (channelCommunicationId === -1 || !channelOpen) {
|
|
509
|
-
this.emit('
|
|
509
|
+
this.emit('warn', `Channel Id: ${channelCommunicationId}, state: ${channelOpen ? 'Open' : 'Closed'}, trying to open it.`);
|
|
510
510
|
};
|
|
511
511
|
|
|
512
512
|
command = CONSTANTS.LocalApi.Channels.System[channelName][command];
|
|
@@ -531,7 +531,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
531
531
|
await this.sendSocketMessage(message, 'gamepadUnpress');
|
|
532
532
|
}, 150)
|
|
533
533
|
} catch (error) {
|
|
534
|
-
this.emit('
|
|
534
|
+
this.emit('warn', `Send system input command error: ${error}`)
|
|
535
535
|
};
|
|
536
536
|
break;
|
|
537
537
|
case 1:
|
|
@@ -551,7 +551,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
551
551
|
const message = json.pack(this.crypto, sequenceNumber1, this.sourceParticipantId, channelCommunicationId);
|
|
552
552
|
this.sendSocketMessage(message, 'json');
|
|
553
553
|
} catch (error) {
|
|
554
|
-
this.emit('
|
|
554
|
+
this.emit('warn', `Send tv remote command error: ${error}`)
|
|
555
555
|
};
|
|
556
556
|
break;
|
|
557
557
|
case 2:
|
|
@@ -568,7 +568,7 @@ class XBOXLOCALAPI extends EventEmitter {
|
|
|
568
568
|
this.sendSocketMessage(message, 'mediaCommand');
|
|
569
569
|
this.mediaRequestId++;
|
|
570
570
|
} catch (error) {
|
|
571
|
-
this.emit('
|
|
571
|
+
this.emit('warn', `Send system media command error: ${error}`)
|
|
572
572
|
};
|
|
573
573
|
break;
|
|
574
574
|
}
|
package/src/restful.js
CHANGED
|
@@ -37,7 +37,7 @@ class RestFul extends EventEmitter {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
} catch (error) {
|
|
40
|
-
this.emit('error', `RESTful error: ${error}`)
|
|
40
|
+
this.emit('error', `RESTful Connect error: ${error}`)
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
@@ -65,7 +65,7 @@ class RestFul extends EventEmitter {
|
|
|
65
65
|
this.restFulData.status = data;
|
|
66
66
|
break;
|
|
67
67
|
default:
|
|
68
|
-
this.emit('
|
|
68
|
+
this.emit('error', `RESTFul update unknown path: ${path}, data: ${data}`)
|
|
69
69
|
break;
|
|
70
70
|
};
|
|
71
71
|
const emitDebug = this.restFulDebug ? this.emit('debug', `RESTFul update path: ${path}, data: ${JSON.stringify(data, null, 2)}`) : false;
|
package/src/webApi/xboxwebapi.js
CHANGED
package/src/xboxdevice.js
CHANGED
|
@@ -57,7 +57,7 @@ class XboxDevice extends EventEmitter {
|
|
|
57
57
|
this.restFulConnected = false;
|
|
58
58
|
|
|
59
59
|
//mqtt
|
|
60
|
-
const mqtt = device.
|
|
60
|
+
const mqtt = device.mqtt ?? {};
|
|
61
61
|
const mqttEnabled = mqtt.enable || false;
|
|
62
62
|
this.mqttConnected = false;
|
|
63
63
|
|
|
@@ -148,6 +148,7 @@ class XboxDevice extends EventEmitter {
|
|
|
148
148
|
});
|
|
149
149
|
} catch (error) {
|
|
150
150
|
this.emit('error', `prepare files error: ${error}`);
|
|
151
|
+
return;
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
//web api client
|
|
@@ -185,6 +186,9 @@ class XboxDevice extends EventEmitter {
|
|
|
185
186
|
.on('debug', (debug) => {
|
|
186
187
|
this.emit('debug', debug);
|
|
187
188
|
})
|
|
189
|
+
.on('warn', (warn) => {
|
|
190
|
+
this.emit('warn', warn);
|
|
191
|
+
})
|
|
188
192
|
.on('error', (error) => {
|
|
189
193
|
this.emit('error', error);
|
|
190
194
|
})
|
|
@@ -330,11 +334,11 @@ class XboxDevice extends EventEmitter {
|
|
|
330
334
|
this.restFulConnected = true;
|
|
331
335
|
this.emit('message', message);
|
|
332
336
|
})
|
|
333
|
-
.on('error', (error) => {
|
|
334
|
-
this.emit('error', error);
|
|
335
|
-
})
|
|
336
337
|
.on('debug', (debug) => {
|
|
337
338
|
this.emit('debug', debug);
|
|
339
|
+
})
|
|
340
|
+
.on('error', (error) => {
|
|
341
|
+
this.emit('warn', error);
|
|
338
342
|
});
|
|
339
343
|
}
|
|
340
344
|
|
|
@@ -415,14 +419,14 @@ class XboxDevice extends EventEmitter {
|
|
|
415
419
|
break;
|
|
416
420
|
};
|
|
417
421
|
} catch (error) {
|
|
418
|
-
this.emit('
|
|
422
|
+
this.emit('warn', `MQTT send error: ${error}.`);
|
|
419
423
|
};
|
|
420
424
|
})
|
|
421
425
|
.on('debug', (debug) => {
|
|
422
426
|
this.emit('debug', debug);
|
|
423
427
|
})
|
|
424
428
|
.on('error', (error) => {
|
|
425
|
-
this.emit('
|
|
429
|
+
this.emit('warn', error);
|
|
426
430
|
});
|
|
427
431
|
};
|
|
428
432
|
|
|
@@ -464,6 +468,9 @@ class XboxDevice extends EventEmitter {
|
|
|
464
468
|
.on('debug', (debug) => {
|
|
465
469
|
this.emit('debug', debug);
|
|
466
470
|
})
|
|
471
|
+
.on('warn', (warn) => {
|
|
472
|
+
this.emit('warn', warn);
|
|
473
|
+
})
|
|
467
474
|
.on('error', (error) => {
|
|
468
475
|
this.emit('error', error);
|
|
469
476
|
})
|
|
@@ -504,7 +511,7 @@ class XboxDevice extends EventEmitter {
|
|
|
504
511
|
this.televisionService.setCharacteristic(Characteristic.DisplayOrder, Encode(1, displayOrder).toString('base64'));
|
|
505
512
|
return true;
|
|
506
513
|
} catch (error) {
|
|
507
|
-
|
|
514
|
+
throw new Error(error);
|
|
508
515
|
};
|
|
509
516
|
}
|
|
510
517
|
|
|
@@ -514,7 +521,7 @@ class XboxDevice extends EventEmitter {
|
|
|
514
521
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved data: ${JSON.stringify(data, null, 2)}`);
|
|
515
522
|
return true;
|
|
516
523
|
} catch (error) {
|
|
517
|
-
|
|
524
|
+
throw new Error(error);
|
|
518
525
|
};
|
|
519
526
|
}
|
|
520
527
|
|
|
@@ -524,7 +531,7 @@ class XboxDevice extends EventEmitter {
|
|
|
524
531
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Read data: ${JSON.stringify(data, null, 2)}`);
|
|
525
532
|
return data;
|
|
526
533
|
} catch (error) {
|
|
527
|
-
|
|
534
|
+
throw new Error(`Read saved data error: ${error}`);
|
|
528
535
|
};
|
|
529
536
|
}
|
|
530
537
|
|
|
@@ -595,7 +602,7 @@ class XboxDevice extends EventEmitter {
|
|
|
595
602
|
|
|
596
603
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `set Power: ${state ? 'ON' : 'OFF'}`);
|
|
597
604
|
} catch (error) {
|
|
598
|
-
this.emit('
|
|
605
|
+
this.emit('warn', `set Power, error: ${error}`);
|
|
599
606
|
};
|
|
600
607
|
});
|
|
601
608
|
|
|
@@ -646,7 +653,7 @@ class XboxDevice extends EventEmitter {
|
|
|
646
653
|
break;
|
|
647
654
|
}
|
|
648
655
|
} catch (error) {
|
|
649
|
-
this.emit('
|
|
656
|
+
this.emit('warn', `set Input error: ${JSON.stringify(error, null, 2)}`);
|
|
650
657
|
};
|
|
651
658
|
});
|
|
652
659
|
|
|
@@ -714,7 +721,7 @@ class XboxDevice extends EventEmitter {
|
|
|
714
721
|
await this.xboxWebApi.send(channelName, 'InjectKey', [{ 'keyType': command }]);
|
|
715
722
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `Remote Key: ${command}`);
|
|
716
723
|
} catch (error) {
|
|
717
|
-
this.emit('
|
|
724
|
+
this.emit('warn', `set Remote Key error: ${JSON.stringify(error, null, 2)}`);
|
|
718
725
|
};
|
|
719
726
|
});
|
|
720
727
|
|
|
@@ -738,7 +745,7 @@ class XboxDevice extends EventEmitter {
|
|
|
738
745
|
const setMediaState = this.power ? false : false;
|
|
739
746
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `set Target Media: ${['PLAY', 'PAUSE', 'STOP', 'LOADING', 'INTERRUPTED'][value]}`);
|
|
740
747
|
} catch (error) {
|
|
741
|
-
this.emit('
|
|
748
|
+
this.emit('warn', `set Target Media error: ${error}`);
|
|
742
749
|
};
|
|
743
750
|
});
|
|
744
751
|
|
|
@@ -761,7 +768,7 @@ class XboxDevice extends EventEmitter {
|
|
|
761
768
|
await this.xboxWebApi.send(channelName, 'InjectKey', [{ 'keyType': command }]);
|
|
762
769
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `set Power Mode Selection: ${powerModeSelection === 0 ? 'SHOW' : 'HIDE'}`);
|
|
763
770
|
} catch (error) {
|
|
764
|
-
this.emit('
|
|
771
|
+
this.emit('warn', `set Power Mode Selection error: ${error}`);
|
|
765
772
|
};
|
|
766
773
|
});
|
|
767
774
|
this.allServices.push(this.televisionService);
|
|
@@ -802,7 +809,7 @@ class XboxDevice extends EventEmitter {
|
|
|
802
809
|
await this.xboxWebApi.send(channelName, command);
|
|
803
810
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `set Volume Selector: ${volumeSelector ? 'Down' : 'UP'}`);
|
|
804
811
|
} catch (error) {
|
|
805
|
-
this.emit('
|
|
812
|
+
this.emit('warn', `set Volume Selector error: ${error}`);
|
|
806
813
|
};
|
|
807
814
|
})
|
|
808
815
|
|
|
@@ -838,7 +845,7 @@ class XboxDevice extends EventEmitter {
|
|
|
838
845
|
await this.xboxWebApi.send(channelName, command);
|
|
839
846
|
const logInfo = this.disableLogInfo ? false : this.emit('message', `set Mute: ${state ? 'ON' : 'OFF'}`);
|
|
840
847
|
} catch (error) {
|
|
841
|
-
this.emit('
|
|
848
|
+
this.emit('warn', `set Mute error: ${error}`);
|
|
842
849
|
};
|
|
843
850
|
});
|
|
844
851
|
this.allServices.push(this.speakerService);
|
|
@@ -919,7 +926,7 @@ class XboxDevice extends EventEmitter {
|
|
|
919
926
|
this.inputsConfigured[index].name = value;
|
|
920
927
|
await this.displayOrder();
|
|
921
928
|
} catch (error) {
|
|
922
|
-
this.emit('
|
|
929
|
+
this.emit('warn', `save Input Name error: ${error}`);
|
|
923
930
|
}
|
|
924
931
|
});
|
|
925
932
|
|
|
@@ -938,7 +945,7 @@ class XboxDevice extends EventEmitter {
|
|
|
938
945
|
await this.saveData(this.inputsTargetVisibilityFile, this.savedInputsTargetVisibility);
|
|
939
946
|
const debug = !this.enableDebugMode ? false : this.emit('debug', `Saved Input: ${input.name} Target Visibility: ${state ? 'HIDEN' : 'SHOWN'}`);
|
|
940
947
|
} catch (error) {
|
|
941
|
-
this.emit('
|
|
948
|
+
this.emit('warn', `save Target Visibility error: ${error}`);
|
|
942
949
|
}
|
|
943
950
|
});
|
|
944
951
|
this.inputsConfigured.push(input);
|
|
@@ -1158,7 +1165,7 @@ class XboxDevice extends EventEmitter {
|
|
|
1158
1165
|
break;
|
|
1159
1166
|
}
|
|
1160
1167
|
} catch (error) {
|
|
1161
|
-
this.emit('
|
|
1168
|
+
this.emit('warn', `set Button error: ${error}`);
|
|
1162
1169
|
};
|
|
1163
1170
|
});
|
|
1164
1171
|
this.buttonsServices.push(buttonService);
|
|
@@ -1168,7 +1175,7 @@ class XboxDevice extends EventEmitter {
|
|
|
1168
1175
|
}
|
|
1169
1176
|
return accessory;
|
|
1170
1177
|
} catch (error) {
|
|
1171
|
-
|
|
1178
|
+
throw new Error(error)
|
|
1172
1179
|
};
|
|
1173
1180
|
}
|
|
1174
1181
|
};
|