diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 4d76dbdb7..86e0d9e01 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -974,15 +974,14 @@ void RulesEvery50ms(void) } } -uint8_t rules_xsns_index = 0; +void RulesEvery100ms(void) { + static uint8_t xsns_index = 0; -void RulesEvery100ms(void) -{ if (Settings.rule_enabled && !Rules.busy && (TasmotaGlobal.uptime > 4)) { // Any rule enabled and allow 4 seconds start-up time for sensors (#3811) ResponseClear(); int tele_period_save = TasmotaGlobal.tele_period; TasmotaGlobal.tele_period = 2; // Do not allow HA updates during next function call - XsnsNextCall(FUNC_JSON_APPEND, rules_xsns_index); // ,"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089} + XsnsNextCall(FUNC_JSON_APPEND, xsns_index); // ,"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089} TasmotaGlobal.tele_period = tele_period_save; if (strlen(TasmotaGlobal.mqtt_data)) { TasmotaGlobal.mqtt_data[0] = '{'; // {"INA219":{"Voltage":4.494,"Current":0.020,"Power":0.089} diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index d107373ce..7731237bd 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -4844,15 +4844,15 @@ int16_t Run_script_sub(const char *type, int8_t tlen, struct GVARS *gv) { return -1; } -uint8_t script_xsns_index = 0; void ScripterEvery100ms(void) { + static uint8_t xsns_index = 0; if (bitRead(Settings.rule_enabled, 0) && (TasmotaGlobal.uptime > 4)) { ResponseClear(); uint16_t script_tele_period_save = TasmotaGlobal.tele_period; TasmotaGlobal.tele_period = 2; - XsnsNextCall(FUNC_JSON_APPEND, script_xsns_index); + XsnsNextCall(FUNC_JSON_APPEND, xsns_index); TasmotaGlobal.tele_period = script_tele_period_save; if (strlen(TasmotaGlobal.mqtt_data)) { TasmotaGlobal.mqtt_data[0] = '{'; diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index ee9777ca6..fe599d7a7 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1157,26 +1157,28 @@ void draw_dt_vars(void) { #define DTV_JSON_SIZE 1024 -void DTVarsTeleperiod(void) { - if (TasmotaGlobal.mqtt_data && TasmotaGlobal.mqtt_data[0]) { - uint32_t jlen = strlen(TasmotaGlobal.mqtt_data); +void DisplayDTVarsTeleperiod(void) { + ResponseClear(); + MqttShowState(); + uint32_t jlen = strlen(TasmotaGlobal.mqtt_data); - if (jlen < DTV_JSON_SIZE) { - char *json = (char*)malloc(jlen + 2); - if (json) { - strlcpy(json, TasmotaGlobal.mqtt_data, jlen + 1); - get_dt_vars(json); - free(json); - } + if (jlen < DTV_JSON_SIZE) { + char *json = (char*)malloc(jlen + 2); + if (json) { + strlcpy(json, TasmotaGlobal.mqtt_data, jlen + 1); + get_dt_vars(json); + free(json); } } } void get_dt_mqtt(void) { + static uint8_t xsns_index = 0; + ResponseClear(); uint16_t script_tele_period_save = TasmotaGlobal.tele_period; TasmotaGlobal.tele_period = 2; - XsnsNextCall(FUNC_JSON_APPEND, script_xsns_index); + XsnsNextCall(FUNC_JSON_APPEND, xsns_index); TasmotaGlobal.tele_period = script_tele_period_save; if (strlen(TasmotaGlobal.mqtt_data)) { TasmotaGlobal.mqtt_data[0] = '{'; @@ -2788,7 +2790,11 @@ bool Xdrv13(uint8_t function) if (Settings.display_model && Settings.display_mode) { XdspCall(FUNC_DISPLAY_EVERY_SECOND); } #endif break; - + case FUNC_AFTER_TELEPERIOD: +#ifdef USE_DT_VARS + DisplayDTVarsTeleperiod(); +#endif // USE_DT_VARS + break; #ifdef USE_DISPLAY_MODES1TO5 case FUNC_MQTT_SUBSCRIBE: DisplayMqttSubscribe();