diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 8adf930641c..ad026d2cef0 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -10,6 +10,7 @@ from homeassistant.components.binary_sensor import ( DEVICE_CLASS_MOISTURE, DEVICE_CLASS_MOTION, DEVICE_CLASS_SAFETY, + DEVICE_CLASS_SMOKE, DEVICE_CLASS_TAMPER, DEVICE_CLASS_VIBRATION, BinarySensorEntity, @@ -98,6 +99,7 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { device_class=DEVICE_CLASS_TAMPER, entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), + TAMPER_BINARY_SENSOR, ), # PIR Detector # https://developer.tuya.com/en/docs/iot/categorypir?id=Kaiuz3ss11b80 @@ -128,6 +130,21 @@ BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { ), TAMPER_BINARY_SENSOR, ), + # Smoke Detector + # https://developer.tuya.com/en/docs/iot/categoryywbj?id=Kaiuz3f6sf952 + "ywbj": ( + TuyaBinarySensorEntityDescription( + key=DPCode.SMOKE_SENSOR_STATUS, + device_class=DEVICE_CLASS_SMOKE, + on_value="alarm", + ), + TuyaBinarySensorEntityDescription( + key=DPCode.SMOKE_SENSOR_STATE, + device_class=DEVICE_CLASS_SMOKE, + on_value="1", + ), + TAMPER_BINARY_SENSOR, + ), # Vibration Sensor # https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno "zd": ( diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index a20206c9369..2c6bb67fa16 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -132,6 +132,7 @@ class DPCode(str, Enum): ANION = "anion" # Ionizer unit BATTERY_PERCENTAGE = "battery_percentage" # Battery percentage BATTERY_STATE = "battery_state" # Battery state + BATTERY_VALUE = "battery_value" # Battery value BRIGHT_CONTROLLER = "bright_controller" BRIGHT_STATE = "bright_state" # Brightness status BRIGHT_VALUE = "bright_value" # Brightness @@ -144,6 +145,9 @@ class DPCode(str, Enum): CH2O_VALUE = "ch2o_value" CHILD_LOCK = "child_lock" # Child lock 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 diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index c1407652d92..6624635fe18 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -57,6 +57,13 @@ BATTERY_SENSORS: tuple[SensorEntityDescription, ...] = ( icon="mdi:battery", entity_category=ENTITY_CATEGORY_DIAGNOSTIC, ), + SensorEntityDescription( + key=DPCode.BATTERY_VALUE, + name="Battery", + device_class=DEVICE_CLASS_BATTERY, + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + state_class=STATE_CLASS_MEASUREMENT, + ), ) # All descriptions can be found here. Mostly the Integer data types in the @@ -198,6 +205,18 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { # Emergency Button # https://developer.tuya.com/en/docs/iot/categorysos?id=Kaiuz3oi6agjy "sos": BATTERY_SENSORS, + # Smoke Detector + # https://developer.tuya.com/en/docs/iot/categoryywbj?id=Kaiuz3f6sf952 + "ywbj": ( + SensorEntityDescription( + key=DPCode.SMOKE_SENSOR_VALUE, + name="Smoke Amount", + icon="mdi:smoke-detector", + entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + device_class=STATE_CLASS_MEASUREMENT, + ), + *BATTERY_SENSORS, + ), # Vibration Sensor # https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno "zd": BATTERY_SENSORS,