Add PM2.5 Sensor (pm25) device support to Tuya (#58329)

This commit is contained in:
Franck Nijhof 2021-10-24 16:01:17 +02:00 committed by GitHub
parent a225d28089
commit f2923d8a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 0 deletions

View File

@ -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": (

View File

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

View File

@ -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": (