@@ -180,6 +180,10 @@ async def refresh(
180180 if update_mspconfig or update_telemetry :
181181 self ._update_equipment ()
182182
183+ # After equipment has been updated
184+ if update_mspconfig :
185+ self ._check_duplicate_equipment_names ()
186+
183187 def _update_equipment (self ) -> None :
184188 """Update equipment objects based on the latest MSPConfig and Telemetry data."""
185189 if not hasattr (self , "mspconfig" ) or self .mspconfig is None :
@@ -208,11 +212,14 @@ def _update_equipment(self) -> None:
208212 else :
209213 self .schedules = EquipmentDict ([Schedule (self , schedule_ , self .telemetry ) for schedule_ in self .mspconfig .schedules ])
210214
211- current_names = {item .name for item in self .all_equipment if item .name is not None }
212- if not current_names .issubset (self ._seen_item_names ):
213- if warning := _check_duplicate_item_names (self .all_equipment , f"{ self .host } :{ self .port } " ):
214- _LOGGER .warning (warning )
215- self ._seen_item_names .update (current_names )
215+ def _check_duplicate_equipment_names (self ) -> None :
216+ """Check for and log a warning if there are items with duplicate names."""
217+ current_names = {i .name for i in self .all_equipment if i .name is not None }
218+ if current_names .issubset (self ._seen_item_names ):
219+ return
220+ self ._seen_item_names .update (current_names )
221+ if warning := _check_duplicate_item_names (self .all_equipment , f"{ self .host } :{ self .port } " ):
222+ _LOGGER .warning (warning )
216223
217224 # Equipment discovery properties
218225 @property
0 commit comments