Add CO2 Detector (co2bj) device support to Tuya (#58093)
This commit is contained in:
parent
b3117ced75
commit
c75346addc
3 changed files with 50 additions and 27 deletions
|
@ -37,11 +37,30 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription):
|
||||||
on_value: bool | float | int | str = True
|
on_value: bool | float | int | str = True
|
||||||
|
|
||||||
|
|
||||||
|
# Commonly used sensors
|
||||||
|
TAMPER_BINARY_SENSOR = TuyaBinarySensorEntityDescription(
|
||||||
|
key=DPCode.TEMPER_ALARM,
|
||||||
|
name="Tamper",
|
||||||
|
device_class=DEVICE_CLASS_TAMPER,
|
||||||
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# All descriptions can be found here. Mostly the Boolean data types in the
|
# All descriptions can be found here. Mostly the Boolean data types in the
|
||||||
# default status set of each category (that don't have a set instruction)
|
# default status set of each category (that don't have a set instruction)
|
||||||
# end up being a binary sensor.
|
# end up being a binary sensor.
|
||||||
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
|
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
|
||||||
BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
||||||
|
# CO2 Detector
|
||||||
|
# https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy
|
||||||
|
"co2bj": (
|
||||||
|
TuyaBinarySensorEntityDescription(
|
||||||
|
key=DPCode.CO2_STATE,
|
||||||
|
device_class=DEVICE_CLASS_SAFETY,
|
||||||
|
on_value="alarm",
|
||||||
|
),
|
||||||
|
TAMPER_BINARY_SENSOR,
|
||||||
|
),
|
||||||
# Human Presence Sensor
|
# Human Presence Sensor
|
||||||
# https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs
|
# https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs
|
||||||
"hps": (
|
"hps": (
|
||||||
|
@ -58,12 +77,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
||||||
key=DPCode.DOORCONTACT_STATE,
|
key=DPCode.DOORCONTACT_STATE,
|
||||||
device_class=DEVICE_CLASS_DOOR,
|
device_class=DEVICE_CLASS_DOOR,
|
||||||
),
|
),
|
||||||
TuyaBinarySensorEntityDescription(
|
TAMPER_BINARY_SENSOR,
|
||||||
key=DPCode.TEMPER_ALARM,
|
|
||||||
name="Tamper",
|
|
||||||
device_class=DEVICE_CLASS_TAMPER,
|
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
# Luminance Sensor
|
# Luminance Sensor
|
||||||
# https://developer.tuya.com/en/docs/iot/categoryldcg?id=Kaiuz3n7u69l8
|
# https://developer.tuya.com/en/docs/iot/categoryldcg?id=Kaiuz3n7u69l8
|
||||||
|
@ -83,12 +97,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
||||||
device_class=DEVICE_CLASS_MOTION,
|
device_class=DEVICE_CLASS_MOTION,
|
||||||
on_value="pir",
|
on_value="pir",
|
||||||
),
|
),
|
||||||
TuyaBinarySensorEntityDescription(
|
TAMPER_BINARY_SENSOR,
|
||||||
key=DPCode.TEMPER_ALARM,
|
|
||||||
name="Tamper",
|
|
||||||
device_class=DEVICE_CLASS_TAMPER,
|
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
# Water Detector
|
# Water Detector
|
||||||
# https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli
|
# https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli
|
||||||
|
@ -98,12 +107,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
||||||
device_class=DEVICE_CLASS_MOISTURE,
|
device_class=DEVICE_CLASS_MOISTURE,
|
||||||
on_value="alarm",
|
on_value="alarm",
|
||||||
),
|
),
|
||||||
TuyaBinarySensorEntityDescription(
|
TAMPER_BINARY_SENSOR,
|
||||||
key=DPCode.TEMPER_ALARM,
|
|
||||||
name="Tamper",
|
|
||||||
device_class=DEVICE_CLASS_TAMPER,
|
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
# Emergency Button
|
# Emergency Button
|
||||||
# https://developer.tuya.com/en/docs/iot/categorysos?id=Kaiuz3oi6agjy
|
# https://developer.tuya.com/en/docs/iot/categorysos?id=Kaiuz3oi6agjy
|
||||||
|
@ -112,12 +116,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
|
||||||
key=DPCode.SOS_STATE,
|
key=DPCode.SOS_STATE,
|
||||||
device_class=DEVICE_CLASS_SAFETY,
|
device_class=DEVICE_CLASS_SAFETY,
|
||||||
),
|
),
|
||||||
TuyaBinarySensorEntityDescription(
|
TAMPER_BINARY_SENSOR,
|
||||||
key=DPCode.TEMPER_ALARM,
|
|
||||||
name="Tamper",
|
|
||||||
device_class=DEVICE_CLASS_TAMPER,
|
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
# Vibration Sensor
|
# Vibration Sensor
|
||||||
# https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno
|
# https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno
|
||||||
|
|
|
@ -136,6 +136,7 @@ class DPCode(str, Enum):
|
||||||
BRIGHT_VALUE_V2 = "bright_value_v2"
|
BRIGHT_VALUE_V2 = "bright_value_v2"
|
||||||
C_F = "c_f" # Temperature unit switching
|
C_F = "c_f" # Temperature unit switching
|
||||||
CHILD_LOCK = "child_lock" # Child lock
|
CHILD_LOCK = "child_lock" # Child lock
|
||||||
|
CO2_STATE = "co2_state"
|
||||||
CO2_VALUE = "co2_value" # CO2 concentration
|
CO2_VALUE = "co2_value" # CO2 concentration
|
||||||
COLOR_DATA_V2 = "color_data_v2"
|
COLOR_DATA_V2 = "color_data_v2"
|
||||||
COLOUR_DATA = "colour_data" # Colored light mode
|
COLOUR_DATA = "colour_data" # Colored light mode
|
||||||
|
|
|
@ -62,9 +62,29 @@ BATTERY_SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
# end up being a sensor.
|
# end up being a sensor.
|
||||||
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
|
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
|
||||||
SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
# Door Window Sensor
|
# CO2 Detector
|
||||||
# https://developer.tuya.com/en/docs/iot/s?id=K9gf48hm02l8m
|
# https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy
|
||||||
"mcs": BATTERY_SENSORS,
|
"co2bj": (
|
||||||
|
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.CO2_VALUE,
|
||||||
|
name="Carbon Dioxide (CO2)",
|
||||||
|
device_class=DEVICE_CLASS_CO2,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
),
|
||||||
|
*BATTERY_SENSORS,
|
||||||
|
),
|
||||||
# Switch
|
# Switch
|
||||||
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
|
# https://developer.tuya.com/en/docs/iot/s?id=K9gf7o5prgf7s
|
||||||
"kg": (
|
"kg": (
|
||||||
|
@ -124,6 +144,9 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = {
|
||||||
),
|
),
|
||||||
*BATTERY_SENSORS,
|
*BATTERY_SENSORS,
|
||||||
),
|
),
|
||||||
|
# Door Window Sensor
|
||||||
|
# https://developer.tuya.com/en/docs/iot/s?id=K9gf48hm02l8m
|
||||||
|
"mcs": BATTERY_SENSORS,
|
||||||
# PIR Detector
|
# PIR Detector
|
||||||
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
|
# https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80
|
||||||
"pir": BATTERY_SENSORS,
|
"pir": BATTERY_SENSORS,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue