Add CO Detector (cobj) device support to Tuya (#58292)

This commit is contained in:
Franck Nijhof 2021-10-23 18:15:12 +02:00 committed by GitHub
parent 581d9ec281
commit 0a272669ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 3 deletions

View file

@ -62,6 +62,21 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
),
TAMPER_BINARY_SENSOR,
),
# CO Detector
# https://developer.tuya.com/en/docs/iot/categorycobj?id=Kaiuz3u1j6q1v
"cobj": (
TuyaBinarySensorEntityDescription(
key=DPCode.CO_STATE,
device_class=DEVICE_CLASS_SAFETY,
on_value="1",
),
TuyaBinarySensorEntityDescription(
key=DPCode.CO_STATUS,
device_class=DEVICE_CLASS_SAFETY,
on_value="alarm",
),
TAMPER_BINARY_SENSOR,
),
# Human Presence Sensor
# https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs
"hps": (

View file

@ -150,10 +150,10 @@ class DPCode(str, Enum):
CH2O_STATE = "ch2o_state"
CH2O_VALUE = "ch2o_value"
CHILD_LOCK = "child_lock" # Child lock
CO_STATE = "co_state"
CO_STATUS = "co_status"
CO_VALUE = "co_value"
CO2_STATE = "co2_state"
SMOKE_SENSOR_STATUS = "smoke_sensor_status"
SMOKE_SENSOR_STATE = "smoke_sensor_state"
SMOKE_SENSOR_VALUE = "smoke_sensor_value"
CO2_VALUE = "co2_value" # CO2 concentration
COLOR_DATA_V2 = "color_data_v2"
COLOUR_DATA = "colour_data" # Colored light mode
@ -211,6 +211,9 @@ class DPCode(str, Enum):
SHAKE = "shake" # Oscillating
SHOCK_STATE = "shock_state" # Vibration status
SITUATION_SET = "situation_set"
SMOKE_SENSOR_STATE = "smoke_sensor_state"
SMOKE_SENSOR_STATUS = "smoke_sensor_status"
SMOKE_SENSOR_VALUE = "smoke_sensor_value"
SOS = "sos" # Emergency State
SOS_STATE = "sos_state" # Emergency mode
SPEED = "speed" # Speed level

View file

@ -14,6 +14,7 @@ from homeassistant.components.sensor import (
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_CO,
DEVICE_CLASS_CO2,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_HUMIDITY,
@ -94,6 +95,17 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
),
*BATTERY_SENSORS,
),
# CO Detector
# https://developer.tuya.com/en/docs/iot/categorycobj?id=Kaiuz3u1j6q1v
"cobj": (
SensorEntityDescription(
key=DPCode.CO_VALUE,
name="Carbon Monoxide",
device_class=DEVICE_CLASS_CO,
state_class=STATE_CLASS_MEASUREMENT,
),
*BATTERY_SENSORS,
),
# Switch
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
"kg": (