From 36f6d399bd5abba4e54bfae182f0f952fffae61d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 30 May 2018 00:13:31 +0200 Subject: [PATCH] Moved {identifier} check to _mqttBackwards --- code/espurna/migrate.ino | 11 +---------- code/espurna/mqtt.ino | 10 ++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 7d8e3437..ce8da265 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -962,7 +962,7 @@ void migrate() { setSetting("btnRelay", 0, 0); setSetting("relayGPIO", 0, 12); setSetting("relayType", 0, RELAY_TYPE_NORMAL); - + #elif defined(PILOTAK_ESP_DIN_V1) setSetting("board", 76); @@ -1013,15 +1013,6 @@ void migrate() { } - #if MQTT_SUPPORT - // Deprecated MQTT substitution - String mqttTopic = getSetting("mqttTopic", MQTT_TOPIC); - if (mqttTopic.indexOf("{identifier}") > 0) { - mqttTopic.replace("{identifier}", "{hostname}"); - setSetting("mqttTopic", mqttTopic); - } - #endif - saveSettings(); } diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index d45ca1f2..c935ba4b 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -249,6 +249,14 @@ void _mqttConfigure() { } +void _mqttBackwards() { + String mqttTopic = getSetting("mqttTopic", MQTT_TOPIC); + if (mqttTopic.indexOf("{identifier}") > 0) { + mqttTopic.replace("{identifier}", "{hostname}"); + setSetting("mqttTopic", mqttTopic); + } +} + unsigned long _mqttNextMessageId() { static unsigned long id = 0; @@ -740,6 +748,8 @@ void mqttReset() { void mqttSetup() { + _mqttBackwards(); + DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"), MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED",