From 696b930b1c11d934af047bde3351f6ac17bf1208 Mon Sep 17 00:00:00 2001 From: dougiteixeira <31328123+dougiteixeira@users.noreply.github.com> Date: Thu, 27 Jan 2022 16:41:13 -0300 Subject: [PATCH] Complementing the Tuya Curtain (cl) category (#65023) Co-authored-by: Franck Nijhof --- homeassistant/components/tuya/const.py | 7 +++++++ homeassistant/components/tuya/select.py | 17 +++++++++++++++++ homeassistant/components/tuya/sensor.py | 10 ++++++++++ .../components/tuya/strings.select.json | 8 ++++++++ homeassistant/components/tuya/switch.py | 16 ++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index 5093745a0bf..79b01140875 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -87,6 +87,8 @@ PLATFORMS = [ class TuyaDeviceClass(StrEnum): """Tuya specific device classes, used for translations.""" + CURTAIN_MODE = "tuya__curtain_mode" + CURTAIN_MOTOR_MODE = "tuya__curtain_motor_mode" BASIC_ANTI_FLICKR = "tuya__basic_anti_flickr" BASIC_NIGHTVISION = "tuya__basic_nightvision" DECIBEL_SENSITIVITY = "tuya__decibel_sensitivity" @@ -187,7 +189,10 @@ class DPCode(StrEnum): CONTROL = "control" CONTROL_2 = "control_2" CONTROL_3 = "control_3" + CONTROL_BACK = "control_back" + CONTROL_BACK_MODE = "control_back_mode" COUNTDOWN = "countdown" # Countdown + COUNTDOWN_LEFT = "countdown_left" COUNTDOWN_SET = "countdown_set" # Countdown setting CRY_DETECTION_SWITCH = "cry_detection_switch" CUP_NUMBER = "cup_number" # NUmber of cups @@ -249,6 +254,7 @@ class DPCode(StrEnum): MOVEMENT_DETECT_PIC = "movement_detect_pic" MUFFLING = "muffling" # Muffling NEAR_DETECTION = "near_detection" + OPPOSITE = "opposite" PAUSE = "pause" PERCENT_CONTROL = "percent_control" PERCENT_CONTROL_2 = "percent_control_2" @@ -341,6 +347,7 @@ class DPCode(StrEnum): TEMP_VALUE = "temp_value" # Color temperature TEMP_VALUE_V2 = "temp_value_v2" TEMPER_ALARM = "temper_alarm" # Tamper alarm + TIME_TOTAL = "time_total" TOTAL_CLEAN_AREA = "total_clean_area" TOTAL_CLEAN_COUNT = "total_clean_count" TOTAL_CLEAN_TIME = "total_clean_time" diff --git a/homeassistant/components/tuya/select.py b/homeassistant/components/tuya/select.py index ce89000acd2..5154afb9ab5 100644 --- a/homeassistant/components/tuya/select.py +++ b/homeassistant/components/tuya/select.py @@ -257,6 +257,23 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { icon="mdi:timer-cog-outline", ), ), + # Curtain + # https://developer.tuya.com/en/docs/iot/f?id=K9gf46o5mtfyc + "cl": ( + SelectEntityDescription( + key=DPCode.CONTROL_BACK_MODE, + name="Motor Mode", + device_class=TuyaDeviceClass.CURTAIN_MOTOR_MODE, + entity_category=EntityCategory.CONFIG, + icon="mdi:swap-horizontal", + ), + SelectEntityDescription( + key=DPCode.MODE, + name="Mode", + device_class=TuyaDeviceClass.CURTAIN_MODE, + entity_category=EntityCategory.CONFIG, + ), + ), } # Socket (duplicate of `kg`) diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index 2799d2b82fc..95ed463ee81 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -729,6 +729,16 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = { state_class=SensorStateClass.MEASUREMENT, ), ), + # Curtain + # https://developer.tuya.com/en/docs/iot/s?id=K9gf48qy7wkre + "cl": ( + TuyaSensorEntityDescription( + key=DPCode.TIME_TOTAL, + name="Last Operation Duration", + entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:progress-clock", + ), + ), } # Socket (duplicate of `kg`) diff --git a/homeassistant/components/tuya/strings.select.json b/homeassistant/components/tuya/strings.select.json index 48bf653979e..c1171f81fcb 100644 --- a/homeassistant/components/tuya/strings.select.json +++ b/homeassistant/components/tuya/strings.select.json @@ -85,6 +85,14 @@ "30": "30°", "60": "60°", "90": "90°" + }, + "tuya__curtain_mode": { + "morning": "Morning", + "night": "Night" + }, + "tuya__curtain_motor_mode": { + "forward": "Forward", + "back": "Back" } } } diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index 4e36aec5ee5..7041b22ebe6 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -514,6 +514,22 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { entity_category=EntityCategory.CONFIG, ), ), + # Curtain + # https://developer.tuya.com/en/docs/iot/f?id=K9gf46o5mtfyc + "cl": ( + SwitchEntityDescription( + key=DPCode.CONTROL_BACK, + name="Reverse", + icon="mdi:swap-horizontal", + entity_category=EntityCategory.CONFIG, + ), + SwitchEntityDescription( + key=DPCode.OPPOSITE, + name="Reverse", + icon="mdi:swap-horizontal", + entity_category=EntityCategory.CONFIG, + ), + ), } # Socket (duplicate of `pc`)