From e65345900ff22959492c9c32e46ec17308389a68 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 19 Oct 2021 23:17:00 +0200 Subject: [PATCH] Add Human Presence Sensor (hps) device support to Tuya (#58054) --- .../components/tuya/binary_sensor.py | 9 ++++++++ homeassistant/components/tuya/const.py | 3 +++ homeassistant/components/tuya/number.py | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/homeassistant/components/tuya/binary_sensor.py b/homeassistant/components/tuya/binary_sensor.py index 22db498a1c4..0a54aa74dfe 100644 --- a/homeassistant/components/tuya/binary_sensor.py +++ b/homeassistant/components/tuya/binary_sensor.py @@ -42,6 +42,15 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription): # end up being a binary sensor. # https://developer.tuya.com/en/docs/iot/standarddescription?id=K9i5ql6waswzq BINARY_SENSORS: dict[str, tuple[TuyaBinarySensorEntityDescription, ...]] = { + # Human Presence Sensor + # https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs + "hps": ( + TuyaBinarySensorEntityDescription( + key=DPCode.PRESENCE_STATE, + device_class=DEVICE_CLASS_MOTION, + on_value="presence", + ), + ), # Door Window Sensor # https://developer.tuya.com/en/docs/iot/s?id=K9gf48hm02l8m "mcs": ( diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 6c6f84214d7..bb98227f3b9 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -156,6 +156,7 @@ class DPCode(str, Enum): FAN_DIRECTION = "fan_direction" # Fan direction FAN_SPEED_ENUM = "fan_speed_enum" # Speed mode FAN_SPEED_PERCENT = "fan_speed_percent" # Stepless speed + FAR_DETECTION = "far_detection" FILTER_RESET = "filter_reset" # Filter (cartridge) reset HUMIDITY_CURRENT = "humidity_current" # Current humidity HUMIDITY_SET = "humidity_set" # Humidity setting @@ -166,6 +167,7 @@ class DPCode(str, Enum): MODE = "mode" # Working mode / Mode MOTION_SWITCH = "motion_switch" # Motion switch MUFFLING = "muffling" # Muffling + NEAR_DETECTION = "near_detection" PAUSE = "pause" PERCENT_CONTROL = "percent_control" PERCENT_CONTROL_2 = "percent_control_2" @@ -176,6 +178,7 @@ class DPCode(str, Enum): PIR = "pir" # Motion sensor POWDER_SET = "powder_set" # Powder POWER_GO = "power_go" + PRESENCE_STATE = "presence_state" PUMP_RESET = "pump_reset" # Water pump reset RECORD_SWITCH = "record_switch" # Recording switch SEEK = "seek" diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index 34325e63d98..0c5aa288f29 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -21,6 +21,27 @@ from .const import DOMAIN, TUYA_DISCOVERY_NEW, DPCode # 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, ...]] = { + # Human Presence Sensor + # https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs + "hps": ( + NumberEntityDescription( + key=DPCode.SENSITIVITY, + name="Sensitivity", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + NumberEntityDescription( + key=DPCode.NEAR_DETECTION, + name="Near Detection", + icon="mdi:signal-distance-variant", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + NumberEntityDescription( + key=DPCode.FAR_DETECTION, + name="Far Detection", + icon="mdi:signal-distance-variant", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + ), # Coffee maker # https://developer.tuya.com/en/docs/iot/categorykfj?id=Kaiuz2p12pc7f "kfj": (