@@ -196,6 +196,13 @@ def _device_data_adam(
196196
197197 return device_data
198198
199+ def check_reg_mode (self , mode : str ) -> bool :
200+ """Helper-function for device_data_climate()."""
201+ gateway = self .gw_devices [self .gateway_id ]
202+ return (
203+ "regulation_modes" in gateway and gateway ["select_regulation_mode" ] == mode
204+ )
205+
199206 def _device_data_climate (
200207 self , device : DeviceData , device_data : DeviceData
201208 ) -> DeviceData :
@@ -220,20 +227,16 @@ def _device_data_climate(
220227 self ._count += 2
221228
222229 # Operation modes: auto, heat, heat_cool, cool and off
223- gateway = self .gw_devices [self .gateway_id ]
224230 device_data ["mode" ] = "auto"
225231 self ._count += 1
226232 if sel_schedule == "None" :
227233 device_data ["mode" ] = "heat"
228234 if self ._cooling_present :
229- device_data ["mode" ] = "heat_cool"
230- if (
231- "regulation_modes" in gateway
232- and gateway ["select_regulation_mode" ] == "cooling"
233- ):
234- device_data ["mode" ] = "cool"
235-
236- if "regulation_modes" in gateway and gateway ["select_regulation_mode" ] == "off" :
235+ device_data ["mode" ] = (
236+ "cool" if self .check_reg_mode ("cooling" ) else "heat_cool"
237+ )
238+
239+ if self .check_reg_mode ("off" ):
237240 device_data ["mode" ] = "off"
238241
239242 if "None" not in avail_schedules :
0 commit comments