From be224265f912370597932f3fd5a775a35427ba5e Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 25 Aug 2026 18:59:25 +0200 Subject: [PATCH] show mqtt disconnect once --- src/ESP32React/MqttSettingsService.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ESP32React/MqttSettingsService.cpp b/src/ESP32React/MqttSettingsService.cpp index fdd6b51c6..5b369d987 100644 --- a/src/ESP32React/MqttSettingsService.cpp +++ b/src/ESP32React/MqttSettingsService.cpp @@ -7,7 +7,7 @@ MqttSettingsService::MqttSettingsService(AsyncWebServer * server, FS * fs, Secur , _fsPersistence(MqttSettings::read, MqttSettings::update, this, fs, MQTT_SETTINGS_FILE) , _reconfigureMqtt(false) , _disconnectedAt(0) - , _disconnectReason(espMqttClientTypes::DisconnectReason::TCP_DISCONNECTED) + , _disconnectReason(espMqttClientTypes::DisconnectReason::USER_OK) , _mqttClient(nullptr) { addUpdateHandler([this] { onConfigUpdated(); }, false); } @@ -133,11 +133,14 @@ void MqttSettingsService::onMqttConnect(bool sessionPresent) { } void MqttSettingsService::onMqttDisconnect(espMqttClientTypes::DisconnectReason reason) { - _disconnectReason = reason; + if (reason != _disconnectReason) { + emsesp::EMSESP::mqtt_.on_disconnect(reason); + _disconnectReason = reason; + } + if (!_disconnectedAt) { _disconnectedAt = uuid::get_uptime(); } - emsesp::EMSESP::mqtt_.on_disconnect(reason); } void MqttSettingsService::onConfigUpdated() {