diff --git a/README.md b/README.md index 73404a8..8bdee24 100644 --- a/README.md +++ b/README.md @@ -5,23 +5,3 @@ A Home Assistant integration for adding custom Tuya categories without waiting for Core to update. This code Home Assistanmt Core pull request and to allow quick additon of more devices. - -This was originally a fork of jsmeyers/home-assistant-tuya-custom (https://github.com/jsmeyers/home-assistant-tuya-custom) but since 06/May/2023 I started it from scratch using the original TUYA folder from HomeAssistant/Core - -This adds 2 different water irrigation valves named ‘GGQ’ (Diivoo dual zone irrigation kit) and ‘SFKZQ’ (Johgee single valve) - - -To add this repo as a custom component in home assistant: - -Go to HACS -Integrations -3 Dots on top right corner -Custom repositories -repository: https://github.com/lasry1/home-assistant-tuya-custom/ -Category: Integration - - -Then you'll need to install it and reboot home assistant - -Hope that helps somebody as I struggled for years adding my irrigation natively to home asssitant. - diff --git a/custom_components/tuya/binary_sensor.py b/custom_components/tuya/binary_sensor.py index 25b2df4..62a4249 100644 --- a/custom_components/tuya/binary_sensor.py +++ b/custom_components/tuya/binary_sensor.py @@ -256,6 +256,23 @@ class TuyaBinarySensorEntityDescription(BinarySensorEntityDescription): ), TAMPER_BINARY_SENSOR, ), + # Smart Water Timer + "sfkzq": ( + TuyaBinarySensorEntityDescription( + key=f"{DPCode.WORK_STATE}_manual", + dpcode=DPCode.WORK_STATE, + name="Manual", + icon="mdi:information", + on_value="manual", + ), + TuyaBinarySensorEntityDescription( + key=f"{DPCode.WORK_STATE}_auto", + dpcode=DPCode.WORK_STATE, + name="Auto", + icon="mdi:information", + on_value="auto", + ), + ), # Water Detector # https://developer.tuya.com/en/docs/iot/categorysj?id=Kaiuz3iub2sli "sj": ( diff --git a/custom_components/tuya/const.py b/custom_components/tuya/const.py index 7110d0f..ac3c77c 100644 --- a/custom_components/tuya/const.py +++ b/custom_components/tuya/const.py @@ -73,38 +73,6 @@ ] -class TuyaDeviceClass(StrEnum): - """Tuya specific device classes, used for translations.""" - - AIR_QUALITY = "tuya__air_quality" - CURTAIN_MODE = "tuya__curtain_mode" - CURTAIN_MOTOR_MODE = "tuya__curtain_motor_mode" - BASIC_ANTI_FLICKR = "tuya__basic_anti_flickr" - BASIC_NIGHTVISION = "tuya__basic_nightvision" - COUNTDOWN = "tuya__countdown" - DECIBEL_SENSITIVITY = "tuya__decibel_sensitivity" - FAN_ANGLE = "tuya__fan_angle" - FINGERBOT_MODE = "tuya__fingerbot_mode" - HUMIDIFIER_SPRAY_MODE = "tuya__humidifier_spray_mode" - HUMIDIFIER_LEVEL = "tuya__humidifier_level" - HUMIDIFIER_MOODLIGHTING = "tuya__humidifier_moodlighting" - IPC_WORK_MODE = "tuya__ipc_work_mode" - LED_TYPE = "tuya__led_type" - LIGHT_MODE = "tuya__light_mode" - MOTION_SENSITIVITY = "tuya__motion_sensitivity" - RECORD_MODE = "tuya__record_mode" - RELAY_STATUS = "tuya__relay_status" - SMART_WEATHER = "tuya__smart_weather" - STATUS = "tuya__status" - VACUUM_CISTERN = "tuya__vacuum_cistern" - VACUUM_COLLECTION = "tuya__vacuum_collection" - VACUUM_MODE = "tuya__vacuum_mode" - WEATHER_DELAY = "tuya__weather_delay" - WORK_STATE = "tuya__work_state" - - - - class WorkMode(StrEnum): """Work modes.""" @@ -267,6 +235,7 @@ class DPCode(StrEnum): MOVEMENT_DETECT_PIC = "movement_detect_pic" MUFFLING = "muffling" # Muffling NEAR_DETECTION = "near_detection" + ONE_OFF = "countdown" OPPOSITE = "opposite" PAUSE = "pause" PERCENT_CONTROL = "percent_control" @@ -371,7 +340,7 @@ class DPCode(StrEnum): TEMP_VALUE_V2 = "temp_value_v2" TEMPER_ALARM = "temper_alarm" # Tamper alarm TIME_TOTAL = "time_total" - TIME_USE = "time_use" # Total seconds of irrigation + TIME_USE = "time_use" TOTAL_CLEAN_AREA = "total_clean_area" TOTAL_CLEAN_COUNT = "total_clean_count" TOTAL_CLEAN_TIME = "total_clean_time" @@ -382,6 +351,7 @@ class DPCode(StrEnum): UPPER_TEMP = "upper_temp" UPPER_TEMP_F = "upper_temp_f" UV = "uv" # UV sterilization + USE_TIME_ONE = "use_time_one" VA_BATTERY = "va_battery" VA_HUMIDITY = "va_humidity" VA_TEMPERATURE = "va_temperature" @@ -404,8 +374,8 @@ class DPCode(StrEnum): WIRELESS_BATTERYLOCK = "wireless_batterylock" WIRELESS_ELECTRICITY = "wireless_electricity" WORK_MODE = "work_mode" # Working mode + WORK_STATE = "work_state" WORK_POWER = "work_power" - WORK_STATE = "work_state" @dataclass diff --git a/custom_components/tuya/light.py b/custom_components/tuya/light.py index 959a183..44b3494 100644 --- a/custom_components/tuya/light.py +++ b/custom_components/tuya/light.py @@ -171,6 +171,15 @@ class TuyaLightEntityDescription(LightEntityDescription): entity_category=EntityCategory.CONFIG, ), ), + # Air Purifier + # https://developer.tuya.com/en/docs/iot/f?id=K9gf46h2s6dzm + "kj": ( + TuyaLightEntityDescription( + key=DPCode.LIGHT, + name="Backlight", + entity_category=EntityCategory.CONFIG, + ), + ), # Air conditioner # https://developer.tuya.com/en/docs/iot/categorykt?id=Kaiuz0z71ov2n "kt": ( diff --git a/custom_components/tuya/manifest.json b/custom_components/tuya/manifest.json index ab30b81..a6d0a28 100644 --- a/custom_components/tuya/manifest.json +++ b/custom_components/tuya/manifest.json @@ -1,25 +1,47 @@ { "domain": "tuya", "name": "Tuya", - "version": "2.0.0", - "documentation": "https://www.home-assistant.io/integrations/tuya", - "requirements": ["tuya-iot-py-sdk==0.6.6"], - "dependencies": ["ffmpeg"], "codeowners": ["@Tuya", "@zlinoliver", "@frenck"], "config_flow": true, - "iot_class": "cloud_push", + "dependencies": ["ffmpeg"], "dhcp": [ - { "macaddress": "105A17*" }, - { "macaddress": "10D561*" }, - { "macaddress": "1869D8*" }, - { "macaddress": "381F8D*" }, - { "macaddress": "508A06*" }, - { "macaddress": "68572D*" }, - { "macaddress": "708976*" }, - { "macaddress": "7CF666*" }, - { "macaddress": "84E342*" }, - { "macaddress": "D4A651*" }, - { "macaddress": "D81F12*" } + { + "macaddress": "105A17*" + }, + { + "macaddress": "10D561*" + }, + { + "macaddress": "1869D8*" + }, + { + "macaddress": "381F8D*" + }, + { + "macaddress": "508A06*" + }, + { + "macaddress": "68572D*" + }, + { + "macaddress": "708976*" + }, + { + "macaddress": "7CF666*" + }, + { + "macaddress": "84E342*" + }, + { + "macaddress": "D4A651*" + }, + { + "macaddress": "D81F12*" + } ], - "loggers": ["tuya_iot"] + "documentation": "https://www.home-assistant.io/integrations/tuya", + "integration_type": "hub", + "iot_class": "cloud_push", + "loggers": ["tuya_iot"], + "requirements": ["tuya-iot-py-sdk==0.6.6"] } diff --git a/custom_components/tuya/number.py b/custom_components/tuya/number.py index f4f8279..af8af6b 100644 --- a/custom_components/tuya/number.py +++ b/custom_components/tuya/number.py @@ -164,6 +164,20 @@ entity_category=EntityCategory.CONFIG, ), ), + # Smart Water Timer + "sfkzq": ( + NumberEntityDescription( + key=DPCode.ONE_OFF, + name="Countdown", + icon="mdi:timer", + ), + NumberEntityDescription( + key=DPCode.COUNTDOWN, + name="Manual Watering Time", + icon="mdi:timer", + entity_category=EntityCategory.CONFIG, + ), + ), # Siren Alarm # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu "sgbj": ( diff --git a/custom_components/tuya/select.py b/custom_components/tuya/select.py index b84737f..02a6268 100644 --- a/custom_components/tuya/select.py +++ b/custom_components/tuya/select.py @@ -136,6 +136,15 @@ translation_key="motion_sensitivity", ), ), + # Smart Water Timer + "sfkzq": ( + SelectEntityDescription( + key=DPCode.WEATHER_DELAY, + name="Weather delay", + entity_category=EntityCategory.CONFIG, + translation_key="weather_delay", + ), + ), # IoT Switch? # Note: Undocumented "tdq": ( diff --git a/custom_components/tuya/sensor.py b/custom_components/tuya/sensor.py index 0964a59..7aca303 100644 --- a/custom_components/tuya/sensor.py +++ b/custom_components/tuya/sensor.py @@ -15,6 +15,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( PERCENTAGE, + TIME_MINUTES, + TIME_SECONDS, EntityCategory, UnitOfElectricCurrent, UnitOfElectricPotential, @@ -34,7 +36,6 @@ TUYA_DISCOVERY_NEW, DPCode, DPType, - TuyaDeviceClass, UnitOfMeasurement, ) @@ -517,34 +518,32 @@ class TuyaSensorEntityDescription(SensorEntityDescription): ), *BATTERY_SENSORS, ), - # Smart Water Timer + # Smart Water Timer "sfkzq": ( TuyaSensorEntityDescription( key=DPCode.WORK_STATE, - name="Mode", - device_class=TuyaDeviceClass.WORK_STATE, - entity_category=EntityCategory.DIAGNOSTIC, + name="Status", ), - # Total seconds of irrigation. Read-write value; the device appears to ignore the write action (maybe firmware bug) TuyaSensorEntityDescription( key=DPCode.TIME_USE, - name="Total Watering Time", - icon="mdi:history", + name="Total runtime", + native_unit_of_measurement=TIME_SECONDS, state_class=SensorStateClass.TOTAL_INCREASING, - entity_category=EntityCategory.DIAGNOSTIC, + icon="mdi:clock-outline", ), - # Number of seconds for the watering session. The device will automatically turn off after this time TuyaSensorEntityDescription( - key=DPCode.COUNTDOWN, - name="Countdown", - icon="mdi:timer-outline", - device_class=TuyaDeviceClass.COUNTDOWN, - entity_category=EntityCategory.DIAGNOSTIC, + key=DPCode.SMART_WEATHER, + name="Weather forecast", + state_class=SensorStateClass.MEASUREMENT, + icon="mdi:weather-partly-cloudy", + ), + TuyaSensorEntityDescription( + key=DPCode.USE_TIME_ONE, + name="Last runtime", + native_unit_of_measurement=TIME_SECONDS, + state_class=SensorStateClass.MEASUREMENT, + icon="mdi:timer", ), - *BATTERY_SENSORS, - ), - # Smart Water Timer2 - "ggq": ( *BATTERY_SENSORS, ), # Water Detector diff --git a/custom_components/tuya/strings.json b/custom_components/tuya/strings.json index 534ff1d..83c43b9 100644 --- a/custom_components/tuya/strings.json +++ b/custom_components/tuya/strings.json @@ -156,6 +156,14 @@ "6h": "6 hours" } }, + "weather_delay": { + "state": { + "cancel": "[%key:common::state::off%]", + "24h": "24 hours", + "48h": "48 hours", + "72h": "72 hours" + } + }, "humidifier_spray_mode": { "state": { "auto": "Auto", @@ -203,6 +211,20 @@ "warm": "Heat preservation" } }, + "work_state": { + "state": { + "auto": "Auto", + "manual": "Manual", + "idle": "Idle" + } + }, + "smart_weather": { + "state": { + "sunny": "Sunny", + "cloudy": "Cloudy", + "rainy": "Rainy" + } + }, "air_quality": { "state": { "great": "Great", diff --git a/custom_components/tuya/switch.py b/custom_components/tuya/switch.py index f184cb1..b0a212b 100644 --- a/custom_components/tuya/switch.py +++ b/custom_components/tuya/switch.py @@ -430,27 +430,6 @@ entity_category=EntityCategory.CONFIG, ), ), - # Smart Water Timer - "sfkzq": ( - SwitchEntityDescription( - key=DPCode.SWITCH, - name="Switch", - icon="mdi:sprinkler-variant", - ), - ), - # Smart Water Timer2 - "ggq": ( - SwitchEntityDescription( - key=DPCode.SWITCH_1, - name="Switch 1", - icon="mdi:sprinkler-variant", - ), - SwitchEntityDescription( - key=DPCode.SWITCH_2, - name="Switch 2", - icon="mdi:sprinkler-variant", - ), - ), # Siren Alarm # https://developer.tuya.com/en/docs/iot/categorysgbj?id=Kaiuz37tlpbnu "sgbj": ( @@ -640,6 +619,13 @@ name="Switch", ), ), + # Smart Water Timer + "sfkzq": ( + SwitchEntityDescription( + key=DPCode.SWITCH, + name="Switch", + ), + ), # Fan # https://developer.tuya.com/en/docs/iot/categoryfs?id=Kaiuz1xweel1c "fs": (