From 2be7773f5e53bdeca6231383f0cc7c7f3c69d0f8 Mon Sep 17 00:00:00 2001 From: PlusPlus-ua Date: Mon, 29 Nov 2021 17:52:15 +0200 Subject: [PATCH] Add Tuya Fingerbot device support (#59880) --- homeassistant/components/tuya/const.py | 4 ++++ homeassistant/components/tuya/number.py | 21 +++++++++++++++++++ homeassistant/components/tuya/select.py | 10 +++++++++ homeassistant/components/tuya/sensor.py | 2 ++ .../components/tuya/strings.select.json | 4 ++++ homeassistant/components/tuya/switch.py | 8 +++++++ .../tuya/translations/select.en.json | 4 ++++ 7 files changed, 53 insertions(+) diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index dc781ad8e42..e551c6a5229 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -85,6 +85,7 @@ DEVICE_CLASS_TUYA_MOTION_SENSITIVITY = "tuya__motion_sensitivity" DEVICE_CLASS_TUYA_RECORD_MODE = "tuya__record_mode" DEVICE_CLASS_TUYA_RELAY_STATUS = "tuya__relay_status" DEVICE_CLASS_TUYA_STATUS = "tuya__status" +DEVICE_CLASS_TUYA_FINGERBOT_MODE = "tuya__fingerbot_mode" TUYA_DISCOVERY_NEW = "tuya_discovery_new" TUYA_HA_SIGNAL_UPDATE_ENTITY = "tuya_entry_update" @@ -138,6 +139,8 @@ class DPCode(str, Enum): ANGLE_HORIZONTAL = "angle_horizontal" ANGLE_VERTICAL = "angle_vertical" ANION = "anion" # Ionizer unit + ARM_DOWN_PERCENT = "arm_down_percent" + ARM_UP_PERCENT = "arm_up_percent" BASIC_ANTI_FLICKER = "basic_anti_flicker" BASIC_DEVICE_VOLUME = "basic_device_volume" BASIC_FLIP = "basic_flip" @@ -168,6 +171,7 @@ class DPCode(str, Enum): CH4_SENSOR_STATE = "ch4_sensor_state" CH4_SENSOR_VALUE = "ch4_sensor_value" CHILD_LOCK = "child_lock" # Child lock + CLICK_SUSTAIN_TIME = "click_sustain_time" CO_STATE = "co_state" CO_STATUS = "co_status" CO_VALUE = "co_value" diff --git a/homeassistant/components/tuya/number.py b/homeassistant/components/tuya/number.py index c4063d22e22..a3ef644fa16 100644 --- a/homeassistant/components/tuya/number.py +++ b/homeassistant/components/tuya/number.py @@ -209,6 +209,27 @@ NUMBERS: dict[str, tuple[NumberEntityDescription, ...]] = { entity_category=ENTITY_CATEGORY_CONFIG, ), ), + # Fingerbot + "szjqr": ( + NumberEntityDescription( + key=DPCode.ARM_DOWN_PERCENT, + name="Move Down %", + icon="mdi:arrow-down-bold", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + NumberEntityDescription( + key=DPCode.ARM_UP_PERCENT, + name="Move Up %", + icon="mdi:arrow-up-bold", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + NumberEntityDescription( + key=DPCode.CLICK_SUSTAIN_TIME, + name="Down Delay", + icon="mdi:timer", + entity_category=ENTITY_CATEGORY_CONFIG, + ), + ), } diff --git a/homeassistant/components/tuya/select.py b/homeassistant/components/tuya/select.py index 921dc21eaaa..4eee162f814 100644 --- a/homeassistant/components/tuya/select.py +++ b/homeassistant/components/tuya/select.py @@ -19,6 +19,7 @@ from .const import ( DEVICE_CLASS_TUYA_BASIC_ANTI_FLICKR, DEVICE_CLASS_TUYA_BASIC_NIGHTVISION, DEVICE_CLASS_TUYA_DECIBEL_SENSITIVITY, + DEVICE_CLASS_TUYA_FINGERBOT_MODE, DEVICE_CLASS_TUYA_IPC_WORK_MODE, DEVICE_CLASS_TUYA_LED_TYPE, DEVICE_CLASS_TUYA_LIGHT_MODE, @@ -209,6 +210,15 @@ SELECTS: dict[str, tuple[SelectEntityDescription, ...]] = { entity_category=ENTITY_CATEGORY_CONFIG, ), ), + # Fingerbot + "szjqr": ( + SelectEntityDescription( + key=DPCode.MODE, + name="Mode", + device_class=DEVICE_CLASS_TUYA_FINGERBOT_MODE, + entity_category=ENTITY_CATEGORY_CONFIG, + ), + ), } diff --git a/homeassistant/components/tuya/sensor.py b/homeassistant/components/tuya/sensor.py index e95ebc2982e..b09d0ca905f 100644 --- a/homeassistant/components/tuya/sensor.py +++ b/homeassistant/components/tuya/sensor.py @@ -496,6 +496,8 @@ SENSORS: dict[str, tuple[SensorEntityDescription, ...]] = { # Vibration Sensor # https://developer.tuya.com/en/docs/iot/categoryzd?id=Kaiuz3a5vrzno "zd": BATTERY_SENSORS, + # Fingerbot + "szjqr": BATTERY_SENSORS, } # Socket (duplicate of `kg`) diff --git a/homeassistant/components/tuya/strings.select.json b/homeassistant/components/tuya/strings.select.json index ccc78704166..6bc005f8ea8 100644 --- a/homeassistant/components/tuya/strings.select.json +++ b/homeassistant/components/tuya/strings.select.json @@ -44,6 +44,10 @@ "on": "[%key:common::state::on%]", "power_off": "[%key:common::state::off%]", "power_on": "[%key:common::state::on%]" + }, + "tuya__fingerbot_mode": { + "click": "Push", + "switch": "Switch" } } } diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index 5fb5a0f39b0..97361a5c2c7 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -449,6 +449,14 @@ SWITCHES: dict[str, tuple[SwitchEntityDescription, ...]] = { entity_category=ENTITY_CATEGORY_CONFIG, ), ), + # Fingerbot + "szjqr": ( + SwitchEntityDescription( + key=DPCode.SWITCH, + name="Switch", + icon="mdi:cursor-pointer", + ), + ), } # Socket (duplicate of `pc`) diff --git a/homeassistant/components/tuya/translations/select.en.json b/homeassistant/components/tuya/translations/select.en.json index 7ac1f656d87..cd03cf8eeaf 100644 --- a/homeassistant/components/tuya/translations/select.en.json +++ b/homeassistant/components/tuya/translations/select.en.json @@ -44,6 +44,10 @@ "on": "On", "power_off": "Off", "power_on": "On" + }, + "tuya__fingerbot_mode": { + "click": "Push", + "switch": "Switch" } } } \ No newline at end of file