From a922d6609f345be9c0c4d4ca1a75e56a825384e3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 15 Dec 2025 12:37:12 +0100 Subject: [PATCH] Fix ESP32-P4 unique MQTT Client based on hosted MCU MAC address --- CHANGELOG.md | 1 + RELEASENOTES.md | 1 + tasmota/tasmota.ino | 1 - tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino | 3 +++ 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c820c43..0f0f6bed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. - DALI watchdog exception - TuyaMCU v1 exception 28 regression from v15.1.0.1 reverted PR24063 (#24220) - ESP8266 TasmotaSerial flush receive buffer on executing `TasmotaSerial.flush();` +- ESP32-P4 unique MQTT Client based on hosted MCU MAC address ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 5371121d7..4276aacf5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -120,5 +120,6 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Fixed - ESP8266 TasmotaSerial flush receive buffer on executing `TasmotaSerial.flush();` +- ESP32-P4 unique MQTT Client based on hosted MCU MAC address - DALI watchdog exception - TuyaMCU v1 exception 28 regression from v15.1.0.1 reverted PR24063 [#24220](https://github.com/arendst/Tasmota/issues/24220) diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index c1f911f3b..e32e490bb 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -671,7 +671,6 @@ void setup(void) { // Github inserts "release" or "commit number" before compiling using sed -i -e 's/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT 85cff52-/g' tasmota_version.h snprintf_P(TasmotaGlobal.image_name, sizeof(TasmotaGlobal.image_name), PSTR("(" STR(TASMOTA_SHA_SHORT) "%s)"), PSTR(CODE_IMAGE_STR)); // Results in (85cff52-tasmota) or (release-tasmota) - Format(TasmotaGlobal.mqtt_client, SettingsText(SET_MQTT_CLIENT), sizeof(TasmotaGlobal.mqtt_client)); Format(TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(TasmotaGlobal.mqtt_topic)); if (strchr(SettingsText(SET_HOSTNAME), '%') != nullptr) { SettingsUpdateText(SET_HOSTNAME, WIFI_HOSTNAME); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino index 3f291159c..df18d9472 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_02_9_mqtt.ino @@ -1112,6 +1112,9 @@ void MqttConnected(void) { } void MqttReconnect(void) { + if (!strlen(TasmotaGlobal.mqtt_client)) { // Do it here as it needs the MAC address from a possible hosted MCU available after WiFi connection + Format(TasmotaGlobal.mqtt_client, SettingsText(SET_MQTT_CLIENT), sizeof(TasmotaGlobal.mqtt_client)); + } Mqtt.allowed = Settings->flag.mqtt_enabled && (TasmotaGlobal.restart_flag == 0); // SetOption3 - Enable MQTT, and don't connect if restart in process if (Mqtt.allowed) { #if defined(USE_MQTT_AZURE_DPS_SCOPEID) && defined(USE_MQTT_AZURE_DPS_PRESHAREDKEY)