FlightRadar24 as an Add-On?

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 “+[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.

Did you ever get this completed?

To be honest, I completely forgot! Has anybody else been working on this, by chance?

yes got it working under docker. Will try to write detailed guide.

Awesome! I sort of dropped the ball on this, so glad it was picked up!

Here is my detailed guide. please feel free to contact me for any issue.

Thanks, but I think this is different from what the OP was looking for, which was to have HA read the flights.json file for use in automations.

I wrapped the awesome docker image from Thom-x as Home Assistant Add-On. Any feedback is appreciated :slight_smile:

1 Like

how do I install this add-on " python-flightradar-client "?

This is not a Home Assistant add-on, but just a Python library. If you are a developer then you can use this to build a Home Assistant integration.

I was able to install it. Where to add the configuration you posted for custom sensor?
In customomize.yaml file?

Ah, that one. The configuration I shared has nothing to do with the Python library I shared separately, but solely relies on the rest sensor. I have this in a package file (included via configuration.yaml), not in customomize.yaml.

I tried adding the following code to my configuration.yaml file

  - 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 24:
  - 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 24:
  - platform: rest
    name: FR24 Feeder
    resource: http://f1c878cb-adsb-multi-portal-feeder: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"] }}'    

but got this error when I checked the configration

Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 194).
Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 194).
Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 194).
Invalid config for [sensor]: required key not provided @ data['platform']. Got None. (See /config/configuration.yaml, line 194).

which is strange bcz this code start at line 256 .

while I have this on line 194

Your forgot a few lines at the beginning:

homeassistant:
  customize:
...

those are already added at the beginning of the configuration file?

Yeah, but followed by lots of unrelated stuff.

new error

expected a dictionary for dictionary value @ data['customize']

Then there is still something wrong with how you set up your configuration file.

The configuration I shared in the second post works as-is in a package file.

I am using @MaxW’s add-on, the only change I made from your code instead of raspberry IP I am using the add-on address as described by him

finally got it working

1 Like