Skip to content

Commit

Permalink
add support for bseed touch switches (#1307)
Browse files Browse the repository at this point in the history
* add support for bseed touch switches

* trying to pass black check

* trying to pass isort check

* trying to pass isort check

* Revert "trying to pass black check"

This reverts commit 7e2f9d0.

* trying to pass check...

* trying to pass check again...

* again...
  • Loading branch information
Tropaion authored Jan 30, 2022
1 parent c6837b9 commit 23a1669
Showing 1 changed file with 250 additions and 5 deletions.
255 changes: 250 additions & 5 deletions zhaquirks/tuya/ts001x.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
"""Tuya 1,2,3 gang no neutral light switch."""

from zigpy.profiles import zha
from zigpy.zcl.clusters.general import Basic, Groups, OnOff, Ota, Scenes, Time
from zigpy.zcl.clusters.general import Basic, Groups, Identify, OnOff, Ota, Scenes, Time

from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODEL,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SKIP_CONFIGURATION,
)
from zhaquirks.tuya import TuyaSwitch, TuyaZBOnOffAttributeCluster
from zhaquirks.tuya import (
TuyaSwitch,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
TuyaZBOnOffAttributeCluster,
)


class TuyaSingleNoNeutralSwitch(TuyaSwitch):
Expand All @@ -23,7 +27,7 @@ class TuyaSingleNoNeutralSwitch(TuyaSwitch):
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)
MODELS_INFO: [("_TZ3000_9hpxg80k", "TS0011")],
MODEL: "TS0011",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=100
# device_version=1
Expand Down Expand Up @@ -71,7 +75,7 @@ class TuyaDoubleNoNeutralSwitch(TuyaSwitch):
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)"
MODELS_INFO: [("_TZ3000_fvh3pjaz", "TS0012")],
MODEL: "TS0012",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=100
# device_version=1
Expand Down Expand Up @@ -227,3 +231,244 @@ class TuyaTripleNoNeutralSwitch(TuyaSwitch):
},
},
}


class Tuya_Single_No_N(TuyaSwitch):
"""Tuya 1 gang no neutral light switch."""

signature = {
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)
MODEL: "TS0011",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=100
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 57344, 57345]
# output_clusters=[a, 19]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
},
}


class Tuya_Double_No_N(TuyaSwitch):
"""Tuya 2 gang no neutral light switch."""

signature = {
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)"
MODEL: "TS0012",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=100
# device_version=1
# input_clusters=[0, 3, 4, 5, 6, 57344, 57345]
# output_clusters=[a, 19]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=100
# device_version=1
# input_clusters=[3, 4, 5, 6, 57344, 57345]
# output_clusters=[]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [],
},
},
}


class Tuya_Triple_No_N(TuyaSwitch):
"""Tuya 3 gang no neutral light switch."""

signature = {
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)
# "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4098,
# maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264,
# maximum_outgoing_transfer_size=82, descriptor_capability_field=0)"
MODEL: "TS0013",
ENDPOINTS: {
# <SimpleDescriptor endpoint=1 profile=260 device_type=100
# device_version=1
# input_clusters=[0, 4, 5, 6]
# output_clusters=[a, 19]>
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [Ota.cluster_id, Time.cluster_id],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=100
# device_version=1
# input_clusters=[4, 5, 6]
# output_clusters=[]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
# <SimpleDescriptor endpoint=3 profile=260 device_type=100
# device_version=1
# input_clusters=[4, 5, 6]
# output_clusters=[]>
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
TuyaZBE000Cluster.cluster_id,
TuyaZBExternalSwitchTypeCluster.cluster_id,
],
OUTPUT_CLUSTERS: [],
},
},
}

replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBE000Cluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [Time.cluster_id, Ota.cluster_id],
},
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [],
},
3: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_LIGHT,
INPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
TuyaZBOnOffAttributeCluster,
TuyaZBExternalSwitchTypeCluster,
],
OUTPUT_CLUSTERS: [],
},
},
}

0 comments on commit 23a1669

Please sign in to comment.