Fix bridge/state online not send after reconnect. https://github.com/Koenkk/zigbee2mqtt/issues/4854

This commit is contained in:
Koen Kanters
2020-11-15 13:22:29 +01:00
parent 6c22f285b4
commit c1e5c75473
2 changed files with 2 additions and 1 deletions
-1
View File
@@ -149,7 +149,6 @@ class Controller {
// MQTT
this.mqtt.on('message', this.onMQTTMessage.bind(this));
await this.mqtt.connect();
this.mqtt.publish('bridge/state', 'online', {retain: true, qos: 0});
// Send all cached states.
if (settings.get().advanced.cache_state_send_on_startup && settings.get().advanced.cache_state) {
+2
View File
@@ -72,8 +72,10 @@ class MQTT extends events.EventEmitter {
return new Promise((resolve) => {
this.client = mqtt.connect(mqttSettings.server, options);
const self = this;
this.client.on('connect', () => {
logger.info('Connected to MQTT server');
self.publish('bridge/state', 'online', {retain: true, qos: 0});
resolve();
});