Add Tuya Multi-functional Sensor (dgnbj) (#71778)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Elad Bar 2022-05-17 18:57:19 +03:00 committed by GitHub
parent 4d8593402e
commit e4573273dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 177 additions and 0 deletions

View file

@ -46,6 +46,79 @@ TAMPER_BINARY_SENSOR = TuyaBinarySensorEntityDescription(
# end up being a binary sensor.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = {
# Multi-functional Sensor
# https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3
"dgnbj": (
TuyaBinarySensorEntityDescription(
key=DPCode.GAS_SENSOR_STATE,
name="Gas",
icon="mdi:gas-cylinder",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.CH4_SENSOR_STATE,
name="Methane",
device_class=BinarySensorDeviceClass.GAS,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.VOC_STATE,
name="Volatile Organic Compound",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.PM25_STATE,
name="Particulate Matter 2.5 µm",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.CO_STATE,
name="Carbon Monoxide",
icon="mdi:molecule-co",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.CO2_STATE,
icon="mdi:molecule-co2",
name="Carbon Dioxide",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.CH2O_STATE,
name="Formaldehyde",
device_class=BinarySensorDeviceClass.SAFETY,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.DOORCONTACT_STATE,
name="Door",
device_class=BinarySensorDeviceClass.DOOR,
),
TuyaBinarySensorEntityDescription(
key=DPCode.WATERSENSOR_STATE,
name="Water Leak",
device_class=BinarySensorDeviceClass.MOISTURE,
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.PRESSURE_STATE,
name="Pressure",
on_value="alarm",
),
TuyaBinarySensorEntityDescription(
key=DPCode.SMOKE_SENSOR_STATE,
name="Smoke",
icon="mdi:smoke-detector",
device_class=BinarySensorDeviceClass.SMOKE,
on_value="alarm",
),
TAMPER_BINARY_SENSOR,
),
# CO2 Detector
# https://developer.tuya.com/en/docs/iot/categoryco2bj?id=Kaiuz3wes7yuy
"co2bj": (

View file

@ -18,6 +18,15 @@ from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode, DPType
# default instructions set of each category end up being a number.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = {
# Multi-functional Sensor
# https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3
"dgnbj": (
NumberEntityDescription(
key=DPCode.ALARM_TIME,
name="Time",
entity_category=EntityCategory.CONFIG,
),
),
# Smart Kettle
# https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
"bh": (

View file

@ -18,6 +18,15 @@ from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode, DPType, TuyaDeviceClass
# default instructions set of each category end up being a select.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = {
# Multi-functional Sensor
# https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3
"dgnbj": (
SelectEntityDescription(
key=DPCode.ALARM_VOLUME,
name="Volume",
entity_category=EntityCategory.CONFIG,
),
),
# Coffee maker
# https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f
"kfj": (

View file

@ -82,6 +82,84 @@ BATTERY_SENSORS: tuple[TuyaSensorEntityDescription, ...] = (
# end up being a sensor.
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
# Multi-functional Sensor
# https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3
"dgnbj": (
TuyaSensorEntityDescription(
key=DPCode.GAS_SENSOR_VALUE,
name="Gas",
icon="mdi:gas-cylinder",
device_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.CH4_SENSOR_VALUE,
name="Methane",
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.VOC_VALUE,
name="Volatile Organic Compound",
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.PM25_VALUE,
name="Particulate Matter 2.5 µm",
device_class=SensorDeviceClass.PM25,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.CO_VALUE,
name="Carbon Monoxide",
icon="mdi:molecule-co",
device_class=SensorDeviceClass.CO,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.CO2_VALUE,
name="Carbon Dioxide",
icon="mdi:molecule-co2",
device_class=SensorDeviceClass.CO2,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.CH2O_VALUE,
name="Formaldehyde",
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.BRIGHT_STATE,
name="Luminosity",
icon="mdi:brightness-6",
),
TuyaSensorEntityDescription(
key=DPCode.BRIGHT_VALUE,
name="Luminosity",
icon="mdi:brightness-6",
device_class=SensorDeviceClass.ILLUMINANCE,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.TEMP_CURRENT,
name="Temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.HUMIDITY_VALUE,
name="Humidity",
device_class=SensorDeviceClass.HUMIDITY,
state_class=SensorStateClass.MEASUREMENT,
),
TuyaSensorEntityDescription(
key=DPCode.SMOKE_SENSOR_VALUE,
name="Smoke Amount",
icon="mdi:smoke-detector",
entity_category=EntityCategory.DIAGNOSTIC,
device_class=SensorStateClass.MEASUREMENT,
),
*BATTERY_SENSORS,
),
# Smart Kettle
# https://developer.tuya.com/en/docs/iot/fbh?id=K9gf484m21yq7
"bh": (

View file

@ -22,6 +22,14 @@ from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode
# All descriptions can be found here:
# https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq
SIRENS: dict[str, tuple[SirenEntityDescription, ...]] = {
# Multi-functional Sensor
# https://developer.tuya.com/en/docs/iot/categorydgnbj?id=Kaiuz3yorvzg3
"dgnbj": (
SirenEntityDescription(
key=DPCode.ALARM_SWITCH,
name="Siren",
),
),
# Siren Alarm
# https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu
"sgbj": (