mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add line numbers to swiss-public-transport (#127332)
* add line numbers * keep only one line sensor * fix unt tests
This commit is contained in:
parent
ff7bc13058
commit
c4cc9f8489
@ -34,6 +34,7 @@ class DataConnection(TypedDict):
|
||||
train_number: str
|
||||
transfers: int
|
||||
delay: int
|
||||
line: str
|
||||
|
||||
|
||||
def calculate_duration_in_seconds(duration_text: str) -> int | None:
|
||||
@ -104,6 +105,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"],
|
||||
)
|
||||
for i in range(limit)
|
||||
if len(connections) > i and connections[i] is not None
|
||||
|
@ -21,6 +21,9 @@
|
||||
},
|
||||
"delay": {
|
||||
"default": "mdi:clock-plus"
|
||||
},
|
||||
"line": {
|
||||
"default": "mdi:transit-connection-variant"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -71,6 +71,11 @@ SENSORS: tuple[SwissPublicTransportSensorEntityDescription, ...] = (
|
||||
native_unit_of_measurement=UnitOfTime.MINUTES,
|
||||
value_fn=lambda data_connection: data_connection["delay"],
|
||||
),
|
||||
SwissPublicTransportSensorEntityDescription(
|
||||
key="line",
|
||||
translation_key="line",
|
||||
value_fn=lambda data_connection: data_connection["line"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@ -46,6 +46,9 @@
|
||||
},
|
||||
"delay": {
|
||||
"name": "Delay"
|
||||
},
|
||||
"line": {
|
||||
"name": "Line"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -5,7 +5,8 @@
|
||||
"platform": 0,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:04:00+0100",
|
||||
@ -13,7 +14,8 @@
|
||||
"platform": 1,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": null
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:05:00+0100",
|
||||
@ -21,7 +23,8 @@
|
||||
"platform": 2,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:06:00+0100",
|
||||
@ -29,7 +32,8 @@
|
||||
"platform": 3,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:07:00+0100",
|
||||
@ -37,7 +41,8 @@
|
||||
"platform": 4,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:08:00+0100",
|
||||
@ -45,7 +50,8 @@
|
||||
"platform": 5,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:09:00+0100",
|
||||
@ -53,7 +59,8 @@
|
||||
"platform": 6,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:10:00+0100",
|
||||
@ -61,7 +68,8 @@
|
||||
"platform": 7,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:11:00+0100",
|
||||
@ -69,7 +77,8 @@
|
||||
"platform": 8,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:12:00+0100",
|
||||
@ -77,7 +86,8 @@
|
||||
"platform": 9,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:13:00+0100",
|
||||
@ -85,7 +95,8 @@
|
||||
"platform": 10,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:14:00+0100",
|
||||
@ -93,7 +104,8 @@
|
||||
"platform": 11,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:15:00+0100",
|
||||
@ -101,7 +113,8 @@
|
||||
"platform": 12,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:16:00+0100",
|
||||
@ -109,7 +122,8 @@
|
||||
"platform": 13,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:17:00+0100",
|
||||
@ -117,7 +131,8 @@
|
||||
"platform": 14,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:18:00+0100",
|
||||
@ -125,6 +140,7 @@
|
||||
"platform": 15,
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0
|
||||
"delay": 0,
|
||||
"line": "T10"
|
||||
}
|
||||
]
|
||||
|
@ -36,6 +36,7 @@ CONNECTIONS = [
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0,
|
||||
"line": "T10",
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:04:00+0100",
|
||||
@ -44,6 +45,7 @@ CONNECTIONS = [
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0,
|
||||
"line": "T10",
|
||||
},
|
||||
{
|
||||
"departure": "2024-01-06T18:05:00+0100",
|
||||
@ -52,6 +54,7 @@ CONNECTIONS = [
|
||||
"transfers": 0,
|
||||
"duration": "10",
|
||||
"delay": 0,
|
||||
"line": "T10",
|
||||
},
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user