mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix swiss public transport line field none (#133964)
* fix #133116 The line can theoretically be none, when no line info is available (lets say walking sections first?) * fix line field * add unit test with missing line field
This commit is contained in:
parent
d415b7bc8d
commit
03fb136218
@ -113,7 +113,7 @@ class SwissPublicTransportDataUpdateCoordinator(
|
||||
destination=self._opendata.to_name,
|
||||
remaining_time=str(self.remaining_time(connections[i]["departure"])),
|
||||
delay=connections[i]["delay"],
|
||||
line=connections[i]["line"],
|
||||
line=connections[i].get("line"),
|
||||
)
|
||||
for i in range(limit)
|
||||
if len(connections) > i and connections[i] is not None
|
||||
@ -134,7 +134,7 @@ class SwissPublicTransportDataUpdateCoordinator(
|
||||
"train_number": connection["train_number"],
|
||||
"transfers": connection["transfers"],
|
||||
"delay": connection["delay"],
|
||||
"line": connection["line"],
|
||||
"line": connection.get("line"),
|
||||
}
|
||||
for connection in await self.fetch_connections(limit)
|
||||
]
|
||||
|
@ -23,8 +23,7 @@
|
||||
"platform": 2,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
"delay": 0
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:06:00+0100",
|
||||
|
Loading…
x
Reference in New Issue
Block a user