FlightAware/Opensky sensor?

What would the configuration look like to set up a sensor that would have the plane information for the most recent overhead flight, using the Opensky or Flightaware add-in?

The “sensor.flightradar24_current_in_area” isn’t quite what I wanted, because it is just the # of flights, and it goes to zero once the flight leaves.

I’m thinking of one sensor of the name/type of plane most recently overhead, and a second sensor for how long since it left (or ‘zero’ if still overhead).

I assume there is some sort of template sensor I could set up to have these two data fields?

Thanks!

I have a vertical stack card on my dashboard that may show you what you want, automagically, from the FlightAware24 add-on. I hear the plane, look up and then glance at the dashboard.

type: vertical-stack
title: Flightradar24
cards:
  - type: entities
    entities:
      - entity: sensor.flightradar24_current_in_area
        name: In area
  - type: conditional
    conditions:
      - condition: numeric_state
        entity: sensor.flightradar24_current_in_area
        above: 0
    card:
      type: markdown
      content: >-
        {% set data = state_attr('sensor.flightradar24_current_in_area',
        'flights') %} {% for flight in data %}
          <ha-icon icon="mdi:airplane"></ha-icon>{{ flight.flight_number }}({{ flight.aircraft_registration }}) - {{ flight.airline_short }} - {{ flight.aircraft_model }}
          {{ flight.airport_origin_city }}{%if flight.airport_origin_city %}<img src="https://flagsapi.com/{{ flight.airport_origin_country_code }}/shiny/16.png" title='{{ flight.airport_origin_country_name }}'/>{% endif %} -> {{ flight.airport_destination_city }}{%
          if 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.time_scheduled_departure %}Departure - {{ flight.time_scheduled_departure | timestamp_custom('%H:%M') }}; {% endif %}{%if flight.time_scheduled_arrival%}Arrival - {{ flight.time_scheduled_arrival | timestamp_custom('%H:%M') }}{% endif %}
          Altitude - {{ flight.altitude }} ft{%if flight.altitude > 0 %} ({{(flight.altitude * 0.3048)| round(0)}} m){% endif%}; Gr. speed - {{ flight.ground_speed }} kts{%if flight.ground_speed > 0 %} ({{(flight.ground_speed * 1.852)| round(0)}} km/h){% endif%}
          {% endfor %}
  - type: iframe
    url: >-
      https://www.flightradar24.com/simple?lat=-redacted -put yours here-&lon=-redacted - put yours here-&z=12&label1=reg&size=small
    aspect_ratio: 100%


Update the url in the last line with the latitude and longitude you wish to display. I have mine centred over the small airfield close by, and it is busy on weekends. Acrobatics can often be awesomely daring, and you want the tail number if there is a crunch.

You could use an entity state change of sensor.flightradar24_current_in_area to trigger your automation routines. It will go up when one arrives in your area, and go back down by one when it leaves. The map shows you where they all are.

When I use that code, the map graphic appears to be one pixel high -

When I paste the URL that is in the code (with my lat/lon), it opens flightradar map fine.

Wait till a plane comes overhead…

That code should give you enough hints to achieve your goals

Figured it out - there is a spurious ’ at the end of your code snippet.

What defines the size of “your area”? I don’t see that in the code.

Removed it. Thanks. Remnant of cut-n-paste into the forum formatting.

I think the map area zoom is 12 miles from centre. Certainly big enough for the virtual 3D box the weekend wannabe acrobats perform in. Fun to watch but sometimes heart stopping when engines cough or aircraft disappear behind trees in vertical mode - they always pull out in time, but one day I will have to make the call and the few seconds saved by knowing the tail number may make a difference for an injured pilot.

Experiment and post your final code solution to your original sensor requirement

There have been updates since: