Skip to content

Commit

Permalink
Moved {identifier} check to _mqttBackwards
Browse files Browse the repository at this point in the history
  • Loading branch information
xoseperez committed May 29, 2018
1 parent 61c61e8 commit 36f6d39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 1 addition & 10 deletions code/espurna/migrate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

}
10 changes: 10 additions & 0 deletions code/espurna/mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 36f6d39

Please sign in to comment.