Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get lasry1 fork #1

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

17 changes: 17 additions & 0 deletions custom_components/tuya/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
38 changes: 4 additions & 34 deletions custom_components/tuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions custom_components/tuya/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
56 changes: 39 additions & 17 deletions custom_components/tuya/manifest.json
Original file line number Diff line number Diff line change
@@ -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"]
}
14 changes: 14 additions & 0 deletions custom_components/tuya/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
9 changes: 9 additions & 0 deletions custom_components/tuya/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down
37 changes: 18 additions & 19 deletions custom_components/tuya/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
PERCENTAGE,
TIME_MINUTES,
TIME_SECONDS,
EntityCategory,
UnitOfElectricCurrent,
UnitOfElectricPotential,
Expand All @@ -34,7 +36,6 @@
TUYA_DISCOVERY_NEW,
DPCode,
DPType,
TuyaDeviceClass,
UnitOfMeasurement,
)

Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions custom_components/tuya/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 7 additions & 21 deletions custom_components/tuya/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": (
Expand Down Expand Up @@ -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": (
Expand Down