mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-19 08:46:32 +00:00
Fix discovery fails when using `%hostname%
` in a topic (#12710)
This commit is contained in:
parent
4fb8f679d7
commit
520612b67c
@ -11,6 +11,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Disable PSRAM on unsupported hardware
|
- Disable PSRAM on unsupported hardware
|
||||||
|
- Replace spaces by hyphens in final hostname (#12710)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Discovery fails when using ``%hostname%`` in a topic (#12710)
|
||||||
|
|
||||||
## [9.5.0.2] 20210714
|
## [9.5.0.2] 20210714
|
||||||
### Added
|
### Added
|
||||||
|
@ -126,6 +126,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||||||
- Refactor platformio [#12442](https://github.com/arendst/Tasmota/issues/12442)
|
- Refactor platformio [#12442](https://github.com/arendst/Tasmota/issues/12442)
|
||||||
- Allow buttons to work in AP normal mode [#12518](https://github.com/arendst/Tasmota/issues/12518)
|
- Allow buttons to work in AP normal mode [#12518](https://github.com/arendst/Tasmota/issues/12518)
|
||||||
- Enable Ping and rule features for any device compiled with more than 1M flash size [#12539](https://github.com/arendst/Tasmota/issues/12539)
|
- Enable Ping and rule features for any device compiled with more than 1M flash size [#12539](https://github.com/arendst/Tasmota/issues/12539)
|
||||||
|
- Replace spaces by hyphens in final hostname [#12710](https://github.com/arendst/Tasmota/issues/12710)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- ESP32 core v2.0.0 setting hostname
|
- ESP32 core v2.0.0 setting hostname
|
||||||
@ -142,6 +143,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
|
|||||||
- Exception 28 when unable to send MQTT message and a topic name without a slash '/' [#12555](https://github.com/arendst/Tasmota/issues/12555)
|
- Exception 28 when unable to send MQTT message and a topic name without a slash '/' [#12555](https://github.com/arendst/Tasmota/issues/12555)
|
||||||
- Wi-Fi initial setup workaround for 11n only routers [#12566](https://github.com/arendst/Tasmota/issues/12566)
|
- Wi-Fi initial setup workaround for 11n only routers [#12566](https://github.com/arendst/Tasmota/issues/12566)
|
||||||
- ESP32 do not use chip temperature sensor as global temperature if external temperature sensor is used [#12630](https://github.com/arendst/Tasmota/issues/12630)
|
- ESP32 do not use chip temperature sensor as global temperature if external temperature sensor is used [#12630](https://github.com/arendst/Tasmota/issues/12630)
|
||||||
|
- Discovery fails when using ``%hostname%`` in a topic [#12710](https://github.com/arendst/Tasmota/issues/12710)
|
||||||
|
|
||||||
### Noted
|
### Noted
|
||||||
- ESP32 single core **tasmota32solo1.bin** binary can only be uploaded using the GUI as OTA upload will trigger the watchdog timer. Fixed once https://github.com/espressif/arduino-esp32/pull/5426 is merged.
|
- ESP32 single core **tasmota32solo1.bin** binary can only be uploaded using the GUI as OTA upload will trigger the watchdog timer. Fixed once https://github.com/espressif/arduino-esp32/pull/5426 is merged.
|
@ -77,6 +77,13 @@ char* GetOtaUrl(char *otaurl, size_t otaurl_size)
|
|||||||
return otaurl;
|
return otaurl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ResolveToken(const char* input) {
|
||||||
|
String resolved = input;
|
||||||
|
resolved.replace(F("%hostname%"), TasmotaGlobal.hostname);
|
||||||
|
resolved.replace(F("%id%"), NetworkUniqueId());
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
|
||||||
char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopic)
|
char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopic)
|
||||||
{
|
{
|
||||||
/* prefix 0 = Cmnd
|
/* prefix 0 = Cmnd
|
||||||
@ -120,8 +127,7 @@ char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopi
|
|||||||
fulltopic.replace(FPSTR(MQTT_TOKEN_PREFIX), SettingsText(SET_MQTTPREFIX1 + prefix));
|
fulltopic.replace(FPSTR(MQTT_TOKEN_PREFIX), SettingsText(SET_MQTTPREFIX1 + prefix));
|
||||||
|
|
||||||
fulltopic.replace(FPSTR(MQTT_TOKEN_TOPIC), (const __FlashStringHelper *)topic);
|
fulltopic.replace(FPSTR(MQTT_TOKEN_TOPIC), (const __FlashStringHelper *)topic);
|
||||||
fulltopic.replace(F("%hostname%"), TasmotaGlobal.hostname);
|
fulltopic = ResolveToken(fulltopic.c_str());
|
||||||
fulltopic.replace(F("%id%"), NetworkUniqueId());
|
|
||||||
}
|
}
|
||||||
fulltopic.replace(F("#"), "");
|
fulltopic.replace(F("#"), "");
|
||||||
fulltopic.replace(F("//"), "/");
|
fulltopic.replace(F("//"), "/");
|
||||||
|
@ -380,6 +380,12 @@ void setup(void) {
|
|||||||
} else {
|
} else {
|
||||||
snprintf_P(TasmotaGlobal.hostname, sizeof(TasmotaGlobal.hostname)-1, SettingsText(SET_HOSTNAME));
|
snprintf_P(TasmotaGlobal.hostname, sizeof(TasmotaGlobal.hostname)-1, SettingsText(SET_HOSTNAME));
|
||||||
}
|
}
|
||||||
|
char *s = TasmotaGlobal.hostname;
|
||||||
|
while (*s) {
|
||||||
|
if (' ' == *s) { *s = '_'; }
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
snprintf_P(TasmotaGlobal.mqtt_topic, sizeof(TasmotaGlobal.mqtt_topic), ResolveToken(TasmotaGlobal.mqtt_topic).c_str());
|
||||||
|
|
||||||
RtcInit();
|
RtcInit();
|
||||||
GpioInit();
|
GpioInit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user