2
2
3
3
from zigpy .quirks import CustomCluster
4
4
from zigpy .quirks .v2 import QuirkBuilder
5
- from zigpy .quirks .v2 .homeassistant import EntityPlatform , EntityType
5
+ from zigpy .quirks .v2 .homeassistant import EntityType , PERCENTAGE
6
6
import zigpy .types as t
7
7
from zigpy .zcl .clusters .hvac import (
8
- ControlSequenceOfOperation ,
9
8
Thermostat ,
10
9
UserInterface ,
10
+ TemperatureDisplayMode ,
11
11
)
12
+ from zigpy .quirks .v2 .homeassistant .sensor import SensorStateClass
12
13
from zigpy .zcl .foundation import ZCLAttributeDef
13
14
14
15
"""Bosch specific thermostat attribute ids."""
15
16
16
17
# Mode of operation with values BoschOperatingMode.
17
18
OPERATING_MODE_ATTR_ID = 0x4007
18
19
20
+ # Valve duty cycle: 0% - 100%
21
+ VALVE_DUTY_CYCLE_ATTR_ID = 0x4020
22
+
19
23
# Window open switch (changes to a lower target temperature when on).
20
24
WINDOW_OPEN_ATTR_ID = 0x4042
21
25
30
34
# Display brightness (0 - 10).
31
35
SCREEN_BRIGHTNESS_ATTR_ID = 0x403B
32
36
33
- # Control sequence of operation (heating/cooling)
34
- CTRL_SEQUENCE_OF_OPERATION_ID = Thermostat .AttributeDefs .ctrl_sequence_of_oper .id
35
-
36
37
37
38
class BoschOperatingMode (t .enum8 ):
38
- """Bosh operating mode attribute values."""
39
+ """Bosch operating mode attribute values."""
39
40
40
41
Schedule = 0x00
41
42
Manual = 0x01
@@ -49,16 +50,15 @@ class State(t.enum8):
49
50
On = 0x01
50
51
51
52
52
- class BoschControlSequenceOfOperation (t .enum8 ):
53
- """Supported ControlSequenceOfOperation modes."""
54
-
55
- Cooling = ControlSequenceOfOperation .Cooling_Only
56
- Heating = ControlSequenceOfOperation .Heating_Only
57
-
58
-
59
53
class BoschThermostatCluster (CustomCluster , Thermostat ):
60
54
"""Bosch thermostat cluster."""
61
55
56
+ # Works around an issue where ZHA thinks "Heating_Only" can't be changed
57
+ # 0x06 is "centralite specific", but works perfectly for this thermostat as well
58
+ _CONSTANT_ATTRIBUTES = {
59
+ Thermostat .AttributeDefs .ctrl_sequence_of_oper .id : 0x06
60
+ }
61
+
62
62
class AttributeDefs (Thermostat .AttributeDefs ):
63
63
"""Bosch thermostat manufacturer specific attributes."""
64
64
@@ -68,6 +68,13 @@ class AttributeDefs(Thermostat.AttributeDefs):
68
68
is_manufacturer_specific = True ,
69
69
)
70
70
71
+ valve_duty_cycle = ZCLAttributeDef (
72
+ id = VALVE_DUTY_CYCLE_ATTR_ID ,
73
+ # Values range from 0-100
74
+ type = t .uint8_t ,
75
+ is_manufacturer_specific = True ,
76
+ )
77
+
71
78
window_open = ZCLAttributeDef (
72
79
id = WINDOW_OPEN_ATTR_ID ,
73
80
type = State ,
@@ -80,6 +87,12 @@ class AttributeDefs(Thermostat.AttributeDefs):
80
87
is_manufacturer_specific = True ,
81
88
)
82
89
90
+ temperature_display_mode = ZCLAttributeDef (
91
+ id = 0x0000 ,
92
+ type = TemperatureDisplayMode ,
93
+ access = "rw" ,
94
+ )
95
+
83
96
84
97
class BoschUserInterfaceCluster (CustomCluster , UserInterface ):
85
98
"""Bosch UserInterface cluster."""
@@ -107,17 +120,34 @@ class AttributeDefs(UserInterface.AttributeDefs):
107
120
.applies_to ("Bosch" , "RBSH-RTH0-BAT-ZB-EU" )
108
121
.replaces (BoschThermostatCluster )
109
122
.replaces (BoschUserInterfaceCluster )
110
- # Operating mode - read-only: controlled automatically through Thermostat.system_mode (HAVC mode).
123
+ # Valve duty cycle, PWM controlled.
124
+ .sensor (
125
+ BoschThermostatCluster .AttributeDefs .valve_duty_cycle .name ,
126
+ BoschThermostatCluster .cluster_id ,
127
+ state_class = SensorStateClass .MEASUREMENT ,
128
+ unit = PERCENTAGE ,
129
+ translation_key = "valve_duty_cycle" ,
130
+ fallback_name = "Valve duty cycle" ,
131
+ )
132
+ # Operating mode - On/Pause automatically from HVAC mode, Schedule/Manual configured here.
111
133
.enum (
112
134
BoschThermostatCluster .AttributeDefs .operating_mode .name ,
113
135
BoschOperatingMode ,
114
136
BoschThermostatCluster .cluster_id ,
115
- entity_platform = EntityPlatform .SENSOR ,
116
- entity_type = EntityType .DIAGNOSTIC ,
137
+ entity_type = EntityType .CONFIG ,
117
138
translation_key = "operating_mode" ,
118
139
fallback_name = "Operating mode" ,
119
140
)
120
- # Fast heating/boost.
141
+ # Temperature display type.
142
+ .enum (
143
+ BoschUserInterfaceCluster .AttributeDefs .temperature_display_mode .name ,
144
+ TemperatureDisplayMode ,
145
+ BoschUserInterfaceCluster .cluster_id ,
146
+ entity_type = EntityType .CONFIG ,
147
+ translation_key = "temperature_display_mode" ,
148
+ fallback_name = "Temperature display mode" ,
149
+ )
150
+ # Fast heating/boost - Only works with Heater type: Radiator.
121
151
.switch (
122
152
BoschThermostatCluster .AttributeDefs .boost_heating .name ,
123
153
BoschThermostatCluster .cluster_id ,
@@ -151,13 +181,5 @@ class AttributeDefs(UserInterface.AttributeDefs):
151
181
translation_key = "display_brightness" ,
152
182
fallback_name = "Display brightness" ,
153
183
)
154
- # Heating vs Cooling.
155
- .enum (
156
- Thermostat .AttributeDefs .ctrl_sequence_of_oper .name ,
157
- BoschControlSequenceOfOperation ,
158
- BoschThermostatCluster .cluster_id ,
159
- translation_key = "ctrl_sequence_of_oper" ,
160
- fallback_name = "Control sequence" ,
161
- )
162
184
.add_to_registry ()
163
185
)
0 commit comments