jcallaghan / home-assistant-config

My Home Assistant configuration & documentation.
https://www.jcallaghan.com/
MIT License
175 stars 8 forks source link

Plane overhead ✈👀 #164

Open jcallaghan opened 4 years ago

Hypfer commented 4 years ago

You could use a cheap rtl-sdr dongle + dump1090-mutability for this to avoid cloud dependencies.

Furthermore, you can use the same webserver which delivers the dump1090 webpage to also do a simple transformation to the GeoJson format, so that you can use the Home Assistant GeoJson Integration to get the data into home assistant.

From there, a template sensor which checks if there are any plane geojson entities with a distance below x could be the way to go.

This is a PHP script which I use for the mentioned geojson transformation ``` 'FeatureCollection', 'features' => [], ], JSON_PRETTY_PRINT); exit; } $input = json_decode($content, true); if (!$input) { echo json_encode([ 'type' => 'FeatureCollection', 'features' => [], ], JSON_PRETTY_PRINT); exit; } $features = []; foreach ($input['aircraft'] as $aircraft) { if (!isset($aircraft['lat']) || !isset($aircraft['lon'])) { continue; } $features[] = [ 'type' => 'Feature', 'geometry' => [ 'type' => 'Point', 'coordinates' => [$aircraft['lon'], $aircraft['lat']], ], 'properties' => [ 'title' => isset($aircraft['flight']) ? 'Flight ' . trim($aircraft['flight']) : 'Plane', 'hex' => $aircraft['hex'], 'altitude' => $aircraft['altitude'], 'heading' => $aircraft['track'], 'speed' => $aircraft['speed'], ], 'id' => "plane".$aircraft['hex'] ]; } echo json_encode([ 'type' => 'FeatureCollection', 'features' => $features ], JSON_PRETTY_PRINT); ?> ```