@@ -28,14 +28,16 @@ def __init__(self) -> None:
2828 SmileHelper .__init__ (self )
2929
3030
31- def _all_device_data (self ) -> None :
32- """Helper-function for get_all_devices ().
31+ def _all_device_zone_data (self ) -> None :
32+ """Helper-function for get_all_device_zones ().
3333
34- Collect data for each device and add to self.gw_data and self.gw_devices .
34+ Collect data for each device/zone and add to self.gw_data and self.gw_device_zones .
3535 """
36- self ._update_gw_devices ()
36+ self ._update_gw_device_zones ()
3737 if self .smile (ADAM ):
3838 self ._update_zones ()
39+ self .gw_device_zones .update (self .zone_data )
40+
3941 self .gw_data .update (
4042 {
4143 "gateway_id" : self .gateway_id ,
@@ -51,39 +53,39 @@ def _all_device_data(self) -> None:
5153 )
5254
5355 def _update_zones (self ) -> None :
54- """Helper-function for _all_device_data () and async_update().
56+ """Helper-function for _all_device_zone_data () and async_update().
5557
5658 Collect data for each zone/location and add to self.zone_data.
5759 """
5860 for location_id , zone in self .zone_data .items ():
5961 data = self ._get_location_data (location_id )
6062 zone .update (data )
6163
62- def _update_gw_devices (self ) -> None :
63- """Helper-function for _all_device_data () and async_update().
64+ def _update_gw_device_zones (self ) -> None :
65+ """Helper-function for _all_device_zone_data () and async_update().
6466
65- Collect data for each device and add to self.gw_devices .
67+ Collect data for each device and add to self.gw_device_zones .
6668 """
6769 mac_list : list [str ] = []
68- for device_id , device in self .gw_devices .items ():
69- data = self ._get_device_data ( device_id )
70- if device_id == self .gateway_id :
70+ for devzone_id , devzone in self .gw_device_zones .items ():
71+ data = self ._get_device_zone_data ( devzone_id )
72+ if devzone_id == self .gateway_id :
7173 mac_list = self ._detect_low_batteries ()
72- self ._add_or_update_notifications (device_id , device , data )
74+ self ._add_or_update_notifications (devzone_id , devzone , data )
7375
74- device .update (data )
76+ devzone .update (data )
7577 is_battery_low = (
7678 mac_list
77- and "low_battery" in device ["binary_sensors" ]
78- and device ["zigbee_mac_address" ] in mac_list
79- and device ["dev_class" ] in ("thermo_sensor" , "thermostatic_radiator_valve" , "zone_thermometer" , "zone_thermostat" )
79+ and "low_battery" in devzone ["binary_sensors" ]
80+ and devzone ["zigbee_mac_address" ] in mac_list
81+ and devzone ["dev_class" ] in ("thermo_sensor" , "thermostatic_radiator_valve" , "zone_thermometer" , "zone_thermostat" )
8082 )
8183 if is_battery_low :
82- device ["binary_sensors" ]["low_battery" ] = True
84+ devzone ["binary_sensors" ]["low_battery" ] = True
8385
84- self ._update_for_cooling (device )
86+ self ._update_for_cooling (devzone )
8587
86- remove_empty_platform_dicts (device )
88+ remove_empty_platform_dicts (devzone )
8789
8890 def _detect_low_batteries (self ) -> list [str ]:
8991 """Helper-function updating the low-battery binary_sensor status from a Battery-is-low message."""
@@ -107,31 +109,31 @@ def _detect_low_batteries(self) -> list[str]:
107109 return mac_address_list
108110
109111 def _add_or_update_notifications (
110- self , device_id : str , device : DeviceZoneData , data : DeviceZoneData
112+ self , devzone_id : str , devzone : DeviceZoneData , data : DeviceZoneData
111113 ) -> None :
112114 """Helper-function adding or updating the Plugwise notifications."""
113115 if (
114- device_id == self .gateway_id
116+ devzone_id == self .gateway_id
115117 and (
116118 self ._is_thermostat or self .smile_type == "power"
117119 )
118120 ) or (
119- "binary_sensors" in device
120- and "plugwise_notification" in device ["binary_sensors" ]
121+ "binary_sensors" in devzone
122+ and "plugwise_notification" in devzone ["binary_sensors" ]
121123 ):
122124 data ["binary_sensors" ]["plugwise_notification" ] = bool (self ._notifications )
123125 self ._count += 1
124126
125- def _update_for_cooling (self , device : DeviceZoneData ) -> None :
127+ def _update_for_cooling (self , devzone : DeviceZoneData ) -> None :
126128 """Helper-function for adding/updating various cooling-related values."""
127129 # For Anna and heating + cooling, replace setpoint with setpoint_high/_low
128130 if (
129131 self .smile (ANNA )
130132 and self ._cooling_present
131- and device ["dev_class" ] == "thermostat"
133+ and devzone ["dev_class" ] == "thermostat"
132134 ):
133- thermostat = device ["thermostat" ]
134- sensors = device ["sensors" ]
135+ thermostat = devzone ["thermostat" ]
136+ sensors = devzone ["sensors" ]
135137 temp_dict : ActuatorData = {
136138 "setpoint_low" : thermostat ["setpoint" ],
137139 "setpoint_high" : MAX_SETPOINT ,
@@ -143,7 +145,7 @@ def _update_for_cooling(self, device: DeviceZoneData) -> None:
143145 }
144146 thermostat .pop ("setpoint" )
145147 temp_dict .update (thermostat )
146- device ["thermostat" ] = temp_dict
148+ devzone ["thermostat" ] = temp_dict
147149 if "setpoint" in sensors :
148150 sensors .pop ("setpoint" )
149151 sensors ["setpoint_low" ] = temp_dict ["setpoint_low" ]
@@ -152,7 +154,7 @@ def _update_for_cooling(self, device: DeviceZoneData) -> None:
152154
153155
154156 def _get_location_data (self , loc_id : str ) -> DeviceZoneData :
155- """Helper-function for _all_device_data () and async_update().
157+ """Helper-function for _all_device_zone_data () and async_update().
156158
157159 Provide device-data, based on Location ID (= loc_id).
158160 """
@@ -163,16 +165,16 @@ def _get_location_data(self, loc_id: str) -> DeviceZoneData:
163165 self ._count += 1
164166
165167 # Thermostat data (presets, temperatures etc)
166- self ._device_data_climate (loc_id , zone , data )
168+ self ._devzone_data_climate (loc_id , zone , data )
167169
168170 return data
169171
170- def _get_device_data (self , dev_id : str ) -> DeviceZoneData :
172+ def _get_device_zone_data (self , dev_id : str ) -> DeviceZoneData :
171173 """Helper-function for _update_gw_devices() and async_update().
172174
173- Provide device-data, based on appliance_id () = dev_id).
175+ Provide device-data, based on appliance_id (= dev_id).
174176 """
175- device = self .gw_devices [dev_id ]
177+ device = self .gw_device_zones [dev_id ]
176178 data = self ._get_measurement_data (dev_id )
177179
178180 # Check availability of wired-connected devices
@@ -193,14 +195,14 @@ def _get_device_data(self, dev_id: str) -> DeviceZoneData:
193195
194196 # Thermostat data for Anna (presets, temperatures etc)
195197 if self .smile (ANNA ) and device ["dev_class" ] == "thermostat" :
196- self ._device_data_climate (dev_id , device , data )
198+ self ._devzone_data_climate (dev_id , device , data )
197199
198200 return data
199201
200202 def _check_availability (
201203 self , device : DeviceZoneData , dev_class : str , data : DeviceZoneData , message : str
202204 ) -> None :
203- """Helper-function for _get_device_data ().
205+ """Helper-function for _get_device_zone_data ().
204206
205207 Provide availability status for the wired-commected devices.
206208 """
@@ -213,7 +215,7 @@ def _check_availability(
213215 data ["available" ] = False
214216
215217 def _device_data_adam (self , device : DeviceZoneData , data : DeviceZoneData ) -> None :
216- """Helper-function for _get_device_data ().
218+ """Helper-function for _get_device_zone_data ().
217219
218220 Determine Adam heating-status for on-off heating via valves,
219221 available regulations_modes and thermostat control_states.
@@ -237,19 +239,19 @@ def _device_data_adam(self, device: DeviceZoneData, data: DeviceZoneData) -> Non
237239 self ._count += 1
238240
239241
240- def _device_data_climate (
242+ def _devzone_data_climate (
241243 self ,
242244 location_id : str ,
243- device : DeviceZoneData ,
245+ devzone : DeviceZoneData ,
244246 data : DeviceZoneData
245247 ) -> None :
246- """Helper-function for _get_device_data ().
248+ """Helper-function for _get_device_zone_data ().
247249
248250 Determine climate-control device data.
249251 """
250252 loc_id = location_id
251- if device .get ("location" ) is not None :
252- loc_id = device ["location" ]
253+ if devzone .get ("location" ) is not None :
254+ loc_id = devzone ["location" ]
253255
254256 # Presets
255257 data ["preset_modes" ] = None
@@ -284,7 +286,7 @@ def _device_data_climate(
284286
285287 def check_reg_mode (self , mode : str ) -> bool :
286288 """Helper-function for device_data_climate()."""
287- gateway = self .gw_devices [self .gateway_id ]
289+ gateway = self .gw_device_zones [self .gateway_id ]
288290 return (
289291 "regulation_modes" in gateway and gateway ["select_regulation_mode" ] == mode
290292 )
0 commit comments