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:
parent
efd0e898f9
commit
dbb2c64d86
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue