diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 8fa067b63..2c2753edd 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -1,6 +1,7 @@ /* 6.2.1.20 20181028 * Add command SetOption35 0..255 (seconds) to delay mDNS initialization to control possible Wifi connect problems * Add command SetOption53 0/1 to toggle gui display of Hostname and IP address + * Add token %hostname% to command FullTopic (#3018) * * 6.2.1.19 20181023 * Fix header file execution order by renaming user_config.h to my_user_config.h diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 15d003cd1..ebc2ddb8a 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -60,6 +60,7 @@ typedef unsigned long power_t; // Power (Relay) type #define MQTT_TOKEN_PREFIX "%prefix%" // To be substituted by mqtt_prefix[x] #define MQTT_TOKEN_TOPIC "%topic%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic +#define MQTT_TOKEN_HOSTNAME "%hostname%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic #define MQTT_TOKEN_ID "%id%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic #define WIFI_HOSTNAME "%s-%04d" // Expands to - diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index 5eadb50a8..2258ab240 100755 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -279,6 +279,7 @@ void GetTopic_P(char *stopic, byte prefix, char *topic, const char* subtopic) } fulltopic.replace(F(MQTT_TOKEN_PREFIX), Settings.mqtt_prefix[prefix]); fulltopic.replace(F(MQTT_TOKEN_TOPIC), topic); + fulltopic.replace(F(MQTT_TOKEN_HOSTNAME), my_hostname); String token_id = WiFi.macAddress(); token_id.replace(":", ""); fulltopic.replace(F(MQTT_TOKEN_ID), token_id);