Add PM 2.5 sensor to TuyaMCU driver

This commit is contained in:
blakadder 2022-08-15 00:58:45 +02:00
parent 0dbf3ab6dc
commit 2716d739f2
2 changed files with 7 additions and 4 deletions

View File

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

View File

@ -103,7 +103,7 @@ const char kTuyaSensors[] PROGMEM = // List of available sensors (can be expande
// 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";
"|" 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: