1111 MIN_SETPOINT ,
1212 NONE ,
1313 OFF ,
14- SWITCH_GROUP_TYPES ,
1514 ZONE_THERMOSTATS ,
1615 ActuatorData ,
1716 DeviceData ,
@@ -28,6 +27,25 @@ def __init__(self) -> None:
2827 SmileHelper .__init__ (self )
2928
3029
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+
3149 def _update_gw_devices (self ) -> None :
3250 """Helper-function for _all_device_data() and async_update().
3351
@@ -84,39 +102,52 @@ def _update_for_cooling(self, device: DeviceData) -> None:
84102 sensors ["setpoint_high" ] = temp_dict ["setpoint_high" ]
85103 self ._count += 2
86104
87- def _all_device_data (self ) -> None :
88- """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 ().
89107
90- 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 .
91109 """
92- self ._update_gw_devices ()
93- self .gw_data .update (
94- {
95- "gateway_id" : self .gateway_id ,
96- "item_count" : self ._count ,
97- "notifications" : self ._notifications ,
98- "smile_name" : self .smile_name ,
99- }
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"
100117 )
101- if self ._is_thermostat :
102- self .gw_data .update (
103- {"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"
104122 )
105123
106- def _device_data_switching_group (
107- self , device : DeviceData , data : DeviceData
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
108139 ) -> None :
109140 """Helper-function for _get_device_data().
110141
111- Determine switching group device data .
142+ Provide availability status for the wired-commected devices .
112143 """
113- if device ["dev_class" ] in SWITCH_GROUP_TYPES :
114- counter = 0
115- for member in device ["members" ]:
116- if self .gw_devices [member ]["switches" ].get ("relay" ):
117- counter += 1
118- data ["switches" ]["relay" ] = counter != 0
144+ if device ["dev_class" ] == dev_class :
145+ data ["available" ] = True
119146 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
120151
121152 def _device_data_adam (self , device : DeviceData , data : DeviceData ) -> None :
122153 """Helper-function for _get_device_data().
@@ -213,50 +244,3 @@ def _get_schedule_states_with_off(
213244 all_off = False
214245 if all_off :
215246 data ["select_schedule" ] = OFF
216-
217- def _check_availability (
218- self , device : DeviceData , dev_class : str , data : DeviceData , message : str
219- ) -> None :
220- """Helper-function for _get_device_data().
221-
222- Provide availability status for the wired-commected devices.
223- """
224- if device ["dev_class" ] == dev_class :
225- data ["available" ] = True
226- self ._count += 1
227- for item in self ._notifications .values ():
228- for msg in item .values ():
229- if message in msg :
230- data ["available" ] = False
231-
232- def _get_device_data (self , dev_id : str ) -> DeviceData :
233- """Helper-function for _all_device_data() and async_update().
234-
235- Provide device-data, based on Location ID (= dev_id), from APPLIANCES.
236- """
237- device = self .gw_devices [dev_id ]
238- data = self ._get_measurement_data (dev_id )
239-
240- # Check availability of wired-connected devices
241- # Smartmeter
242- self ._check_availability (
243- device , "smartmeter" , data , "P1 does not seem to be connected"
244- )
245- # OpenTherm device
246- if device ["name" ] != "OnOff" :
247- self ._check_availability (
248- device , "heater_central" , data , "no OpenTherm communication"
249- )
250-
251- # Switching groups data
252- self ._device_data_switching_group (device , data )
253- # Adam data
254- self ._device_data_adam (device , data )
255- # Skip obtaining data for non master-thermostats
256- if device ["dev_class" ] not in ZONE_THERMOSTATS :
257- return data
258-
259- # Thermostat data (presets, temperatures etc)
260- self ._device_data_climate (device , data )
261-
262- return data
0 commit comments