-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathhs1sa_efa.py
More file actions
221 lines (203 loc) · 6.65 KB
/
hs1sa_efa.py
File metadata and controls
221 lines (203 loc) · 6.65 KB
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
"""Heiman HS1SA-E smoke sensor."""
from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import QuirkBuilder, ReportingConfig
from zigpy.quirks.v2.homeassistant import EntityPlatform, EntityType
from zigpy.quirks.v2.homeassistant.binary_sensor import BinarySensorDeviceClass
import zigpy.types as t
from zigpy.zcl.clusters.security import IasWd, IasZone
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef
from zhaquirks.quirk_ids import SIREN_BASIC
class SmokeSirenEnum(t.enum8):
"""Smoke siren type."""
Stop = 0
Smoke_siren = 1
CO_siren = 2
class ChamberContaminationEnum(t.enum8):
"""Chamber contamination level."""
Normal = 0
Light_contamination = 1
Medium_contamination = 2
Critical_contamination = 3
class SmokeLevelUnitEnum(t.enum8):
"""Smoke level unit."""
dbm = 0
pct_ft_obs = 1
class CustomHeimanCluster(CustomCluster):
"""Heiman custom cluster."""
cluster_id = 0xFC90
class AttributeDefs(BaseAttributeDefs):
"""Attribute definitions."""
sensor_self_check_state = ZCLAttributeDef(
id=0x0001,
type=t.enum8,
manufacturer_code=0x120B,
)
sensor_fault_state = ZCLAttributeDef(
id=0x0002,
type=t.uint8_t,
manufacturer_code=0x120B,
)
sensor_mute_state = ZCLAttributeDef(
id=0x0009,
type=t.uint8_t,
manufacturer_code=0x120B,
)
heartbeat_indicator = ZCLAttributeDef(
id=0x1004,
type=t.uint8_t,
manufacturer_code=0x120B,
)
siren_for_automation = ZCLAttributeDef(
id=0x0012,
type=SmokeSirenEnum,
manufacturer_code=0x120B,
)
interconnectable = ZCLAttributeDef(
id=0x1007,
type=t.uint8_t,
manufacturer_code=0x120B,
)
smoke_level = ZCLAttributeDef(
id=0x0016,
type=t.uint8_t,
manufacturer_code=0x120B,
)
smoke_unit = ZCLAttributeDef(
id=0x0018,
type=SmokeLevelUnitEnum,
manufacturer_code=0x120B,
)
chamber_contamination = ZCLAttributeDef(
id=0x0017,
type=ChamberContaminationEnum,
manufacturer_code=0x120B,
)
rebooted_count = ZCLAttributeDef(
id=0x0019,
type=t.uint16_t,
manufacturer_code=0x120B,
)
rejoined_count = ZCLAttributeDef(
id=0x001A,
type=t.uint16_t,
manufacturer_code=0x120B,
)
reported_packages = ZCLAttributeDef(
id=0x001B,
type=t.uint16_t,
manufacturer_code=0x120B,
)
remote_mute = ZCLAttributeDef(
id=0x0008,
type=t.uint8_t,
manufacturer_code=0x120B,
)
remote_test = ZCLAttributeDef(
id=0x1009,
type=t.uint8_t,
manufacturer_code=0x120B,
)
(
QuirkBuilder()
.applies_to("HEIMAN", "HS1SA-EF-3.0")
.applies_to("HEIMAN", "HS1SA-E-PLUS")
.friendly_name(manufacturer="HEIMAN", model="HS1SA-E-PLUS") # Used by newer fw
.replaces(CustomHeimanCluster)
.exposes_feature(SIREN_BASIC)
.change_entity_metadata(
endpoint_id=1,
cluster_id=IasWd.cluster_id,
new_primary=False,
new_entity_category=EntityType.CONFIG,
)
.switch(
CustomHeimanCluster.AttributeDefs.heartbeat_indicator.name,
CustomHeimanCluster.cluster_id,
translation_key="heartbeat_indicator",
fallback_name="Heartbeat indicator",
)
# XXX: siren_for_automation should be added as a siren entity, needs zigpy API
.enum(
CustomHeimanCluster.AttributeDefs.chamber_contamination.name,
ChamberContaminationEnum,
CustomHeimanCluster.cluster_id,
entity_platform=EntityPlatform.SENSOR,
entity_type=EntityType.DIAGNOSTIC,
translation_key="chamber_contamination",
fallback_name="Chamber contamination",
)
.binary_sensor(
CustomHeimanCluster.AttributeDefs.sensor_self_check_state.name,
CustomHeimanCluster.cluster_id,
reporting_config=ReportingConfig(
min_interval=2, max_interval=0, reportable_change=1
),
translation_key="self_test_state",
fallback_name="Self-test",
)
.binary_sensor(
CustomHeimanCluster.AttributeDefs.sensor_fault_state.name,
CustomHeimanCluster.cluster_id,
device_class=BinarySensorDeviceClass.PROBLEM,
fallback_name="Fault",
)
.binary_sensor(
CustomHeimanCluster.AttributeDefs.sensor_mute_state.name,
CustomHeimanCluster.cluster_id,
translation_key="muted",
fallback_name="Muted",
)
.binary_sensor(
CustomHeimanCluster.AttributeDefs.interconnectable.name,
CustomHeimanCluster.cluster_id,
translation_key="interconnectable",
fallback_name="Interconnectable",
)
.switch(
CustomHeimanCluster.AttributeDefs.remote_mute.name,
CustomHeimanCluster.cluster_id,
translation_key="buzzer_manual_mute",
fallback_name="Buzzer manual mute",
)
.command_button(
IasZone.ServerCommandDefs.init_test_mode.name,
IasZone.cluster_id,
command_kwargs={"test_mode_duration": 5, "current_zone_sensitivity_level": 0},
translation_key="remote_test",
fallback_name="Remote test",
)
# XXX: The unit depends on the smoke_unit attribute, so we can't use one at all
.sensor(
CustomHeimanCluster.AttributeDefs.smoke_level.name,
CustomHeimanCluster.cluster_id,
divisor=100,
translation_key="smoke_level",
fallback_name="Smoke level",
)
# Zigbee debug sensors:
.sensor(
CustomHeimanCluster.AttributeDefs.rebooted_count.name,
CustomHeimanCluster.cluster_id,
entity_type=EntityType.DIAGNOSTIC,
initially_disabled=True,
translation_key="rebooted_count",
fallback_name="Rebooted count",
)
.sensor(
CustomHeimanCluster.AttributeDefs.rejoined_count.name,
CustomHeimanCluster.cluster_id,
entity_type=EntityType.DIAGNOSTIC,
initially_disabled=True,
translation_key="rejoined_count",
fallback_name="Rejoined count",
)
.sensor(
CustomHeimanCluster.AttributeDefs.reported_packages.name,
CustomHeimanCluster.cluster_id,
entity_type=EntityType.DIAGNOSTIC,
initially_disabled=True,
translation_key="reported_packages",
fallback_name="Reported packages",
)
.add_to_registry()
)