IMPORTANT, the flightaware service is NOT (!) free
Hi all, triggered by another user, I discovered that flightware API offers a lot of data and I set about to allow me to track incoming flights on the airports I ‘usually’ go to and with airlines I ‘usually’ take
To do:
- become a member of flightaware API and get the API key
- use a command line sensor with curl and jq alike below. I use the scheduled arrivals (upcoming) and templates for airport , filter start/end time, filter airline (see below)
- create input_select sensors with the airline and airport ID that you are interested in
- create a card, I used flex-table card below
Notes: there is a lot of information available, also about the planes themselves so this is just an example. EDIT: I will also try to get the details of a flightnumber that I type in myself
- platform: command_line
name: flight_arrivals
unique_id: flight_arrivals
scan_interval: 300
command: >
curl -X GET -H "x-apikey:YOUR_OWN_APIKEY" "https://aeroapi.flightaware.com/aeroapi/airports/{{states('input_select.airports')}}/flights?max_pages=3&airline={{ states('input_select.airlines')}}&start={{ utcnow().strftime("%Y-%m-%dT%H:%M:00Z") }}&end={{ now().strftime('%F') }}T23:59:00Z" | jq '{flights: [.scheduled_arrivals[] | { flight: .ident, flight_iata: .ident_iata, origin_city: .origin.city, origin_name: .origin.name , aricraft: .aircraft_type , status: .status , arrival_gate: .gate_destination, arrival_terminal: .terminal_destination , destination_city: .destination.city, destination_name: .destination.name , scheduled_arrival: .scheduled_in, estimated_arrival: .estimated_in, arrival_delay: .arrival_delay }]}'
value_template: >
{{ value_json.flights | length }}
json_attributes:
- flights
card:
type: custom:stack-in-card
mode: vertical
cards:
- type: horizontal-stack
cards:
- type: vertical-stack
cards:
- type: entities
entities:
- entity: input_select.airports
- type: entities
entities:
- entity: input_select.airlines
- type: button
show_name: true
show_icon: true
name: refresh
tap_action:
action: call-service
service: homeassistant.update_entity
target:
entity_id: sensor.flight_arrivals
data: {}
icon: mdi:autorenew
- type: custom:flex-table-card
clickable: true
sort_by: state
max_rows: 15
entities:
include: sensor.flight_arrivals
columns:
- name: Flight
data: flights
modify: x.flight
- name: Origin
data: flights
modify: x.origin_city
- name: Delay(min)
data: flights
modify: |
if(x.arrival_delay == 0)
{""}
else {
parseInt(x.arrival_delay / 60) }
- name: Arrival
data: flights
modify: |
if(x.estimated_arrival == null )
{"-"}
else {
var date = new Date(x.estimated_arrival);
String(date.getDate()).padStart(2,'0')+"/"+
(String(date.getMonth()+ 1).padStart(2,'0'))+
" "+
String(date.getHours()).padStart(2,'0')+":"+
String(date.getMinutes()).padStart(2,'0')
}