Add VOC Sensor (voc) device support to Tuya (#58332)

This commit is contained in:
Franck Nijhof 2021-10-24 15:58:11 +02:00 committed by GitHub
parent 0f965c6b31
commit 539fdaad69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions

View File

@ -161,6 +161,16 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
),
TAMPER_BINARY_SENSOR,
),
# Volatile Organic Compound Sensor
# Note: Undocumented in cloud API docs, based on test device
"voc": (
TuyaBinarySensorEntityDescription(
key=DPCode.VOC_STATE,
device_class=DEVICE_CLASS_SAFETY,
on_value="alarm",
),
TAMPER_BINARY_SENSOR,
),
# Pressure Sensor
# https://developer.tuya.com/en/docs/iot/categoryylcg?id=Kaiuz3kc2e4gm
"ylcg": (

View File

@ -291,6 +291,7 @@ class DPCode(str, Enum):
UV = "uv" # UV sterilization
VA_HUMIDITY = "va_humidity"
VA_TEMPERATURE = "va_temperature"
VOC_STATE = "voc_state"
VOC_VALUE = "voc_value"
WARM = "warm" # Heat preservation
WARM_TIME = "warm_time" # Heat preservation time

View File

@ -264,6 +264,46 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
# Solar Light
# https://developer.tuya.com/en/docs/iot/tynd?id=Kaof8j02e1t98
"tyndj": BATTERY_SENSORS,
# Volatile Organic Compound Sensor
# Note: Undocumented in cloud API docs, based on test device
"voc": (
SensorEntityDescription(
key=DPCode.CO2_VALUE,
name="Carbon Dioxide",
device_class=DEVICE_CLASS_CO2,
state_class=STATE_CLASS_MEASUREMENT,
),
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.HUMIDITY_VALUE,
name="Humidity",
device_class=DEVICE_CLASS_HUMIDITY,
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.VOC_VALUE,
name="Volatile Organic Compound",
device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
state_class=STATE_CLASS_MEASUREMENT,
),
*BATTERY_SENSORS,
),
# Pressure Sensor
# https://developer.tuya.com/en/docs/iot/categoryylcg?id=Kaiuz3kc2e4gm
"ylcg": (