homebridge-xbox-tv 3.2.2 → 3.3.0-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.
@@ -696,25 +696,41 @@
696
696
  ],
697
697
  "required": false
698
698
  },
699
- "enableDebugMode": {
700
- "title": "Debug",
699
+ "disableLogDeviceInfo": {
700
+ "title": "Disable Log Device Info",
701
701
  "type": "boolean",
702
702
  "default": false,
703
- "description": "This enable debug mode.",
703
+ "description": "This disable logging device info by every connections device to the network.",
704
704
  "required": false
705
705
  },
706
706
  "disableLogInfo": {
707
707
  "title": "Disable Log Info",
708
708
  "type": "boolean",
709
709
  "default": false,
710
- "description": "This disable logging values and states on every it change.",
711
710
  "required": false
712
711
  },
713
- "disableLogDeviceInfo": {
714
- "title": "Disable Log Device Info",
712
+ "disableLogSuccess": {
713
+ "title": "Disable Log Success",
714
+ "type": "boolean",
715
+ "default": false,
716
+ "required": false
717
+ },
718
+ "disableLogWarn": {
719
+ "title": "Disable Log Warn",
720
+ "type": "boolean",
721
+ "default": false,
722
+ "required": false
723
+ },
724
+ "disableLogError": {
725
+ "title": "Disable Log Error",
726
+ "type": "boolean",
727
+ "default": false,
728
+ "required": false
729
+ },
730
+ "enableDebugMode": {
731
+ "title": "Enable Log Debug",
715
732
  "type": "boolean",
716
733
  "default": false,
717
- "description": "This disable log device info by every connections device to the network.",
718
734
  "required": false
719
735
  },
720
736
  "restFul": {
@@ -983,11 +999,14 @@
983
999
  },
984
1000
  {
985
1001
  "key": "devices[]",
986
- "title": "System",
1002
+ "title": "Log",
987
1003
  "items": [
988
- "devices[].enableDebugMode",
1004
+ "devices[].disableLogDeviceInfo",
989
1005
  "devices[].disableLogInfo",
990
- "devices[].disableLogDeviceInfo"
1006
+ "devices[].disableLogSuccess",
1007
+ "devices[].disableLogWarn",
1008
+ "devices[].disableLogError",
1009
+ "devices[].enableDebugMode"
991
1010
  ]
992
1011
  },
993
1012
  {
package/index.js CHANGED
@@ -33,9 +33,14 @@ class XboxPlatform {
33
33
  return;
34
34
  }
35
35
 
36
- //debug config
37
- const enableDebugMode = device.enableDebugMode;
38
- const debug = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, Did finish launching.`) : false;
36
+ //log config
37
+ const enableDebugMode = device.enableDebugMode || false;
38
+ const disableLogDeviceInfo = device.disableLogDeviceInfo || false;
39
+ const disableLogInfo = device.disableLogInfo || false;
40
+ const disableLogSuccess = device.disableLogSuccess || false;
41
+ const disableLogWarn = device.disableLogWarn || false;
42
+ const disableLogError = device.disableLogError || false;
43
+ const debug = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, did finish launching.`);
39
44
  const config = {
40
45
  ...device,
41
46
  xboxLiveId: 'removed',
@@ -46,7 +51,7 @@ class XboxPlatform {
46
51
  passwd: 'removed'
47
52
  }
48
53
  };
49
- const debug1 = enableDebugMode ? log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}`) : false;
54
+ const debug1 = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, Config: ${JSON.stringify(config, null, 2)}.`);
50
55
 
51
56
  //check files exists, if not then create it
52
57
  const postFix = host.split('.').join('');
@@ -72,7 +77,7 @@ class XboxPlatform {
72
77
  }
73
78
  });
74
79
  } catch (error) {
75
- log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}`);
80
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, Prepare files error: ${error}.`);
76
81
  return;
77
82
  }
78
83
 
@@ -81,38 +86,38 @@ class XboxPlatform {
81
86
  const xboxDevice = new XboxDevice(api, device, authTokenFile, devInfoFile, inputsFile, inputsNamesFile, inputsTargetVisibilityFile);
82
87
  xboxDevice.on('publishAccessory', (accessory) => {
83
88
  api.publishExternalAccessories(PluginName, [accessory]);
84
- log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
89
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, Published as external accessory.`);
85
90
  })
86
91
  .on('devInfo', (devInfo) => {
87
- log.info(devInfo);
92
+ const emitLog = disableLogDeviceInfo ? false : log.info(devInfo);
88
93
  })
89
- .on('success', (message) => {
90
- log.success(`Device: ${host} ${deviceName}, ${message}`);
94
+ .on('success', (success) => {
95
+ const emitLog = disableLogSuccess ? false : log.success(`Device: ${host} ${deviceName}, ${success}.`);
91
96
  })
92
- .on('message', (message) => {
93
- log.info(`Device: ${host} ${deviceName}, ${message}`);
97
+ .on('info', (info) => {
98
+ const emitLog = disableLogInfo ? false : log.info(`Device: ${host} ${deviceName}, ${info}.`);
94
99
  })
95
100
  .on('debug', (debug) => {
96
- log.info(`Device: ${host} ${deviceName}, debug: ${debug}`);
101
+ const emitLog = !enableDebugMode ? false : log.info(`Device: ${host} ${deviceName}, debug: ${debug}.`);
97
102
  })
98
103
  .on('warn', (warn) => {
99
- log.warn(`warn: ${host} ${deviceName}, ${warn}`);
104
+ const lemitLogog = disableLogWarn ? false : log.warn(`Device: ${host} ${deviceName}, ${warn}.`);
100
105
  })
101
106
  .on('error', (error) => {
102
- log.error(`Device: ${host} ${deviceName}, ${error}`);
107
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}.`);
103
108
  });
104
109
 
105
110
  //create impulse generator
106
111
  const impulseGenerator = new ImpulseGenerator();
107
112
  impulseGenerator.on('start', async () => {
108
113
  try {
109
- await xboxDevice.start();
110
- impulseGenerator.stop();
114
+ const startDone = await xboxDevice.start();
115
+ const stopImpulseGenerator = startDone ? impulseGenerator.stop() : false;
111
116
  } catch (error) {
112
- const logError = disableLogConnectError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
117
+ const emitLog = disableLogError ? false : log.error(`Device: ${host} ${deviceName}, ${error}, trying again.`);
113
118
  };
114
119
  }).on('state', (state) => {
115
- const debug = enableDebugMode ? state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`) : false;
120
+ const emitLog = !enableDebugMode ? false : state ? log.info(`Device: ${host} ${deviceName}, Start impulse generator started.`) : log.info(`Device: ${host} ${deviceName}, Start impulse generator stopped.`);
116
121
  });
117
122
 
118
123
  //start impulse generator
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "3.2.2",
4
+ "version": "3.3.0-beta.0",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -40,7 +40,7 @@
40
40
  "elliptic": "^6.6.1",
41
41
  "hex-to-binary": "^1.0.1",
42
42
  "jsrsasign": "^11.1.0",
43
- "uuid": "^11.0.3",
43
+ "uuid": "^11.0.5",
44
44
  "ping": "^0.4.4",
45
45
  "express": "^4.21.2",
46
46
  "axios": "^1.7.9"
@@ -8,7 +8,8 @@ class ImpulseGenerator extends EventEmitter {
8
8
 
9
9
  async start(timers) {
10
10
  if (this.timersState) {
11
- await this.stop();
11
+ this.state(true);
12
+ return true;
12
13
  }
13
14
 
14
15
  this.timers = [];
@@ -22,28 +23,27 @@ class ImpulseGenerator extends EventEmitter {
22
23
  };
23
24
 
24
25
  //update state
25
- this.timersState = true;
26
- this.state();
27
-
26
+ this.state(true);
28
27
  return true;
29
28
  }
30
29
 
31
30
  async stop() {
32
- if (this.timersState) {
33
- this.timers.forEach(timer => clearInterval(timer));
31
+ if (!this.timersState) {
32
+ this.state(false);
33
+ return true;
34
34
  }
35
35
 
36
36
  //update state
37
+ this.timers.forEach(timer => clearInterval(timer));
37
38
  this.timers = [];
38
- this.timersState = false;
39
- this.state();
40
-
41
- return true;
39
+ this.state(false);
40
+ return true
42
41
  }
43
42
 
44
- state() {
45
- this.emit('state', this.timersState);
46
- return this.timersState;
43
+ state(state) {
44
+ this.timersState = state;
45
+ this.emit('state', state);
47
46
  }
48
47
  }
49
48
  export default ImpulseGenerator;
49
+