homebridge-xbox-tv 4.3.2 → 4.3.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 +7 -0
- package/package.json +1 -1
- package/src/hadiscovery.js +8 -0
- package/src/mqtt.js +5 -0
- package/src/xboxdevice.js +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,13 @@ 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.3.3] - (29.09.2026)
|
|
22
|
+
|
|
23
|
+
### Changes
|
|
24
|
+
|
|
25
|
+
- fixed: MQTT, when the broker was not running yet at the start of Homebridge the device never published over MQTT and the Home Assistant discovery was not set up until a restart. The device now starts publishing and sets up the discovery as soon as the broker comes online
|
|
26
|
+
- fixed: Home Assistant discovery, the config and the state are published again after a restart of the broker, a broker without persistence loses the retained messages
|
|
27
|
+
|
|
21
28
|
## [4.3.2] - (28.09.2026)
|
|
22
29
|
|
|
23
30
|
### Changes
|
package/package.json
CHANGED
package/src/hadiscovery.js
CHANGED
|
@@ -74,6 +74,14 @@ class HaDiscovery {
|
|
|
74
74
|
return true;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// The broker may have lost the retained messages (restart without persistence), the next publish sends
|
|
78
|
+
// the config, the whole state and the image again
|
|
79
|
+
reset() {
|
|
80
|
+
this.lastConfig = '';
|
|
81
|
+
this.lastState = '';
|
|
82
|
+
this.lastImageKey = undefined;
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
// Publish the image of the current source (app icon, channel picon) once per source.
|
|
78
86
|
// key identifies the image, fetchImage returns a Buffer or null, null clears the image
|
|
79
87
|
async updateImage(key, fetchImage) {
|
package/src/mqtt.js
CHANGED
|
@@ -36,6 +36,7 @@ class Mqtt extends EventEmitter {
|
|
|
36
36
|
} : {})
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
this.connected = false;
|
|
39
40
|
const startTime = Date.now();
|
|
40
41
|
let hasConnected = false;
|
|
41
42
|
let warnedStalled = false;
|
|
@@ -45,6 +46,9 @@ class Mqtt extends EventEmitter {
|
|
|
45
46
|
hasConnected = true;
|
|
46
47
|
this.emit('connected', `MQTT v${protocolVersion} connected.`);
|
|
47
48
|
if (this.haDiscovery) this.publishRetained(this.availabilityTopic, 'online').catch(() => { });
|
|
49
|
+
// Every connect, also when the broker was not running at start or restarted, devices publish again
|
|
50
|
+
this.connected = true;
|
|
51
|
+
this.emit('online');
|
|
48
52
|
|
|
49
53
|
try {
|
|
50
54
|
await new Promise((resolve, reject) => {
|
|
@@ -90,6 +94,7 @@ class Mqtt extends EventEmitter {
|
|
|
90
94
|
if (config.logDebug) this.emit('debug', 'MQTT Reconnecting...');
|
|
91
95
|
})
|
|
92
96
|
.on('close', () => {
|
|
97
|
+
this.connected = false;
|
|
93
98
|
if (!hasConnected && !warnedStalled && Date.now() - startTime > 30000) {
|
|
94
99
|
warnedStalled = true;
|
|
95
100
|
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/xboxdevice.js
CHANGED
|
@@ -54,6 +54,9 @@ class XboxDevice extends EventEmitter {
|
|
|
54
54
|
this.mqtt = device.mqtt ?? {};
|
|
55
55
|
this.mqtt1 = mqtt1;
|
|
56
56
|
this.mqttConnected = mqttConnected;
|
|
57
|
+
// The broker may come online after the start or restart, the device then publishes again
|
|
58
|
+
this.haReady = false;
|
|
59
|
+
this.mqtt1?.on('online', () => this.mqttOnline().catch((error) => this.emit('warn', `MQTT online error: ${error}`)));
|
|
57
60
|
this.functions = new Functions();
|
|
58
61
|
|
|
59
62
|
//sensors
|
|
@@ -1016,6 +1019,15 @@ class XboxDevice extends EventEmitter {
|
|
|
1016
1019
|
}
|
|
1017
1020
|
|
|
1018
1021
|
//home assistant discovery
|
|
1022
|
+
// MQTT connected, at start when the broker was not running yet or after a restart of the broker
|
|
1023
|
+
async mqttOnline() {
|
|
1024
|
+
this.mqttConnected = true;
|
|
1025
|
+
if (!this.haReady) return;
|
|
1026
|
+
if (!this.ha) return this.setupHaDiscovery();
|
|
1027
|
+
this.ha.reset();
|
|
1028
|
+
await this.haPublishConfig();
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1019
1031
|
async setupHaDiscovery() {
|
|
1020
1032
|
if (!this.mqttConnected || !this.mqtt.haDiscovery) return;
|
|
1021
1033
|
|
|
@@ -1307,6 +1319,7 @@ class XboxDevice extends EventEmitter {
|
|
|
1307
1319
|
|
|
1308
1320
|
// Prepare accessory
|
|
1309
1321
|
const accessory = await this.prepareAccessory();
|
|
1322
|
+
this.haReady = true;
|
|
1310
1323
|
this.setupHaDiscovery();
|
|
1311
1324
|
return accessory;
|
|
1312
1325
|
} catch (error) {
|