-
Notifications
You must be signed in to change notification settings - Fork 5
/
sensor.py
235 lines (212 loc) · 7.4 KB
/
sensor.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
"""Module to handle quirks of the Sinopé Technologies water leak sensor and level monitor.
It add manufacturer attributes for IasZone cluster for the water leak alarm.
Supported devices are WL4200, WL4200S and LM4110-ZB
"""
import zigpy.profiles.zha as zha_p
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
AnalogInput,
Basic,
Identify,
Ota,
PollControl,
PowerConfiguration,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.measurement import TemperatureMeasurement
from zigpy.zcl.clusters.security import IasZone
from zhaquirks.const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.sinope import SINOPE, SINOPE_MANUFACTURER_CLUSTER_ID
class SinopeManufacturerCluster(CustomCluster):
"""SinopeManufacturerCluster manufacturer cluster."""
cluster_id = SINOPE_MANUFACTURER_CLUSTER_ID
name = "Sinopé Manufacturer specific"
ep_attribute = "sinope_manufacturer_specific"
attributes = {
0x0003: ("firmware_number", t.uint16_t, True),
0x0004: ("firmware_version", t.CharacterString, True),
0x0030: ("unknown_attr_2", t.uint8_t, True),
0x0031: ("unknown_attr_3", t.uint16_t, True),
0x0032: ("min_temperature_limit", t.int16s, True),
0x0033: ("max_temperature_limit", t.int16s, True),
0x0034: ("device_status", t.bitmap8, True),
0x0035: ("unknown_attr_7", t.uint16_t, True),
0x0036: ("unknown_attr_8", t.uint16_t, True),
0x0080: ("unknown_attr_9", t.uint32_t, True),
0x0200: ("status", t.bitmap32, True),
0xFFFD: ("cluster_revision", t.uint16_t, True),
}
class SinopeTechnologiesIasZoneCluster(CustomCluster, IasZone):
"""SinopeTechnologiesIasZoneCluster custom cluster."""
class LeakStatus(t.enum8):
"""Leak_status values."""
Dry = 0x00
Leak = 0x01
attributes = IasZone.attributes.copy()
attributes.update(
{
0x0030: ("leak_status", LeakStatus, True),
}
)
class SinopeTechnologiesSensor(CustomDevice):
"""SinopeTechnologiesSensor custom device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0 input_clusters=[0, 1, 3, 1026, 1280, 2821, 65281]
# output_clusters=[3, 25]>
MODELS_INFO: [
(SINOPE, "WL4200"),
(SINOPE, "WL4200S"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
TemperatureMeasurement.cluster_id,
SinopeTechnologiesIasZoneCluster,
Diagnostic.cluster_id,
SinopeManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
],
}
}
}
class SinopeTechnologiesSensor2(CustomDevice):
"""SinopeTechnologiesSensor2 custom device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0 input_clusters=[0, 1, 3, 20, 1026, 1280, 2821, 65281]
# output_clusters=[3, 25]>
MODELS_INFO: [
(SINOPE, "WL4200"),
(SINOPE, "WL4200S"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
IasZone.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
SinopeTechnologiesIasZoneCluster,
Diagnostic.cluster_id,
SinopeManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
Ota.cluster_id,
],
}
}
}
class SinopeTechnologiesLevelMonitor(CustomDevice):
"""SinopeTechnologiesLevelMonitor custom device."""
signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=0
# device_version=0 input_clusters=[0, 1, 3, 12, 32, 1026, 2821, 65281]
# output_clusters=[25]>
MODELS_INFO: [
(SINOPE, "LM4110-ZB"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
AnalogInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
SINOPE_MANUFACTURER_CLUSTER_ID,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
},
}
replacement = {
ENDPOINTS: {
1: {
PROFILE_ID: zha_p.PROFILE_ID,
DEVICE_TYPE: zha_p.DeviceType.METER_INTERFACE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
AnalogInput.cluster_id,
PollControl.cluster_id,
TemperatureMeasurement.cluster_id,
Diagnostic.cluster_id,
SinopeManufacturerCluster,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
}
}
}