FlightRadar24 as an Add-On?

Tags: #<Tag:0x00007f7392b542c8>

Hi, I’m a “limited skill techie” with little coding experience, but I like to goof around with my RPi3 or Arduino from time to time. I discovered Home Assistant and HASS IO recently and although frustrating at times - am learning a lot. My wife has, however, asked me to reduce the number of “random computer boxes” as she calls them, that are around the house. I currently use a RPi2 to feed data to FlightRadar24 with a DVB stick.

I figured that actually I could probably just plug the stick into my RPi3 and run the flightradar software on there… and that’s where it got complicated:

  1. Tried to log in to my home assistant pi and run the flightradar24 install script
  2. Failed - No apt-get on hass io instances
  3. Then read up on how Hass io works, figured maybe I can create my own add on
  4. Realized that’s much harder than I thought…
  5. Found out that the add-ons run in docker instances
  6. Found a docker that has flightradar installed
  7. Tried to follow the steps to create a local add on… and am totally lost. I have a Dockerfile, but I have no clue what to put in any of the other files (e.g. run sh)

Any pointers would be appreciated! My main purpose is just to feed flightradar24, but I also thought you could use it for something cool (but probably useless) like:

  • If a plane flies within 5km, turn the light on
  • If a specific airline flies overhead, turn a light the color of the airline’s logo
  • (ok maybe useful) if a plane flies overhead at altitude of less than X feet, ignore any alerts from sensors that detect noise

Any suggestions?

1 Like

I can’t help you on achieving the first part. I’m running Home Assistant on a Ubuntu server, and the Flightradar24 software on a Raspberry Pi. I was never planning on consolidating the two onto one server.

So far, I have done a fairly simple integration to show some basic statistics in Home Assistant - connectivity, number of planes, current software version.
Here my package file:

# ADS-B System / Flightradar 24

homeassistant:
  customize:
    sensor.fr24_feeder:
      hidden: true
    sensor.fr24_feeder_aircraft_tracked:
      icon: mdi:airplane
    sensor.fr24_feeder_aircraft_uploaded:
      icon: mdi:airplane
    sensor.fr24_feeder_radar_code:
      icon: mdi:radar

binary_sensor:
  - platform: template
    sensors:
      fr24_feeder_receiver_connected:
        friendly_name: Receiver Connected
        value_template: '{{ is_state_attr("sensor.fr24_feeder", "rx_connected", "1") }}'
        device_class: connectivity
      fr24_feeder_link_connected:
        friendly_name: Link Connected
        value_template: '{{ is_state_attr("sensor.fr24_feeder", "feed_status", "connected") }}'
        device_class: connectivity

sensor:
  - platform: rest
    name: FR24 Feeder
    resource: http://<raspberry pi>:8754/monitor.json
    value_template: '{{ value_json.feed_alias }}'
    method: GET
    scan_interval: 60
    json_attributes:
      - rx_connected
      - feed_status
      - d11_map_size
      - feed_num_ac_tracked
      - build_version
      - feed_alias
  - platform: template
    sensors:
      fr24_feeder_radar_code:
        friendly_name: Radar Code
        value_template: '{{ states.sensor.fr24_feeder.attributes["feed_alias"] }}'
      fr24_feeder_aircraft_tracked:
        friendly_name: Aircraft Tracked
        value_template: '{{ states.sensor.fr24_feeder.attributes["d11_map_size"] | round(0) }}'
        unit_of_measurement: 'aircrafts'
      fr24_feeder_aircraft_uploaded:
        friendly_name: Aircraft Uploaded
        value_template: '{{ states.sensor.fr24_feeder.attributes["feed_num_ac_tracked"] | round(0) }}'
        unit_of_measurement: 'aircrafts'
      fr24_feeder_version:
        friendly_name: Version
        value_template: '{{ states.sensor.fr24_feeder.attributes["build_version"] }}'

Other than that, I have been busy working on the new geo_location component and some GeoJSON feed platforms.
The Flightradar24 use-case could be a very interesting geo_location platform. Some data like longitude/latitude, altitude, flight number are available directly from your local Flightradar24 server. I’ll have a look at how complex it would be to add this as a new platform. This would already place all planes on the map, and give you the distance of each plane to your home.
The next version of Home Assistant should then also contain a geo_location trigger which you can use to automate things while planes are entering or leaving a zone around your home.

7 Likes

This info from exxamalte is outdated as the FlightAware software for Raspberry Pi has been through a bunch of iterations and now the JSON files are all different. I am a FlightAware contributor and a Home Assistant user, but I know nothing about how to get the HA yaml corrected. The source for the new JSON info about FlightAware is here: https://github.com/flightaware/dump1090/blob/c3541bcbeac0c6a83b50b988e503b49a349a40ad/README-json.md

The only thing I knew how to test was to confirm the JSON files work when you put it in this format (per the link I posted above): http://:8080/data/aircraft.json

There are several JSON files now to choose from. Most interesting to me would be how many local aircraft I’m tracking in the last 5 minutes and perhaps the total number uploaded in the last hour.

No, it’s not. I am still running the exact same configuration and it’s working perfectly fine.
Please note that this is working with Flightradar24 (not FlightAware). I am running version 1.0.24-7 of their software on Raspbian.

I stand corrected. Thanks for letting me know the difference exxamalte! Looks like a similar project as FlightAware, I thought we were talking about the same thing…

Yours must be this… nearly identical to my setup just different software

Cheers!

No worries. Apart from the (simple) configuration above, I have been experimenting with using the real-time data I get from the software and somehow use that in HA. At the time there had been two data access points - one Flightradar24-specific, and one that uses the Dump1090 data which I believe is also used by the FlightAware software (that’s the /data/aircraft.json end-point).

I haven’t found the time to work on this any further, and the library itself isn’t async yet. Here is the current state:

This is my “Aircraft Tracked” graph:

4 Likes

Great info.

I’m running PI24 on a Pi2 and Home Assistant on a server.

Got the tracking working, with the use of monitor.json.

Only aircraft.json isn’t accessible (yet) it says 'FORBIDDEN :> ’

Want the names of the last 5 tracked airplanes on screen.
This can be usefull in an automation to trigger a light when a specific string is equal. For when you want to know when a specific airplane is near.

Try using http://[raspberry pi]:8754/flights.json. I have no idea how to make HA read it, but will try to learn!

So here’s the output of my flights.json file:

{
“xabe579”: [
“ABE579”,
0,
0,
56,
5650,
271,
“3215”,
0,
“”,
“”,
1596308215,
“”,
“”,
“”,
0,
3072,
“”
],
“xa5287a”: [
“A5287A”,
37.6133,
-122.4295,
141,
8550,
256,
“3372”,
0,
“”,
“”,
1596308276,
“”,
“”,
“”,
0,
832,
“SKW5291”
]
}>

Or, more generically, there’s one json object for each tracked aircraft, with a key name of “[x]+[modeS].” Then the value is an array of:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

Mode S
Latitude
Longitude
Heading (maybe)
Altitude
Airspeed (maybe)
Squawk code
0
“”
“”
Some kind of unique ID
“”
“”
“”
0
Don’t know
Callsign

Now I just need to figure out how to iterate through it.

Found this post about running a for…each loop through a JSON object when the key name is unknown, but haven’t figured out how to make it work.