@@ -337,12 +337,9 @@ def _all_appliances(self) -> None:
337337
338338 self ._create_gw_entities (appl )
339339
340- ######################################################
341- #TODO: at this indent appl is not available/defined!!#
342- ######################################################
343340 # For P1 collect the connected SmartMeter info
344341 if self .smile_type == "power" :
345- self ._p1_smartmeter_info_finder (appl )
342+ self ._p1_smartmeter_info_finder ()
346343 # P1: for gateway and smartmeter switch entity_id - part 2
347344 for item in self .gw_entities :
348345 if item != self .gateway_id :
@@ -372,16 +369,19 @@ def _all_locations(self) -> None:
372369
373370 self ._loc_data [loc .loc_id ] = {"name" : loc .name }
374371
375- def _p1_smartmeter_info_finder (self , appl : Munch ) -> None :
372+ def _p1_smartmeter_info_finder (self ) -> None :
376373 """Collect P1 DSMR SmartMeter info."""
374+ appl = Munch ()
377375 loc_id = next (iter (self ._loc_data .keys ()))
378- location = self ._domain_objects .find (f'./location[@id="{ loc_id } "]' )
376+ if (location := self ._domain_objects .find (f'./location[@id="{ loc_id } "]' )) is None :
377+ return None
378+
379379 locator = MODULE_LOCATOR
380380 module_data = self ._get_module_data (location , locator )
381381 if not module_data ["contents" ]:
382382 LOGGER .error ("No module data found for SmartMeter" ) # pragma: no cover
383383 return None # pragma: no cover
384-
384+ appl . available = None
385385 appl .entity_id = self .gateway_id
386386 appl .firmware = module_data ["firmware_version" ]
387387 appl .hardware = module_data ["hardware_version" ]
0 commit comments