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
19
- # Valve position : 0% - 100%
20
- VALVE_POSITION_ATTR_ID = 0x4020
20
+ # Valve duty cycle : 0% - 100%
21
+ VALVE_DUTY_CYCLE_ATTR_ID = 0x4020
21
22
22
23
# Window open switch (changes to a lower target temperature when on).
23
24
WINDOW_OPEN_ATTR_ID = 0x4042
33
34
# Display brightness (0 - 10).
34
35
SCREEN_BRIGHTNESS_ATTR_ID = 0x403B
35
36
36
- # Control sequence of operation (heating/cooling)
37
- CTRL_SEQUENCE_OF_OPERATION_ID = Thermostat .AttributeDefs .ctrl_sequence_of_oper .id
38
-
39
37
40
38
class BoschOperatingMode (t .enum8 ):
41
- """Bosh operating mode attribute values."""
39
+ """Bosch operating mode attribute values."""
42
40
43
41
Schedule = 0x00
44
42
Manual = 0x01
@@ -52,16 +50,15 @@ class State(t.enum8):
52
50
On = 0x01
53
51
54
52
55
- class BoschControlSequenceOfOperation (t .enum8 ):
56
- """Supported ControlSequenceOfOperation modes."""
57
-
58
- Cooling = ControlSequenceOfOperation .Cooling_Only
59
- Heating = ControlSequenceOfOperation .Heating_Only
60
-
61
-
62
53
class BoschThermostatCluster (CustomCluster , Thermostat ):
63
54
"""Bosch thermostat cluster."""
64
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
+
65
62
class AttributeDefs (Thermostat .AttributeDefs ):
66
63
"""Bosch thermostat manufacturer specific attributes."""
67
64
@@ -71,8 +68,8 @@ class AttributeDefs(Thermostat.AttributeDefs):
71
68
is_manufacturer_specific = True ,
72
69
)
73
70
74
- pi_heating_demand = ZCLAttributeDef (
75
- id = VALVE_POSITION_ATTR_ID ,
71
+ valve_duty_cycle = ZCLAttributeDef (
72
+ id = VALVE_DUTY_CYCLE_ATTR_ID ,
76
73
# Values range from 0-100
77
74
type = t .uint8_t ,
78
75
is_manufacturer_specific = True ,
@@ -89,6 +86,12 @@ class AttributeDefs(Thermostat.AttributeDefs):
89
86
type = State ,
90
87
is_manufacturer_specific = True ,
91
88
)
89
+
90
+ temperature_display_mode = ZCLAttributeDef (
91
+ id = 0x0000 ,
92
+ type = TemperatureDisplayMode ,
93
+ access = "rw" ,
94
+ )
92
95
93
96
94
97
class BoschUserInterfaceCluster (CustomCluster , UserInterface ):
@@ -117,16 +120,33 @@ class AttributeDefs(UserInterface.AttributeDefs):
117
120
.applies_to ("Bosch" , "RBSH-RTH0-BAT-ZB-EU" )
118
121
.replaces (BoschThermostatCluster )
119
122
.replaces (BoschUserInterfaceCluster )
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
+ )
120
132
# Operating mode - read-only: controlled automatically through Thermostat.system_mode (HAVC mode).
121
133
.enum (
122
134
BoschThermostatCluster .AttributeDefs .operating_mode .name ,
123
135
BoschOperatingMode ,
124
136
BoschThermostatCluster .cluster_id ,
125
- entity_platform = EntityPlatform .SENSOR ,
126
- entity_type = EntityType .DIAGNOSTIC ,
137
+ entity_type = EntityType .CONFIG ,
127
138
translation_key = "operating_mode" ,
128
139
fallback_name = "Operating mode" ,
129
140
)
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
+ )
130
150
# Fast heating/boost.
131
151
.switch (
132
152
BoschThermostatCluster .AttributeDefs .boost_heating .name ,
@@ -161,13 +181,5 @@ class AttributeDefs(UserInterface.AttributeDefs):
161
181
translation_key = "display_brightness" ,
162
182
fallback_name = "Display brightness" ,
163
183
)
164
- # Heating vs Cooling.
165
- .enum (
166
- Thermostat .AttributeDefs .ctrl_sequence_of_oper .name ,
167
- BoschControlSequenceOfOperation ,
168
- BoschThermostatCluster .cluster_id ,
169
- translation_key = "ctrl_sequence_of_oper" ,
170
- fallback_name = "Control sequence" ,
171
- )
172
184
.add_to_registry ()
173
185
)
0 commit comments