From 3cdfb84b79e7e5b8b1ebb1b7da61f1dca180bc03 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sat, 23 Oct 2021 18:15:52 +0200 Subject: [PATCH] Add Gas Detector (rqbj) device support to Tuya (#58293) --- homeassistant/components/tuya/binary_sensor.py | 16 ++++++++++++++++ homeassistant/components/tuya/const.py | 3 +++ homeassistant/components/tuya/sensor.py | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 202362da0d9..33a0eef3572 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -7,6 +7,7 @@ from tuya_iot import TuyaDevice, TuyaDeviceManager from homeassistant.components.binary_sensor import ( DEVICE_CLASS_DOOR, + DEVICE_CLASS_GAS, DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOTION, DEVICE_CLASS_SAFETY, @@ -126,6 +127,21 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { ), TAMPER_BINARY_SENSOR, ), + # Gas Detector + # https://developer.tuya.com/en/docs/iot/categoryrqbj?id=Kaiuz3d162ubw + "rqbj": ( + TuyaBinarySensorEntityDescription( + key=DPCode.GAS_SENSOR_STATUS, + device_class=DEVICE_CLASS_GAS, + on_value="alarm", + ), + TuyaBinarySensorEntityDescription( + key=DPCode.GAS_SENSOR_STATE, + device_class=DEVICE_CLASS_GAS, + on_value="1", + ), + TAMPER_BINARY_SENSOR, + ), # Water Detector # https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli "sj": ( diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index eb2f10429a0..0f42bc9265c 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -177,6 +177,9 @@ class DPCode(str, Enum): FAN_SPEED_PERCENT = "fan_speed_percent" # Stepless speed FAR_DETECTION = "far_detection" FILTER_RESET = "filter_reset" # Filter (cartridge) reset + GAS_SENSOR_STATE = "gas_sensor_state" + GAS_SENSOR_STATUS = "gas_sensor_status" + GAS_SENSOR_VALUE = "gas_sensor_value" HUMIDITY_CURRENT = "humidity_current" # Current humidity HUMIDITY_SET = "humidity_set" # Humidity setting HUMIDITY_VALUE = "humidity_value" # Humidity diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index bea3b52a26e..eddbd650688 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -211,6 +211,16 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { # PIR Detector # https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80 "pir": BATTERY_SENSORS, + # Gas Detector + # https://developer.tuya.com/en/docs/iot/categoryrqbj?id=Kaiuz3d162ubw + "rqbj": ( + SensorEntityDescription( + key=DPCode.GAS_SENSOR_VALUE, + icon="mdi:gas-cylinder", + device_class=STATE_CLASS_MEASUREMENT, + ), + *BATTERY_SENSORS, + ), # Water Detector # https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli "sj": BATTERY_SENSORS,