AlexandrErohin / home-assistant-flightradar24

Flightradar24 integration for Home Assistant
https://community.home-assistant.io/t/custom-component-flightradar24
MIT License
137 stars 15 forks source link

Feature request: Two Devices #11

Closed ckglobalroaming closed 6 months ago

ckglobalroaming commented 8 months ago

Is it possible to create a second device with a different radial? I am lloking to have 500m radial and a 30Km radial. I have tried and created the second device but it does not initialize.

Many Thanks for the hardwork.

AlexandrErohin commented 8 months ago

Ill try to fix this in the next releases

ckglobalroaming commented 8 months ago

Thanks. Have been playing with the config today. RADIAL HEADING & DISTANCE: I have set a home lat lon on the HA side and calculated the radial distance and heading from my home. This works but would be better if it could be calculated within the integration.

DIRECTION: Also would be good if the integration could calculate inbound or outbound based on the radial distance delta between the current and last adsb lat lon

SORT ORDER: Can the data array have a sort option for closest to farthest based on the radial. Would be good if the list showed the closest aircraft to the home lat lon.

Just some thoughts. Great project, thanks for your effort.

motoridersd commented 8 months ago

I'd like this as well. Would be nice to monitor the two large airport areas near me, or even more if one were so inclined.

16-9 commented 8 months ago

I noticed that flightradar24_entry event does not document the device it is associated with. So, when defining two devices, that event would not provide any info as far as which perimeter was crossed. I imagine the alternative would be to trigger on a value change of sensor.zone1_flightradar24_entered_area vs sensor.zone2_flightradar24_entered_area

AlexandrErohin commented 8 months ago

@ckglobalroaming DISTANCE: I can add this but the accuracy of this varies greatly. For example a flight data says it is near to you for some minutes and then it jumps to 12km away from you. Or it says for some minutes it is 6km away, but you have already seen him flights by. Flightradar24 not always gives you correct live fligh position. Sometimes it is differ more then 10km. SORT ORDER: it is good when you have 2-3 active flights, but when you are near an airport that could be more the 10 flights. When you have a lot of flights - you have a list of flights more then fits on cellphone screen and you need to scroll to see them all. And when you have sorting in the list, every update will make a list completely different. So if you would like to visually track a flight you will have to always scroll the screen to find a new flight list position

AlexandrErohin commented 8 months ago

Added multiple simultaneous integration support. Now you can create more then one device

motoridersd commented 7 months ago

I've also added a few and it works great! Thank you

motoridersd commented 7 months ago

@ckglobalroaming DISTANCE: I can add this but the accuracy of this varies greatly. For example a flight data says it is near to you for some minutes and then it jumps to 12km away from you. Or it says for some minutes it is 6km away, but you have already seen him flights by. Flightradar24 not always gives you correct live fligh position. Sometimes it is differ more then 10km. SORT ORDER: it is good when you have 2-3 active flights, but when you are near an airport that could be more the 10 flights. When you have a lot of flights - you have a list of flights more then fits on cellphone screen and you need to scroll to see them all. And when you have sorting in the list, every update will make a list completely different. So if you would like to visually track a flight you will have to always scroll the screen to find a new flight list position

For the list I've added some filters using if statements to the value template. For example, to limit what I see in the table to commercial airliners above 1000 feet, contains flight.airline_short, and is not the local commuter airport

{% set data = state_attr('sensor.flightradar24_current_in_area', 'flights') %} {% for flight in data | sort (attribute='altitude') %} {% if flight.altitude > 1000 and flight.airline_short and not flight.airport_origin_code_iata == 'MYF' and not flight.airport_destination_code_iata == 'MYF' %}
  <ha-icon icon="mdi:airplane"></ha-icon>{{ flight.flight_number }} - {{ 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%}
  {% endif %}
  {% endfor %}

I've also used some of the other available values to show a photo of the aircraft outside my window:

image

{% set data = state_attr('sensor.flightradar24_current_in_area',
'flights') %} {% for flight in data %} {% if flight.altitude > 500
and flight.altitude < 3000 and flight.airline_short and
flight.airport_destination_code_iata == 'SAN' %} <table>
<tr>
<td><img src="{{flight.aircraft_photo_small}}" height="90"></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<td>
<td>
{{ flight.flight_number }} {{ flight.aircraft_code }}<br>
{{ flight.airline_short }}<br>
{{ flight.airport_origin_code_iata }} <ha-icon icon="mdi:airplane"></ha-icon> {{ flight.airport_destination_code_iata }}<br>
Altitude - {{ flight.altitude }} ft{%if flight.altitude > 0 %} ({{(flight.altitude * 0.3048)| round(0)}} m){% endif%}<br> 
</td>
</tr>
AlexandrErohin commented 7 months ago

@16-9 Added tracked_by_device to events to know what device has fired the event