From 3768d5ab9fec44b8c9ff6fca9428ccad7e5826a5 Mon Sep 17 00:00:00 2001 From: blakadder Date: Mon, 29 Mar 2021 20:32:59 +0200 Subject: [PATCH] add gas sensor with %LEL units --- tasmota/i18n.h | 1 + tasmota/tasmota.h | 2 +- tasmota/xdrv_16_tuyamcu.ino | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 9b997230f..76252e241 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -843,6 +843,7 @@ const char HTTP_SNS_COLOR_RED[] PROGMEM = "{s}%s " D_COLOR_RED "{ const char HTTP_SNS_COLOR_GREEN[] PROGMEM = "{s}%s " D_COLOR_GREEN "{m}%u " "{e}"; const char HTTP_SNS_COLOR_BLUE[] PROGMEM = "{s}%s " D_COLOR_BLUE "{m}%u " "{e}"; const char HTTP_SNS_MILLILITERS[] PROGMEM = "{s}%s " D_VOLUME "{m}%s " D_UNIT_MILLILITERS "{e}"; +const char HTTP_SNS_GAS[] PROGMEM = "{s}%s " D_GAS "{m}%d " D_UNIT_PERCENT "LEL{e}"; #endif // USE_WEBSERVER #endif // _I18N_H_ diff --git a/tasmota/tasmota.h b/tasmota/tasmota.h index 85784956f..f270e5cef 100644 --- a/tasmota/tasmota.h +++ b/tasmota/tasmota.h @@ -430,7 +430,7 @@ enum TuyaSupportedFunctions { TUYA_MCU_FUNC_NONE, TUYA_MCU_FUNC_LOWPOWER_MODE = 51, TUYA_MCU_FUNC_ENUM1 = 61, TUYA_MCU_FUNC_ENUM2, TUYA_MCU_FUNC_ENUM3, TUYA_MCU_FUNC_ENUM4, TUYA_MCU_FUNC_TEMP = 71, TUYA_MCU_FUNC_TEMPSET, TUYA_MCU_FUNC_HUM, TUYA_MCU_FUNC_HUMSET, - TUYA_MCU_FUNC_LX = 75, TUYA_MCU_FUNC_TVOC, TUYA_MCU_FUNC_CO2, TUYA_MCU_FUNC_ECO2, + TUYA_MCU_FUNC_LX = 75, TUYA_MCU_FUNC_TVOC, TUYA_MCU_FUNC_CO2, TUYA_MCU_FUNC_ECO2, TUYA_MCU_FUNC_GAS, TUYA_MCU_FUNC_TIMER1 = 81, TUYA_MCU_FUNC_TIMER2, TUYA_MCU_FUNC_TIMER3, TUYA_MCU_FUNC_TIMER4, TUYA_MCU_FUNC_MOTOR_DIR = 97, TUYA_MCU_FUNC_ERROR = 98, diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 476328ef1..a3e9a8638 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -95,9 +95,9 @@ struct TUYA { #define D_CMND_TUYA_SET_HUM "SetHum" #define D_CMND_TUYA_SET_TIMER "SetTimer" -const char kTuyaSensors[] PROGMEM = // Lit of available sensors (can be expanded in the future) +const char kTuyaSensors[] PROGMEM = // List of available sensors (can be expanded in the future) "" D_JSON_TEMPERATURE "|TempSet|" D_JSON_HUMIDITY "|HumSet|" D_JSON_ILLUMINANCE - "|" D_JSON_TVOC "|" D_JSON_ECO2 "|" D_JSON_CO2 "|||Timer1|Timer2|Timer3|TImer4"; + "|" D_JSON_TVOC "|" D_JSON_ECO2 "|" D_JSON_CO2 "|" D_JSON_GAS "||Timer1|Timer2|Timer3|TImer4"; const char kTuyaCommand[] PROGMEM = D_PRFX_TUYA "|" // Prefix D_CMND_TUYA_MCU "|" D_CMND_TUYA_MCU_SEND_STATE "|" D_CMND_TUYARGB "|" D_CMND_TUYA_ENUM "|" D_CMND_TUYA_ENUM_LIST; @@ -268,7 +268,7 @@ void CmndTuyaEnum(void) { // Command to control up to four type 4 Enum if (added) { ResponseAppend_P(PSTR(",")); } - ResponseAppend_P(PSTR("\"Enum%d\":%d"), i + 1, Tuya.EnumState[i]); // Returns the avtual values of Enum as list + ResponseAppend_P(PSTR("\"Enum%d\":%d"), i + 1, Tuya.EnumState[i]); // Returns the actual values of Enum as list added = true; } } @@ -392,7 +392,7 @@ inline bool TuyaFuncIdValid(uint8_t fnId) { (fnId >= TUYA_MCU_FUNC_MOTOR_DIR && fnId <= TUYA_MCU_FUNC_DUMMY) || (fnId == TUYA_MCU_FUNC_LOWPOWER_MODE) || (fnId >= TUYA_MCU_FUNC_TEMP && fnId <= TUYA_MCU_FUNC_HUMSET) || - (fnId >= TUYA_MCU_FUNC_LX && fnId <= TUYA_MCU_FUNC_ECO2) || + (fnId >= TUYA_MCU_FUNC_LX && fnId <= TUYA_MCU_FUNC_GAS) || (fnId >= TUYA_MCU_FUNC_TIMER1 && fnId <= TUYA_MCU_FUNC_TIMER4); } uint8_t TuyaGetFuncId(uint8_t dpid) { @@ -1381,6 +1381,9 @@ void TuyaSensorsShow(bool json) case 78: WSContentSend_PD(HTTP_SNS_CO2EAVG, "", Tuya.Sensors[7]); break; + case 79: + WSContentSend_PD(HTTP_SNS_GAS, "", Tuya.Sensors[8]); + break; case 81: case 82: case 83: