Add Human Presence Sensor (hps) device support to Tuya (#58054)

This commit is contained in:
Franck Nijhof 2021-10-19 23:17:00 +02:00 committed by GitHub
parent 0fe5baa425
commit e65345900f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 0 deletions

View file

@ -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": (

View file

@ -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"

View file

@ -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": (