@@ -760,7 +760,7 @@ def _rule_ids_by_name(self, name: str, loc_id: str) -> dict[str]:
760760 Obtain the rule_id from the given name and and provide the location_id, when present.
761761 """
762762 schema_ids : dict [str ] = {}
763- locator = f'.// contexts/context/zone/location[@id="{ loc_id } "]'
763+ locator = f'./contexts/context/zone/location[@id="{ loc_id } "]'
764764 for rule in self ._domain_objects .findall (f'./rule[name="{ name } "]' ):
765765 if rule .find (locator ) is not None :
766766 schema_ids [rule .attrib ["id" ]] = loc_id
@@ -774,8 +774,8 @@ def _rule_ids_by_tag(self, tag: str, loc_id: str) -> dict[str]:
774774 Obtain the rule_id from the given template_tag and provide the location_id, when present.
775775 """
776776 schema_ids : dict [str ] = {}
777- locator1 = f'.// template[@tag="{ tag } "]'
778- locator2 = f'.// contexts/context/zone/location[@id="{ loc_id } "]'
777+ locator1 = f'./template[@tag="{ tag } "]'
778+ locator2 = f'./contexts/context/zone/location[@id="{ loc_id } "]'
779779 for rule in self ._domain_objects .findall ("./rule" ):
780780 if rule .find (locator1 ) is not None :
781781 if rule .find (locator2 ) is not None :
@@ -972,7 +972,7 @@ def _thermostat_uri(self, loc_id: str) -> str:
972972 if self ._smile_legacy :
973973 return self ._thermostat_uri_legacy ()
974974
975- locator = f'location[@id="{ loc_id } "]/actuator_functionalities/thermostat_functionality'
975+ locator = f'./ location[@id="{ loc_id } "]/actuator_functionalities/thermostat_functionality'
976976 thermostat_functionality_id = self ._locations .find (locator ).attrib ["id" ]
977977
978978 return f"{ LOCATIONS } ;id={ loc_id } /thermostat;id={ thermostat_functionality_id } "
@@ -1020,7 +1020,7 @@ def _heating_valves(self) -> int | None:
10201020 loc_found = 0
10211021 open_valve_count = 0
10221022 for appliance in self ._appliances .findall ("./appliance" ):
1023- locator = '.// logs/point_log[type="valve_position"]/period/measurement'
1023+ locator = './logs/point_log[type="valve_position"]/period/measurement'
10241024 if (appl_loc := appliance .find (locator )) is not None :
10251025 loc_found += 1
10261026 if float (appl_loc .text ) > 0.0 :
@@ -1042,7 +1042,7 @@ def _power_data_peak_value(self, loc: str) -> Munch:
10421042 return loc
10431043
10441044 loc .locator = (
1045- f'.// { loc .log_type } [type="{ loc .measurement } "]/period/measurement'
1045+ f'./{ loc .log_type } [type="{ loc .measurement } "]/period/measurement'
10461046 )
10471047
10481048 # Locator not found
@@ -1088,7 +1088,7 @@ def _power_data_from_location(self, loc_id: str) -> dict[str, Any] | None:
10881088 for loc .log_type in log_list :
10891089 for loc .peak_select in peak_list :
10901090 loc .locator = (
1091- f'.// { loc .log_type } [type="{ loc .measurement } "]/period/'
1091+ f'./{ loc .log_type } [type="{ loc .measurement } "]/period/'
10921092 f'measurement[@{ t_string } ="{ loc .peak_select } "]'
10931093 )
10941094 loc = self ._power_data_peak_value (loc )
@@ -1111,7 +1111,7 @@ def _preset(self, loc_id: str) -> str | None:
11111111 if (preset := self ._domain_objects .find (locator )) is not None :
11121112 return preset .text
11131113
1114- locator = "rule[active='true']/directives/when/then"
1114+ locator = "./ rule[active='true']/directives/when/then"
11151115 if (
11161116 active_rule := self ._domain_objects .find (locator )
11171117 ) is None or "icon" not in active_rule .keys ():
@@ -1134,7 +1134,7 @@ def _schemas_legacy(
11341134 name = rule_name
11351135
11361136 log_type = "schedule_state"
1137- locator = f"appliance[type='thermostat']/logs/point_log[type='{ log_type } ']/period/measurement"
1137+ locator = f"./ appliance[type='thermostat']/logs/point_log[type='{ log_type } ']/period/measurement"
11381138 active = False
11391139 if (result := search .find (locator )) is not None :
11401140 active = result .text == "on"
@@ -1173,9 +1173,9 @@ def _schemas(self, location: str) -> tuple[str, ...]:
11731173
11741174 schedules : dict [str , Any ] = {}
11751175 for rule_id , loc_id in rule_ids .items ():
1176- name = self ._domain_objects .find (f'rule[@id="{ rule_id } "]/name' ).text
1176+ name = self ._domain_objects .find (f'./ rule[@id="{ rule_id } "]/name' ).text
11771177 schedule : dict [str , float ] = {}
1178- locator = f'rule[@id="{ rule_id } "]/directives'
1178+ locator = f'./ rule[@id="{ rule_id } "]/directives'
11791179 directives = self ._domain_objects .find (locator )
11801180 for directive in directives :
11811181 entry = directive .find ("then" ).attrib
@@ -1218,9 +1218,11 @@ def _last_used_schedule(self, loc_id: str, rule_ids: dict[str]) -> str | None:
12181218 schemas : dict [str ] | None = {}
12191219
12201220 for rule_id in rule_ids :
1221- schema_name = self ._domain_objects .find (f'rule[@id="{ rule_id } "]/name' ).text
1221+ schema_name = self ._domain_objects .find (
1222+ f'./rule[@id="{ rule_id } "]/name'
1223+ ).text
12221224 schema_date = self ._domain_objects .find (
1223- f'rule[@id="{ rule_id } "]/modified_date'
1225+ f'./ rule[@id="{ rule_id } "]/modified_date'
12241226 ).text
12251227 schema_time = parse (schema_date )
12261228 schemas [schema_name ] = (schema_time - epoch ).total_seconds ()
@@ -1236,10 +1238,7 @@ def _object_value(self, obj_id: str, measurement: str) -> float | int | bool | N
12361238 """
12371239 val : float | int | None = None
12381240 search = self ._domain_objects
1239- locator = (
1240- f'./location[@id="{ obj_id } "]/logs/point_log'
1241- f'[type="{ measurement } "]/period/measurement'
1242- )
1241+ locator = f'./location[@id="{ obj_id } "]/logs/point_log[type="{ measurement } "]/period/measurement'
12431242 if (found := search .find (locator )) is not None :
12441243 val = format_measure (found .text , None )
12451244 return val
@@ -1258,7 +1257,7 @@ def _get_lock_state(self, xml: str) -> dict[str, Any]:
12581257 func_type = "relay"
12591258 appl_class = xml .find ("type" ).text
12601259 if appl_class not in ["central_heating_pump" , "valve_actuator" ]:
1261- locator = f".// { actuator } /{ func_type } /lock"
1260+ locator = f"./{ actuator } /{ func_type } /lock"
12621261 if (found := xml .find (locator )) is not None :
12631262 data ["lock" ] = format_measure (found .text , None )
12641263
0 commit comments