From 65481c23ef30b1fee0b3b5439ad3fd5600da0b95 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 26 May 2018 05:29:17 +0300 Subject: [PATCH] Replace {identifier} with {hostname} --- code/espurna/migrate.ino | 9 +++++++++ code/espurna/mqtt.ino | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/espurna/migrate.ino b/code/espurna/migrate.ino index 5ea604b3..5faf0dc1 100644 --- a/code/espurna/migrate.ino +++ b/code/espurna/migrate.ino @@ -1001,6 +1001,15 @@ 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 b74be3f8..d45ca1f2 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -218,7 +218,6 @@ void _mqttConfigure() { if (_mqtt_topic.endsWith("/")) _mqtt_topic.remove(_mqtt_topic.length()-1); // Placeholders - _mqtt_topic.replace("{identifier}", getSetting("hostname")); _mqtt_topic.replace("{hostname}", getSetting("hostname")); _mqtt_topic.replace("{magnitude}", "#"); if (_mqtt_topic.indexOf("#") == -1) _mqtt_topic = _mqtt_topic + "/#";