mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Nextbus: Sort results for upcoming times (#29811)
Sort upcoming times across all direction's for a particular route and stop.
This commit is contained in:
parent
9049e090f9
commit
4f1f4a1b4f
@ -225,7 +225,9 @@ class NextBusDepartureSensor(Entity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Generate list of upcoming times
|
# Generate list of upcoming times
|
||||||
self._attributes["upcoming"] = ", ".join(p["minutes"] for p in predictions)
|
self._attributes["upcoming"] = ", ".join(
|
||||||
|
sorted(p["minutes"] for p in predictions)
|
||||||
|
)
|
||||||
|
|
||||||
latest_prediction = maybe_first(predictions)
|
latest_prediction = maybe_first(predictions)
|
||||||
self._state = utc_from_timestamp(
|
self._state = utc_from_timestamp(
|
||||||
|
@ -206,7 +206,7 @@ async def test_direction_list(
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Outbound 2",
|
"title": "Outbound 2",
|
||||||
"prediction": {"minutes": "4", "epochTime": "1553807374000"},
|
"prediction": {"minutes": "0", "epochTime": "1553807374000"},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ async def test_direction_list(
|
|||||||
assert state.attributes["route"] == VALID_ROUTE_TITLE
|
assert state.attributes["route"] == VALID_ROUTE_TITLE
|
||||||
assert state.attributes["stop"] == VALID_STOP_TITLE
|
assert state.attributes["stop"] == VALID_STOP_TITLE
|
||||||
assert state.attributes["direction"] == "Outbound, Outbound 2"
|
assert state.attributes["direction"] == "Outbound, Outbound 2"
|
||||||
assert state.attributes["upcoming"] == "1, 2, 3, 4"
|
assert state.attributes["upcoming"] == "0, 1, 2, 3"
|
||||||
|
|
||||||
|
|
||||||
async def test_custom_name(
|
async def test_custom_name(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user