Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![HACS Custom](https://img.shields.io/badge/HACS-Custom-blue.svg)](https://hacs.xyz/)
[![Hassfest](https://github.com/WickedGhost/avinor_flight_data/actions/workflows/hassfest.yml/badge.svg)](https://github.com/WickedGhost/avinor_flight_data/actions/workflows/hassfest.yml)
[![HACS Validation](https://github.com/WickedGhost/avinor_flight_data/actions/workflows/hacs.yml/badge.svg)](https://github.com/WickedGhost/avinor_flight_data/actions/workflows/hacs.yml)
[![Version 1.1.1](https://img.shields.io/badge/Version-1.1.1-orange.svg)](custom_components/avinor_flight_data/manifest.json)
[![Version 1.1.2](https://img.shields.io/badge/Version-1.1.2-orange.svg)](custom_components/avinor_flight_data/manifest.json)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

Custom Home Assistant integration that keeps your dashboards up to date with arrivals and departures from the official Avinor data feed.
Expand Down Expand Up @@ -159,6 +159,8 @@ title: Ankomster OSL

## Release Notes

- **1.1.2**
- Airlabs schedule-backed entities now use airport names in the airport column instead of raw IATA codes.
- **1.1.1**
- Refreshed config wizard translations for the Airlabs API key field so the explanatory text is picked up correctly.
- **1.1.0**
Expand Down
3 changes: 2 additions & 1 deletion custom_components/avinor_flight_data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ async def _normalize_schedule_rows(
for row in deduped:
other_airport = self._get_counterparty_airport(row, direction)
meta = airport_meta.get(other_airport or "", {})
airport_display = str(meta.get("name") or other_airport or "")
flights.append(
{
"uniqueId": self._schedule_identity(row),
Expand All @@ -376,7 +377,7 @@ async def _normalize_schedule_rows(
"dom_int": self._classify_airlabs_flight(country_code=str(meta.get("country_code") or "").upper(), airport_code=other_airport),
"schedule_time": self._schedule_time_utc(row, direction),
"arr_dep": direction,
"airport": other_airport,
"airport": airport_display,
"check_in": row.get("dep_gate") if direction == "D" else None,
"gate": row.get("arr_gate") if direction == "A" else row.get("dep_gate"),
"status_code": self._map_airlabs_status(row.get("status")),
Expand Down
2 changes: 1 addition & 1 deletion custom_components/avinor_flight_data/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"issue_tracker": "https://github.com/WickedGhost/avinor_flight_data/issues",
"loggers": ["custom_components.avinor_flight_data"],
"requirements": ["xmltodict==0.13.0"],
"version": "1.1.1"
"version": "1.1.2"
}
19 changes: 12 additions & 7 deletions tests/test_api_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ def utc_in(hours: int) -> str:
]
}
airport_payloads = {
"CPH": {"response": [{"iata_code": "CPH", "country_code": "DK"}]},
"TRD": {"response": [{"iata_code": "TRD", "country_code": "NO"}]},
"KRK": {"response": [{"iata_code": "KRK", "country_code": "PL"}]},
"LTN": {"response": [{"iata_code": "LTN", "country_code": "GB"}]},
"CPH": {"response": [{"iata_code": "CPH", "country_code": "DK", "name": "Copenhagen Airport"}]},
"TRD": {"response": [{"iata_code": "TRD", "country_code": "NO", "name": "Trondheim Airport"}]},
"KRK": {"response": [{"iata_code": "KRK", "country_code": "PL", "name": "Krakow Airport"}]},
"LTN": {"response": [{"iata_code": "LTN", "country_code": "GB", "name": "London Luton Airport"}]},
}

def payload(url, params):
Expand All @@ -305,7 +305,12 @@ def payload(url, params):
assert [flight["flightId"] for flight in result["flights"]] == ["SK1398", "WF481", "FR6216", "U28635"]
assert [flight["dom_int"] for flight in result["flights"]] == ["S", "D", "S", "I"]
assert [flight["status_code"] for flight in result["flights"]] == ["A", "E", "E", "EXP"]
assert result["flights"][0]["airport"] == "CPH"
assert [flight["airport"] for flight in result["flights"]] == [
"Copenhagen Airport",
"Trondheim Airport",
"Krakow Airport",
"London Luton Airport",
]


@pytest.mark.asyncio
Expand All @@ -328,7 +333,7 @@ def payload(url, params):
]
}
if url.endswith("/airports"):
return {"response": [{"iata_code": "LGW", "country_code": "GB"}]}
return {"response": [{"iata_code": "LGW", "country_code": "GB", "name": "London Gatwick Airport"}]}
raise AssertionError(f"Unexpected URL: {url}")

client = StubAirlabsClient(payload)
Expand All @@ -341,6 +346,6 @@ def payload(url, params):
)

assert len(result["flights"]) == 1
assert result["flights"][0]["airport"] == "LGW"
assert result["flights"][0]["airport"] == "London Gatwick Airport"
assert result["flights"][0]["dom_int"] == "I"
assert result["flights"][0]["arr_dep"] == "D"
Loading