diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9a3f8198e..7ce640e57 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -186,11 +186,13 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ## Changelog Version 6.4.1 20181223 * Change RAM usage BMP/BME I2C sensors + * Change FallbackTopic from cmnd/\/ to cmnd/\_fb/ to discriminate from Topic (#1528) * Change FallbackTopic detection (#4706) * Change Hass discovery to short MQTT messages as used by Hass 0.81 and up (#4711) * Fix possible dtostrf buffer overflows by increasing buffers * Fix wifi strongest signal detection (#4704) * Fix Alexa "this value is outside the range of the device". Needs power cycle and Alexa deletion/discovery cycle. (#3159, #4712) + * Add Slovak language file (#4663) * Add support for AZ-Instrument 7798 CO2 meter/datalogger (#4672) * Add define WIFI_SOFT_AP_CHANNEL in my_user_config.h to set Soft Access Point Channel number between 1 and 13 as used by Wifi Manager web GUI (#4673) * Add define USE_MQTT_TLS_CA_CERT for checking MQTT TLS against root ca using Let's Encrypt cert from sonoff_letsencrypt.h - not supported with core 2.3.0 (#4703) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index aa0b4381a..d305600c7 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,10 +1,12 @@ /* 6.4.1 20181223 * Change RAM usage BMP/BME I2C sensors + * Change FallbackTopic from cmnd// to cmnd/_fb/ to discriminate from Topic (#1528) * Change FallbackTopic detection (#4706) * Change Hass discovery to short MQTT messages as used by Hass 0.81 and up (#4711) * Fix possible dtostrf buffer overflows by increasing buffers * Fix wifi strongest signal detection (#4704) * Fix Alexa "this value is outside the range of the device". Needs power cycle and Alexa deletion/discovery cycle. (#3159, #4712) + * Add Slovak language file (#4663) * Add support for AZ-Instrument 7798 CO2 meter/datalogger (#4672) * Add define WIFI_SOFT_AP_CHANNEL in my_user_config.h to set Soft Access Point Channel number between 1 and 13 as used by Wifi Manager web GUI (#4673) * Add define USE_MQTT_TLS_CA_CERT for checking MQTT TLS against root ca using Let's Encrypt cert from sonoff_letsencrypt.h - not supported with core 2.3.0 (#4703) diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index b262c7d9b..be5964a94 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -245,20 +245,25 @@ char* GetOtaUrl(char *otaurl, size_t otaurl_size) return otaurl; } -void GetTopic_P(char *stopic, byte prefix, char *topic, const char* subtopic) +char* GetTopic_P(char *stopic, byte prefix, char *topic, const char* subtopic) { /* prefix 0 = Cmnd prefix 1 = Stat prefix 2 = Tele + prefix 4 = Cmnd fallback + prefix 5 = Stat fallback + prefix 6 = Tele fallback */ char romram[CMDSZ]; String fulltopic; snprintf_P(romram, sizeof(romram), subtopic); - if (fallback_topic_flag) { + if (fallback_topic_flag || (prefix > 3)) { + prefix &= 3; fulltopic = FPSTR(kPrefixes[prefix]); fulltopic += F("/"); fulltopic += mqtt_client; + fulltopic += F("_fb"); // cmnd/_fb } else { fulltopic = Settings.mqtt_fulltopic; if ((0 == prefix) && (-1 == fulltopic.indexOf(F(MQTT_TOKEN_PREFIX)))) { @@ -280,6 +285,12 @@ void GetTopic_P(char *stopic, byte prefix, char *topic, const char* subtopic) fulltopic.replace(F("//"), "/"); if (!fulltopic.endsWith("/")) fulltopic += "/"; snprintf_P(stopic, TOPSZ, PSTR("%s%s"), fulltopic.c_str(), romram); + return stopic; +} + +char* GetFallbackTopic_P(char *stopic, byte prefix, const char* subtopic) +{ + return GetTopic_P(stopic, prefix +4, NULL, subtopic); } char* GetStateText(byte state) @@ -467,8 +478,10 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len) if (XdrvMqttData(topicBuf, sizeof(topicBuf), dataBuf, sizeof(dataBuf))) return; grpflg = (strstr(topicBuf, Settings.mqtt_grptopic) != NULL); - snprintf_P(stemp1, sizeof(stemp1), PSTR(D_CMND "/%s/"), mqtt_client); // Full Fallback topic = cmnd/DVES_xxxxxxxx + + GetFallbackTopic_P(stemp1, CMND, ""); // Full Fallback topic = cmnd/DVES_xxxxxxxx_fb/ fallback_topic_flag = (!strncmp(topicBuf, stemp1, strlen(stemp1))); + type = strrchr(topicBuf, '/'); // Last part of received topic is always the command (type) index = 1; @@ -2742,8 +2755,9 @@ void setup(void) } blink_powersave = power; - snprintf_P(log_data, sizeof(log_data), PSTR(D_PROJECT " %s %s (" D_CMND_TOPIC " %s, " D_FALLBACK " %s, " D_CMND_GROUPTOPIC " %s) " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), - PROJECT, Settings.friendlyname[0], mqtt_topic, mqtt_client, Settings.mqtt_grptopic, my_version, my_image); + char stopic[TOPSZ]; + snprintf_P(log_data, sizeof(log_data), PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), + PROJECT, Settings.friendlyname[0], my_version, my_image); AddLog(LOG_LEVEL_INFO); #ifdef BE_MINIMAL snprintf_P(log_data, sizeof(log_data), PSTR(D_WARNING_MINIMAL_VERSION)); diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index bd76b3c0e..046181283 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -1323,13 +1323,12 @@ void HandleInformation(void) if (Settings.flag.mqtt_enabled) { func += F("}1" D_MQTT_HOST "}2"); func += Settings.mqtt_host; func += F("}1" D_MQTT_PORT "}2"); func += String(Settings.mqtt_port); - func += F("}1" D_MQTT_CLIENT " &
 " D_FALLBACK_TOPIC "}2"); func += mqtt_client; func += F("}1" D_MQTT_USER "}2"); func += Settings.mqtt_user; + func += F("}1" D_MQTT_CLIENT "}2"); func += mqtt_client; func += F("}1" D_MQTT_TOPIC "}2"); func += Settings.mqtt_topic; func += F("}1" D_MQTT_GROUP_TOPIC "}2"); func += Settings.mqtt_grptopic; - GetTopic_P(stopic, CMND, mqtt_topic, ""); - func += F("}1" D_MQTT_FULL_TOPIC "}2"); func += stopic; - + func += F("}1" D_MQTT_FULL_TOPIC "}2"); func += GetTopic_P(stopic, CMND, mqtt_topic, ""); + func += F("}1" D_MQTT " " D_FALLBACK_TOPIC "}2"); func += GetFallbackTopic_P(stopic, CMND, ""); } else { func += F("}1" D_MQTT "}2" D_DISABLED); } diff --git a/sonoff/xdrv_02_mqtt.ino b/sonoff/xdrv_02_mqtt.ino index a19f80f82..e3f848ce8 100644 --- a/sonoff/xdrv_02_mqtt.ino +++ b/sonoff/xdrv_02_mqtt.ino @@ -406,9 +406,7 @@ void MqttConnected(void) if (strstr(Settings.mqtt_fulltopic, MQTT_TOKEN_TOPIC) != NULL) { GetTopic_P(stopic, CMND, Settings.mqtt_grptopic, PSTR("#")); MqttSubscribe(stopic); - fallback_topic_flag = 1; - GetTopic_P(stopic, CMND, mqtt_client, PSTR("#")); - fallback_topic_flag = 0; + GetFallbackTopic_P(stopic, CMND, PSTR("#")); MqttSubscribe(stopic); } @@ -417,7 +415,8 @@ void MqttConnected(void) if (mqtt_initial_connection_state) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_FALLBACKTOPIC "\":\"%s\",\"" D_CMND_GROUPTOPIC "\":\"%s\"}"), - my_module.name, my_version, my_image, mqtt_client, Settings.mqtt_grptopic); + my_module.name, my_version, my_image, GetFallbackTopic_P(stopic, CMND, ""), Settings.mqtt_grptopic); +// my_module.name, my_version, my_image, mqtt_client, Settings.mqtt_grptopic); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "1")); #ifdef USE_WEBSERVER if (Settings.webserver) { diff --git a/tools/decode-config.py b/tools/decode-config.py index b53dbaae9..d1daccf22 100644 --- a/tools/decode-config.py +++ b/tools/decode-config.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -VER = '2.1.0014' +VER = '2.1.0015' """ decode-config.py - Backup/Restore Sonoff-Tasmota configuration data @@ -811,7 +811,11 @@ Setting_6_3_0_16['flag3'][0].update ({ 'button_switch_force_local':('