mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Refactor access TasnotaGlobal.mqtt_data
This commit is contained in:
parent
4ed6335428
commit
e5e8ef4736
@ -1191,6 +1191,14 @@ char* ResponseGetTime(uint32_t format, char* time_str)
|
|||||||
return time_str;
|
return time_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* ResponseData(void) {
|
||||||
|
#ifdef MQTT_DATA_STRING
|
||||||
|
return (char*)TasmotaGlobal.mqtt_data.c_str();
|
||||||
|
#else
|
||||||
|
return TasmotaGlobal.mqtt_data;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ResponseSize(void) {
|
uint32_t ResponseSize(void) {
|
||||||
#ifdef MQTT_DATA_STRING
|
#ifdef MQTT_DATA_STRING
|
||||||
return MAX_LOGSZ; // Arbitratry max length satisfying full log entry
|
return MAX_LOGSZ; // Arbitratry max length satisfying full log entry
|
||||||
@ -1333,29 +1341,15 @@ int ResponseJsonEndEnd(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ResponseContains_P(const char* needle) {
|
bool ResponseContains_P(const char* needle) {
|
||||||
|
/*
|
||||||
#ifdef MQTT_DATA_STRING
|
#ifdef MQTT_DATA_STRING
|
||||||
return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr);
|
return (strstr_P(TasmotaGlobal.mqtt_data.c_str(), needle) != nullptr);
|
||||||
#else
|
#else
|
||||||
return (strstr_P(TasmotaGlobal.mqtt_data, needle) != nullptr);
|
return (strstr_P(TasmotaGlobal.mqtt_data, needle) != nullptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
uint32_t ResponseContains_P(const char* needle) {
|
|
||||||
const char *tmp;
|
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
tmp = TasmotaGlobal.mqtt_data.c_str();
|
|
||||||
#else
|
|
||||||
tmp = TasmotaGlobal.mqtt_data;
|
|
||||||
#endif
|
|
||||||
uint32_t count = 0;
|
|
||||||
while (tmp = strstr_P(tmp, needle)) {
|
|
||||||
count++;
|
|
||||||
tmp++;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
return (strstr_P(ResponseData(), needle) != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* GPIO Module and Template management
|
* GPIO Module and Template management
|
||||||
|
@ -432,7 +432,7 @@ void CmndStatusResponse(uint32_t index) {
|
|||||||
all_status = (const char*) nullptr;
|
all_status = (const char*) nullptr;
|
||||||
} else {
|
} else {
|
||||||
if (0 == index) { all_status = ""; }
|
if (0 == index) { all_status = ""; }
|
||||||
all_status += TasmotaGlobal.mqtt_data;
|
all_status += ResponseData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (index < 99) {
|
else if (index < 99) {
|
||||||
|
@ -2135,11 +2135,7 @@ void HandleOtherConfiguration(void) {
|
|||||||
WSContentSendStyle();
|
WSContentSendStyle();
|
||||||
|
|
||||||
TemplateJson();
|
TemplateJson();
|
||||||
#ifdef MQTT_DATA_STRING
|
WSContentSend_P(HTTP_FORM_OTHER, ResponseData(), (USER_MODULE == Settings->module) ? PSTR(" checked disabled") : "",
|
||||||
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
|
(Settings->flag.mqtt_enabled) ? PSTR(" checked") : "", // SetOption3 - Enable MQTT
|
||||||
SettingsText(SET_FRIENDLYNAME1), SettingsText(SET_DEVICENAME));
|
SettingsText(SET_FRIENDLYNAME1), SettingsText(SET_DEVICENAME));
|
||||||
|
|
||||||
|
@ -670,16 +670,12 @@ void MqttPublishPayload(const char* topic, const char* payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublish(const char* topic, bool retained) {
|
void MqttPublish(const char* topic, bool retained) {
|
||||||
// Publish <topic> default TasmotaGlobal.mqtt_data string with optional retained
|
// Publish <topic> default ResponseData string with optional retained
|
||||||
#ifdef MQTT_DATA_STRING
|
MqttPublishPayload(topic, ResponseData(), 0, retained);
|
||||||
MqttPublishPayload(topic, TasmotaGlobal.mqtt_data.c_str(), 0, retained);
|
|
||||||
#else
|
|
||||||
MqttPublishPayload(topic, TasmotaGlobal.mqtt_data, 0, retained);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublish(const char* topic) {
|
void MqttPublish(const char* topic) {
|
||||||
// Publish <topic> default TasmotaGlobal.mqtt_data string no retained
|
// Publish <topic> default ResponseData string no retained
|
||||||
MqttPublish(topic, false);
|
MqttPublish(topic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,40 +746,36 @@ void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* su
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, const char* payload) {
|
void MqttPublishPayloadPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, const char* payload) {
|
||||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string no retained
|
// Publish <prefix>/<device>/<RESULT or <subtopic>> default ResponseData string no retained
|
||||||
// then process rules
|
// then process rules
|
||||||
MqttPublishPayloadPrefixTopicRulesProcess_P(prefix, subtopic, payload, false);
|
MqttPublishPayloadPrefixTopicRulesProcess_P(prefix, subtopic, payload, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) {
|
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retained) {
|
||||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string with optional retained
|
// Publish <prefix>/<device>/<RESULT or <subtopic>> default ResponseData string with optional retained
|
||||||
#ifdef MQTT_DATA_STRING
|
MqttPublishPayloadPrefixTopic_P(prefix, subtopic, ResponseData(), 0, retained);
|
||||||
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) {
|
void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic) {
|
||||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string no retained
|
// Publish <prefix>/<device>/<RESULT or <subtopic>> default ResponseData string no retained
|
||||||
MqttPublishPrefixTopic_P(prefix, subtopic, false);
|
MqttPublishPrefixTopic_P(prefix, subtopic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, bool retained) {
|
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic, bool retained) {
|
||||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string with optional retained
|
// Publish <prefix>/<device>/<RESULT or <subtopic>> default ResponseData string with optional retained
|
||||||
// then process rules
|
// then process rules
|
||||||
MqttPublishPrefixTopic_P(prefix, subtopic, retained);
|
MqttPublishPrefixTopic_P(prefix, subtopic, retained);
|
||||||
XdrvRulesProcess(0);
|
XdrvRulesProcess(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic) {
|
void MqttPublishPrefixTopicRulesProcess_P(uint32_t prefix, const char* subtopic) {
|
||||||
// Publish <prefix>/<device>/<RESULT or <subtopic>> default TasmotaGlobal.mqtt_data string no retained
|
// Publish <prefix>/<device>/<RESULT or <subtopic>> default ResponseData string no retained
|
||||||
// then process rules
|
// then process rules
|
||||||
MqttPublishPrefixTopicRulesProcess_P(prefix, subtopic, false);
|
MqttPublishPrefixTopicRulesProcess_P(prefix, subtopic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttPublishTeleSensor(void) {
|
void MqttPublishTeleSensor(void) {
|
||||||
// Publish tele/<device>/SENSOR default TasmotaGlobal.mqtt_data string with optional retained
|
// Publish tele/<device>/SENSOR default ResponseData string with optional retained
|
||||||
// then process rules
|
// then process rules
|
||||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings->flag.mqtt_sensor_retain); // CMND_SENSORRETAIN
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings->flag.mqtt_sensor_retain); // CMND_SENSORRETAIN
|
||||||
}
|
}
|
||||||
@ -1079,17 +1071,9 @@ void MqttReconnect(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String azureMqtt_userString = String(SettingsText(SET_MQTT_HOST)) + "/" + String(SettingsText(SET_MQTT_CLIENT)); + "/?api-version=2018-06-30";
|
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, ResponseData(), MQTT_CLEAN_SESSION)) {
|
||||||
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
|
#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)) {
|
if (MqttClient.connect(TasmotaGlobal.mqtt_client, mqtt_user, mqtt_pwd, stopic, 1, lwt_retain, ResponseData(), 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
|
#endif // USE_MQTT_AZURE_IOT
|
||||||
#ifdef USE_MQTT_TLS
|
#ifdef USE_MQTT_TLS
|
||||||
if (Mqtt.mqtt_tls) {
|
if (Mqtt.mqtt_tls) {
|
||||||
|
@ -987,11 +987,7 @@ void RulesEvery100ms(void) {
|
|||||||
if (ResponseLength()) {
|
if (ResponseLength()) {
|
||||||
ResponseJsonStart(); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}
|
ResponseJsonStart(); // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089}
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
#ifdef MQTT_DATA_STRING
|
RulesProcessEvent(ResponseData());
|
||||||
RulesProcessEvent(TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
#else
|
|
||||||
RulesProcessEvent(TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2403,11 +2403,7 @@ chknext:
|
|||||||
char rstring[SCRIPT_MAXSSIZE];
|
char rstring[SCRIPT_MAXSSIZE];
|
||||||
rstring[0] = 0;
|
rstring[0] = 0;
|
||||||
int8_t index = fvar;
|
int8_t index = fvar;
|
||||||
#ifdef MQTT_DATA_STRING
|
char *wd = ResponseData();
|
||||||
char *wd = (char*)TasmotaGlobal.mqtt_data.c_str();
|
|
||||||
#else
|
|
||||||
char *wd = TasmotaGlobal.mqtt_data;
|
|
||||||
#endif
|
|
||||||
strlcpy(rstring, wd, glob_script_mem.max_ssize);
|
strlcpy(rstring, wd, glob_script_mem.max_ssize);
|
||||||
if (index) {
|
if (index) {
|
||||||
if (strlen(wd) && index) {
|
if (strlen(wd) && index) {
|
||||||
@ -2432,11 +2428,7 @@ chknext:
|
|||||||
// preserve mqtt_data
|
// preserve mqtt_data
|
||||||
char *mqd = (char*)malloc(ResponseSize()+2);
|
char *mqd = (char*)malloc(ResponseSize()+2);
|
||||||
if (mqd) {
|
if (mqd) {
|
||||||
#ifdef MQTT_DATA_STRING
|
strlcpy(mqd, ResponseData(), ResponseSize());
|
||||||
strlcpy(mqd, TasmotaGlobal.mqtt_data.c_str(), ResponseSize());
|
|
||||||
#else
|
|
||||||
strlcpy(mqd, TasmotaGlobal.mqtt_data, ResponseSize());
|
|
||||||
#endif
|
|
||||||
wd = mqd;
|
wd = mqd;
|
||||||
char *lwd = wd;
|
char *lwd = wd;
|
||||||
while (index) {
|
while (index) {
|
||||||
@ -5007,11 +4999,7 @@ void ScripterEvery100ms(void) {
|
|||||||
if (ResponseLength()) {
|
if (ResponseLength()) {
|
||||||
ResponseJsonStart();
|
ResponseJsonStart();
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
#ifdef MQTT_DATA_STRING
|
Run_Scripter(">T", 2, ResponseData());
|
||||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
#else
|
|
||||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bitRead(Settings->rule_enabled, 0)) {
|
if (bitRead(Settings->rule_enabled, 0)) {
|
||||||
@ -7735,13 +7723,12 @@ int32_t http_req(char *host, char *request) {
|
|||||||
#ifdef USE_WEBSEND_RESPONSE
|
#ifdef USE_WEBSEND_RESPONSE
|
||||||
#ifdef MQTT_DATA_STRING
|
#ifdef MQTT_DATA_STRING
|
||||||
TasmotaGlobal.mqtt_data = http.getString();
|
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
|
#else
|
||||||
strlcpy(TasmotaGlobal.mqtt_data, http.getString().c_str(), ResponseSize());
|
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
|
#endif
|
||||||
|
//AddLog(LOG_LEVEL_INFO, PSTR("HTTP RESULT %s"), ResponseData());
|
||||||
|
Run_Scripter(">E", 2, ResponseData());
|
||||||
|
|
||||||
glob_script_mem.glob_error = 0;
|
glob_script_mem.glob_error = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -8442,41 +8429,24 @@ bool Xdrv10(uint8_t function)
|
|||||||
break;
|
break;
|
||||||
case FUNC_RULES_PROCESS:
|
case FUNC_RULES_PROCESS:
|
||||||
if (bitRead(Settings->rule_enabled, 0)) {
|
if (bitRead(Settings->rule_enabled, 0)) {
|
||||||
#ifdef MQTT_DATA_STRING
|
|
||||||
#ifdef USE_SCRIPT_STATUS
|
#ifdef USE_SCRIPT_STATUS
|
||||||
if (!strncmp_P(TasmotaGlobal.mqtt_data.c_str(), PSTR("{\"Status"), 8)) {
|
if (!strncmp_P(ResponseData(), PSTR("{\"Status"), 8)) {
|
||||||
Run_Scripter(">U", 2, TasmotaGlobal.mqtt_data.c_str());
|
Run_Scripter(">U", 2, ResponseData());
|
||||||
} else {
|
} else {
|
||||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str());
|
Run_Scripter(">E", 2, ResponseData());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data.c_str());
|
Run_Scripter(">E", 2, ResponseData());
|
||||||
#endif
|
#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);
|
|
||||||
} else {
|
|
||||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Run_Scripter(">E", 2, TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
#endif // MQTT_DATA_STRING
|
|
||||||
result = glob_script_mem.event_handeled;
|
result = glob_script_mem.event_handeled;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUNC_TELEPERIOD_RULES_PROCESS:
|
case FUNC_TELEPERIOD_RULES_PROCESS:
|
||||||
if (bitRead(Settings->rule_enabled, 0)) {
|
if (bitRead(Settings->rule_enabled, 0)) {
|
||||||
#ifdef MQTT_DATA_STRING
|
if (ResponseLength()) {
|
||||||
if (TasmotaGlobal.mqtt_data.length()) {
|
Run_Scripter(">T", 2, ResponseData());
|
||||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (TasmotaGlobal.mqtt_data[0]) {
|
|
||||||
Run_Scripter(">T", 2, TasmotaGlobal.mqtt_data);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
|
@ -896,11 +896,7 @@ void HAssAnnounceSensors(void)
|
|||||||
TasmotaGlobal.tele_period = tele_period_save;
|
TasmotaGlobal.tele_period = tele_period_save;
|
||||||
size_t sensordata_len = ResponseLength();
|
size_t sensordata_len = ResponseLength();
|
||||||
char sensordata[sensordata_len+2]; // dynamically adjust the size
|
char sensordata[sensordata_len+2]; // dynamically adjust the size
|
||||||
#ifdef MQTT_DATA_STRING
|
strcpy(sensordata, ResponseData()); // we can use strcpy since the buffer has the right size
|
||||||
strcpy(sensordata, TasmotaGlobal.mqtt_data.c_str()); // we can use strcpy since the buffer has the right size
|
|
||||||
#else
|
|
||||||
strcpy(sensordata, TasmotaGlobal.mqtt_data); // we can use strcpy since the buffer has the right size
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ******************* JSON TEST *******************
|
// ******************* JSON TEST *******************
|
||||||
// char sensordata[512];
|
// char sensordata[512];
|
||||||
|
@ -1301,11 +1301,7 @@ void DisplayDTVarsTeleperiod(void) {
|
|||||||
if (jlen < DTV_JSON_SIZE) {
|
if (jlen < DTV_JSON_SIZE) {
|
||||||
char *json = (char*)malloc(jlen + 2);
|
char *json = (char*)malloc(jlen + 2);
|
||||||
if (json) {
|
if (json) {
|
||||||
#ifdef MQTT_DATA_STRING
|
strlcpy(json, ResponseData(), jlen + 1);
|
||||||
strlcpy(json, (char*)TasmotaGlobal.mqtt_data.c_str(), jlen + 1);
|
|
||||||
#else
|
|
||||||
strlcpy(json, TasmotaGlobal.mqtt_data, jlen + 1);
|
|
||||||
#endif
|
|
||||||
get_dt_vars(json);
|
get_dt_vars(json);
|
||||||
free(json);
|
free(json);
|
||||||
}
|
}
|
||||||
@ -1324,11 +1320,7 @@ void get_dt_mqtt(void) {
|
|||||||
ResponseJsonStart();
|
ResponseJsonStart();
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
}
|
}
|
||||||
#ifdef MQTT_DATA_STRING
|
get_dt_vars(ResponseData());
|
||||||
get_dt_vars((char*)TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
#else
|
|
||||||
get_dt_vars(TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_dt_vars(char *json) {
|
void get_dt_vars(char *json) {
|
||||||
@ -1743,13 +1735,8 @@ void DisplayLocalSensor(void)
|
|||||||
{
|
{
|
||||||
if ((Settings->display_mode &0x02) && (0 == TasmotaGlobal.tele_period)) {
|
if ((Settings->display_mode &0x02) && (0 == TasmotaGlobal.tele_period)) {
|
||||||
char no_topic[1] = { 0 };
|
char no_topic[1] = { 0 };
|
||||||
#ifdef MQTT_DATA_STRING
|
// DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, ResponseData()); // Add local topic
|
||||||
// DisplayAnalyzeJson(TasmotaGlobal.mqtt_topic, TasmotaGlobal.mqtt_data.c_str()); // Add local topic
|
DisplayAnalyzeJson(no_topic, ResponseData()); // Discard any 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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,11 +1227,7 @@ void TuyaSerialInput(void)
|
|||||||
if (Settings->flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt
|
if (Settings->flag3.tuya_serial_mqtt_publish) { // SetOption66 - Enable TuyaMcuReceived messages over Mqtt
|
||||||
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
|
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_TUYA_MCU_RECEIVED));
|
||||||
} else {
|
} else {
|
||||||
#ifdef MQTT_DATA_STRING
|
AddLog(LOG_LEVEL_DEBUG, ResponseData());
|
||||||
AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
#else
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
XdrvRulesProcess(0);
|
XdrvRulesProcess(0);
|
||||||
|
|
||||||
|
@ -751,11 +751,7 @@ public:
|
|||||||
if (Settings->flag3.tuya_serial_mqtt_publish) {
|
if (Settings->flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
} else {
|
} else {
|
||||||
#ifdef MQTT_DATA_STRING
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), ResponseData());
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1577,11 +1577,7 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin
|
|||||||
ResponseAppend_P(PSTR("}}"));
|
ResponseAppend_P(PSTR("}}"));
|
||||||
|
|
||||||
if (buf.len() > 0) {
|
if (buf.len() > 0) {
|
||||||
#ifdef MQTT_DATA_STRING
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), ResponseData());
|
||||||
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
|
ZCLMessage zcl(buf.len()); // message is 4 bytes
|
||||||
zcl.shortaddr = shortaddr;
|
zcl.shortaddr = shortaddr;
|
||||||
zcl.cluster = cluster;
|
zcl.cluster = cluster;
|
||||||
|
@ -152,11 +152,7 @@ void ZigbeeInputLoop(void) {
|
|||||||
if (Settings->flag3.tuya_serial_mqtt_publish) {
|
if (Settings->flag3.tuya_serial_mqtt_publish) {
|
||||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR));
|
||||||
} else {
|
} else {
|
||||||
#ifdef MQTT_DATA_STRING
|
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), ResponseData());
|
||||||
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
|
// now process the message
|
||||||
ZigbeeProcessInput(znp_buffer);
|
ZigbeeProcessInput(znp_buffer);
|
||||||
@ -601,11 +597,7 @@ void ZigbeeProcessInputEZSP(SBuffer &buf) {
|
|||||||
log_level = LOG_LEVEL_DEBUG;
|
log_level = LOG_LEVEL_DEBUG;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef MQTT_DATA_STRING
|
AddLog(log_level, PSTR(D_LOG_ZIGBEE "%s"), ResponseData()); // TODO move to LOG_LEVEL_DEBUG when stable
|
||||||
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
|
// Pass message to state machine
|
||||||
|
@ -123,11 +123,7 @@ extern "C" {
|
|||||||
const char * command = be_tostring(vm, 2);
|
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
|
be_pop(vm, 2); // clear the stack before calling, because of re-entrant call to Berry in a Rule
|
||||||
ExecuteCommand(command, SRC_BERRY);
|
ExecuteCommand(command, SRC_BERRY);
|
||||||
#ifdef MQTT_DATA_STRING
|
be_pushstring(vm, ResponseData());
|
||||||
be_pushstring(vm, TasmotaGlobal.mqtt_data.c_str());
|
|
||||||
#else
|
|
||||||
be_pushstring(vm, TasmotaGlobal.mqtt_data);
|
|
||||||
#endif
|
|
||||||
be_return(vm); // Return
|
be_return(vm); // Return
|
||||||
}
|
}
|
||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
|
@ -256,7 +256,7 @@ char* InfluxDbNumber(char* alternative, const char* source) {
|
|||||||
void InfluxDbProcessJson(void) {
|
void InfluxDbProcessJson(void) {
|
||||||
if (!IFDB.init) { return; }
|
if (!IFDB.init) { return; }
|
||||||
|
|
||||||
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: JSON %s"), TasmotaGlobal.mqtt_data.c_str());
|
// AddLog(LOG_LEVEL_DEBUG, PSTR("IFX: JSON %s"), ResponseData());
|
||||||
|
|
||||||
String jsonStr = TasmotaGlobal.mqtt_data;
|
String jsonStr = TasmotaGlobal.mqtt_data;
|
||||||
JsonParser parser((char *)jsonStr.c_str());
|
JsonParser parser((char *)jsonStr.c_str());
|
||||||
|
@ -2689,11 +2689,7 @@ void MI32ShowSomeSensors(){
|
|||||||
}
|
}
|
||||||
ResponseAppend_P(PSTR("}"));
|
ResponseAppend_P(PSTR("}"));
|
||||||
MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR), Settings->flag.mqtt_sensor_retain);
|
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, ResponseData());
|
||||||
//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
|
#ifdef USE_HOME_ASSISTANT
|
||||||
if(hass_mode==2){
|
if(hass_mode==2){
|
||||||
@ -2746,11 +2742,7 @@ void MI32ShowOneMISensor(){
|
|||||||
id);
|
id);
|
||||||
|
|
||||||
MqttPublish(SensorTopic);
|
MqttPublish(SensorTopic);
|
||||||
#ifdef MQTT_DATA_STRING
|
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, ResponseData());
|
||||||
//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++;
|
MI32.mqttCurrentSingleSlot++;
|
||||||
}
|
}
|
||||||
@ -3006,11 +2998,7 @@ void MI32DiscoveryOneMISensor(){
|
|||||||
//vTaskDelay(100/ portTICK_PERIOD_MS);
|
//vTaskDelay(100/ portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
} // end if hass discovery
|
} // end if hass discovery
|
||||||
#ifdef MQTT_DATA_STRING
|
//AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, ResponseData());
|
||||||
//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
|
#endif //USE_HOME_ASSISTANT
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3088,11 +3076,7 @@ void MI32ShowTriggeredSensors(){
|
|||||||
} else {
|
} else {
|
||||||
MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings->flag.mqtt_sensor_retain);
|
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, ResponseData());
|
||||||
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);
|
XdrvRulesProcess(0);
|
||||||
|
|
||||||
} else { // else don't and clear
|
} else { // else don't and clear
|
||||||
|
Loading…
x
Reference in New Issue
Block a user