@@ -27,6 +27,25 @@ def __init__(self) -> None:
2727 SmileHelper .__init__ (self )
2828
2929
30+ def _all_device_data (self ) -> None :
31+ """Helper-function for get_all_devices().
32+
33+ Collect data for each device and add to self.gw_data and self.gw_devices.
34+ """
35+ self ._update_gw_devices ()
36+ self .gw_data .update (
37+ {
38+ "gateway_id" : self .gateway_id ,
39+ "item_count" : self ._count ,
40+ "notifications" : self ._notifications ,
41+ "smile_name" : self .smile_name ,
42+ }
43+ )
44+ if self ._is_thermostat :
45+ self .gw_data .update (
46+ {"heater_id" : self ._heater_id , "cooling_present" : self ._cooling_present }
47+ )
48+
3049 def _update_gw_devices (self ) -> None :
3150 """Helper-function for _all_device_data() and async_update().
3251
@@ -83,25 +102,53 @@ def _update_for_cooling(self, device: DeviceData) -> None:
83102 sensors ["setpoint_high" ] = temp_dict ["setpoint_high" ]
84103 self ._count += 2
85104
86- def _all_device_data (self ) -> None :
87- """Helper-function for get_all_devices ().
105+ def _get_device_data (self , dev_id : str ) -> DeviceData :
106+ """Helper-function for _all_device_data() and async_update ().
88107
89- Collect data for each device and add to self.gw_data and self.gw_devices .
108+ Provide device- data, based on Location ID (= dev_id), from APPLIANCES .
90109 """
91- self ._update_gw_devices ()
92- self .gw_data .update (
93- {
94- "gateway_id" : self .gateway_id ,
95- "item_count" : self ._count ,
96- "notifications" : self ._notifications ,
97- "smile_name" : self .smile_name ,
98- }
110+ device = self .gw_devices [dev_id ]
111+ data = self ._get_measurement_data (dev_id )
112+
113+ # Check availability of wired-connected devices
114+ # Smartmeter
115+ self ._check_availability (
116+ device , "smartmeter" , data , "P1 does not seem to be connected"
99117 )
100- if self ._is_thermostat :
101- self .gw_data .update (
102- {"heater_id" : self ._heater_id , "cooling_present" : self ._cooling_present }
118+ # OpenTherm device
119+ if device ["name" ] != "OnOff" :
120+ self ._check_availability (
121+ device , "heater_central" , data , "no OpenTherm communication"
103122 )
104123
124+ # Switching groups data
125+ self ._device_data_switching_group (device , data )
126+ # Adam data
127+ self ._device_data_adam (device , data )
128+ # Skip obtaining data for non master-thermostats
129+ if device ["dev_class" ] not in ZONE_THERMOSTATS :
130+ return data
131+
132+ # Thermostat data (presets, temperatures etc)
133+ self ._device_data_climate (device , data )
134+
135+ return data
136+
137+ def _check_availability (
138+ self , device : DeviceData , dev_class : str , data : DeviceData , message : str
139+ ) -> None :
140+ """Helper-function for _get_device_data().
141+
142+ Provide availability status for the wired-commected devices.
143+ """
144+ if device ["dev_class" ] == dev_class :
145+ data ["available" ] = True
146+ self ._count += 1
147+ for item in self ._notifications .values ():
148+ for msg in item .values ():
149+ if message in msg :
150+ data ["available" ] = False
151+
105152 def _device_data_adam (self , device : DeviceData , data : DeviceData ) -> None :
106153 """Helper-function for _get_device_data().
107154
@@ -197,50 +244,3 @@ def _get_schedule_states_with_off(
197244 all_off = False
198245 if all_off :
199246 data ["select_schedule" ] = OFF
200-
201- def _check_availability (
202- self , device : DeviceData , dev_class : str , data : DeviceData , message : str
203- ) -> None :
204- """Helper-function for _get_device_data().
205-
206- Provide availability status for the wired-commected devices.
207- """
208- if device ["dev_class" ] == dev_class :
209- data ["available" ] = True
210- self ._count += 1
211- for item in self ._notifications .values ():
212- for msg in item .values ():
213- if message in msg :
214- data ["available" ] = False
215-
216- def _get_device_data (self , dev_id : str ) -> DeviceData :
217- """Helper-function for _all_device_data() and async_update().
218-
219- Provide device-data, based on Location ID (= dev_id), from APPLIANCES.
220- """
221- device = self .gw_devices [dev_id ]
222- data = self ._get_measurement_data (dev_id )
223-
224- # Check availability of wired-connected devices
225- # Smartmeter
226- self ._check_availability (
227- device , "smartmeter" , data , "P1 does not seem to be connected"
228- )
229- # OpenTherm device
230- if device ["name" ] != "OnOff" :
231- self ._check_availability (
232- device , "heater_central" , data , "no OpenTherm communication"
233- )
234-
235- # Switching groups data
236- self ._device_data_switching_group (device , data )
237- # Adam data
238- self ._device_data_adam (device , data )
239- # Skip obtaining data for non master-thermostats
240- if device ["dev_class" ] not in ZONE_THERMOSTATS :
241- return data
242-
243- # Thermostat data (presets, temperatures etc)
244- self ._device_data_climate (device , data )
245-
246- return data
0 commit comments