Fix broken aftership sensor after pyaftership 21.11.0 bump (#66855)

* Fix update to pyaftership 21.11.0

Variable name collision and a missing property access was causing this sensor to always return zero elements.

* Move subscripting out of awaited statement
This commit is contained in:
dewdrop 2022-02-20 06:33:19 -08:00 committed by GitHub
parent efd0e898f9
commit dbb2c64d86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,10 +149,10 @@ class AfterShipSensor(SensorEntity):
status_to_ignore = {"delivered"}
status_counts: dict[str, int] = {}
trackings = []
parsed_trackings = []
not_delivered_count = 0
for track in trackings:
for track in trackings["trackings"]:
status = track["tag"].lower()
name = (
track["tracking_number"] if track["title"] is None else track["title"]
@ -163,7 +163,7 @@ class AfterShipSensor(SensorEntity):
else track["checkpoints"][-1]
)
status_counts[status] = status_counts.get(status, 0) + 1
trackings.append(
parsed_trackings.append(
{
"name": name,
"tracking_number": track["tracking_number"],
@ -183,7 +183,7 @@ class AfterShipSensor(SensorEntity):
self._attributes = {
**status_counts,
ATTR_TRACKINGS: trackings,
ATTR_TRACKINGS: parsed_trackings,
}
self._state = not_delivered_count