Skip to content

Commit

Permalink
Added callsign for device_tracker if flight number doesnt exists
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrErohin committed Oct 8, 2024
1 parent 33c07ef commit d158217
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ in [Edit Configuration](edit-configuration). When it is enabled - this integrati
for every additional tracked flight from `sensor.flightradar24_additional_tracked`.

To create device_tracker for a flight:
1. Add a flight to Additional tracked by flight number
2. Use device_tracker `device_tracker.FLIGHT_NUMBER`.
1. Add a flight to Additional tracked by flight number. If it has no flight number, use callsign
2. Use device_tracker `device_tracker.FLIGHT_NUMBER` if flight number exists or `device_tracker.CALL_SIGN`.

To find device_tracker - Go to `Developer tools` and search for your flight number or callsign - you’ll find sensor
like `device_tracker.FLIGHT_NUMBER` or `device_tracker.CALL_SIGN`.

### Configuration
- Add to track
Expand Down
11 changes: 6 additions & 5 deletions custom_components/flightradar24/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ def update_items(
new_tracked: list[FlightRadar24Tracker] = []
active: list[str] = []
for flight in coordinator.tracked.values():
active.append(flight['flight_number'])
if flight['flight_number'] not in tracked:
tracked[flight['flight_number']] = FlightRadar24Tracker(coordinator, flight)
new_tracked.append(tracked[flight['flight_number']])
flight_id = flight['flight_number'] if flight['flight_number'] else flight['callsign']
active.append(flight_id)
if flight_id not in tracked:
tracked[flight_id] = FlightRadar24Tracker(coordinator, flight)
new_tracked.append(tracked[flight_id])
else:
tracked[flight['flight_number']].info = flight
tracked[flight_id].info = flight

if new_tracked:
async_add_entities(new_tracked)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/flightradar24/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/AlexandrErohin/home-assistant-flightradar24/issues",
"requirements": ["FlightRadarAPI==1.3.34", "pycountry==23.12.11"],
"version": "1.21.0"
"version": "1.21.1"
}

0 comments on commit d158217

Please sign in to comment.