From 2716d739f2300e43b87382830327a01c645286d7 Mon Sep 17 00:00:00 2001 From: blakadder Date: Mon, 15 Aug 2022 00:58:45 +0200 Subject: [PATCH] Add PM 2.5 sensor to TuyaMCU driver --- tasmota/include/tasmota.h | 2 +- tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu.ino | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index 4a2aaa813..6284b9c29 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -501,7 +501,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_GAS, + TUYA_MCU_FUNC_LX = 75, TUYA_MCU_FUNC_TVOC, TUYA_MCU_FUNC_CO2, TUYA_MCU_FUNC_ECO2, TUYA_MCU_FUNC_GAS, TUYA_MCU_FUNC_PM25, 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/tasmota_xdrv_driver/xdrv_16_tuyamcu.ino b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu.ino index f95dc86b9..12ee1e815 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_16_tuyamcu.ino @@ -102,8 +102,8 @@ struct TUYA { const char kTuyaSensors[] PROGMEM = // List of available sensors (can be expanded in the future) // 71 72 73 74 75 "" D_JSON_TEMPERATURE "|TempSet|" D_JSON_HUMIDITY "|HumSet|" D_JSON_ILLUMINANCE -// 76 77 78 79 80 81 82 83 84 - "|" D_JSON_TVOC "|" D_JSON_ECO2 "|" D_JSON_CO2 "|" D_JSON_GAS "||Timer1|Timer2|Timer3|TImer4"; +// 76 77 78 79 80 81 82 83 84 + "|" D_JSON_TVOC "|" D_JSON_ECO2 "|" D_JSON_CO2 "|" D_JSON_GAS "|" D_ENVIRONMENTAL_CONCENTRATION "|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 "|TempSetRes"; @@ -426,7 +426,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_GAS) || + (fnId >= TUYA_MCU_FUNC_LX && fnId <= TUYA_MCU_FUNC_PM25) || (fnId >= TUYA_MCU_FUNC_TIMER1 && fnId <= TUYA_MCU_FUNC_TIMER4); } uint8_t TuyaGetFuncId(uint8_t dpid) { @@ -1484,6 +1484,9 @@ void TuyaSensorsShow(bool json) case 79: WSContentSend_PD(HTTP_SNS_GAS, "", Tuya.Sensors[8]); break; + case 80: + WSContentSend_PD(PSTR("{s}" D_ENVIRONMENTAL_CONCENTRATION " 2.5 " D_UNIT_MICROMETER "{m}%d " D_UNIT_MICROGRAM_PER_CUBIC_METER "{e}"), Tuya.Sensors[9]); + break; case 81: case 82: case 83: