Add token %hostname%

Add token %hostname% to command FullTopic (#3018)
This commit is contained in:
Theo Arends 2018-10-29 12:38:44 +01:00
parent cc56677ba3
commit 6b86c473d9
3 changed files with 3 additions and 0 deletions

View File

@ -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

View File

@ -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 <MQTT_TOPIC>-<last 4 decimal chars of MAC address>

View File

@ -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);