Skip to content

Commit 0629f01

Browse files
authored
Add Bosch control relay II (BMCT-SLC / RBSH-MMS-ZB-EU) (#4052)
1 parent a522ab8 commit 0629f01

File tree

1 file changed

+211
-0
lines changed

1 file changed

+211
-0
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
"""Device handler for Bosch Light/shutter control unit II."""
2+
3+
from typing import Final
4+
5+
from zigpy import types as t
6+
from zigpy.quirks.v2 import QuirkBuilder
7+
from zigpy.quirks.v2.homeassistant import UnitOfTime
8+
from zigpy.zcl.clusters.closures import WindowCovering
9+
from zigpy.zcl.foundation import BaseAttributeDefs, ZCLAttributeDef
10+
11+
from zhaquirks import CustomCluster
12+
from zhaquirks.bosch import BOSCH
13+
14+
15+
class BoschDeviceMode(t.enum8):
16+
"""Device mode enum."""
17+
18+
Disabled = 0x00
19+
Cover = 0x01
20+
Light = 0x04
21+
22+
23+
class BoschSwitchType(t.enum8):
24+
"""Switch type enum."""
25+
26+
Button = 0x01
27+
Button_key_change = 0x02
28+
Rocker_switch = 0x03
29+
Rocker_switch_key_change = 0x04
30+
31+
32+
class BoschMotorState(t.enum8):
33+
"""Motor state enum."""
34+
35+
Stopped = 0x00
36+
Opening = 0x01
37+
Closing = 0x02
38+
39+
40+
class BoschLightShutterControlII(CustomCluster):
41+
"""Custom cluster for Bosch BMCT-SLZ device control."""
42+
43+
cluster_id: Final[t.uint16_t] = 0xFCA0
44+
45+
class AttributeDefs(BaseAttributeDefs):
46+
"""Manufacturer specific attributes."""
47+
48+
device_mode = ZCLAttributeDef(
49+
id=0x0000,
50+
type=BoschDeviceMode,
51+
access="rwp",
52+
is_manufacturer_specific=True,
53+
)
54+
55+
switch_type = ZCLAttributeDef(
56+
id=0x0001,
57+
type=BoschSwitchType,
58+
access="rwp",
59+
is_manufacturer_specific=True,
60+
)
61+
62+
calibration_opening_time = ZCLAttributeDef(
63+
id=0x0002,
64+
type=t.uint32_t,
65+
access="rwp",
66+
is_manufacturer_specific=True,
67+
)
68+
69+
calibration_closing_time = ZCLAttributeDef(
70+
id=0x0003,
71+
type=t.uint32_t,
72+
access="rwp",
73+
is_manufacturer_specific=True,
74+
)
75+
76+
calibration_button_hold_time = ZCLAttributeDef(
77+
id=0x0005,
78+
type=t.uint8_t,
79+
access="rwp",
80+
is_manufacturer_specific=True,
81+
)
82+
83+
child_lock = ZCLAttributeDef(
84+
id=0x0008,
85+
type=t.Bool,
86+
access="rwp",
87+
is_manufacturer_specific=True,
88+
)
89+
90+
calibration_motor_start_delay = ZCLAttributeDef(
91+
id=0x000F,
92+
type=t.uint8_t,
93+
access="rwp",
94+
is_manufacturer_specific=True,
95+
)
96+
97+
motor_state = ZCLAttributeDef(
98+
id=0x0013,
99+
type=BoschMotorState,
100+
access="rp",
101+
is_manufacturer_specific=True,
102+
)
103+
104+
105+
class BoschWindowCovering(CustomCluster, WindowCovering):
106+
"""Custom Bosch window covering cluster.
107+
108+
The Bosch reported type of Shutter only enables tilt commands (per the Zigbee cluster spec).
109+
This is overridden to Tilt_blind_tilt_and_lift because the device is a generic relay.
110+
"""
111+
112+
_CONSTANT_ATTRIBUTES = {
113+
WindowCovering.AttributeDefs.window_covering_type.id: WindowCovering.WindowCoveringType.Tilt_blind_tilt_and_lift,
114+
}
115+
116+
117+
(
118+
QuirkBuilder(BOSCH, "RBSH-MMS-ZB-EU")
119+
.friendly_name(manufacturer=BOSCH, model="BMCT-SLZ")
120+
.replace_cluster_occurrences(BoschLightShutterControlII)
121+
.replaces(BoschWindowCovering)
122+
.sensor(
123+
BoschLightShutterControlII.AttributeDefs.motor_state.name,
124+
BoschLightShutterControlII.cluster_id,
125+
translation_key="motor_state",
126+
fallback_name="Motor state",
127+
)
128+
.enum(
129+
BoschLightShutterControlII.AttributeDefs.device_mode.name,
130+
BoschDeviceMode,
131+
BoschLightShutterControlII.cluster_id,
132+
translation_key="device_mode",
133+
fallback_name="Device mode",
134+
)
135+
.enum(
136+
BoschLightShutterControlII.AttributeDefs.switch_type.name,
137+
BoschSwitchType,
138+
BoschLightShutterControlII.cluster_id,
139+
translation_key="switch_type",
140+
fallback_name="Switch type",
141+
)
142+
.number(
143+
BoschLightShutterControlII.AttributeDefs.calibration_closing_time.name,
144+
BoschLightShutterControlII.cluster_id,
145+
min_value=1,
146+
max_value=90,
147+
step=0.1,
148+
unit=UnitOfTime.SECONDS,
149+
mode="box",
150+
multiplier=0.1,
151+
translation_key="closing_duration",
152+
fallback_name="Closing duration",
153+
)
154+
.number(
155+
BoschLightShutterControlII.AttributeDefs.calibration_opening_time.name,
156+
BoschLightShutterControlII.cluster_id,
157+
min_value=1,
158+
max_value=90,
159+
step=0.1,
160+
unit=UnitOfTime.SECONDS,
161+
mode="box",
162+
multiplier=0.1,
163+
translation_key="opening_duration",
164+
fallback_name="Opening duration",
165+
)
166+
.number(
167+
BoschLightShutterControlII.AttributeDefs.calibration_button_hold_time.name,
168+
BoschLightShutterControlII.cluster_id,
169+
min_value=0.1,
170+
max_value=2,
171+
step=0.1,
172+
unit=UnitOfTime.SECONDS,
173+
mode="box",
174+
multiplier=0.1,
175+
translation_key="long_press_duration",
176+
fallback_name="Long press duration",
177+
)
178+
.number(
179+
BoschLightShutterControlII.AttributeDefs.calibration_motor_start_delay.name,
180+
BoschLightShutterControlII.cluster_id,
181+
min_value=0,
182+
max_value=20,
183+
step=0.1,
184+
unit=UnitOfTime.SECONDS,
185+
mode="box",
186+
multiplier=0.1,
187+
translation_key="motor_start_delay",
188+
fallback_name="Motor start delay",
189+
)
190+
.switch(
191+
BoschLightShutterControlII.AttributeDefs.child_lock.name,
192+
BoschLightShutterControlII.cluster_id,
193+
translation_key="child_lock",
194+
fallback_name="Child lock",
195+
)
196+
.switch(
197+
BoschLightShutterControlII.AttributeDefs.child_lock.name,
198+
BoschLightShutterControlII.cluster_id,
199+
endpoint_id=2,
200+
translation_key="child_lock",
201+
fallback_name="Child lock",
202+
)
203+
.switch(
204+
BoschLightShutterControlII.AttributeDefs.child_lock.name,
205+
BoschLightShutterControlII.cluster_id,
206+
endpoint_id=3,
207+
translation_key="child_lock",
208+
fallback_name="Child lock",
209+
)
210+
.add_to_registry()
211+
)

0 commit comments

Comments
 (0)