@@ -117,7 +117,7 @@ def _get_appliances(self) -> None:
117117 for appliance in self ._domain_objects .findall ("./appliance" ):
118118 appl = Munch ()
119119 appl .available = None
120- appl .entity_id = appliance .attrib [ "id" ]
120+ appl .entity_id = appliance .get ( "id" )
121121 appl .location = None
122122 appl .name = appliance .find ("name" ).text
123123 appl .model = None
@@ -139,7 +139,7 @@ def _get_appliances(self) -> None:
139139 continue
140140
141141 if (appl_loc := appliance .find ("location" )) is not None :
142- appl .location = appl_loc .attrib [ "id" ]
142+ appl .location = appl_loc .get ( "id" )
143143 # Set location to the _home_loc_id when the appliance-location is not found,
144144 # except for thermostat-devices without a location, they are not active
145145 elif appl .pwclass not in THERMOSTAT_CLASSES :
@@ -206,7 +206,7 @@ def _get_locations(self) -> None:
206206 loc = Munch ()
207207 locations = self ._domain_objects .findall ("./location" )
208208 for location in locations :
209- loc .loc_id = location .attrib [ "id" ]
209+ loc .loc_id = location .get ( "id" )
210210 loc .name = location .find ("name" ).text
211211 loc ._type = location .find ("type" ).text
212212 self ._loc_data [loc .loc_id ] = {
@@ -269,7 +269,7 @@ def _appliance_info_finder(self, appl: Munch, appliance: etree.Element) -> Munch
269269
270270 def _appl_gateway_info (self , appl : Munch , appliance : etree .Element ) -> Munch :
271271 """Helper-function for _appliance_info_finder()."""
272- self ._gateway_id = appliance .attrib [ "id" ]
272+ self ._gateway_id = appliance .get ( "id" )
273273 appl .firmware = str (self .smile .version )
274274 appl .hardware = self .smile .hw_version
275275 appl .mac = self .smile .mac_address
@@ -319,7 +319,7 @@ def _get_appliances_with_offset_functionality(self) -> list[str]:
319319 './/actuator_functionalities/offset_functionality[type="temperature_offset"]/offset/../../..'
320320 )
321321 for item in offset_appls :
322- therm_list .append (item .attrib [ "id" ] )
322+ therm_list .append (item .get ( "id" ) )
323323
324324 return therm_list
325325
@@ -502,7 +502,7 @@ def _get_plugwise_notifications(self) -> None:
502502 self ._notifications = {}
503503 for notification in self ._domain_objects .findall ("./notification" ):
504504 try :
505- msg_id = notification .attrib [ "id" ]
505+ msg_id = notification .get ( "id" )
506506 msg_type = notification .find ("type" ).text
507507 msg = notification .find ("message" ).text
508508 self ._notifications [msg_id ] = {msg_type : msg }
@@ -903,7 +903,7 @@ def _presets(self, loc_id: str) -> dict[str, list[float]]:
903903 directives = self ._domain_objects .find (f'rule[@id="{ rule_id } "]/directives' )
904904 for directive in directives :
905905 preset = directive .find ("then" ).attrib
906- presets [directive .attrib [ "preset" ] ] = [
906+ presets [directive .get ( "preset" ) ] = [
907907 float (preset ["heating_setpoint" ]),
908908 float (preset ["cooling_setpoint" ]),
909909 ]
@@ -920,13 +920,13 @@ def _rule_ids_by_name(self, name: str, loc_id: str) -> dict[str, dict[str, str]]
920920 for rule in self ._domain_objects .findall (f'./rule[name="{ name } "]' ):
921921 active = rule .find ("active" ).text
922922 if rule .find (locator ) is not None :
923- schedule_ids [rule .attrib [ "id" ] ] = {
923+ schedule_ids [rule .get ( "id" ) ] = {
924924 "location" : loc_id ,
925925 "name" : name ,
926926 "active" : active ,
927927 }
928928 else :
929- schedule_ids [rule .attrib [ "id" ] ] = {
929+ schedule_ids [rule .get ( "id" ) ] = {
930930 "location" : NONE ,
931931 "name" : name ,
932932 "active" : active ,
@@ -947,13 +947,13 @@ def _rule_ids_by_tag(self, tag: str, loc_id: str) -> dict[str, dict[str, str]]:
947947 name = rule .find ("name" ).text
948948 active = rule .find ("active" ).text
949949 if rule .find (locator2 ) is not None :
950- schedule_ids [rule .attrib [ "id" ] ] = {
950+ schedule_ids [rule .get ( "id" ) ] = {
951951 "location" : loc_id ,
952952 "name" : name ,
953953 "active" : active ,
954954 }
955955 else :
956- schedule_ids [rule .attrib [ "id" ] ] = {
956+ schedule_ids [rule .get ( "id" ) ] = {
957957 "location" : NONE ,
958958 "name" : name ,
959959 "active" : active ,
@@ -1002,6 +1002,6 @@ def _thermostat_uri(self, loc_id: str) -> str:
10021002 Determine the location-set_temperature uri - from LOCATIONS.
10031003 """
10041004 locator = f'./location[@id="{ loc_id } "]/actuator_functionalities/thermostat_functionality'
1005- thermostat_functionality_id = self ._domain_objects .find (locator ).attrib [ "id" ]
1005+ thermostat_functionality_id = self ._domain_objects .find (locator ).get ( "id" )
10061006
10071007 return f"{ LOCATIONS } ;id={ loc_id } /thermostat;id={ thermostat_functionality_id } "
0 commit comments