From 5185085ca4ee409af0cd8eecc729039e1b3f0f7d Mon Sep 17 00:00:00 2001 From: Barbudor Date: Tue, 9 Nov 2021 21:07:43 +0100 Subject: [PATCH] fix garbage on web gui when abs_num not available --- tasmota/xsns_21_sgp30.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasmota/xsns_21_sgp30.ino b/tasmota/xsns_21_sgp30.ino index ff5445455..e012813cb 100644 --- a/tasmota/xsns_21_sgp30.ino +++ b/tasmota/xsns_21_sgp30.ino @@ -114,14 +114,14 @@ void Sgp30Show(bool json) { if (sgp30_ready) { char abs_hum[33]; - - if (TasmotaGlobal.global_update && (TasmotaGlobal.humidity > 0) && !isnan(TasmotaGlobal.temperature_celsius)) { + bool ahum_available = TasmotaGlobal.global_update && (TasmotaGlobal.humidity > 0) && !isnan(TasmotaGlobal.temperature_celsius); + if (ahum_available) { // has humidity + temperature dtostrfd(sgp30_abshum,4,abs_hum); } if (json) { ResponseAppend_P(PSTR(",\"SGP30\":{\"" D_JSON_ECO2 "\":%d,\"" D_JSON_TVOC "\":%d"), sgp.eCO2, sgp.TVOC); - if (TasmotaGlobal.global_update && TasmotaGlobal.humidity>0 && !isnan(TasmotaGlobal.temperature_celsius)) { + if (ahum_available) { ResponseAppend_P(PSTR(",\"" D_JSON_AHUM "\":%s"),abs_hum); } ResponseJsonEnd(); @@ -131,7 +131,7 @@ void Sgp30Show(bool json) #ifdef USE_WEBSERVER } else { WSContentSend_PD(HTTP_SNS_SGP30, sgp.eCO2, sgp.TVOC); - if (TasmotaGlobal.global_update) { + if (ahum_available) { WSContentSend_PD(HTTP_SNS_AHUM, abs_hum); } #endif