diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index 035baa12..49bd6212 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -745,6 +745,7 @@ def get_count( result = {} today = get_formatted_date() track = None + found = [] # Return Amazon delivered info if sensor_type == const.AMAZON_DELIVERED: @@ -788,17 +789,20 @@ def get_count( data[0], count, ) - - if ( - const.ATTR_PATTERN - in const.SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"].keys() - ): - track = const.SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"][ - const.ATTR_PATTERN - ][0] - - if track is not None and get_tracking_num and count > 0: - tracking = get_tracking(data[0], account, track) + found.append(data[0]) + + if ( + const.ATTR_PATTERN + in const.SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"].keys() + ): + track = const.SENSOR_DATA[f"{sensor_type.split('_')[0]}_tracking"][ + const.ATTR_PATTERN + ][0] + + if track is not None and get_tracking_num and count > 0: + for sdata in found: + tracking.extend(get_tracking(sdata, account, track)) + tracking = list(dict.fromkeys(tracking)) if len(tracking) > 0: # Use tracking numbers found for count (more accurate)