File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -202,23 +202,32 @@ def _get_p1_smartmeter_info(self) -> None:
202202
203203 def _get_locations (self ) -> None :
204204 """Collect all locations."""
205+ counter = 0
205206 loc = Munch ()
206207 locations = self ._domain_objects .findall ("./location" )
207208 for location in locations :
208209 loc .loc_id = location .attrib ["id" ]
209210 loc .name = location .find ("name" ).text
211+ loc ._type = location .find ("type" ).text
210212 self ._loc_data [loc .loc_id ] = {
211213 "name" : loc .name ,
212214 "primary" : [],
213215 "primary_prio" : 0 ,
214216 "secondary" : [],
215217 }
216- if loc .name == "Home" :
218+ # Home location is of type building
219+ if loc ._type == "building" :
220+ counter += 1
217221 self ._home_loc_id = loc .loc_id
218222 self ._home_location = self ._domain_objects .find (
219223 f"./location[@id='{ loc .loc_id } ']"
220224 )
221225
226+ if counter == 0 :
227+ raise KeyError (
228+ "Error, location Home (building) not found!"
229+ ) # pragma: no cover
230+
222231 def _appliance_info_finder (self , appl : Munch , appliance : etree .Element ) -> Munch :
223232 """Collect info for all appliances found."""
224233 match appl .pwclass :
You can’t perform that action at this time.
0 commit comments