Skip to content

Commit

Permalink
fix: better fix for #488 (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
firstof9 authored Jul 15, 2021
2 parents bc3cd1b + 16a33ab commit 1dbdea3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1dbdea3

Please sign in to comment.