Skip to content

Commit

Permalink
Add VOC Sensor (voc) device support to Tuya (#58332)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck committed Oct 24, 2021
1 parent 0f965c6 commit 539fdaa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions homeassistant/components/tuya/binary_sensor.py
Expand Up @@ -161,6 +161,16 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription):
),
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": (
Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/tuya/const.py
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions homeassistant/components/tuya/sensor.py
Expand Up @@ -264,6 +264,46 @@
# 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": (
Expand Down

0 comments on commit 539fdaa

Please sign in to comment.