homebridge-xbox-tv 4.4.2 → 4.4.3

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
@@ -18,6 +18,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
18
  - For plugin < v4.1.0 use Homebridge UI <= v5.5.0
19
19
  - For plugin >= v4.1.0 use Homebridge UI >= v5.13.0
20
20
 
21
+ ## [4.4.3] - (18.11.2026)
22
+
23
+ ### Changes
24
+
25
+ - fixed: the RESTFul server tries again every 10 seconds when its port cannot be opened at the start of the plugin, a server that starts later is used by the running device
26
+ - fixed: MQTT does not queue the messages while the broker is not connected, the plugin stops to publish when the connection to the broker is lost and starts again after it is connected
27
+ - updated: dependencies, axios and @homebridge/plugin-ui-utils to the latest versions
28
+
21
29
  ## [4.4.2] - (14.11.2026)
22
30
 
23
31
  ### Changes
package/index.js CHANGED
@@ -128,9 +128,11 @@ class XboxPlatform {
128
128
  logWarn: logLevel.warn,
129
129
  logDebug: logLevel.debug,
130
130
  })
131
- .once('connected', (msg) => {
131
+ .on('connected', (msg) => {
132
132
  clearTimeout(timer);
133
133
  restFulConnected = true;
134
+ // The server can start later than the plugin, when the port was busy, the running device uses it from then
135
+ if (activeDevice) activeDevice.restFulConnected = true;
134
136
  if (logLevel.success) log.success(`Device: ${host} ${name}, ${msg}`);
135
137
  resolve();
136
138
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Xbox TV",
3
3
  "name": "homebridge-xbox-tv",
4
- "version": "4.4.2",
4
+ "version": "4.4.3",
5
5
  "description": "Homebridge plugin to control Xbox game consoles.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -36,12 +36,12 @@
36
36
  "node": "^20 || ^22 || ^24 || ^25 || ^26"
37
37
  },
38
38
  "dependencies": {
39
- "@homebridge/plugin-ui-utils": "^2.2.7",
39
+ "@homebridge/plugin-ui-utils": "^2.3.0",
40
40
  "mqtt": "^5.16.1",
41
41
  "hex-to-binary": "^1.0.1",
42
42
  "uuid": "^14.0.3",
43
43
  "express": "^5.3.0",
44
- "axios": "^1.21.0"
44
+ "axios": "^1.21.1"
45
45
  },
46
46
  "keywords": [
47
47
  "homebridge",
package/src/mqtt.js CHANGED
@@ -94,7 +94,10 @@ class Mqtt extends EventEmitter {
94
94
  if (config.logDebug) this.emit('debug', 'MQTT Reconnecting...');
95
95
  })
96
96
  .on('close', () => {
97
+ // The broker is gone, the plugin stops to publish until it is connected again, the client would only queue the messages
98
+ const wasConnected = this.connected;
97
99
  this.connected = false;
100
+ if (wasConnected) this.emit('offline');
98
101
  if (!hasConnected && !warnedStalled && Date.now() - startTime > 30000) {
99
102
  warnedStalled = true;
100
103
  this.emit('warn', `MQTT has not connected after 30s of retries using protocol v${protocolVersion}. Check broker address, credentials, and whether the broker supports this MQTT protocol version.`);
package/src/restful.js CHANGED
@@ -126,15 +126,31 @@ class RestFul extends EventEmitter {
126
126
  });
127
127
 
128
128
  // Start the server
129
- this.server = app.listen(this.port, () => {
130
- this.emit('connected', `RESTful started on port: ${this.port}`);
131
- });
129
+ this.listen(app);
132
130
  } catch (error) {
133
131
  if (this.logWarn) this.emit('warn', `RESTful Connect error: ${error}`);
134
132
  }
135
133
  }
136
134
 
135
+ // When the port cannot be opened, for example it is still used after a restart, the server tries again until it starts
136
+ listen(app) {
137
+ this.server = app.listen(this.port);
138
+ const server = this.server;
139
+ server.once('listening', () => {
140
+ this.listenWarned = false;
141
+ this.emit('connected', `RESTful started on port: ${this.port}`);
142
+ });
143
+ server.on('error', (error) => {
144
+ if (this.closed) return;
145
+ if (this.logWarn && !this.listenWarned) this.emit('warn', `RESTful cannot start on port: ${this.port}, ${error.code ?? error}, trying again every 10 seconds`);
146
+ this.listenWarned = true;
147
+ server.close();
148
+ setTimeout(() => this.listen(app), 10000).unref?.();
149
+ });
150
+ }
151
+
137
152
  close() {
153
+ this.closed = true;
138
154
  if (this.server) {
139
155
  this.server.close();
140
156
  this.server = null;
package/src/xboxdevice.js CHANGED
@@ -57,6 +57,7 @@ class XboxDevice extends EventEmitter {
57
57
  // The broker may come online after the start or restart, the device then publishes again
58
58
  this.haReady = false;
59
59
  this.mqtt1?.on('online', () => this.mqttOnline().catch((error) => this.emit('warn', `MQTT online error: ${error}`)));
60
+ this.mqtt1?.on('offline', () => { this.mqttConnected = false; });
60
61
  this.functions = new Functions();
61
62
 
62
63
  //sensors
@@ -1028,6 +1029,7 @@ class XboxDevice extends EventEmitter {
1028
1029
  if (!mqtt1) return;
1029
1030
 
1030
1031
  this.mqtt1.on('online', () => this.mqttOnline().catch((error) => this.emit('warn', `MQTT online error: ${error}`)));
1032
+ this.mqtt1.on('offline', () => { this.mqttConnected = false; });
1031
1033
  if (mqttConnected) await this.mqttOnline();
1032
1034
  }
1033
1035