Fix define USE_DT_VARS

This commit is contained in:
Theo Arends 2021-04-05 13:33:00 +02:00
parent c378d70fef
commit f6f13fe249
3 changed files with 23 additions and 18 deletions

View File

@ -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}

View File

@ -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] = '{';

View File

@ -1157,8 +1157,9 @@ void draw_dt_vars(void) {
#define DTV_JSON_SIZE 1024
void DTVarsTeleperiod(void) {
if (TasmotaGlobal.mqtt_data && TasmotaGlobal.mqtt_data[0]) {
void DisplayDTVarsTeleperiod(void) {
ResponseClear();
MqttShowState();
uint32_t jlen = strlen(TasmotaGlobal.mqtt_data);
if (jlen < DTV_JSON_SIZE) {
@ -1170,13 +1171,14 @@ void DTVarsTeleperiod(void) {
}
}
}
}
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();