homebridge-xbox-tv 3.3.4-beta.1 → 3.3.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/CHANGELOG.md CHANGED
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
  - After update to 2.x.x the plugin settings (xboxLiveId) need to be updated
11
11
  - After update to v3.0.0 RESTFull and MQTT config settings need to be updated
12
12
 
13
+ ## [3.3.4] - (05.02.2025)
14
+
15
+ ## Changes
16
+
17
+ - Web Api improvements of authoriztion check and remote management
18
+ - cleanup
19
+
13
20
  ## [3.3.3] - (04.02.2025)
14
21
 
15
22
  ## Changes
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.4-beta.1",
4
+ "version": "3.3.4",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -17,6 +17,7 @@ class XboxWebApi extends EventEmitter {
17
17
 
18
18
  //variables
19
19
  this.authorized = false;
20
+ this.rmEnabled = false;
20
21
 
21
22
  const authConfig = {
22
23
  webApiClientId: config.webApiClientId,
@@ -55,15 +56,27 @@ class XboxWebApi extends EventEmitter {
55
56
  this.tokens = data.tokens;
56
57
  this.authorized = true;
57
58
 
58
- //create axios instance
59
- this.axiosInstance = axios.create({
60
- method: 'GET',
61
- headers: headers
62
- });
59
+ if (!this.authorized) {
60
+ this.emit('warn', `not authorized`);
61
+ return false;
62
+ };
63
63
 
64
64
  //check xbox live data
65
65
  try {
66
- await this.xboxLiveData();
66
+ //create axios instance
67
+ this.axiosInstance = axios.create({
68
+ method: 'GET',
69
+ headers: headers
70
+ });
71
+
72
+ const rmEnabled = await this.consoleStatus();
73
+ const debug1 = rmEnabled ? false : this.emit('warn', `Remote management not enabled, please check your console settings`);
74
+ this.rmEnabled = rmEnabled;
75
+
76
+ //await this.consolesList();
77
+ await this.installedApps();
78
+ //await this.storageDevices();
79
+ //await this.userProfile();
67
80
  } catch (error) {
68
81
  this.emit('error', `Check xbox live data error: ${error}`);
69
82
  };
@@ -74,21 +87,6 @@ class XboxWebApi extends EventEmitter {
74
87
  };
75
88
  }
76
89
 
77
- async xboxLiveData() {
78
- try {
79
- const rmEnabled = await this.consoleStatus();
80
- const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings`) : false;
81
- //await this.consolesList();
82
- await this.installedApps();
83
- //await this.storageDevices();
84
- //await this.userProfile();
85
-
86
- return true;
87
- } catch (error) {
88
- throw new Error(`Xbox live data error: ${error}`);
89
- };
90
- };
91
-
92
90
  async consoleStatus() {
93
91
  try {
94
92
  const url = `${WebApi.Url.Xccs}/consoles/${this.xboxLiveId}`;
@@ -399,8 +397,8 @@ class XboxWebApi extends EventEmitter {
399
397
  }
400
398
 
401
399
  async send(commandType, command, payload) {
402
- if (!this.authorized) {
403
- this.emit('warn', `not authorized`);
400
+ if (!this.authorized || !this.rmEnabled) {
401
+ this.emit('warn', `not authorized or remote management not enabled`);
404
402
  return;
405
403
  };
406
404
 
package/src/xboxdevice.js CHANGED
@@ -973,7 +973,7 @@ class XboxDevice extends EventEmitter {
973
973
  }
974
974
 
975
975
  //sort inputs list
976
- const sortInputsDisplayOrder = this.televisionService ? await this.displayOrder() : false;
976
+ await this.displayOrder();
977
977
 
978
978
  return accessory;
979
979
  } catch (error) {
@@ -1043,7 +1043,7 @@ class XboxDevice extends EventEmitter {
1043
1043
  const timers = [{ name: 'checkAuthorization', sampling: 900000 }];
1044
1044
  const startImpulseGenerator = checkAuthorization ? await this.xboxWebApi.impulseGenerator.start(timers) : false;
1045
1045
  } catch (error) {
1046
- this.emit('error', error);
1046
+ this.emit('error', `Start web api error: ${error}`);
1047
1047
  };
1048
1048
  };
1049
1049
 
@@ -1166,11 +1166,11 @@ class XboxDevice extends EventEmitter {
1166
1166
  this.emit('info', `Media State: ${['PLAY', 'PAUSE', 'STOPPED', 'LOADING', 'INTERRUPTED'][mediaState]}`);
1167
1167
  };
1168
1168
  })
1169
- .on('success', (message) => {
1170
- this.emit('success', message);
1169
+ .on('success', (success) => {
1170
+ this.emit('success', success);
1171
1171
  })
1172
- .on('info', (message) => {
1173
- this.emit('info', message);
1172
+ .on('info', (info) => {
1173
+ this.emit('info', info);
1174
1174
  })
1175
1175
  .on('debug', (debug) => {
1176
1176
  this.emit('debug', debug);
@@ -1181,8 +1181,8 @@ class XboxDevice extends EventEmitter {
1181
1181
  .on('error', (error) => {
1182
1182
  this.emit('error', error);
1183
1183
  })
1184
- .on('disconnected', (message) => {
1185
- this.emit('info', message);
1184
+ .on('disconnected', (info) => {
1185
+ this.emit('info', info);
1186
1186
  })
1187
1187
  .on('restFul', (path, data) => {
1188
1188
  const restFul = this.restFulConnected ? this.restFul1.update(path, data) : false;