diff --git a/tasmota/support.ino b/tasmota/support.ino index ccf3bdf8d..170f7f819 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1170,36 +1170,80 @@ char* ResponseGetTime(uint32_t format, char* time_str) } uint32_t ResponseSize(void) { +#ifdef MQTT_DATA_STRING + return MESSZ; +#else return sizeof(TasmotaGlobal.mqtt_data); +#endif } uint32_t ResponseLength(void) { +#ifdef MQTT_DATA_STRING + return TasmotaGlobal.mqtt_data.length(); +#else return strlen(TasmotaGlobal.mqtt_data); +#endif } void ResponseClear(void) { // Reset string length to zero +#ifdef MQTT_DATA_STRING + TasmotaGlobal.mqtt_data = ""; +#else TasmotaGlobal.mqtt_data[0] = '\0'; +#endif } void ResponseJsonStart(void) { // Insert a JSON start bracket { +#ifdef MQTT_DATA_STRING + TasmotaGlobal.mqtt_data.setCharAt(0,'{'); +#else TasmotaGlobal.mqtt_data[0] = '{'; +#endif } int Response_P(const char* format, ...) // Content send snprintf_P char data { // This uses char strings. Be aware of sending %% if % is needed +#ifdef MQTT_DATA_STRING + va_list arg; + va_start(arg, format); + char* mqtt_data = ext_vsnprintf_malloc_P(format, arg); + va_end(arg); + if (mqtt_data != nullptr) { + TasmotaGlobal.mqtt_data = mqtt_data; + free(mqtt_data); + } else { + TasmotaGlobal.mqtt_data = ""; + } + return TasmotaGlobal.mqtt_data.length(); +#else va_list args; va_start(args, format); int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, ResponseSize(), format, args); va_end(args); return len; +#endif } int ResponseTime_P(const char* format, ...) // Content send snprintf_P char data { // This uses char strings. Be aware of sending %% if % is needed +#ifdef MQTT_DATA_STRING + char timestr[100]; + TasmotaGlobal.mqtt_data = ResponseGetTime(Settings.flag2.time_format, timestr); + + va_list arg; + va_start(arg, format); + char* mqtt_data = ext_vsnprintf_malloc_P(format, arg); + va_end(arg); + if (mqtt_data != nullptr) { + TasmotaGlobal.mqtt_data += mqtt_data; + free(mqtt_data); + } + return TasmotaGlobal.mqtt_data.length(); +#else va_list args; va_start(args, format); @@ -1209,17 +1253,30 @@ int ResponseTime_P(const char* format, ...) // Content send snprintf_P char d int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, ResponseSize() - mlen, format, args); va_end(args); return len + mlen; +#endif } int ResponseAppend_P(const char* format, ...) // Content send snprintf_P char data { // This uses char strings. Be aware of sending %% if % is needed +#ifdef MQTT_DATA_STRING + va_list arg; + va_start(arg, format); + char* mqtt_data = ext_vsnprintf_malloc_P(format, arg); + va_end(arg); + if (mqtt_data != nullptr) { + TasmotaGlobal.mqtt_data += mqtt_data; + free(mqtt_data); + } + return TasmotaGlobal.mqtt_data.length(); +#else va_list args; va_start(args, format); int mlen = ResponseLength(); int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, ResponseSize() - mlen, format, args); va_end(args); return len + mlen; +#endif } int ResponseAppendTimeFormat(uint32_t format) @@ -1253,7 +1310,11 @@ int ResponseJsonEndEnd(void) } bool ResponseContains_P(const char* needle) { +#ifdef MQTT_DATA_STRING + return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr); +#else return (strstr_P(TasmotaGlobal.mqtt_data, needle) != nullptr); +#endif } /*********************************************************************************************\ diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index b01d87ff4..d48878b39 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1137,7 +1137,7 @@ void Every250mSeconds(void) char *bch = strrchr(full_ota_url, '/'); // Only consider filename after last backslash prevent change of urls having "-" in it if (bch == nullptr) { bch = full_ota_url; } // No path found so use filename only char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz) - if (ech == nullptr) { ech = full_ota_url + strlen(full_ota_url); } // Point to '/0' at end of mqtt_data becoming an empty string + if (ech == nullptr) { ech = full_ota_url + strlen(full_ota_url); } // Point to '/0' at end of full_ota_url becoming an empty string //AddLog(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech); @@ -1146,7 +1146,7 @@ void Every250mSeconds(void) char *pch = strrchr(bch, '-'); // Find last dash (-) and ignore remainder - handles tasmota-DE if (pch == nullptr) { pch = ech; } // No dash so ignore filetype - *pch = '\0'; // mqtt_data = http://domus1:80/api/arduino/tasmota + *pch = '\0'; // full_ota_url = http://domus1:80/api/arduino/tasmota snprintf_P(full_ota_url, sizeof(full_ota_url), PSTR("%s-" D_JSON_MINIMAL "%s"), full_ota_url, ota_url_type); // Minimal filename must be filename-minimal } #endif // FIRMWARE_MINIMAL diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 4c09c733f..3e6549424 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -196,13 +196,18 @@ struct { String backlog[MAX_BACKLOG]; // Command backlog buffer #endif +#ifdef MQTT_DATA_STRING + String mqtt_data; // Buffer filled by Response functions +#else + char mqtt_data[MESSZ]; // MQTT publish buffer +#endif + char version[16]; // Composed version string like 255.255.255.255 char image_name[33]; // Code image and/or commit char hostname[33]; // Composed Wifi hostname char serial_in_buffer[INPUT_BUFFER_SIZE]; // Receive buffer char mqtt_client[99]; // Composed MQTT Clientname char mqtt_topic[TOPSZ]; // Composed MQTT topic - char mqtt_data[MESSZ]; // MQTT publish buffer and web page ajax buffer char log_buffer[LOG_BUFFER_SIZE]; // Web log buffer } TasmotaGlobal; diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 60e4b3f80..2dea686d5 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -266,6 +266,8 @@ const uint16_t LOG_BUFFER_SIZE = 4000; // Max number of characters in lo #define TASM_FILE_AUTOEXEC "/autoexec.bat" // Commands executed after restart #define TASM_FILE_CONFIG "/config.sys" // Settings executed after restart +#define MQTT_DATA_STRING // Use heap instead of fixed memory for TasmotaGlobal.mqtt_data + #ifndef MQTT_MAX_PACKET_SIZE #define MQTT_MAX_PACKET_SIZE 1200 // Bytes //#define MQTT_MAX_PACKET_SIZE 2048 // Bytes diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 64ebf2378..52f4cb72e 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2070,7 +2070,11 @@ void HandleOtherConfiguration(void) { WSContentSendStyle(); TemplateJson(); +#ifdef MQTT_DATA_STRING + WSContentSend_P(HTTP_FORM_OTHER, TasmotaGlobal.mqtt_data.c_str(), (USER_MODULE == Settings.module) ? PSTR(" checked disabled") : "", +#else WSContentSend_P(HTTP_FORM_OTHER, TasmotaGlobal.mqtt_data, (USER_MODULE == Settings.module) ? PSTR(" checked disabled") : "", +#endif (Settings.flag.mqtt_enabled) ? PSTR(" checked") : "", // SetOption3 - Enable MQTT SettingsText(SET_FRIENDLYNAME1), SettingsText(SET_DEVICENAME)); diff --git a/tasmota/xdrv_02_9_mqtt.ino b/tasmota/xdrv_02_9_mqtt.ino index eaf8f6ce6..bd43f57c9 100644 --- a/tasmota/xdrv_02_9_mqtt.ino +++ b/tasmota/xdrv_02_9_mqtt.ino @@ -604,8 +604,6 @@ void MqttPublishLoggingAsync(bool refresh) { while (GetLog(Settings.mqttlog_level, &index, &line, &len)) { char stopic[TOPSZ]; GetTopic_P(stopic, STAT, TasmotaGlobal.mqtt_topic, PSTR("LOGGING")); -// strlcpy(TasmotaGlobal.mqtt_data, line, len); // No JSON and ugly!! -// MqttPublishLib(stopic, (const uint8_t*)TasmotaGlobal.mqtt_data, ResponseLength(), false); MqttPublishLib(stopic, (const uint8_t*)line, len -1, false); } } @@ -652,7 +650,11 @@ void MqttPublishPayload(const char* topic, const char* payload) { void MqttPublish(const char* topic, bool retained) { // Publish default TasmotaGlobal.mqtt_data string with optional retained +#ifdef MQTT_DATA_STRING + MqttPublishPayload(topic, TasmotaGlobal.mqtt_data.c_str(), 0, retained); +#else MqttPublishPayload(topic, TasmotaGlobal.mqtt_data, 0, retained); +#endif } void MqttPublish(const char* topic) { @@ -734,7 +736,11 @@ void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* su void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) { // Publish //> default TasmotaGlobal.mqtt_data string with optional retained +#ifdef MQTT_DATA_STRING + MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data.c_str(), 0, retained); +#else MqttPublishPayloadPrefixTopic_P(prefix, subtopic, TasmotaGlobal.mqtt_data, 0, retained); +#endif } void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic) { @@ -1045,9 +1051,17 @@ void MqttReconnect(void) { } String azureMqtt_userString = String(SettingsText(SET_MQTT_HOST)) + "/" + String(SettingsText(SET_MQTT_CLIENT)); + "/?api-version=2018-06-30"; +#ifdef MQTT_DATA_STRING + if (MqttClient.connect(TasmotaGlobal.mqtt_client, azureMqtt_userString.c_str(), azureMqtt_password.c_str(), stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data.c_str(), MQTT_CLEAN_SESSION)) { +#else if (MqttClient.connect(TasmotaGlobal.mqtt_client, azureMqtt_userString.c_str(), azureMqtt_password.c_str(), stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data, MQTT_CLEAN_SESSION)) { +#endif +#else +#ifdef MQTT_DATA_STRING + if (MqttClient.connect(TasmotaGlobal.mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data.c_str(), MQTT_CLEAN_SESSION)) { #else if (MqttClient.connect(TasmotaGlobal.mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, lwt_retain, TasmotaGlobal.mqtt_data, MQTT_CLEAN_SESSION)) { +#endif #endif // USE_MQTT_AZURE_IOT #ifdef USE_MQTT_TLS if (Mqtt.mqtt_tls) { diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index a0b114f1b..7fbdde313 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -797,7 +797,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) /*******************************************************************************************/ -bool RulesProcessEvent(char *json_event) +bool RulesProcessEvent(const char *json_event) { if (Rules.busy) { return false; } @@ -986,7 +986,11 @@ void RulesEvery100ms(void) { if (ResponseLength()) { ResponseJsonStart(); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089} ResponseJsonEnd(); +#ifdef MQTT_DATA_STRING + RulesProcessEvent(TasmotaGlobal.mqtt_data.c_str()); +#else RulesProcessEvent(TasmotaGlobal.mqtt_data); +#endif } } } diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 1fb0341fe..f5105a35f 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -2401,7 +2401,11 @@ chknext: char rstring[SCRIPT_MAXSSIZE]; rstring[0] = 0; int8_t index = fvar; +#ifdef MQTT_DATA_STRING char *wd = TasmotaGlobal.mqtt_data; +#else + char *wd = TasmotaGlobal.mqtt_data.c_str(); +#endif strlcpy(rstring, wd, glob_script_mem.max_ssize); if (index) { if (strlen(wd) && index) { @@ -2426,7 +2430,11 @@ chknext: // preserve mqtt_data char *mqd = (char*)malloc(ResponseSize()+2); if (mqd) { +#ifdef MQTT_DATA_STRING + strlcpy(mqd, TasmotaGlobal.mqtt_data.c_str(), ResponseSize()); +#else strlcpy(mqd, TasmotaGlobal.mqtt_data, ResponseSize()); +#endif wd = mqd; char *lwd = wd; while (index) { @@ -4982,7 +4990,11 @@ void ScripterEvery100ms(void) { if (ResponseLength()) { ResponseJsonStart(); ResponseJsonEnd(); +#ifdef MQTT_DATA_STRING + Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str()); +#else Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data); +#endif } } if (bitRead(Settings.rule_enabled, 0)) { @@ -7567,7 +7579,7 @@ void ScriptJsonAppend(void) { #endif //USE_SCRIPT_JSON_EXPORT -bool RulesProcessEvent(char *json_event) { +bool RulesProcessEvent(const char *json_event) { if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E", 2, json_event); return true; } @@ -7703,9 +7715,15 @@ int32_t http_req(char *host, char *request) { } #ifdef USE_WEBSEND_RESPONSE +#ifdef MQTT_DATA_STRING + TasmotaGlobal.mqtt_data = http.getString(); + //AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), TasmotaGlobal.mqtt_data.c_str()); + Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str()); +#else strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize()); //AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), TasmotaGlobal.mqtt_data); Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data); +#endif glob_script_mem.glob_error = 0; #endif @@ -8405,6 +8423,17 @@ bool Xdrv10(uint8_t function) break; case FUNC_RULES_PROCESS: if (bitRead(Settings.rule_enabled, 0)) { +#ifdef MQTT_DATA_STRING +#ifdef USE_SCRIPT_STATUS + if (!strncmp_P(TasmotaGlobal.mqtt_data.c_str(), PSTR("{\"Status"), 8)) { + Run_Scripter(">U", 2, TasmotaGlobal.mqtt_data.c_str()); + } else { + Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str()); + } +#else + Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str()); +#endif +#else // MQTT_DATA_STRING #ifdef USE_SCRIPT_STATUS if (!strncmp_P(TasmotaGlobal.mqtt_data, PSTR("{\"Status"), 8)) { Run_Scripter(">U", 2, TasmotaGlobal.mqtt_data); @@ -8414,14 +8443,21 @@ bool Xdrv10(uint8_t function) #else Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data); #endif +#endif // MQTT_DATA_STRING result = glob_script_mem.event_handeled; } break; case FUNC_TELEPERIOD_RULES_PROCESS: if (bitRead(Settings.rule_enabled, 0)) { +#ifdef MQTT_DATA_STRING + if (TasmotaGlobal.mqtt_data.length()) { + Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str()); + } +#else if (TasmotaGlobal.mqtt_data[0]) { Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data); } +#endif } break; #ifdef USE_WEBSERVER diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 08db2aaac..36fa9bd22 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -355,8 +355,17 @@ void NewHAssDiscovery(void) // NEW DISCOVERY -void TryResponseAppend_P(const char *format, ...) -{ +void TryResponseAppend_P(const char *format, ...) { +#ifdef MQTT_DATA_STRING + va_list arg; + va_start(arg, format); + char* mqtt_data = ext_vsnprintf_malloc_P(format, arg); + va_end(arg); + if (mqtt_data != nullptr) { + TasmotaGlobal.mqtt_data += mqtt_data; + free(mqtt_data); + } +#else va_list args; va_start(args, format); char dummy[2]; @@ -378,6 +387,7 @@ void TryResponseAppend_P(const char *format, ...) vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, slen, format, args); } va_end(args); +#endif } void HAssAnnounceRelayLight(void) diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index b7bbb90cb..05071034e 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1301,7 +1301,11 @@ void DisplayDTVarsTeleperiod(void) { if (jlen < DTV_JSON_SIZE) { char *json = (char*)malloc(jlen + 2); if (json) { +#ifdef MQTT_DATA_STRING + strlcpy(json, TasmotaGlobal.mqtt_data.c_str(), jlen + 1); +#else strlcpy(json, TasmotaGlobal.mqtt_data, jlen + 1); +#endif get_dt_vars(json); free(json); } @@ -1320,7 +1324,11 @@ void get_dt_mqtt(void) { ResponseJsonStart(); ResponseJsonEnd(); } +#ifdef MQTT_DATA_STRING + get_dt_vars(TasmotaGlobal.mqtt_data.c_str()); +#else get_dt_vars(TasmotaGlobal.mqtt_data); +#endif } void get_dt_vars(char *json) { @@ -1737,8 +1745,13 @@ void DisplayLocalSensor(void) { if ((Settings.display_mode &0x02) && (0 == TasmotaGlobal.tele_period)) { char no_topic[1] = { 0 }; +#ifdef MQTT_DATA_STRING +// DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, TasmotaGlobal.mqtt_data.c_str()); // Add local topic + DisplayAnalyzeJson(no_topic, TasmotaGlobal.mqtt_data.c_str()); // Discard any topic +#else // DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, TasmotaGlobal.mqtt_data); // Add local topic DisplayAnalyzeJson(no_topic, TasmotaGlobal.mqtt_data); // Discard any topic +#endif } } diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 92c8178e8..295860c33 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -1227,7 +1227,11 @@ void TuyaSerialInput(void) if (Settings.flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED)); } else { +#ifdef MQTT_DATA_STRING + AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data.c_str()); +#else AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data); +#endif } XdrvRulesProcess(0); diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino index 583c13307..ab6bf44d0 100644 --- a/tasmota/xdrv_23_zigbee_5_converters.ino +++ b/tasmota/xdrv_23_zigbee_5_converters.ino @@ -751,7 +751,11 @@ public: if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { +#ifdef MQTT_DATA_STRING + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str()); +#else AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); +#endif } } diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index 2d13b1e62..578b4c733 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -1577,7 +1577,11 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin ResponseAppend_P(PSTR("}}")); if (buf.len() > 0) { +#ifdef MQTT_DATA_STRING + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data.c_str()); +#else AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data); +#endif ZCLMessage zcl(buf.len()); // message is 4 bytes zcl.shortaddr = shortaddr; zcl.cluster = cluster; diff --git a/tasmota/xdrv_23_zigbee_9_serial.ino b/tasmota/xdrv_23_zigbee_9_serial.ino index 814f137a1..12442d200 100644 --- a/tasmota/xdrv_23_zigbee_9_serial.ino +++ b/tasmota/xdrv_23_zigbee_9_serial.ino @@ -152,7 +152,11 @@ void ZigbeeInputLoop(void) { if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { +#ifdef MQTT_DATA_STRING + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str()); +#else AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); +#endif } // now process the message ZigbeeProcessInput(znp_buffer); @@ -597,7 +601,11 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) { log_level = LOG_LEVEL_DEBUG; break; } +#ifdef MQTT_DATA_STRING + AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data.c_str()); // TODO move to LOG_LEVEL_DEBUG when stable +#else AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable +#endif } // Pass message to state machine diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index 75d5d359e..4aedf3330 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -97,7 +97,11 @@ extern "C" { const char * command = be_tostring(vm, 2); be_pop(vm, 2); // clear the stack before calling, because of re-entrant call to Berry in a Rule ExecuteCommand(command, SRC_BERRY); +#ifdef MQTT_DATA_STRING + be_pushstring(vm, TasmotaGlobal.mqtt_data.c_str()); +#else be_pushstring(vm, TasmotaGlobal.mqtt_data); +#endif be_return(vm); // Return } be_raise(vm, kTypeError, nullptr); diff --git a/tasmota/xdrv_interface.ino b/tasmota/xdrv_interface.ino index 79035ef9c..c0d99d71e 100644 --- a/tasmota/xdrv_interface.ino +++ b/tasmota/xdrv_interface.ino @@ -1093,7 +1093,11 @@ bool XdrvRulesProcess(bool teleperiod, const char* payload) { } bool XdrvRulesProcess(bool teleperiod) { +#ifdef MQTT_DATA_STRING + return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data.c_str()); +#else return XdrvRulesProcess(teleperiod, TasmotaGlobal.mqtt_data); +#endif } #ifdef USE_DEBUG_DRIVER diff --git a/tasmota/xsns_62_esp32_mi_ble.ino b/tasmota/xsns_62_esp32_mi_ble.ino index db1675098..aa99a6e80 100644 --- a/tasmota/xsns_62_esp32_mi_ble.ino +++ b/tasmota/xsns_62_esp32_mi_ble.ino @@ -2689,7 +2689,11 @@ void MI32ShowSomeSensors(){ } ResponseAppend_P(PSTR("}")); MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); +#ifdef MQTT_DATA_STRING + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str()); +#else //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); +#endif #ifdef USE_HOME_ASSISTANT if(hass_mode==2){ @@ -2742,7 +2746,11 @@ void MI32ShowOneMISensor(){ id); MqttPublish(SensorTopic); +#ifdef MQTT_DATA_STRING + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str()); +#else //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); +#endif } MI32.mqttCurrentSingleSlot++; } @@ -2998,7 +3006,11 @@ void MI32DiscoveryOneMISensor(){ //vTaskDelay(100/ portTICK_PERIOD_MS); } } // end if hass discovery +#ifdef MQTT_DATA_STRING + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data.c_str()); +#else //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); +#endif #endif //USE_HOME_ASSISTANT } @@ -3076,8 +3088,11 @@ void MI32ShowTriggeredSensors(){ } else { MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); } +#ifdef MQTT_DATA_STRING + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data.c_str()); +#else AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data); - +#endif XdrvRulesProcess(0); } else { // else don't and clear