Skip to content
Open
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
4 changes: 2 additions & 2 deletions tests/test_tuya_spells.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
TUYA_QUERY_DATA,
EnchantedDevice,
TuyaNewManufCluster,
TuyaZBOnOffAttributeCluster,
TuyaOnOffCluster,
)
import zhaquirks.tuya.tuya_valve

Expand Down Expand Up @@ -55,7 +55,7 @@ class TuyaTestSpellDevice(EnchantedDevice):
DEVICE_TYPE: zha.DeviceType.SMART_PLUG,
INPUT_CLUSTERS: [
Basic.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaOnOffCluster,
TuyaNewManufCluster,
],
OUTPUT_CLUSTERS: [],
Expand Down
4 changes: 3 additions & 1 deletion zhaquirks/quirk_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
KONKE_BUTTON = "konke.button_remote" # remote with custom handling in cluster handler

# Tuya
TUYA_PLUG_ONOFF = "tuya.plug_on_off_attributes" # plugs with configurable attributes on the OnOff cluster
TUYA_ON_OFF_CLUSTER = (
"tuya.on_off_cluster" # devices with extra attributes on the OnOff cluster
)
TUYA_PLUG_MANUFACTURER = "tuya.plug_manufacturer_attributes" # plugs with configurable attributes on a custom cluster

# Xiaomi
Expand Down
19 changes: 3 additions & 16 deletions zhaquirks/tuya/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,20 +1033,8 @@ class PowerOnState(t.enum8):
LastState = 0x02


class TuyaZBOnOffAttributeCluster(CustomCluster, OnOff):
"""Tuya Zigbee On Off cluster with extra attributes."""

class AttributeDefs(OnOff.AttributeDefs):
"""Attribute definitions."""

child_lock: Final = ZCLAttributeDef(id=0x8000, type=t.Bool)
backlight_mode: Final = ZCLAttributeDef(id=0x8001, type=SwitchBackLight)
power_on_state: Final = ZCLAttributeDef(id=0x8002, type=PowerOnState)
switch_mode: Final = ZCLAttributeDef(id=0x8004, type=SwitchMode)


class TuyaSmartRemoteOnOffCluster(OnOff, EventableCluster):
"""TuyaSmartRemoteOnOffCluster: fire events corresponding to press type."""
class TuyaOnOffCluster(OnOff, EventableCluster):
"""TuyaOnOffCluster: fire events corresponding to press type."""

rotate_type = {
0x00: RIGHT,
Expand All @@ -1058,12 +1046,11 @@ class TuyaSmartRemoteOnOffCluster(OnOff, EventableCluster):
0x01: DOUBLE_PRESS,
0x02: LONG_PRESS,
}
name = "TS004X_cluster"
ep_attribute = "TS004X_cluster"

class AttributeDefs(OnOff.AttributeDefs):
"""Attribute definitions."""

child_lock: Final = ZCLAttributeDef(id=0x8000, type=t.Bool)
backlight_mode: Final = ZCLAttributeDef(id=0x8001, type=SwitchBackLight)
power_on_state: Final = ZCLAttributeDef(id=0x8002, type=PowerOnState)
switch_mode: Final = ZCLAttributeDef(id=0x8004, type=SwitchMode)
Expand Down
4 changes: 2 additions & 2 deletions zhaquirks/tuya/ts0001_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.smartenergy import Metering

from zhaquirks.tuya import TuyaZBExternalSwitchTypeCluster, TuyaZBOnOffAttributeCluster
from zhaquirks.tuya import TuyaOnOffCluster, TuyaZBExternalSwitchTypeCluster


class CustomElectricalMeasurement(ElectricalMeasurement, CustomCluster):
Expand Down Expand Up @@ -46,7 +46,7 @@ class CustomMetering(Metering, CustomCluster):
.applies_to("_TZ3000_jsfzkftc", "TS0001")
.replaces(CustomMetering)
.replaces(CustomElectricalMeasurement)
.replaces(TuyaZBOnOffAttributeCluster)
.replaces(TuyaOnOffCluster)
.replaces(TuyaZBExternalSwitchTypeCluster)
.add_to_registry()
)
8 changes: 4 additions & 4 deletions zhaquirks/tuya/ts000f_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
)
from zhaquirks.tuya import (
EnchantedDevice,
TuyaOnOffCluster,
TuyaZB1888Cluster,
TuyaZBE000Cluster,
TuyaZBElectricalMeasurement,
TuyaZBExternalSwitchTypeCluster,
TuyaZBMeteringCluster,
TuyaZBOnOffAttributeCluster,
)


Expand Down Expand Up @@ -80,7 +80,7 @@ class Tuya_1G_Wall_Switch_Metering(EnchantedDevice):
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaOnOffCluster,
Time.cluster_id,
TuyaZBMeteringCluster,
TuyaZBElectricalMeasurement,
Expand Down Expand Up @@ -150,7 +150,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice):
Basic.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaOnOffCluster,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
Expand All @@ -165,7 +165,7 @@ class Tuya_2G_Wall_Switch_Metering(EnchantedDevice):
INPUT_CLUSTERS: [
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaOnOffCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [],
Expand Down
Loading
Loading