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

Add Tuya Royal Gardineer irrigation valve quirk #3505

Merged
merged 8 commits into from
Nov 27, 2024
72 changes: 72 additions & 0 deletions zhaquirks/tuya/ts0601_valve.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
TUYA_CLUSTER_ID,
EnchantedDevice,
TuyaLocalCluster,
TuyaPowerConfigurationCluster2AAA,
TuyaPowerConfigurationCluster4AA,
)
from zhaquirks.tuya.builder import TuyaQuirkBuilder
Expand Down Expand Up @@ -568,3 +569,74 @@ class GiexIrrigationStatus(t.enum8):
.skip_configuration()
.add_to_registry()
)


class RoyalGardineerWeatherDelay(t.enum8):
"""Royal Gardineer Irrigation Valve weather delay enum."""

Disabled = 0x00
Delayed_24h = 0x01
Delayed_48h = 0x02
Delayed_72h = 0x03


class RoyalGardineerTimerState(t.enum8):
"""Royal Gardineer Irrigation Valve timer state enum."""

Disabled = 0x00
Active = 0x01
Enabled = 0x02


(
TuyaQuirkBuilder("_TZE200_2wg5qrjy", "TS0601")
.tuya_onoff(dp_id=1)
# Should be TuyaPowerConfigurationCluster2AA, but it is broken at this time.
TheJulianJES marked this conversation as resolved.
Show resolved Hide resolved
.tuya_battery(dp_id=7, power_cfg=TuyaPowerConfigurationCluster2AAA)
TheJulianJES marked this conversation as resolved.
Show resolved Hide resolved
# Might need a converter: x // 10
.tuya_metering(dp_id=5)
# Timer time left/remaining (raw value in seconds).
.tuya_number(
dp_id=11,
attribute_name="timer_time_left",
type=t.uint32_t,
min_value=1,
max_value=600,
step=1,
multiplier=1 / 60,
unit=UnitOfTime.MINUTES,
translation_key="timer_time_left",
fallback_name="Timer time left",
)
TheJulianJES marked this conversation as resolved.
Show resolved Hide resolved
# Weather delay.
.tuya_enum(
dp_id=10,
attribute_name="weather_delay",
enum_class=RoyalGardineerWeatherDelay,
translation_key="weather_delay",
fallback_name="Weather delay",
initially_disabled=True,
)
# Timer state - read-only.
.tuya_enum(
dp_id=12,
attribute_name="timer_state",
enum_class=RoyalGardineerTimerState,
entity_platform=EntityPlatform.SENSOR,
entity_type=EntityType.DIAGNOSTIC,
translation_key="timer_state",
fallback_name="Timer state",
)
# Last valve open duration - read-only (raw value in seconds).
.tuya_sensor(
dp_id=15,
attribute_name="last_valve_open_duration",
type=t.uint32_t,
divisor=60,
entity_type=EntityType.DIAGNOSTIC,
unit=UnitOfTime.MINUTES,
translation_key="last_valve_open_duration",
fallback_name="Last valve open duration",
)
.add_to_registry()
)