66from __future__ import annotations
77
88import json
9- import xmltodict
109from typing import cast
1110
1211from plugwise .constants import (
4241from defusedxml import ElementTree as etree
4342from munch import Munch
4443from packaging .version import Version , parse
44+ import xmltodict
4545
4646
4747class Smile (SmileComm ):
@@ -124,7 +124,6 @@ async def connect(self) -> Version:
124124 result_dict = dict (xmltodict .parse (result_str , attr_prefix = "" ))
125125 for key in ["ame_regulation" , "template" ]:
126126 result_dict ["domain_objects" ].pop (key , None )
127- LOGGER .debug ("HOI result_dict: %s" , json .dumps (result_dict , indent = 4 ))
128127 modules : dict [str , dict [str , str ]] = {}
129128 for module in result_dict ["domain_objects" ]["module" ]:
130129 link_id : str | None = None
@@ -148,7 +147,16 @@ async def connect(self) -> Version:
148147 "vendor_name" : module ["vendor_name" ],
149148 }
150149
151- LOGGER .debug ("HOI modules: %s" , modules )
150+ for appliance in result_dict ["domain_objects" ]["appliance" ]:
151+ for module in modules :
152+ for log in appliance ["logs" ]["point_log" ]:
153+ for _ , item in log .items ():
154+ if isinstance (item , dict ) and "id" in item :
155+ if item ["id" ] == module :
156+ appliance ["module" ] = modules [module ]
157+
158+ result_dict ["domain_objects" ].pop ("module" )
159+ LOGGER .debug ("HOI result_dict: %s" , json .dumps (result_dict , indent = 4 ))
152160
153161 # Work-around for Stretch fw 2.7.18
154162 if not (vendor_names := result .findall ("./module/vendor_name" )):
0 commit comments