diff --git a/homeassistant/components/swiss_public_transport/coordinator.py b/homeassistant/components/swiss_public_transport/coordinator.py index ff14e81a44ee2366c5b8fa29b8502ed90ab005ea..e6413e6f77269257e93e7a325ef27fc3a4489094 100644 --- a/homeassistant/components/swiss_public_transport/coordinator.py +++ b/homeassistant/components/swiss_public_transport/coordinator.py @@ -75,13 +75,6 @@ class SwissPublicTransportDataUpdateCoordinator( return departure_datetime - dt_util.as_local(dt_util.utcnow()) return None - def nth_departure_time(self, i: int) -> datetime | None: - """Get nth departure time.""" - connections = self._opendata.connections - if len(connections) > i and connections[i] is not None: - return dt_util.parse_datetime(connections[i]["departure"]) - return None - async def _async_update_data(self) -> list[DataConnection]: return await self.fetch_connections(limit=CONNECTIONS_COUNT) @@ -101,7 +94,7 @@ class SwissPublicTransportDataUpdateCoordinator( connections = self._opendata.connections return [ DataConnection( - departure=self.nth_departure_time(i), + departure=dt_util.parse_datetime(connections[i]["departure"]), train_number=connections[i]["number"], platform=connections[i]["platform"], transfers=connections[i]["transfers"], diff --git a/tests/components/swiss_public_transport/fixtures/connections.json b/tests/components/swiss_public_transport/fixtures/connections.json index f2cd1014e6326332701bed1144acddf70957ee89..7e61206c36634a745d7e83e70f278fda2c47ac29 100644 --- a/tests/components/swiss_public_transport/fixtures/connections.json +++ b/tests/components/swiss_public_transport/fixtures/connections.json @@ -99,7 +99,7 @@ "line": "T10" }, { - "departure": "2024-01-06T18:14:00+0100", + "departure": "invalid", "number": 11, "platform": 11, "transfers": 0,