diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 3c1a666ec79..a1483447749 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -137,6 +137,16 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { ), TAMPER_BINARY_SENSOR, ), + # PM2.5 Sensor + # https://developer.tuya.com/en/docs/iot/categorypm25?id=Kaiuz3qof3yfu + "pm2.5": ( + TuyaBinarySensorEntityDescription( + key=DPCode.PM25_STATE, + device_class=DEVICE_CLASS_SAFETY, + on_value="alarm", + ), + TAMPER_BINARY_SENSOR, + ), # Gas Detector # https://developer.tuya.com/en/docs/iot/categoryrqbj?id=Kaiuz3d162ubw "rqbj": ( diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 5b8fd87242f..5da0bad19ac 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -227,6 +227,9 @@ class DPCode(str, Enum): PERCENT_STATE_2 = "percent_state_2" PERCENT_STATE_3 = "percent_state_3" PIR = "pir" # Motion sensor + PM1 = "pm1" + PM10 = "pm10" + PM25_STATE = "pm25_state" PM25_VALUE = "pm25_value" POWDER_SET = "powder_set" # Powder POWER_GO = "power_go" diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index c74316f484f..77ec9c1140d 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -19,6 +19,8 @@ from homeassistant.const import ( DEVICE_CLASS_CURRENT, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, + DEVICE_CLASS_PM1, + DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, DEVICE_CLASS_POWER, DEVICE_CLASS_PRESSURE, @@ -222,6 +224,58 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { # PIR Detector # https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80 "pir": BATTERY_SENSORS, + # PM2.5 Sensor + # https://developer.tuya.com/en/docs/iot/categorypm25?id=Kaiuz3qof3yfu + "pm2.5": ( + SensorEntityDescription( + key=DPCode.PM25_VALUE, + name="Particulate Matter 2.5 µm", + device_class=DEVICE_CLASS_PM25, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.CH2O_VALUE, + name="Formaldehyde", + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.VOC_VALUE, + name="Volatile Organic Compound", + device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.TEMP_CURRENT, + name="Temperature", + device_class=DEVICE_CLASS_TEMPERATURE, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.CO2_VALUE, + name="Carbon Dioxide", + device_class=DEVICE_CLASS_CO2, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.HUMIDITY_VALUE, + name="Humidity", + device_class=DEVICE_CLASS_HUMIDITY, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.PM1, + name="Particulate Matter 1.0 µm", + device_class=DEVICE_CLASS_PM1, + state_class=STATE_CLASS_MEASUREMENT, + ), + SensorEntityDescription( + key=DPCode.PM10, + name="Particulate Matter 10.0 µm", + device_class=DEVICE_CLASS_PM10, + state_class=STATE_CLASS_MEASUREMENT, + ), + *BATTERY_SENSORS, + ), # Heater # https://developer.tuya.com/en/docs/iot/categoryqn?id=Kaiuz18kih0sm "qn": (