homebridge-openwrt-control 0.4.1 → 0.4.2
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 +6 -0
- package/package.json +1 -1
- package/src/hadiscovery.js +7 -0
- package/src/mqtt.js +5 -0
- package/src/router.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
- After update to v0.1.0 the plugin need to be reconfigured!
|
|
11
11
|
|
|
12
|
+
## [0.4.2] - (29.09.2026)
|
|
13
|
+
|
|
14
|
+
### Changes
|
|
15
|
+
|
|
16
|
+
- 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
|
|
17
|
+
|
|
12
18
|
## [0.4.1] - (25.09.2026)
|
|
13
19
|
|
|
14
20
|
### Changes
|
package/package.json
CHANGED
package/src/hadiscovery.js
CHANGED
|
@@ -53,6 +53,13 @@ class HaDiscovery {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// The broker may have lost the retained messages (restart without persistence), the next sync sends everything again
|
|
57
|
+
reset() {
|
|
58
|
+
this.lastConfig = {};
|
|
59
|
+
this.lastState = '';
|
|
60
|
+
this.lastImage = {};
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
has(suffix, available) {
|
|
57
64
|
if (available) this.seen.add(suffix);
|
|
58
65
|
return this.seen.has(suffix);
|
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/router.js
CHANGED
|
@@ -224,6 +224,11 @@ class Router extends EventEmitter {
|
|
|
224
224
|
.on('connected', msg => {
|
|
225
225
|
this.mqttConnected = true;
|
|
226
226
|
this.emit('success', msg);
|
|
227
|
+
})
|
|
228
|
+
.on('online', () => {
|
|
229
|
+
// Every connect, the broker may have lost the retained messages after a restart
|
|
230
|
+
this.mqttConnected = true;
|
|
231
|
+
this.ha?.reset();
|
|
227
232
|
this.haSync();
|
|
228
233
|
})
|
|
229
234
|
.on('set', async (key, value) => {
|