diff --git a/README.md b/README.md index 057c828..9d045c2 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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** diff --git a/custom_components/avinor_flight_data/api.py b/custom_components/avinor_flight_data/api.py index e6877c1..32c9417 100644 --- a/custom_components/avinor_flight_data/api.py +++ b/custom_components/avinor_flight_data/api.py @@ -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), @@ -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")), diff --git a/custom_components/avinor_flight_data/manifest.json b/custom_components/avinor_flight_data/manifest.json index 944537f..1ec449a 100644 --- a/custom_components/avinor_flight_data/manifest.json +++ b/custom_components/avinor_flight_data/manifest.json @@ -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" } diff --git a/tests/test_api_parsing.py b/tests/test_api_parsing.py index e2e21e8..4126828 100644 --- a/tests/test_api_parsing.py +++ b/tests/test_api_parsing.py @@ -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): @@ -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 @@ -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) @@ -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"