Hi,
I’m trying to update a google sheet with information about flights entering my area using this awesome component. I’m not good at writing my own yaml so this is where I’m getting stuck. I’d like a new row created in a google sheet that lists things like flight number, altitude, destination. Probably through an automation.
I’ve created other basic automations in the past for ‘heatpump on when its cold’ etc. But nothing like this…
Google sheets integration and flightradar24 are running successfully already.
I can put information into my google sheet using Developer Tools>Actions>Google Sheets: Append to sheet, so the intergration is working and flightradar24 updates my dashboard with info on flights in my area.
Also I’m using Core 2024.12.5 Supervisor 2024.12.0 Operating System 14.1 Frontend 20241127.8
I’m stuck with what yaml to put into my google sheets configuration through the Automations GUI.
It asks for information to be entered into the ‘data’ fields. These need to first inform the column name (e.g. Plane ID:) then some yaml to get the right info from FlightRadar24.
This information ‘I Think’ is only available when a plane is in the area.
Getting 3 errors:
Error while executing automation automation.loud_plane: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’
Loud Plane: Error executing script. Error for call_service at pos 1: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘event’
Template variable error: ‘dict object’ has no attribute ‘event’ when rendering ‘{{ trigger.event.data.callsign }}’
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 %}
I started looking at this again today, having a little bit of uninterrupted time to play around with my HA setup. I did find where I can add a flight to be tracked using a Lovelace card:
When I enter one of my planes in there, however, whether by flight number or tail number, it is not persistent. I see nothing in my Developers Tools that shows a tracker for the flight or tail number was created.
I think there might be another configuration step, but following the instructions in the documentation takes me back & forth between two sections.
The only change I’ve made to configuration.yaml at this point is to decrease the database size, as suggested.
Further investigation, I can see in my logs that FR24 complained “no flights found” when I tried to enter either the flight number or the tail number. Indeed, the plane is sitting on the ground. I’d like it to be tracked if/when it takes off, and also notified of that action.
Ok, so i think i have it set up now. i do however keep receiving ground vehicle details.
Could someone please help a noob figure out how i can set it to ignore the ground vehicles?
this is what is displayed for a GV.
None(None) - None - Airport Ground Vehicle
None → None
I did look for what to add to the code to ignore them, but i can not find it.