1111 SPECIAL_PLUG_TYPES ,
1212 SWITCH_GROUP_TYPES ,
1313 ApplianceType ,
14- DeviceZoneData ,
15- ModelData ,
14+ GwEntityData ,
15+ ModuleData ,
1616 SensorType ,
1717)
1818from plugwise .util import (
@@ -40,7 +40,7 @@ def __init__(self) -> None:
4040 self ._heater_id : str
4141 self ._on_off_device : bool
4242 self ._opentherm_device : bool
43- self .gw_device_zones : dict [str , DeviceZoneData ]
43+ self .gw_entities : dict [str , GwEntityData ]
4444 self .smile_name : str
4545 self .smile_type : str
4646
@@ -108,7 +108,7 @@ def _appl_thermostat_info(self, appl: Munch, xml_1: etree, xml_2: etree = None)
108108
109109 return appl
110110
111- def _collect_power_values (self , data : DeviceZoneData , loc : Munch , tariff : str , legacy : bool = False ) -> None :
111+ def _collect_power_values (self , data : GwEntityData , loc : Munch , tariff : str , legacy : bool = False ) -> None :
112112 """Something."""
113113 for loc .peak_select in ("nl_peak" , "nl_offpeak" ):
114114 loc .locator = (
@@ -160,8 +160,8 @@ def _power_data_energy_diff(
160160 measurement : str ,
161161 net_string : SensorType ,
162162 f_val : float | int ,
163- direct_data : DeviceZoneData ,
164- ) -> DeviceZoneData :
163+ data : GwEntityData ,
164+ ) -> GwEntityData :
165165 """Calculate differential energy."""
166166 if (
167167 "electricity" in measurement
@@ -174,21 +174,21 @@ def _power_data_energy_diff(
174174 if net_string not in direct_data ["sensors" ]:
175175 tmp_val : float | int = 0
176176 else :
177- tmp_val = direct_data ["sensors" ][net_string ]
177+ tmp_val = data ["sensors" ][net_string ]
178178
179179 if isinstance (f_val , int ):
180180 tmp_val += f_val * diff
181181 else :
182182 tmp_val += float (f_val * diff )
183183 tmp_val = float (f"{ round (tmp_val , 3 ):.3f} " )
184184
185- direct_data ["sensors" ][net_string ] = tmp_val
185+ data ["sensors" ][net_string ] = tmp_val
186186
187- return direct_data
187+ return data
188188
189- def _create_gw_device_zones (self , appl : Munch ) -> None :
190- """Helper-function for creating/updating gw_device_zones ."""
191- self .gw_device_zones [appl .dev_id ] = {"dev_class" : appl .pwclass }
189+ def _create_gw_entities (self , appl : Munch ) -> None :
190+ """Helper-function for creating/updating gw_entities ."""
191+ self .gw_entities [appl .dev_id ] = {"dev_class" : appl .pwclass }
192192 self ._count += 1
193193 for key , value in {
194194 "available" : appl .available ,
@@ -204,30 +204,30 @@ def _create_gw_device_zones(self, appl: Munch) -> None:
204204 }.items ():
205205 if value is not None or key == "location" :
206206 appl_key = cast (ApplianceType , key )
207- self .gw_device_zones [appl .dev_id ][appl_key ] = value
207+ self .gw_entities [appl .dev_id ][appl_key ] = value
208208 self ._count += 1
209209
210- def _device_data_switching_group (
211- self , device : DeviceZoneData , data : DeviceZoneData
210+ def _entity_switching_group (
211+ self , entity : GwEntityData , data : GwEntityData
212212 ) -> None :
213213 """Helper-function for _get_device_zone_data().
214214
215215 Determine switching group device data.
216216 """
217- if device ["dev_class" ] in SWITCH_GROUP_TYPES :
217+ if entity ["dev_class" ] in SWITCH_GROUP_TYPES :
218218 counter = 0
219- for member in device ["members" ]:
220- if self .gw_device_zones [member ]["switches" ].get ("relay" ):
219+ for member in entity ["members" ]:
220+ if self .gw_entities [member ]["switches" ].get ("relay" ):
221221 counter += 1
222222 data ["switches" ]["relay" ] = counter != 0
223223 self ._count += 1
224224
225- def _get_group_switches (self ) -> dict [str , DeviceZoneData ]:
226- """Helper-function for smile.py: get_all_device_zones ().
225+ def _get_group_switches (self ) -> dict [str , GwEntityData ]:
226+ """Helper-function for smile.py: get_all_gateway_entities ().
227227
228228 Collect switching- or pump-group info.
229229 """
230- switch_groups : dict [str , DeviceZoneData ] = {}
230+ switch_groups : dict [str , GwEntityData ] = {}
231231 # P1 and Anna don't have switchgroups
232232 if self .smile_type == "power" or self .smile (ANNA ):
233233 return switch_groups
@@ -240,25 +240,21 @@ def _get_group_switches(self) -> dict[str, DeviceZoneData]:
240240 group_appliances = group .findall ("appliances/appliance" )
241241 for item in group_appliances :
242242 # Check if members are not orphaned - stretch
243- if item .attrib ["id" ] in self .gw_device_zones :
243+ if item .attrib ["id" ] in self .gw_entities :
244244 members .append (item .attrib ["id" ])
245245
246246 if group_type in SWITCH_GROUP_TYPES and members :
247- switch_groups .update (
248- {
249- group_id : {
250- "dev_class" : group_type ,
251- "model" : "Switchgroup" ,
252- "name" : group_name ,
253- "members" : members ,
254- },
255- },
256- )
247+ switch_groups [group_id ] = {
248+ "dev_class" : group_type ,
249+ "model" : "Switchgroup" ,
250+ "name" : group_name ,
251+ "members" : members ,
252+ }
257253 self ._count += 4
258254
259255 return switch_groups
260256
261- def _get_lock_state (self , xml : etree , data : DeviceZoneData , stretch_v2 : bool = False ) -> None :
257+ def _get_lock_state (self , xml : etree , data : GwEntityData , stretch_v2 : bool = False ) -> None :
262258 """Helper-function for _get_measurement_data().
263259
264260 Adam & Stretches: obtain the relay-switch lock state.
@@ -280,12 +276,12 @@ def _get_module_data(
280276 locator : str ,
281277 xml_2 : etree = None ,
282278 legacy : bool = False ,
283- ) -> ModelData :
279+ ) -> ModuleData :
284280 """Helper-function for _energy_device_info_finder() and _appliance_info_finder().
285281
286282 Collect requested info from MODULES.
287283 """
288- model_data : ModelData = {
284+ module_data : ModuleData = {
289285 "contents" : False ,
290286 "firmware_version" : None ,
291287 "hardware_version" : None ,
@@ -304,25 +300,25 @@ def _get_module_data(
304300 search = return_valid (xml_2 , self ._domain_objects )
305301 module = search .find (loc )
306302 if module is not None : # pylint: disable=consider-using-assignment-expr
307- model_data ["contents" ] = True
308- get_vendor_name (module , model_data )
309- model_data ["vendor_model" ] = module .find ("vendor_model" ).text
310- model_data ["hardware_version" ] = module .find ("hardware_version" ).text
311- model_data ["firmware_version" ] = module .find ("firmware_version" ).text
312- self ._get_zigbee_data (module , model_data , legacy )
303+ module_data ["contents" ] = True
304+ get_vendor_name (module , module_data )
305+ module_data ["vendor_model" ] = module .find ("vendor_model" ).text
306+ module_data ["hardware_version" ] = module .find ("hardware_version" ).text
307+ module_data ["firmware_version" ] = module .find ("firmware_version" ).text
308+ self ._get_zigbee_data (module , module_data , legacy )
313309
314- return model_data
310+ return module_data
315311
316- def _get_zigbee_data (self , module : etree , model_data : ModelData , legacy : bool ) -> None :
317- """Helper-function for _get_model_data ()."""
312+ def _get_zigbee_data (self , module : etree , module_data : ModuleData , legacy : bool ) -> None :
313+ """Helper-function for _get_module_data ()."""
318314 if legacy :
319315 # Stretches
320316 if (router := module .find ("./protocols/network_router" )) is not None :
321- model_data ["zigbee_mac_address" ] = router .find ("mac_address" ).text
317+ module_data ["zigbee_mac_address" ] = router .find ("mac_address" ).text
322318 # Also look for the Circle+/Stealth M+
323319 if (coord := module .find ("./protocols/network_coordinator" )) is not None :
324- model_data ["zigbee_mac_address" ] = coord .find ("mac_address" ).text
320+ module_data ["zigbee_mac_address" ] = coord .find ("mac_address" ).text
325321 # Adam
326322 elif (zb_node := module .find ("./protocols/zig_bee_node" )) is not None :
327- model_data ["zigbee_mac_address" ] = zb_node .find ("mac_address" ).text
328- model_data ["reachable" ] = zb_node .find ("reachable" ).text == "true"
323+ module_data ["zigbee_mac_address" ] = zb_node .find ("mac_address" ).text
324+ module_data ["reachable" ] = zb_node .find ("reachable" ).text == "true"
0 commit comments