fratsloos / fr24_card

Lovelace card for showing Dump1090 data from FR24 in Home Assistant
44 stars 5 forks source link

Filter (e.g., distance < X, altitude < Y) #12

Open mikeage opened 2 years ago

mikeage commented 2 years ago

It would be very useful if we could add filters to the aircraft displayed. E.g., I'd like to only show planes within 10 NM, under 10k altitude.

I'm not sure what the best syntax would be; there is an existing hide: empty option, but I'm not sure what the cleanest way to be would be represent the filters that need a value, and whether it should default to and or or (and how to specify the opposite behavior), which is one reason I'm not submitting a PR. (the other two are poor JS skills and extreme laziness!)

fratsloos commented 2 years ago

I'm not sure yet how to implement it, but I'm thinking about something like this for the config:

type: custom:fr24-card
entity: sensor.fr24_aircraft
filter:
    type: or # and, or
    rules:
        - distance: <10
        - altitude: >=5

This will work with both options for units configuration parameter (default and metric) and can be applied after the units are converted (if metric is used).

The syntax for the rules should support the operators >, <, >=, <= and =. It should work on columns that have a number as their value. But not all; based on the above syntax, filtering on track would not be of any value. Therefore I am thinking of supporting the following columns in the filter: altitude, distance, speed.

Maybe in the future also a filter on columns with a text value. For example country.

robsymax commented 2 years ago

I've been looking for a solution to logging aircraft noise and being able to count aircraft within a set distance and below a set height would be great. It could also be refined further by aircraft type, speed/acceleration/etc. Is this possible?

fratsloos commented 2 years ago

@robsymax I think that's beyond the scope of this card. This card is for showing the current tracked aircrafts. It won't store any data. Theoretically this is possible by calling HA's API and updating an entity, but I won't develop that. You can always fork this repo and open a PR if you have developed such functionality.