Custom Component: Flightradar24

I made some modifications to the markdown code.

  • Labels in grey and only content in white
  • none Values are not shown
  • Translation to german
    2024-12-30_15h09_28

And I also tried to identify helicopters but the code is not working as expected.
The loop is working fine and sets the is_heli to true, but after the endfor is_heli is reset to false again. Does anybody know how to solve that?

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') %}  
    {% set heli_prefixes = ["Airbus AS", "Airbus H", "Bell", "EC", "Hughes", "MD", "R44"] %}   
    {% for flight in data %}
      {% set is_heli = false %}
      {% for prefix in heli_prefixes %}
        {% if flight.aircraft_model.startswith(prefix) %}
          {% set is_heli = true %}
          {% break %}
        {% endif %}
      {% endfor %}
      {% if is_heli %}<ha-icon icon="mdi:helicopter"></ha-icon>{% else %}<ha-icon icon="mdi:airplane"></ha-icon>{% endif %}{% if flight.aircraft_registration is not none %}<font color="orange">{{ flight.aircraft_registration }}</font> - {% endif %}<font color="white">{{ flight.aircraft_model }}</font>{% if flight.airline_short is not none %}<font color="darkgrey"> - Airline: </font><font color="white">{{ flight.airline_short }}</font>{% endif %}
      {% if flight.flight_number is not none %}<font color="darkgrey">Flight</font> <font color="white">{{ flight.flight_number }}</font> <font color="darkgrey">from</font> <font color="white">{{ flight.airport_origin_city }}</font> {% 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 %} <font color="darkgrey">to</font> <font color="white">{{ flight.airport_destination_city }}</font> {% 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 %}{% else %}<font color="darkgrey">keine Flugnummer verfügbar</font>{% endif %}
      {% if flight.time_scheduled_departure is not none %}<font color="darkgrey">Startzeit: </font><font color="white">{{ flight.time_scheduled_departure | timestamp_custom('%H:%M') }}</font>{% endif %}{% if flight.time_scheduled_arrival is not none %}<font color="darkgrey"> | Ankunftszeit: </font><font color="white">{{ flight.time_scheduled_arrival | timestamp_custom('%H:%M') }}</font>{% else %}<font color="darkgrey">keine Flugdaten verfügbar</font>{% endif %}
      {% if flight.altitude > 0 %}<font color="darkgrey">Flughöhe: </font><font color="white">{{ flight.altitude }} ft | {{(flight.altitude * 0.3048) | round(0)}} m</font>{% endif %}
      {% if flight.ground_speed > 0 %}<font color="darkgrey">Geschwindigkeit: </font><font color="white">{{ flight.ground_speed }} kts | {{(flight.ground_speed * 1.852) | round(0)}} km/h</font>{% endif %}
    {% endfor %}
1 Like