-
Notifications
You must be signed in to change notification settings - Fork 720
/
cctswitch.py
137 lines (130 loc) · 3.69 KB
/
cctswitch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""Device handler for CCS-Switch-D0001 remote control."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Basic,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
)
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink
from zhaquirks.const import (
ARGS,
CLUSTER_ID,
COMMAND,
COMMAND_MOVE,
COMMAND_MOVE_ON_OFF,
COMMAND_RELEASE,
COMMAND_STEP,
COMMAND_STEP_ON_OFF,
COMMAND_TOGGLE,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PARAMS,
PROFILE_ID,
SHORT_PRESS,
TURN_ON,
)
from zhaquirks.lds import MANUFACTURER
class CCTSwitch(CustomDevice):
"""Custom device representing CCTSwitch-D0001 remote control."""
signature = {
# <SimpleDescriptor endpoint = 1 profile = 260 device_type = 2048
# device_version = 1 input_clusters = [0, 1, 3, 4096, 64769]
# output_clusters = [3, 4, 6, 8, 25, 768, 4096] >
MODELS_INFO: [(MANUFACTURER, "ZBT-CCTSwitch-D0001")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
LightLink.cluster_id,
0xFD01,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.COLOR_CONTROLLER,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
LightLink.cluster_id,
0xFD01,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
Color.cluster_id,
LightLink.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {
COMMAND: COMMAND_TOGGLE,
CLUSTER_ID: 6,
ENDPOINT_ID: 1,
},
(LONG_PRESS, TURN_ON): {
COMMAND: COMMAND_RELEASE,
CLUSTER_ID: 5,
ENDPOINT_ID: 1,
ARGS: [],
},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 0},
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_MOVE_ON_OFF,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 0},
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"step_mode": 1},
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_MOVE,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
PARAMS: {"move_mode": 1},
},
}