Custom Component: Flightradar24

v1.9.0 Released

Changelog

Thank you for this! Works great!

Here is an improved card example that works well for most tracked as well and does not show Nones and Nulls.

type: vertical-stack
cards:
  - type: conditional
    conditions:
      - condition: numeric_state
        entity: sensor.flightradar24_most_tracked
        above: 0
    card:
      type: markdown
      content: >-
        {% set data = state_attr('sensor.flightradar24_most_tracked', 'flights')
        %}

        {% for flight in data %} 

          <ha-icon icon="mdi:airplane"></ha-icon>{%if flight.get('flight_number') and flight.flight_number %}{{ flight.flight_number }} - {% endif %}{%if flight.get('airline_short') and flight.airline_short %}{{ flight.airline_short }} - {% endif %}{%if flight.get('aircraft_model') and flight.aircraft_model %}{{ flight.aircraft_model }} - {% endif %}{%if flight.get('callsign') and flight.callsign %}{{ flight.callsign }}{% endif %}
          {%if flight.get('airport_origin_city') and flight.get('airport_origin_country_code') and flight.airport_origin_city %}{{ flight.airport_origin_city }}<img src="https://flagsapi.com/{{ flight.airport_origin_country_code }}/shiny/16.png" title='{{ flight.airport_origin_country_name }}'/> -> {{ flight.airport_destination_city }}{% endif %}{%
          if flight.get('airport_destination_country_code') and flight.airport_destination_country_code %}<img src="https://flagsapi.com/{{ flight.airport_destination_country_code }}/shiny/16.png" title='{{ flight.airport_destination_country_name }}'/>{% endif %}
          {%if flight.get('time_scheduled_departure') and flight.time_scheduled_departure %}Departure - {{ flight.time_scheduled_departure | timestamp_custom('%H:%M') }}; {% endif %}{%if flight.get('time_scheduled_arrival') and flight.time_scheduled_arrival%}Arrival - {{ flight.time_scheduled_arrival | timestamp_custom('%H:%M') }}{% endif %}{%if flight.get('time_estimated_arrival') and flight.time_estimated_arrival%}; Estimated Arrival - {{ flight.time_estimated_arrival | timestamp_custom('%H:%M') }}{% endif %}
          {%if flight.get('altitude') and flight.altitude %}Altitude - {{ flight.altitude }} ft;{% endif%}{%if flight.get('altitude') and flight.altitude > 0 %} ({{(flight.altitude * 0.3048)| round(0)}} m){% endif%}{%if flight.get('ground_speed') and flight.ground_speed %} Gr. speed - {{ flight.ground_speed }} kts{%if flight.get('ground_speed') and flight.ground_speed > 0 %} ({{(flight.ground_speed * 1.852)| round(0)}} km/h){% endif%}{% endif%}
          [Open FlightRadar](https://www.flightradar24.com/{{ flight.callsign }})

        {% endfor %}
view_layout:
  position: sidebar

@AlexandrErohin It would be trully great to get an event on landing and lift off for the manually tracked planes. Would this be possible to be added as an event please?

1 Like

@maurizio53 time parameters contain timestamp.
To get readable format use as_datetime() function
like

{{ as_datetime(1712331600) }}

@JurajNyiri Ill try to add in next releases

1 Like

Thanks, but how to add this to the notifications?
I know i can add {{ trigger.event.data.arrival_time }}, but how to transform this in readable format?

that’s not really specific to this integration so you might get the answer/info you need, as well as a whole lot of other background detail from somewhere like this thread…

You’ll end up with something like the below (which shows “Now” as a custom timestamp displaying > 2024-04-05 19:41)

{{ as_timestamp(now(),0)|timestamp_custom("%Y-%m-%d %H:%M" ) }}

edit - and as a disclaimer I’ve a trial and error sort of approach so the above code may not be 100%

Hey guys, question: I’m tracking one of the Lifeliners in The Netherlands. I’ve set up a circle with a radius of 2000 m and I get a notification when it enters or leaves the circle. But right after it lands, I get another notification that it took off again, while it’s on the ground. What causes this and how can I prevent this? I’m currently tracking it’s callsign.

Hi Jurai…how are you getting this card to work properly…
Looking at the attributes of the sensor.flightradar24_most_tracked from GitHub - AlexandrErohin/home-assistant-flightradar24: Flightradar24 integration for Home Assistant as well as what’s in HA it doesn’t have a load of the data you are showing in your card code…for example airport_destination_country_code or time_scheduled_departure or altitude, etc

Have you done some “magic” to bring this extra data in that I’m missing or what’s going on?

It’s hidden when it does not exist via it conditions.

1 Like

Cheers…makes sense…so using the same code for cards for both Local Flights and “top 10”…

So now my query becomes if it’s possible to add the extra attributes to the Top 10 sensor that are already available via sensor.flightradar24_current_in_area
@AlexandrErohin do you think that’s an option?

@mountainbikert What is your automation for take off notification?

@Gav_in top 10 sensor has all attributes which gives FlightRadar. Attributes for top 10 sensor and current_in_area sensor are different

1 Like

Hi @AlexandrErohin

alias: LIFELN3 opgestegen
description: ""
trigger:
  - platform: event
    event_type: flightradar24_exit
condition:
  - condition: template
    value_template: "{{ trigger.event.data.aircraft_registration == 'PH-LLN' }}"
action:
  - service: notify.mobile_app_mymobilephone
    data:
      message: >-
        {{ trigger.event.data.aircraft_registration }} (LifeLiner 3) bezig met
        opstijgen van Volkel Airbase.
      title: LifeLiner 3 Alert
      data:
        ttl: 0
        priority: high
mode: single

@mountainbikert how you differentiate between taking off and landing? if by entering or exiting the area - try to increase the radius

@AlexandrErohin Thanks, I had it set at 2000 meter, I’ll try 4000 meter now.

Hey @AlexandrErohin ,

Thanks very much for your reply! I gave it a go and have it sort of working.

I have a trigger condition that monitors my calendar and filters for my flight numbers. The issue seems that the flight will only populate if the flight has already departed, as you alluded to. So I set the automation to run at departure time +5 minutes. So long as my flight departs on time, all is well. However, if my flight is delayed, it is not added to the additional tracked flights. Is there any way that you can think of to work around this? I could have it fire to add the flight every couple of minutes after departure time for a little while, but that seems clumsy? Any ideas?

Here’s what I have so far.

alias: Flight Radar 24 Test Level 1
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "0:5:0"
    entity_id: calendar.my_access_mycalendar
condition:
  - condition: template
    value_template: "{{ trigger.calendar_event.summary | regex_match('^(?!T).*\\\\d{3,4}.*') }}"
action:
  - service: notify.mobile_app_my_phone
    metadata: {}
    data:
      message: Flight Radar 24 test. Are you going flying?
      title: FT24 Test Title
  - service: text.set_value
    metadata: {}
    data:
      value: DL{{ trigger.event.data.aircraft_registration }}
    target:
      entity_id: text.flightradar24_add_to_track
    enabled: true
mode: single

Thanks again for all of your work!

EDIT: I’ve also been playing around with the map card as well. I’ll set the lat/lon/zoom to see most of North America, as that’s where most of my flying is. Of course, the map is cluttered with all active flights. Is there any way to only display the additional.tracked.flights parameter? I see on Flightradar24, you can filter based on callsign for subscribers. I’d pay the $15/yr to add this functionality. Is this possible? I see there is parameter of {{ flight.flight_number }} in the map card’s code, not sure it’s for what we’re looking to do though.

I will think about scheduled flights

Unfortunately, I dont have Flightradar24 subscription, so I can suggestion you nothing on this :frowning:
You may play with the url. There is filter called filter_callsign for airline filter

https://www.flightradar24.com/simple?lat=LATITUDE&lon=LONGITUDE&z=ZOOM&label1=reg&size=small&filter_callsign=DLH

@AlexandrErohin I tried a radius of 4000 and 5000 meter but I keep getting the same messages. Is there any other way to solve this?

@mountainbikert The integration doesnt have taking off and landing notifications. How do you define these states?

I assume that when it leaves the airport, it takes off and when it returns it lands. I checked on the location and added a circle around the location with a 5000 meter radius. Sometimes they have to go around the airport and they may leave the circle and get back in immediately. That could cause 2 notifications. But now a flight taking of causes 2 notifications. If you use my automation you can check, I can supply you with the exact coordinates if needed.