@@ -231,18 +231,30 @@ async def get_device_battery_details(
231231 if not matching_devices :
232232 return None
233233
234- if len (matching_devices ) > 1 :
235- return None
234+ first_matched_device = matching_devices [0 ]
236235
237- matched_device = matching_devices [0 ]
236+ if len (matching_devices ) > 1 :
237+ # Check if all matching devices are duplicates (all fields identical)
238+ all_same = all (
239+ device .manufacturer == first_matched_device .manufacturer
240+ and device .model == first_matched_device .model
241+ and device .model_id == first_matched_device .model_id
242+ and device .hw_version == first_matched_device .hw_version
243+ and device .model_match_method == first_matched_device .model_match_method
244+ and device .battery_type == first_matched_device .battery_type
245+ and device .battery_quantity == first_matched_device .battery_quantity
246+ for device in matching_devices [1 :]
247+ )
248+ if not all_same :
249+ return None
238250
239251 return DeviceBatteryDetails (
240- manufacturer = matched_device .manufacturer ,
241- model = matched_device .model ,
242- model_id = matched_device .model_id or "" ,
243- hw_version = matched_device .hw_version or "" ,
244- battery_type = matched_device .battery_type ,
245- battery_quantity = matched_device .battery_quantity ,
252+ manufacturer = first_matched_device .manufacturer ,
253+ model = first_matched_device .model ,
254+ model_id = first_matched_device .model_id or "" ,
255+ hw_version = first_matched_device .hw_version or "" ,
256+ battery_type = first_matched_device .battery_type ,
257+ battery_quantity = first_matched_device .battery_quantity ,
246258 )
247259
248260 @property
0 commit comments