@@ -169,99 +169,83 @@ def _all_device_data(self) -> None:
169169 )
170170
171171 def _device_data_switching_group (
172- self , device : DeviceData , device_data : DeviceData
173- ) -> DeviceData :
172+ self , device : DeviceData , data : DeviceData
173+ ) -> None :
174174 """Helper-function for _get_device_data().
175175
176176 Determine switching group device data.
177177 """
178- if device ["dev_class" ] not in SWITCH_GROUP_TYPES :
179- return device_data
180-
181- counter = 0
182- for member in device ["members" ]:
183- if self .gw_devices [member ]["switches" ].get ("relay" ):
184- counter += 1
185- device_data ["switches" ]["relay" ] = counter != 0
186- self ._count += 1
187- return device_data
178+ if device ["dev_class" ] in SWITCH_GROUP_TYPES :
179+ counter = 0
180+ for member in device ["members" ]:
181+ if self .gw_devices [member ]["switches" ].get ("relay" ):
182+ counter += 1
183+ data ["switches" ]["relay" ] = counter != 0
184+ self ._count += 1
188185
189- def _device_data_adam (
190- self , device : DeviceData , device_data : DeviceData
191- ) -> DeviceData :
186+ def _device_data_adam (self , device : DeviceData , data : DeviceData ) -> None :
192187 """Helper-function for _get_device_data().
193188
194189 Determine Adam heating-status for on-off heating via valves,
195190 available regulations_modes and thermostat control_states.
196191 """
197- if not self .smile (ADAM ):
198- return device_data
199-
200- # Indicate heating_state based on valves being open in case of city-provided heating
201- if (
202- device ["dev_class" ] == "heater_central"
203- and self ._on_off_device
204- and isinstance (self ._heating_valves (), int )
205- ):
206- device_data ["binary_sensors" ]["heating_state" ] = self ._heating_valves () != 0
207-
208- # Show the allowed regulation modes for Adam
209- if device ["dev_class" ] == "gateway" and self ._reg_allowed_modes :
210- device_data ["regulation_modes" ] = self ._reg_allowed_modes
211- self ._count += 1
212-
213- # Control_state, only for Adam master thermostats
214- if device ["dev_class" ] in ZONE_THERMOSTATS :
215- loc_id = device ["location" ]
216- if ctrl_state := self ._control_state (loc_id ):
217- device_data ["control_state" ] = ctrl_state
192+ if self .smile (ADAM ):
193+ # Indicate heating_state based on valves being open in case of city-provided heating
194+ if (
195+ device ["dev_class" ] == "heater_central"
196+ and self ._on_off_device
197+ and isinstance (self ._heating_valves (), int )
198+ ):
199+ data ["binary_sensors" ]["heating_state" ] = self ._heating_valves () != 0
200+
201+ # Show the allowed regulation modes for Adam
202+ if device ["dev_class" ] == "gateway" and self ._reg_allowed_modes :
203+ data ["regulation_modes" ] = self ._reg_allowed_modes
218204 self ._count += 1
219205
220- return device_data
206+ # Control_state, only for Adam master thermostats
207+ if device ["dev_class" ] in ZONE_THERMOSTATS :
208+ loc_id = device ["location" ]
209+ if ctrl_state := self ._control_state (loc_id ):
210+ data ["control_state" ] = ctrl_state
211+ self ._count += 1
221212
222- def _device_data_climate (
223- self , device : DeviceData , device_data : DeviceData
224- ) -> DeviceData :
213+ def _device_data_climate (self , device : DeviceData , data : DeviceData ) -> None :
225214 """Helper-function for _get_device_data().
226215
227216 Determine climate-control device data.
228217 """
229218 loc_id = device ["location" ]
230219
231220 # Presets
232- device_data ["preset_modes" ] = None
233- device_data ["active_preset" ] = None
221+ data ["preset_modes" ] = None
222+ data ["active_preset" ] = None
234223 self ._count += 2
235224 if presets := self ._presets (loc_id ):
236- device_data ["preset_modes" ] = list (presets )
237- device_data ["active_preset" ] = self ._preset (loc_id )
225+ data ["preset_modes" ] = list (presets )
226+ data ["active_preset" ] = self ._preset (loc_id )
238227
239228 # Schedule
240229 avail_schedules , sel_schedule = self ._schedules (loc_id )
241- device_data ["available_schedules" ] = avail_schedules
242- device_data ["select_schedule" ] = sel_schedule
230+ data ["available_schedules" ] = avail_schedules
231+ data ["select_schedule" ] = sel_schedule
243232 self ._count += 2
244233
245234 # Operation modes: auto, heat, heat_cool, cool and off
246- device_data ["mode" ] = "auto"
235+ data ["mode" ] = "auto"
247236 self ._count += 1
248237 if sel_schedule == NONE :
249- device_data ["mode" ] = "heat"
238+ data ["mode" ] = "heat"
250239 if self ._cooling_present :
251- device_data ["mode" ] = (
252- "cool" if self .check_reg_mode ("cooling" ) else "heat_cool"
253- )
240+ data ["mode" ] = "cool" if self .check_reg_mode ("cooling" ) else "heat_cool"
254241
255242 if self .check_reg_mode ("off" ):
256- device_data ["mode" ] = "off"
243+ data ["mode" ] = "off"
257244
258- if NONE in avail_schedules :
259- return device_data
260-
261- self ._get_schedule_states_with_off (
262- loc_id , avail_schedules , sel_schedule , device_data
263- )
264- return device_data
245+ if NONE not in avail_schedules :
246+ self ._get_schedule_states_with_off (
247+ loc_id , avail_schedules , sel_schedule , data
248+ )
265249
266250 def check_reg_mode (self , mode : str ) -> bool :
267251 """Helper-function for device_data_climate()."""
@@ -329,15 +313,15 @@ def _get_device_data(self, dev_id: str) -> DeviceData:
329313 )
330314
331315 # Switching groups data
332- data = self ._device_data_switching_group (device , data )
316+ self ._device_data_switching_group (device , data )
333317 # Adam data
334- data = self ._device_data_adam (device , data )
318+ self ._device_data_adam (device , data )
335319 # Skip obtaining data for non master-thermostats
336320 if device ["dev_class" ] not in ZONE_THERMOSTATS :
337321 return data
338322
339323 # Thermostat data (presets, temperatures etc)
340- data = self ._device_data_climate (device , data )
324+ self ._device_data_climate (device , data )
341325
342326 return data
343327
0 commit comments