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 )
@@ -247,31 +244,36 @@ def _get_lock_state(
247244
248245 def _get_module_data (
249246 self ,
250- xml_1 : etree .Element ,
251- locator : str ,
252247 key : str | None = None ,
253- xml_2 : etree .Element | None = None ,
254248 legacy : bool = False ,
255249 ) -> ModuleData :
256250 """Helper-function for _energy_device_info_finder() and _appliance_info_finder().
257251
258252 Collect requested info from MODULES.
259253 """
260- module_data : ModuleData = {
261- "contents" : False ,
262- "firmware_version" : None ,
263- "hardware_version" : None ,
264- "reachable" : None ,
265- "vendor_name" : None ,
266- "vendor_model" : None ,
267- "zigbee_mac_address" : None ,
268- }
269-
270- for appl_search in xml_1 .findall (locator ):
271- link_tag = appl_search .tag
272- if key is not None and key not in link_tag :
254+ module = self .data .get_module (link_id )
255+
256+ for service_type , services in appliance .services .iter_services ():
257+ if key and key not in service_type :
258+ continue
259+ for service in services :
260+ module = self .data .get_module (service .id )
261+ if not module :
273262 continue
274263
264+ return ModuleData (
265+ contents = True ,
266+ firmware_version = None ,
267+ hardware_version = None ,
268+ reachable = None ,
269+ vendor_name = None ,
270+ vendor_model = None ,
271+ zigbee_mac_address = None ,
272+ )
273+ return ModuleData ()
274+
275+ # TODO legacy
276+ """
275277 link_id = appl_search.get("id")
276278 loc = f".//services/{link_tag}[@id='{link_id}']...."
277279 # Not possible to walrus for some reason...
@@ -287,5 +289,4 @@ def _get_module_data(
287289 get_zigbee_data(module, module_data, legacy)
288290
289291 break
290-
291- return module_data
292+ """
0 commit comments