1616 SWITCH_GROUP_TYPES ,
1717 ApplianceType ,
1818 GwEntityData ,
19- ModuleData ,
20- )
21- from plugwise .util import (
22- check_heater_central ,
23- check_model ,
24- get_vendor_name ,
25- return_valid ,
19+ # ModuleData,
2620)
21+ from plugwise .util import check_heater_central , check_model , return_valid
2722
2823from defusedxml import ElementTree as etree
2924from munch import Munch
3025
26+ from .model import ModuleData
27+
3128
3229def get_zigbee_data (
3330 module : etree .Element , module_data : ModuleData , legacy : bool
@@ -120,7 +117,7 @@ def _appl_heater_central_info(
120117 return appl
121118
122119 def _appl_thermostat_info (
123- self , appl : Munch , xml_1 : etree .Element , xml_2 : etree .Element = None
120+ self , appl : Appliance , xml_1 : etree .Element , xml_2 : etree .Element = None
124121 ) -> Munch :
125122 """Helper-function for _appliance_info_finder()."""
126123 locator = "./logs/point_log[type='thermostat']/thermostat"
@@ -144,21 +141,21 @@ def _appl_thermostat_info(
144141
145142 return appl
146143
147- def _create_gw_entities (self , appl : Munch ) -> None :
144+ def _create_gw_entities (self , appl : Appliance ) -> None :
148145 """Helper-function for creating/updating gw_entities."""
149- self .gw_entities [appl .entity_id ] = {"dev_class" : appl .pwclass }
146+ self .gw_entities [appl .id ] = {"dev_class" : appl .type }
150147 self ._count += 1
151148 for key , value in {
152149 "available" : appl .available ,
153- "firmware" : appl .firmware ,
154- "hardware" : appl .hardware ,
150+ "firmware" : appl .firmware_version ,
151+ "hardware" : appl .hardware_version ,
155152 "location" : appl .location ,
156- "mac_address" : appl .mac ,
153+ "mac_address" : appl .mac_address ,
157154 "model" : appl .model ,
158155 "model_id" : appl .model_id ,
159156 "name" : appl .name ,
160157 "vendor" : appl .vendor_name ,
161- "zigbee_mac_address" : appl .zigbee_mac ,
158+ "zigbee_mac_address" : appl .zigbee_mac_address ,
162159 }.items ():
163160 if value is not None or key == "location" :
164161 appl_key = cast (ApplianceType , key )
@@ -237,31 +234,36 @@ def _get_lock_state(
237234
238235 def _get_module_data (
239236 self ,
240- xml_1 : etree .Element ,
241- locator : str ,
242237 key : str | None = None ,
243- xml_2 : etree .Element | None = None ,
244238 legacy : bool = False ,
245239 ) -> ModuleData :
246240 """Helper-function for _energy_device_info_finder() and _appliance_info_finder().
247241
248242 Collect requested info from MODULES.
249243 """
250- module_data : ModuleData = {
251- "contents" : False ,
252- "firmware_version" : None ,
253- "hardware_version" : None ,
254- "reachable" : None ,
255- "vendor_name" : None ,
256- "vendor_model" : None ,
257- "zigbee_mac_address" : None ,
258- }
259-
260- for appl_search in xml_1 .findall (locator ):
261- link_tag = appl_search .tag
262- if key is not None and key not in link_tag :
244+ module = self .data .get_module (link_id )
245+
246+ for service_type , services in appliance .services .iter_services ():
247+ if key and key not in service_type :
248+ continue
249+ for service in services :
250+ module = self .data .get_module (service .id )
251+ if not module :
263252 continue
264253
254+ return ModuleData (
255+ contents = True ,
256+ firmware_version = None ,
257+ hardware_version = None ,
258+ reachable = None ,
259+ vendor_name = None ,
260+ vendor_model = None ,
261+ zigbee_mac_address = None ,
262+ )
263+ return ModuleData ()
264+
265+ # TODO legacy
266+ """
265267 link_id = appl_search.get("id")
266268 loc = f".//services/{link_tag}[@id='{link_id}']...."
267269 # Not possible to walrus for some reason...
@@ -277,5 +279,4 @@ def _get_module_data(
277279 get_zigbee_data(module, module_data, legacy)
278280
279281 break
280-
281- return module_data
282+ """
0 commit comments