AlexandrErohin / home-assistant-flightradar24

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

Feature Request: add an event for half duration covering of a tracked flight #64

Closed ohuc closed 1 month ago

ohuc commented 1 month ago

a event which can allow us to know, when a flight reaches half of the duration of its total time would be highly useful!

AlexandrErohin commented 1 month ago

Hi

I think it is better to keep the integration simple to make it easy to use. As it has a lot of parameters to allow a user make his own automation to succeed any user goals.

But remember that half of the duration of its flight time is estimated and cannot be accurate!

To make this automation 1) You need to create Date and Time ISO sensor https://www.home-assistant.io/integrations/time_date 2) Edit this automation triggering half flight notification for your needs

alias: Half flight notification
description: ""
trigger:
  - platform: event
    event_type: flightradar24_area_took_off
condition: []
action:
  - wait_template: "{{ as_timestamp(states('sensor.date_time_iso')) >= half_time|int }}"
  - service: notify.persistent_notification
    data:
      message: Half flight - {{ half_time}}
variables:
  half_time: >-
    {% set flight = trigger.event.data %}{{(flight.time_scheduled_arrival|int -
    flight.time_scheduled_departure|int)/2 +
    as_timestamp(states('sensor.date_time_iso'))}}
mode: parallel